difftreelog
refac: rename address -> Address
in: master
14 files changed
crates/evm-coder/procedural/src/to_log.rsdiffbeforeafterboth231231232 #[automatically_derived]232 #[automatically_derived]233 impl ::evm_coder::events::ToLog for #name {233 impl ::evm_coder::events::ToLog for #name {234 fn to_log(&self, contract: address) -> ::ethereum::Log {234 fn to_log(&self, contract: Address) -> ::ethereum::Log {235 use ::evm_coder::events::ToTopic;235 use ::evm_coder::events::ToTopic;236 use ::evm_coder::abi::AbiWrite;236 use ::evm_coder::abi::AbiWrite;237 let mut writer = ::evm_coder::abi::AbiWriter::new();237 let mut writer = ::evm_coder::abi::AbiWriter::new();crates/evm-coder/src/abi/test.rsdiffbeforeafterboth101101102#[test]102#[test]103fn encode_decode_vec_tuple_address_uint256() {103fn encode_decode_vec_tuple_address_uint256() {104 test_impl::<Vec<(address, U256)>>(104 test_impl::<Vec<(Address, U256)>>(105 0x1ACF2D55,105 0x1ACF2D55,106 vec![106 vec![107 (107 (crates/evm-coder/src/events.rsdiffbeforeafterboth53 }53 }54}54}555556impl ToTopic for address {56impl ToTopic for Address {57 fn to_topic(&self) -> H256 {57 fn to_topic(&self) -> H256 {58 let mut out = [0u8; 32];58 let mut out = [0u8; 32];59 out[12..32].copy_from_slice(&self.0);59 out[12..32].copy_from_slice(&self.0);crates/evm-coder/src/lib.rsdiffbeforeafterboth131 use alloc::{vec::Vec};131 use alloc::{vec::Vec};132 use primitive_types::{U256, H160, H256};132 use primitive_types::{U256, H160, H256};133133134 pub type address = H160;134 pub type Address = H160;135 pub type bytes4 = [u8; 4];135 pub type bytes4 = [u8; 4];136 pub type topic = H256;136 pub type topic = H256;137137147 /// Makes function payable147 /// Makes function payable148 pub type value = U256;148 pub type value = U256;149 /// Makes function caller-sensitive149 /// Makes function caller-sensitive150 pub type caller = address;150 pub type caller = Address;151 //#endregion151 //#endregion152152153 /// Ethereum typed call message, similar to solidity153 /// Ethereum typed call message, similar to soliditycrates/evm-coder/tests/log.rsdiffbeforeafterboth23enum ERC721Log {23enum ERC721Log {24 Transfer {24 Transfer {25 #[indexed]25 #[indexed]26 from: address,26 from: Address,27 #[indexed]27 #[indexed]28 to: address,28 to: Address,29 value: U256,29 value: U256,30 },30 },31 Eee {31 Eee {32 #[indexed]32 #[indexed]33 aaa: address,33 aaa: Address,34 bbb: U256,34 bbb: U256,35 },35 },36}36}crates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth25 unreachable!()25 unreachable!()26 }26 }27 /// Get balance of specified owner27 /// Get balance of specified owner28 fn balance_of(&self, _owner: address) -> Result<U256> {28 fn balance_of(&self, _owner: Address) -> Result<U256> {29 unreachable!()29 unreachable!()30 }30 }31 fn transfer(&mut self, _caller: caller, _to: address, _value: U256) -> Result<bool> {31 fn transfer(&mut self, _caller: caller, _to: Address, _value: U256) -> Result<bool> {32 unreachable!()32 unreachable!()33 }33 }34 fn transfer_from(34 fn transfer_from(35 &mut self,35 &mut self,36 _caller: caller,36 _caller: caller,37 _from: address,37 _from: Address,38 _to: address,38 _to: Address,39 _value: U256,39 _value: U256,40 ) -> Result<bool> {40 ) -> Result<bool> {41 unreachable!()41 unreachable!()42 }42 }43 fn approve(&mut self, _caller: caller, _spender: address, _value: U256) -> Result<bool> {43 fn approve(&mut self, _caller: caller, _spender: Address, _value: U256) -> Result<bool> {44 unreachable!()44 unreachable!()45 }45 }46 fn allowance(&self, _owner: address, _spender: address) -> Result<U256> {46 fn allowance(&self, _owner: Address, _spender: Address) -> Result<U256> {47 unreachable!()47 unreachable!()48 }48 }49}49}pallets/common/src/erc.rsdiffbeforeafterboth43 CollectionCreated {43 CollectionCreated {44 /// Collection owner.44 /// Collection owner.45 #[indexed]45 #[indexed]46 owner: address,46 owner: Address,474748 /// Collection ID.48 /// Collection ID.49 #[indexed]49 #[indexed]50 collection_id: address,50 collection_id: Address,51 },51 },52 /// The collection has been destroyed.52 /// The collection has been destroyed.53 CollectionDestroyed {53 CollectionDestroyed {54 /// Collection ID.54 /// Collection ID.55 #[indexed]55 #[indexed]56 collection_id: address,56 collection_id: Address,57 },57 },58 /// The collection has been changed.58 /// The collection has been changed.59 CollectionChanged {59 CollectionChanged {60 /// Collection ID.60 /// Collection ID.61 #[indexed]61 #[indexed]62 collection_id: address,62 collection_id: Address,63 },63 },646465 /// The token has been changed.65 /// The token has been changed.66 TokenChanged {66 TokenChanged {67 /// Collection ID.67 /// Collection ID.68 #[indexed]68 #[indexed]69 collection_id: address,69 collection_id: Address,70 /// Token ID.70 /// Token ID.71 token_id: U256,71 token_id: U256,72 },72 },208 ///208 ///209 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.209 /// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.210 #[solidity(hide)]210 #[solidity(hide)]211 fn set_collection_sponsor(&mut self, caller: caller, sponsor: address) -> Result<()> {211 fn set_collection_sponsor(&mut self, caller: caller, sponsor: Address) -> Result<()> {212 self.consume_store_reads_and_writes(1, 1)?;212 self.consume_store_reads_and_writes(1, 1)?;213213214 let caller = T::CrossAccountId::from_eth(caller);214 let caller = T::CrossAccountId::from_eth(caller);351 }351 }352352353 /// Get contract address.353 /// Get contract address.354 fn contract_address(&self) -> Result<address> {354 fn contract_address(&self) -> Result<Address> {355 Ok(crate::eth::collection_id_to_address(self.id))355 Ok(crate::eth::collection_id_to_address(self.id))356 }356 }357357388 /// Add collection admin.388 /// Add collection admin.389 /// @param newAdmin Address of the added administrator.389 /// @param newAdmin Address of the added administrator.390 #[solidity(hide)]390 #[solidity(hide)]391 fn add_collection_admin(&mut self, caller: caller, new_admin: address) -> Result<()> {391 fn add_collection_admin(&mut self, caller: caller, new_admin: Address) -> Result<()> {392 self.consume_store_reads_and_writes(2, 2)?;392 self.consume_store_reads_and_writes(2, 2)?;393393394 let caller = T::CrossAccountId::from_eth(caller);394 let caller = T::CrossAccountId::from_eth(caller);401 ///401 ///402 /// @param admin Address of the removed administrator.402 /// @param admin Address of the removed administrator.403 #[solidity(hide)]403 #[solidity(hide)]404 fn remove_collection_admin(&mut self, caller: caller, admin: address) -> Result<()> {404 fn remove_collection_admin(&mut self, caller: caller, admin: Address) -> Result<()> {405 self.consume_store_reads_and_writes(2, 2)?;405 self.consume_store_reads_and_writes(2, 2)?;406406407 let caller = T::CrossAccountId::from_eth(caller);407 let caller = T::CrossAccountId::from_eth(caller);437 &mut self,437 &mut self,438 caller: caller,438 caller: caller,439 enable: bool,439 enable: bool,440 collections: Vec<address>,440 collections: Vec<Address>,441 ) -> Result<()> {441 ) -> Result<()> {442 self.consume_store_reads_and_writes(1, 1)?;442 self.consume_store_reads_and_writes(1, 1)?;443443526 ///526 ///527 /// @param user Address of a trusted user.527 /// @param user Address of a trusted user.528 #[solidity(hide)]528 #[solidity(hide)]529 fn add_to_collection_allow_list(&mut self, caller: caller, user: address) -> Result<()> {529 fn add_to_collection_allow_list(&mut self, caller: caller, user: Address) -> Result<()> {530 self.consume_store_writes(1)?;530 self.consume_store_writes(1)?;531531532 let caller = T::CrossAccountId::from_eth(caller);532 let caller = T::CrossAccountId::from_eth(caller);555 ///555 ///556 /// @param user Address of a removed user.556 /// @param user Address of a removed user.557 #[solidity(hide)]557 #[solidity(hide)]558 fn remove_from_collection_allow_list(&mut self, caller: caller, user: address) -> Result<()> {558 fn remove_from_collection_allow_list(&mut self, caller: caller, user: Address) -> Result<()> {559 self.consume_store_writes(1)?;559 self.consume_store_writes(1)?;560560561 let caller = T::CrossAccountId::from_eth(caller);561 let caller = T::CrossAccountId::from_eth(caller);599 /// @param user account to verify599 /// @param user account to verify600 /// @return "true" if account is the owner or admin600 /// @return "true" if account is the owner or admin601 #[solidity(hide, rename_selector = "isOwnerOrAdmin")]601 #[solidity(hide, rename_selector = "isOwnerOrAdmin")]602 fn is_owner_or_admin_eth(&self, user: address) -> Result<bool> {602 fn is_owner_or_admin_eth(&self, user: Address) -> Result<bool> {603 let user = T::CrossAccountId::from_eth(user);603 let user = T::CrossAccountId::from_eth(user);604 Ok(self.is_owner_or_admin(&user))604 Ok(self.is_owner_or_admin(&user))605 }605 }640 /// @dev Owner can be changed only by current owner640 /// @dev Owner can be changed only by current owner641 /// @param newOwner new owner account641 /// @param newOwner new owner account642 #[solidity(hide, rename_selector = "changeCollectionOwner")]642 #[solidity(hide, rename_selector = "changeCollectionOwner")]643 fn set_owner(&mut self, caller: caller, new_owner: address) -> Result<()> {643 fn set_owner(&mut self, caller: caller, new_owner: Address) -> Result<()> {644 self.consume_store_writes(1)?;644 self.consume_store_writes(1)?;645645646 let caller = T::CrossAccountId::from_eth(caller);646 let caller = T::CrossAccountId::from_eth(caller);pallets/common/src/eth.rsdiffbeforeafterboth181819use alloc::format;19use alloc::format;20use sp_std::{vec, vec::Vec};20use sp_std::{vec, vec::Vec};21use evm_coder::{AbiCoder, types::address};21use evm_coder::{AbiCoder, types::Address};22pub use pallet_evm::{Config, account::CrossAccountId};22pub use pallet_evm::{Config, account::CrossAccountId};23use sp_core::{H160, U256};23use sp_core::{H160, U256};24use up_data_structs::CollectionId;24use up_data_structs::CollectionId;30];30];313132/// Maps the ethereum address of the collection in substrate.32/// Maps the ethereum address of the collection in substrate.33pub fn map_eth_to_id(eth: &H160) -> Option<CollectionId> {33pub fn map_eth_to_id(eth: &Address) -> Option<CollectionId> {34 if eth[0..16] != ETH_COLLECTION_PREFIX {34 if eth[0..16] != ETH_COLLECTION_PREFIX {35 return None;35 return None;36 }36 }40}40}414142/// Maps the substrate collection id in ethereum.42/// Maps the substrate collection id in ethereum.43pub fn collection_id_to_address(id: CollectionId) -> H160 {43pub fn collection_id_to_address(id: CollectionId) -> Address {44 let mut out = [0; 20];44 let mut out = [0; 20];45 out[0..16].copy_from_slice(Ð_COLLECTION_PREFIX);45 out[0..16].copy_from_slice(Ð_COLLECTION_PREFIX);46 out[16..20].copy_from_slice(&u32::to_be_bytes(id.0));46 out[16..20].copy_from_slice(&u32::to_be_bytes(id.0));47 H160(out)47 H160(out)48}48}494950/// Check if the ethereum address is a collection.50/// Check if the ethereum address is a collection.51pub fn is_collection(address: &H160) -> bool {51pub fn is_collection(address: &Address) -> bool {52 address[0..16] == ETH_COLLECTION_PREFIX52 address[0..16] == ETH_COLLECTION_PREFIX53}53}545466/// Cross account struct66/// Cross account struct67#[derive(Debug, Default, AbiCoder)]67#[derive(Debug, Default, AbiCoder)]68pub struct CrossAddress {68pub struct CrossAddress {69 pub(crate) eth: address,69 pub(crate) eth: Address,70 pub(crate) sub: U256,70 pub(crate) sub: U256,71}71}7272pallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth49 ContractSponsorSet {49 ContractSponsorSet {50 /// Contract address of the affected collection.50 /// Contract address of the affected collection.51 #[indexed]51 #[indexed]52 contract_address: address,52 contract_address: Address,53 /// New sponsor address.53 /// New sponsor address.54 sponsor: address,54 sponsor: Address,55 },55 },565657 /// New sponsor was confirm.57 /// New sponsor was confirm.58 ContractSponsorshipConfirmed {58 ContractSponsorshipConfirmed {59 /// Contract address of the affected collection.59 /// Contract address of the affected collection.60 #[indexed]60 #[indexed]61 contract_address: address,61 contract_address: Address,62 /// New sponsor address.62 /// New sponsor address.63 sponsor: address,63 sponsor: Address,64 },64 },656566 /// Collection sponsor was removed.66 /// Collection sponsor was removed.67 ContractSponsorRemoved {67 ContractSponsorRemoved {68 /// Contract address of the affected collection.68 /// Contract address of the affected collection.69 #[indexed]69 #[indexed]70 contract_address: address,70 contract_address: Address,71 },71 },72}72}737396 /// @dev Returns zero address if contract does not exists96 /// @dev Returns zero address if contract does not exists97 /// @param contractAddress Contract to get owner of97 /// @param contractAddress Contract to get owner of98 /// @return address Owner of contract98 /// @return address Owner of contract99 fn contract_owner(&self, contract_address: address) -> Result<address> {99 fn contract_owner(&self, contract_address: Address) -> Result<Address> {100 Ok(<Owner<T>>::get(contract_address))100 Ok(<Owner<T>>::get(contract_address))101 }101 }102102106 fn set_sponsor(106 fn set_sponsor(107 &mut self,107 &mut self,108 caller: caller,108 caller: caller,109 contract_address: address,109 contract_address: Address,110 sponsor: address,110 sponsor: Address,111 ) -> Result<()> {111 ) -> Result<()> {112 self.recorder().consume_sload()?;112 self.recorder().consume_sload()?;113 self.recorder().consume_sstore()?;113 self.recorder().consume_sstore()?;125 /// Set contract as self sponsored.125 /// Set contract as self sponsored.126 ///126 ///127 /// @param contractAddress Contract for which a self sponsoring is being enabled.127 /// @param contractAddress Contract for which a self sponsoring is being enabled.128 fn self_sponsored_enable(&mut self, caller: caller, contract_address: address) -> Result<()> {128 fn self_sponsored_enable(&mut self, caller: caller, contract_address: Address) -> Result<()> {129 self.recorder().consume_sload()?;129 self.recorder().consume_sload()?;130 self.recorder().consume_sstore()?;130 self.recorder().consume_sstore()?;131131146 /// Remove sponsor.146 /// Remove sponsor.147 ///147 ///148 /// @param contractAddress Contract for which a sponsorship is being removed.148 /// @param contractAddress Contract for which a sponsorship is being removed.149 fn remove_sponsor(&mut self, caller: caller, contract_address: address) -> Result<()> {149 fn remove_sponsor(&mut self, caller: caller, contract_address: Address) -> Result<()> {150 self.recorder().consume_sload()?;150 self.recorder().consume_sload()?;151 self.recorder().consume_sstore()?;151 self.recorder().consume_sstore()?;152152161 /// @dev Caller must be same that set via [`setSponsor`].161 /// @dev Caller must be same that set via [`setSponsor`].162 ///162 ///163 /// @param contractAddress Сontract for which need to confirm sponsorship.163 /// @param contractAddress Сontract for which need to confirm sponsorship.164 fn confirm_sponsorship(&mut self, caller: caller, contract_address: address) -> Result<()> {164 fn confirm_sponsorship(&mut self, caller: caller, contract_address: Address) -> Result<()> {165 self.recorder().consume_sload()?;165 self.recorder().consume_sload()?;166 self.recorder().consume_sstore()?;166 self.recorder().consume_sstore()?;167167175 ///175 ///176 /// @param contractAddress The contract for which a sponsor is requested.176 /// @param contractAddress The contract for which a sponsor is requested.177 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.177 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.178 fn sponsor(&self, contract_address: address) -> Result<Option<eth::CrossAddress>> {178 fn sponsor(&self, contract_address: Address) -> Result<Option<eth::CrossAddress>> {179 Ok(match Pallet::<T>::get_sponsor(contract_address) {179 Ok(match Pallet::<T>::get_sponsor(contract_address) {180 Some(ref value) => Some(eth::CrossAddress::from_sub_cross_account::<T>(value)),180 Some(ref value) => Some(eth::CrossAddress::from_sub_cross_account::<T>(value)),181 None => None,181 None => None,186 ///186 ///187 /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.187 /// @param contractAddress The contract for which the presence of a confirmed sponsor is checked.188 /// @return **true** if contract has confirmed sponsor.188 /// @return **true** if contract has confirmed sponsor.189 fn has_sponsor(&self, contract_address: address) -> Result<bool> {189 fn has_sponsor(&self, contract_address: Address) -> Result<bool> {190 Ok(Pallet::<T>::get_sponsor(contract_address).is_some())190 Ok(Pallet::<T>::get_sponsor(contract_address).is_some())191 }191 }192192193 /// Check tat contract has pending sponsor.193 /// Check tat contract has pending sponsor.194 ///194 ///195 /// @param contractAddress The contract for which the presence of a pending sponsor is checked.195 /// @param contractAddress The contract for which the presence of a pending sponsor is checked.196 /// @return **true** if contract has pending sponsor.196 /// @return **true** if contract has pending sponsor.197 fn has_pending_sponsor(&self, contract_address: address) -> Result<bool> {197 fn has_pending_sponsor(&self, contract_address: Address) -> Result<bool> {198 Ok(match Sponsoring::<T>::get(contract_address) {198 Ok(match Sponsoring::<T>::get(contract_address) {199 SponsorshipState::Disabled | SponsorshipState::Confirmed(_) => false,199 SponsorshipState::Disabled | SponsorshipState::Confirmed(_) => false,200 SponsorshipState::Unconfirmed(_) => true,200 SponsorshipState::Unconfirmed(_) => true,201 })201 })202 }202 }203203204 fn sponsoring_enabled(&self, contract_address: address) -> Result<bool> {204 fn sponsoring_enabled(&self, contract_address: Address) -> Result<bool> {205 Ok(<Pallet<T>>::sponsoring_mode(contract_address) != SponsoringModeT::Disabled)205 Ok(<Pallet<T>>::sponsoring_mode(contract_address) != SponsoringModeT::Disabled)206 }206 }207207208 fn set_sponsoring_mode(208 fn set_sponsoring_mode(209 &mut self,209 &mut self,210 caller: caller,210 caller: caller,211 contract_address: address,211 contract_address: Address,212 mode: SponsoringModeT,212 mode: SponsoringModeT,213 ) -> Result<()> {213 ) -> Result<()> {214 self.recorder().consume_sload()?;214 self.recorder().consume_sload()?;223 /// Get current contract sponsoring rate limit223 /// Get current contract sponsoring rate limit224 /// @param contractAddress Contract to get sponsoring rate limit of224 /// @param contractAddress Contract to get sponsoring rate limit of225 /// @return uint32 Amount of blocks between two sponsored transactions225 /// @return uint32 Amount of blocks between two sponsored transactions226 fn sponsoring_rate_limit(&self, contract_address: address) -> Result<u32> {226 fn sponsoring_rate_limit(&self, contract_address: Address) -> Result<u32> {227 self.recorder().consume_sload()?;227 self.recorder().consume_sload()?;228228229 Ok(<SponsoringRateLimit<T>>::get(contract_address)229 Ok(<SponsoringRateLimit<T>>::get(contract_address)240 fn set_sponsoring_rate_limit(240 fn set_sponsoring_rate_limit(241 &mut self,241 &mut self,242 caller: caller,242 caller: caller,243 contract_address: address,243 contract_address: Address,244 rate_limit: u32,244 rate_limit: u32,245 ) -> Result<()> {245 ) -> Result<()> {246 self.recorder().consume_sload()?;246 self.recorder().consume_sload()?;260 fn set_sponsoring_fee_limit(260 fn set_sponsoring_fee_limit(261 &mut self,261 &mut self,262 caller: caller,262 caller: caller,263 contract_address: address,263 contract_address: Address,264 fee_limit: U256,264 fee_limit: U256,265 ) -> Result<()> {265 ) -> Result<()> {266 self.recorder().consume_sload()?;266 self.recorder().consume_sload()?;276 /// @param contractAddress Contract to get sponsoring fee limit of276 /// @param contractAddress Contract to get sponsoring fee limit of277 /// @return uint256 Maximum amount of fee that could be spent by single277 /// @return uint256 Maximum amount of fee that could be spent by single278 /// transaction278 /// transaction279 fn sponsoring_fee_limit(&self, contract_address: address) -> Result<U256> {279 fn sponsoring_fee_limit(&self, contract_address: Address) -> Result<U256> {280 self.recorder().consume_sload()?;280 self.recorder().consume_sload()?;281281282 Ok(get_sponsoring_fee_limit::<T>(contract_address))282 Ok(get_sponsoring_fee_limit::<T>(contract_address))287 /// @param contractAddress Contract to check allowlist of287 /// @param contractAddress Contract to check allowlist of288 /// @param user User to check288 /// @param user User to check289 /// @return bool Is specified users exists in contract allowlist289 /// @return bool Is specified users exists in contract allowlist290 fn allowed(&self, contract_address: address, user: address) -> Result<bool> {290 fn allowed(&self, contract_address: Address, user: Address) -> Result<bool> {291 self.0.consume_sload()?;291 self.0.consume_sload()?;292 Ok(<Pallet<T>>::allowed(contract_address, user))292 Ok(<Pallet<T>>::allowed(contract_address, user))293 }293 }301 fn toggle_allowed(301 fn toggle_allowed(302 &mut self,302 &mut self,303 caller: caller,303 caller: caller,304 contract_address: address,304 contract_address: Address,305 user: address,305 user: Address,306 is_allowed: bool,306 is_allowed: bool,307 ) -> Result<()> {307 ) -> Result<()> {308 self.recorder().consume_sload()?;308 self.recorder().consume_sload()?;320 /// in case of allowlist access enabled, only users from allowlist may call this contract320 /// in case of allowlist access enabled, only users from allowlist may call this contract321 /// @param contractAddress Contract to get allowlist access of321 /// @param contractAddress Contract to get allowlist access of322 /// @return bool Is specified contract has allowlist access enabled322 /// @return bool Is specified contract has allowlist access enabled323 fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {323 fn allowlist_enabled(&self, contract_address: Address) -> Result<bool> {324 Ok(<AllowlistEnabled<T>>::get(contract_address))324 Ok(<AllowlistEnabled<T>>::get(contract_address))325 }325 }326326330 fn toggle_allowlist(330 fn toggle_allowlist(331 &mut self,331 &mut self,332 caller: caller,332 caller: caller,333 contract_address: address,333 contract_address: Address,334 enabled: bool,334 enabled: bool,335 ) -> Result<()> {335 ) -> Result<()> {336 self.recorder().consume_sload()?;336 self.recorder().consume_sload()?;441 }441 }442}442}443443444fn get_sponsoring_fee_limit<T: Config>(contract_address: address) -> U256 {444fn get_sponsoring_fee_limit<T: Config>(contract_address: Address) -> U256 {445 <SponsoringFeeLimit<T>>::get(contract_address)445 <SponsoringFeeLimit<T>>::get(contract_address)446 .get(&0xffffffff)446 .get(&0xffffffff)447 .cloned()447 .cloned()pallets/fungible/src/erc.rsdiffbeforeafterboth43pub enum ERC20Events {43pub enum ERC20Events {44 Transfer {44 Transfer {45 #[indexed]45 #[indexed]46 from: address,46 from: Address,47 #[indexed]47 #[indexed]48 to: address,48 to: Address,49 value: U256,49 value: U256,50 },50 },51 Approval {51 Approval {52 #[indexed]52 #[indexed]53 owner: address,53 owner: Address,54 #[indexed]54 #[indexed]55 spender: address,55 spender: Address,56 value: U256,56 value: U256,57 },57 },58}58}79 unreachable!()79 unreachable!()80 })80 })81 }81 }82 fn balance_of(&self, owner: address) -> Result<U256> {82 fn balance_of(&self, owner: Address) -> Result<U256> {83 self.consume_store_reads(1)?;83 self.consume_store_reads(1)?;84 let owner = T::CrossAccountId::from_eth(owner);84 let owner = T::CrossAccountId::from_eth(owner);85 let balance = <Balance<T>>::get((self.id, owner));85 let balance = <Balance<T>>::get((self.id, owner));86 Ok(balance.into())86 Ok(balance.into())87 }87 }88 #[weight(<SelfWeightOf<T>>::transfer())]88 #[weight(<SelfWeightOf<T>>::transfer())]89 fn transfer(&mut self, caller: caller, to: address, amount: U256) -> Result<bool> {89 fn transfer(&mut self, caller: caller, to: Address, amount: U256) -> Result<bool> {90 let caller = T::CrossAccountId::from_eth(caller);90 let caller = T::CrossAccountId::from_eth(caller);91 let to = T::CrossAccountId::from_eth(to);91 let to = T::CrossAccountId::from_eth(to);92 let amount = amount.try_into().map_err(|_| "amount overflow")?;92 let amount = amount.try_into().map_err(|_| "amount overflow")?;102 fn transfer_from(102 fn transfer_from(103 &mut self,103 &mut self,104 caller: caller,104 caller: caller,105 from: address,105 from: Address,106 to: address,106 to: Address,107 amount: U256,107 amount: U256,108 ) -> Result<bool> {108 ) -> Result<bool> {109 let caller = T::CrossAccountId::from_eth(caller);109 let caller = T::CrossAccountId::from_eth(caller);119 Ok(true)119 Ok(true)120 }120 }121 #[weight(<SelfWeightOf<T>>::approve())]121 #[weight(<SelfWeightOf<T>>::approve())]122 fn approve(&mut self, caller: caller, spender: address, amount: U256) -> Result<bool> {122 fn approve(&mut self, caller: caller, spender: Address, amount: U256) -> Result<bool> {123 let caller = T::CrossAccountId::from_eth(caller);123 let caller = T::CrossAccountId::from_eth(caller);124 let spender = T::CrossAccountId::from_eth(spender);124 let spender = T::CrossAccountId::from_eth(spender);125 let amount = amount.try_into().map_err(|_| "amount overflow")?;125 let amount = amount.try_into().map_err(|_| "amount overflow")?;128 .map_err(dispatch_to_evm::<T>)?;128 .map_err(dispatch_to_evm::<T>)?;129 Ok(true)129 Ok(true)130 }130 }131 fn allowance(&self, owner: address, spender: address) -> Result<U256> {131 fn allowance(&self, owner: Address, spender: Address) -> Result<U256> {132 self.consume_store_reads(1)?;132 self.consume_store_reads(1)?;133 let owner = T::CrossAccountId::from_eth(owner);133 let owner = T::CrossAccountId::from_eth(owner);134 let spender = T::CrossAccountId::from_eth(spender);134 let spender = T::CrossAccountId::from_eth(spender);137 }137 }138138139 /// @notice Returns collection helper contract address139 /// @notice Returns collection helper contract address140 fn collection_helper_address(&self) -> Result<address> {140 fn collection_helper_address(&self) -> Result<Address> {141 Ok(T::ContractAddress::get())141 Ok(T::ContractAddress::get())142 }142 }143}143}148 /// @param to account that will receive minted tokens148 /// @param to account that will receive minted tokens149 /// @param amount amount of tokens to mint149 /// @param amount amount of tokens to mint150 #[weight(<SelfWeightOf<T>>::create_item())]150 #[weight(<SelfWeightOf<T>>::create_item())]151 fn mint(&mut self, caller: caller, to: address, amount: U256) -> Result<bool> {151 fn mint(&mut self, caller: caller, to: Address, amount: U256) -> Result<bool> {152 let caller = T::CrossAccountId::from_eth(caller);152 let caller = T::CrossAccountId::from_eth(caller);153 let to = T::CrossAccountId::from_eth(to);153 let to = T::CrossAccountId::from_eth(to);154 let amount = amount.try_into().map_err(|_| "amount overflow")?;154 let amount = amount.try_into().map_err(|_| "amount overflow")?;214 /// @param amount The amount that will be burnt.214 /// @param amount The amount that will be burnt.215 #[solidity(hide)]215 #[solidity(hide)]216 #[weight(<SelfWeightOf<T>>::burn_from())]216 #[weight(<SelfWeightOf<T>>::burn_from())]217 fn burn_from(&mut self, caller: caller, from: address, amount: U256) -> Result<bool> {217 fn burn_from(&mut self, caller: caller, from: Address, amount: U256) -> Result<bool> {218 let caller = T::CrossAccountId::from_eth(caller);218 let caller = T::CrossAccountId::from_eth(caller);219 let from = T::CrossAccountId::from_eth(from);219 let from = T::CrossAccountId::from_eth(from);220 let amount = amount.try_into().map_err(|_| "amount overflow")?;220 let amount = amount.try_into().map_err(|_| "amount overflow")?;254 /// Mint tokens for multiple accounts.254 /// Mint tokens for multiple accounts.255 /// @param amounts array of pairs of account address and amount255 /// @param amounts array of pairs of account address and amount256 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]256 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]257 fn mint_bulk(&mut self, caller: caller, amounts: Vec<(address, U256)>) -> Result<bool> {257 fn mint_bulk(&mut self, caller: caller, amounts: Vec<(Address, U256)>) -> Result<bool> {258 let caller = T::CrossAccountId::from_eth(caller);258 let caller = T::CrossAccountId::from_eth(caller);259 let budget = self259 let budget = self260 .recorder260 .recorderpallets/nonfungible/src/erc.rsdiffbeforeafterboth261 /// any transfer, the approved address for that NFT (if any) is reset to none.261 /// any transfer, the approved address for that NFT (if any) is reset to none.262 Transfer {262 Transfer {263 #[indexed]263 #[indexed]264 from: address,264 from: Address,265 #[indexed]265 #[indexed]266 to: address,266 to: Address,267 #[indexed]267 #[indexed]268 token_id: U256,268 token_id: U256,269 },269 },273 /// address for that NFT (if any) is reset to none.273 /// address for that NFT (if any) is reset to none.274 Approval {274 Approval {275 #[indexed]275 #[indexed]276 owner: address,276 owner: Address,277 #[indexed]277 #[indexed]278 approved: address,278 approved: Address,279 #[indexed]279 #[indexed]280 token_id: U256,280 token_id: U256,281 },281 },284 #[allow(dead_code)]284 #[allow(dead_code)]285 ApprovalForAll {285 ApprovalForAll {286 #[indexed]286 #[indexed]287 owner: address,287 owner: Address,288 #[indexed]288 #[indexed]289 operator: address,289 operator: Address,290 approved: bool,290 approved: bool,291 },291 },292}292}373 }373 }374374375 /// @dev Not implemented375 /// @dev Not implemented376 fn token_of_owner_by_index(&self, _owner: address, _index: U256) -> Result<U256> {376 fn token_of_owner_by_index(&self, _owner: Address, _index: U256) -> Result<U256> {377 // TODO: Not implemetable377 // TODO: Not implemetable378 Err("not implemented".into())378 Err("not implemented".into())379 }379 }396 /// function throws for queries about the zero address.396 /// function throws for queries about the zero address.397 /// @param owner An address for whom to query the balance397 /// @param owner An address for whom to query the balance398 /// @return The number of NFTs owned by `owner`, possibly zero398 /// @return The number of NFTs owned by `owner`, possibly zero399 fn balance_of(&self, owner: address) -> Result<U256> {399 fn balance_of(&self, owner: Address) -> Result<U256> {400 self.consume_store_reads(1)?;400 self.consume_store_reads(1)?;401 let owner = T::CrossAccountId::from_eth(owner);401 let owner = T::CrossAccountId::from_eth(owner);402 let balance = <AccountBalance<T>>::get((self.id, owner));402 let balance = <AccountBalance<T>>::get((self.id, owner));407 /// about them do throw.407 /// about them do throw.408 /// @param tokenId The identifier for an NFT408 /// @param tokenId The identifier for an NFT409 /// @return The address of the owner of the NFT409 /// @return The address of the owner of the NFT410 fn owner_of(&self, token_id: U256) -> Result<address> {410 fn owner_of(&self, token_id: U256) -> Result<Address> {411 self.consume_store_reads(1)?;411 self.consume_store_reads(1)?;412 let token: TokenId = token_id.try_into()?;412 let token: TokenId = token_id.try_into()?;413 Ok(*<TokenData<T>>::get((self.id, token))413 Ok(*<TokenData<T>>::get((self.id, token))419 #[solidity(rename_selector = "safeTransferFrom")]419 #[solidity(rename_selector = "safeTransferFrom")]420 fn safe_transfer_from_with_data(420 fn safe_transfer_from_with_data(421 &mut self,421 &mut self,422 _from: address,422 _from: Address,423 _to: address,423 _to: Address,424 _token_id: U256,424 _token_id: U256,425 _data: bytes,425 _data: bytes,426 ) -> Result<()> {426 ) -> Result<()> {427 // TODO: Not implemetable427 // TODO: Not implemetable428 Err("not implemented".into())428 Err("not implemented".into())429 }429 }430 /// @dev Not implemented430 /// @dev Not implemented431 fn safe_transfer_from(&mut self, _from: address, _to: address, _token_id: U256) -> Result<()> {431 fn safe_transfer_from(&mut self, _from: Address, _to: Address, _token_id: U256) -> Result<()> {432 // TODO: Not implemetable432 // TODO: Not implemetable433 Err("not implemented".into())433 Err("not implemented".into())434 }434 }446 fn transfer_from(446 fn transfer_from(447 &mut self,447 &mut self,448 caller: caller,448 caller: caller,449 from: address,449 from: Address,450 to: address,450 to: Address,451 token_id: U256,451 token_id: U256,452 ) -> Result<()> {452 ) -> Result<()> {453 let caller = T::CrossAccountId::from_eth(caller);453 let caller = T::CrossAccountId::from_eth(caller);470 /// @param approved The new approved NFT controller470 /// @param approved The new approved NFT controller471 /// @param tokenId The NFT to approve471 /// @param tokenId The NFT to approve472 #[weight(<SelfWeightOf<T>>::approve())]472 #[weight(<SelfWeightOf<T>>::approve())]473 fn approve(&mut self, caller: caller, approved: address, token_id: U256) -> Result<()> {473 fn approve(&mut self, caller: caller, approved: Address, token_id: U256) -> Result<()> {474 let caller = T::CrossAccountId::from_eth(caller);474 let caller = T::CrossAccountId::from_eth(caller);475 let approved = T::CrossAccountId::from_eth(approved);475 let approved = T::CrossAccountId::from_eth(approved);476 let token = token_id.try_into()?;476 let token = token_id.try_into()?;488 fn set_approval_for_all(488 fn set_approval_for_all(489 &mut self,489 &mut self,490 caller: caller,490 caller: caller,491 operator: address,491 operator: Address,492 approved: bool,492 approved: bool,493 ) -> Result<()> {493 ) -> Result<()> {494 let caller = T::CrossAccountId::from_eth(caller);494 let caller = T::CrossAccountId::from_eth(caller);500 }500 }501501502 /// @dev Not implemented502 /// @dev Not implemented503 fn get_approved(&self, _token_id: U256) -> Result<address> {503 fn get_approved(&self, _token_id: U256) -> Result<Address> {504 // TODO: Not implemetable504 // TODO: Not implemetable505 Err("not implemented".into())505 Err("not implemented".into())506 }506 }507507508 /// @notice Tells whether the given `owner` approves the `operator`.508 /// @notice Tells whether the given `owner` approves the `operator`.509 #[weight(<SelfWeightOf<T>>::allowance_for_all())]509 #[weight(<SelfWeightOf<T>>::allowance_for_all())]510 fn is_approved_for_all(&self, owner: address, operator: address) -> Result<bool> {510 fn is_approved_for_all(&self, owner: Address, operator: Address) -> Result<bool> {511 let owner = T::CrossAccountId::from_eth(owner);511 let owner = T::CrossAccountId::from_eth(owner);512 let operator = T::CrossAccountId::from_eth(operator);512 let operator = T::CrossAccountId::from_eth(operator);513513539 /// @param to The new owner539 /// @param to The new owner540 /// @return uint256 The id of the newly minted token540 /// @return uint256 The id of the newly minted token541 #[weight(<SelfWeightOf<T>>::create_item())]541 #[weight(<SelfWeightOf<T>>::create_item())]542 fn mint(&mut self, caller: caller, to: address) -> Result<U256> {542 fn mint(&mut self, caller: caller, to: Address) -> Result<U256> {543 let token_id: U256 = <TokensMinted<T>>::get(self.id)543 let token_id: U256 = <TokensMinted<T>>::get(self.id)544 .checked_add(1)544 .checked_add(1)545 .ok_or("item id overflow")?545 .ok_or("item id overflow")?555 /// @param tokenId ID of the minted NFT555 /// @param tokenId ID of the minted NFT556 #[solidity(hide, rename_selector = "mint")]556 #[solidity(hide, rename_selector = "mint")]557 #[weight(<SelfWeightOf<T>>::create_item())]557 #[weight(<SelfWeightOf<T>>::create_item())]558 fn mint_check_id(&mut self, caller: caller, to: address, token_id: U256) -> Result<bool> {558 fn mint_check_id(&mut self, caller: caller, to: Address, token_id: U256) -> Result<bool> {559 let caller = T::CrossAccountId::from_eth(caller);559 let caller = T::CrossAccountId::from_eth(caller);560 let to = T::CrossAccountId::from_eth(to);560 let to = T::CrossAccountId::from_eth(to);561 let token_id: u32 = token_id.try_into()?;561 let token_id: u32 = token_id.try_into()?;594 fn mint_with_token_uri(594 fn mint_with_token_uri(595 &mut self,595 &mut self,596 caller: caller,596 caller: caller,597 to: address,597 to: Address,598 token_uri: string,598 token_uri: string,599 ) -> Result<U256> {599 ) -> Result<U256> {600 let token_id: U256 = <TokensMinted<T>>::get(self.id)600 let token_id: U256 = <TokensMinted<T>>::get(self.id)616 fn mint_with_token_uri_check_id(616 fn mint_with_token_uri_check_id(617 &mut self,617 &mut self,618 caller: caller,618 caller: caller,619 to: address,619 to: Address,620 token_id: U256,620 token_id: U256,621 token_uri: string,621 token_uri: string,622 ) -> Result<bool> {622 ) -> Result<bool> {784 /// @param to The new owner784 /// @param to The new owner785 /// @param tokenId The NFT to transfer785 /// @param tokenId The NFT to transfer786 #[weight(<SelfWeightOf<T>>::transfer())]786 #[weight(<SelfWeightOf<T>>::transfer())]787 fn transfer(&mut self, caller: caller, to: address, token_id: U256) -> Result<()> {787 fn transfer(&mut self, caller: caller, to: Address, token_id: U256) -> Result<()> {788 let caller = T::CrossAccountId::from_eth(caller);788 let caller = T::CrossAccountId::from_eth(caller);789 let to = T::CrossAccountId::from_eth(to);789 let to = T::CrossAccountId::from_eth(to);790 let token = token_id.try_into()?;790 let token = token_id.try_into()?;853 /// @param tokenId The NFT to transfer853 /// @param tokenId The NFT to transfer854 #[solidity(hide)]854 #[solidity(hide)]855 #[weight(<SelfWeightOf<T>>::burn_from())]855 #[weight(<SelfWeightOf<T>>::burn_from())]856 fn burn_from(&mut self, caller: caller, from: address, token_id: U256) -> Result<()> {856 fn burn_from(&mut self, caller: caller, from: Address, token_id: U256) -> Result<()> {857 let caller = T::CrossAccountId::from_eth(caller);857 let caller = T::CrossAccountId::from_eth(caller);858 let from = T::CrossAccountId::from_eth(from);858 let from = T::CrossAccountId::from_eth(from);859 let token = token_id.try_into()?;859 let token = token_id.try_into()?;907 /// @param tokenIds IDs of the minted NFTs907 /// @param tokenIds IDs of the minted NFTs908 #[solidity(hide)]908 #[solidity(hide)]909 #[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]909 #[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]910 fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<U256>) -> Result<bool> {910 fn mint_bulk(&mut self, caller: caller, to: Address, token_ids: Vec<U256>) -> Result<bool> {911 let caller = T::CrossAccountId::from_eth(caller);911 let caller = T::CrossAccountId::from_eth(caller);912 let to = T::CrossAccountId::from_eth(to);912 let to = T::CrossAccountId::from_eth(to);913 let mut expected_index = <TokensMinted<T>>::get(self.id)913 let mut expected_index = <TokensMinted<T>>::get(self.id)947 fn mint_bulk_with_token_uri(947 fn mint_bulk_with_token_uri(948 &mut self,948 &mut self,949 caller: caller,949 caller: caller,950 to: address,950 to: Address,951 tokens: Vec<(U256, string)>,951 tokens: Vec<(U256, string)>,952 ) -> Result<bool> {952 ) -> Result<bool> {953 let key = key::url();953 let key = key::url();1035 }1035 }103610361037 /// @notice Returns collection helper contract address1037 /// @notice Returns collection helper contract address1038 fn collection_helper_address(&self) -> Result<address> {1038 fn collection_helper_address(&self) -> Result<Address> {1039 Ok(T::ContractAddress::get())1039 Ok(T::ContractAddress::get())1040 }1040 }1041}1041}pallets/refungible/src/erc.rsdiffbeforeafterboth262 /// may be created and assigned without emitting Transfer.262 /// may be created and assigned without emitting Transfer.263 Transfer {263 Transfer {264 #[indexed]264 #[indexed]265 from: address,265 from: Address,266 #[indexed]266 #[indexed]267 to: address,267 to: Address,268 #[indexed]268 #[indexed]269 token_id: U256,269 token_id: U256,270 },270 },271 /// @dev Not supported271 /// @dev Not supported272 Approval {272 Approval {273 #[indexed]273 #[indexed]274 owner: address,274 owner: Address,275 #[indexed]275 #[indexed]276 approved: address,276 approved: Address,277 #[indexed]277 #[indexed]278 token_id: U256,278 token_id: U256,279 },279 },280 /// @dev Not supported280 /// @dev Not supported281 #[allow(dead_code)]281 #[allow(dead_code)]282 ApprovalForAll {282 ApprovalForAll {283 #[indexed]283 #[indexed]284 owner: address,284 owner: Address,285 #[indexed]285 #[indexed]286 operator: address,286 operator: Address,287 approved: bool,287 approved: bool,288 },288 },289}289}370 }370 }371371372 /// Not implemented372 /// Not implemented373 fn token_of_owner_by_index(&self, _owner: address, _index: U256) -> Result<U256> {373 fn token_of_owner_by_index(&self, _owner: Address, _index: U256) -> Result<U256> {374 // TODO: Not implemetable374 // TODO: Not implemetable375 Err("not implemented".into())375 Err("not implemented".into())376 }376 }393 /// function throws for queries about the zero address.393 /// function throws for queries about the zero address.394 /// @param owner An address for whom to query the balance394 /// @param owner An address for whom to query the balance395 /// @return The number of RFTs owned by `owner`, possibly zero395 /// @return The number of RFTs owned by `owner`, possibly zero396 fn balance_of(&self, owner: address) -> Result<U256> {396 fn balance_of(&self, owner: Address) -> Result<U256> {397 self.consume_store_reads(1)?;397 self.consume_store_reads(1)?;398 let owner = T::CrossAccountId::from_eth(owner);398 let owner = T::CrossAccountId::from_eth(owner);399 let balance = <AccountBalance<T>>::get((self.id, owner));399 let balance = <AccountBalance<T>>::get((self.id, owner));407 /// the tokens that are partially owned.407 /// the tokens that are partially owned.408 /// @param tokenId The identifier for an RFT408 /// @param tokenId The identifier for an RFT409 /// @return The address of the owner of the RFT409 /// @return The address of the owner of the RFT410 fn owner_of(&self, token_id: U256) -> Result<address> {410 fn owner_of(&self, token_id: U256) -> Result<Address> {411 self.consume_store_reads(2)?;411 self.consume_store_reads(2)?;412 let token = token_id.try_into()?;412 let token = token_id.try_into()?;413 let owner = <Pallet<T>>::token_owner(self.id, token);413 let owner = <Pallet<T>>::token_owner(self.id, token);420 #[solidity(rename_selector = "safeTransferFrom")]420 #[solidity(rename_selector = "safeTransferFrom")]421 fn safe_transfer_from_with_data(421 fn safe_transfer_from_with_data(422 &mut self,422 &mut self,423 _from: address,423 _from: Address,424 _to: address,424 _to: Address,425 _token_id: U256,425 _token_id: U256,426 _data: bytes,426 _data: bytes,427 ) -> Result<()> {427 ) -> Result<()> {431431432 /// @dev Not implemented432 /// @dev Not implemented433 #[solidity(rename_selector = "safeTransferFrom")]433 #[solidity(rename_selector = "safeTransferFrom")]434 fn safe_transfer_from(&mut self, _from: address, _to: address, _token_id: U256) -> Result<()> {434 fn safe_transfer_from(&mut self, _from: Address, _to: Address, _token_id: U256) -> Result<()> {435 // TODO: Not implemetable435 // TODO: Not implemetable436 Err("not implemented".into())436 Err("not implemented".into())437 }437 }450 fn transfer_from(450 fn transfer_from(451 &mut self,451 &mut self,452 caller: caller,452 caller: caller,453 from: address,453 from: Address,454 to: address,454 to: Address,455 token_id: U256,455 token_id: U256,456 ) -> Result<()> {456 ) -> Result<()> {457 let caller = T::CrossAccountId::from_eth(caller);457 let caller = T::CrossAccountId::from_eth(caller);472 }472 }473473474 /// @dev Not implemented474 /// @dev Not implemented475 fn approve(&mut self, _caller: caller, _approved: address, _token_id: U256) -> Result<()> {475 fn approve(&mut self, _caller: caller, _approved: Address, _token_id: U256) -> Result<()> {476 Err("not implemented".into())476 Err("not implemented".into())477 }477 }478478484 fn set_approval_for_all(484 fn set_approval_for_all(485 &mut self,485 &mut self,486 caller: caller,486 caller: caller,487 operator: address,487 operator: Address,488 approved: bool,488 approved: bool,489 ) -> Result<()> {489 ) -> Result<()> {490 let caller = T::CrossAccountId::from_eth(caller);490 let caller = T::CrossAccountId::from_eth(caller);496 }496 }497497498 /// @dev Not implemented498 /// @dev Not implemented499 fn get_approved(&self, _token_id: U256) -> Result<address> {499 fn get_approved(&self, _token_id: U256) -> Result<Address> {500 // TODO: Not implemetable500 // TODO: Not implemetable501 Err("not implemented".into())501 Err("not implemented".into())502 }502 }503503504 /// @notice Tells whether the given `owner` approves the `operator`.504 /// @notice Tells whether the given `owner` approves the `operator`.505 #[weight(<SelfWeightOf<T>>::allowance_for_all())]505 #[weight(<SelfWeightOf<T>>::allowance_for_all())]506 fn is_approved_for_all(&self, owner: address, operator: address) -> Result<bool> {506 fn is_approved_for_all(&self, owner: Address, operator: Address) -> Result<bool> {507 let owner = T::CrossAccountId::from_eth(owner);507 let owner = T::CrossAccountId::from_eth(owner);508 let operator = T::CrossAccountId::from_eth(operator);508 let operator = T::CrossAccountId::from_eth(operator);509509570 /// @param to The new owner570 /// @param to The new owner571 /// @return uint256 The id of the newly minted token571 /// @return uint256 The id of the newly minted token572 #[weight(<SelfWeightOf<T>>::create_item())]572 #[weight(<SelfWeightOf<T>>::create_item())]573 fn mint(&mut self, caller: caller, to: address) -> Result<U256> {573 fn mint(&mut self, caller: caller, to: Address) -> Result<U256> {574 let token_id: U256 = <TokensMinted<T>>::get(self.id)574 let token_id: U256 = <TokensMinted<T>>::get(self.id)575 .checked_add(1)575 .checked_add(1)576 .ok_or("item id overflow")?576 .ok_or("item id overflow")?586 /// @param tokenId ID of the minted RFT586 /// @param tokenId ID of the minted RFT587 #[solidity(hide, rename_selector = "mint")]587 #[solidity(hide, rename_selector = "mint")]588 #[weight(<SelfWeightOf<T>>::create_item())]588 #[weight(<SelfWeightOf<T>>::create_item())]589 fn mint_check_id(&mut self, caller: caller, to: address, token_id: U256) -> Result<bool> {589 fn mint_check_id(&mut self, caller: caller, to: Address, token_id: U256) -> Result<bool> {590 let caller = T::CrossAccountId::from_eth(caller);590 let caller = T::CrossAccountId::from_eth(caller);591 let to = T::CrossAccountId::from_eth(to);591 let to = T::CrossAccountId::from_eth(to);592 let token_id: u32 = token_id.try_into()?;592 let token_id: u32 = token_id.try_into()?;630 fn mint_with_token_uri(630 fn mint_with_token_uri(631 &mut self,631 &mut self,632 caller: caller,632 caller: caller,633 to: address,633 to: Address,634 token_uri: string,634 token_uri: string,635 ) -> Result<U256> {635 ) -> Result<U256> {636 let token_id: U256 = <TokensMinted<T>>::get(self.id)636 let token_id: U256 = <TokensMinted<T>>::get(self.id)652 fn mint_with_token_uri_check_id(652 fn mint_with_token_uri_check_id(653 &mut self,653 &mut self,654 caller: caller,654 caller: caller,655 to: address,655 to: Address,656 token_id: U256,656 token_id: U256,657 token_uri: string,657 token_uri: string,658 ) -> Result<bool> {658 ) -> Result<bool> {800 /// @param to The new owner800 /// @param to The new owner801 /// @param tokenId The RFT to transfer801 /// @param tokenId The RFT to transfer802 #[weight(<SelfWeightOf<T>>::transfer_creating_removing())]802 #[weight(<SelfWeightOf<T>>::transfer_creating_removing())]803 fn transfer(&mut self, caller: caller, to: address, token_id: U256) -> Result<()> {803 fn transfer(&mut self, caller: caller, to: Address, token_id: U256) -> Result<()> {804 let caller = T::CrossAccountId::from_eth(caller);804 let caller = T::CrossAccountId::from_eth(caller);805 let to = T::CrossAccountId::from_eth(to);805 let to = T::CrossAccountId::from_eth(to);806 let token = token_id.try_into()?;806 let token = token_id.try_into()?;883 /// @param tokenId The RFT to transfer883 /// @param tokenId The RFT to transfer884 #[solidity(hide)]884 #[solidity(hide)]885 #[weight(<SelfWeightOf<T>>::burn_from())]885 #[weight(<SelfWeightOf<T>>::burn_from())]886 fn burn_from(&mut self, caller: caller, from: address, token_id: U256) -> Result<()> {886 fn burn_from(&mut self, caller: caller, from: Address, token_id: U256) -> Result<()> {887 let caller = T::CrossAccountId::from_eth(caller);887 let caller = T::CrossAccountId::from_eth(caller);888 let from = T::CrossAccountId::from_eth(from);888 let from = T::CrossAccountId::from_eth(from);889 let token = token_id.try_into()?;889 let token = token_id.try_into()?;944 /// @param tokenIds IDs of the minted RFTs944 /// @param tokenIds IDs of the minted RFTs945 #[solidity(hide)]945 #[solidity(hide)]946 #[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]946 #[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]947 fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<U256>) -> Result<bool> {947 fn mint_bulk(&mut self, caller: caller, to: Address, token_ids: Vec<U256>) -> Result<bool> {948 let caller = T::CrossAccountId::from_eth(caller);948 let caller = T::CrossAccountId::from_eth(caller);949 let to = T::CrossAccountId::from_eth(to);949 let to = T::CrossAccountId::from_eth(to);950 let mut expected_index = <TokensMinted<T>>::get(self.id)950 let mut expected_index = <TokensMinted<T>>::get(self.id)990 fn mint_bulk_with_token_uri(990 fn mint_bulk_with_token_uri(991 &mut self,991 &mut self,992 caller: caller,992 caller: caller,993 to: address,993 to: Address,994 tokens: Vec<(U256, string)>,994 tokens: Vec<(U256, string)>,995 ) -> Result<bool> {995 ) -> Result<bool> {996 let key = key::url();996 let key = key::url();1088 /// Returns EVM address for refungible token1088 /// Returns EVM address for refungible token1089 ///1089 ///1090 /// @param token ID of the token1090 /// @param token ID of the token1091 fn token_contract_address(&self, token: U256) -> Result<address> {1091 fn token_contract_address(&self, token: U256) -> Result<Address> {1092 Ok(T::EvmTokenAddressMapping::token_to_address(1092 Ok(T::EvmTokenAddressMapping::token_to_address(1093 self.id,1093 self.id,1094 token.try_into().map_err(|_| "token id overflow")?,1094 token.try_into().map_err(|_| "token id overflow")?,1095 ))1095 ))1096 }1096 }109710971098 /// @notice Returns collection helper contract address1098 /// @notice Returns collection helper contract address1099 fn collection_helper_address(&self) -> Result<address> {1099 fn collection_helper_address(&self) -> Result<Address> {1100 Ok(T::ContractAddress::get())1100 Ok(T::ContractAddress::get())1101 }1101 }1102}1102}pallets/refungible/src/erc_token.rsdiffbeforeafterboth525253#[solidity_interface(name = ERC1633)]53#[solidity_interface(name = ERC1633)]54impl<T: Config> RefungibleTokenHandle<T> {54impl<T: Config> RefungibleTokenHandle<T> {55 fn parent_token(&self) -> Result<address> {55 fn parent_token(&self) -> Result<Address> {56 Ok(collection_id_to_address(self.id))56 Ok(collection_id_to_address(self.id))57 }57 }585869 /// of burning tokens the transfer is to 0.69 /// of burning tokens the transfer is to 0.70 Transfer {70 Transfer {71 #[indexed]71 #[indexed]72 from: address,72 from: Address,73 #[indexed]73 #[indexed]74 to: address,74 to: Address,75 value: U256,75 value: U256,76 },76 },77 /// @dev This event is emitted when the amount of tokens (value) is approved77 /// @dev This event is emitted when the amount of tokens (value) is approved78 /// by the owner to be used by the spender.78 /// by the owner to be used by the spender.79 Approval {79 Approval {80 #[indexed]80 #[indexed]81 owner: address,81 owner: Address,82 #[indexed]82 #[indexed]83 spender: address,83 spender: Address,84 value: U256,84 value: U256,85 },85 },86}86}118 /// @dev Gets the balance of the specified address.118 /// @dev Gets the balance of the specified address.119 /// @param owner The address to query the balance of.119 /// @param owner The address to query the balance of.120 /// @return An uint256 representing the amount owned by the passed address.120 /// @return An uint256 representing the amount owned by the passed address.121 fn balance_of(&self, owner: address) -> Result<U256> {121 fn balance_of(&self, owner: Address) -> Result<U256> {122 self.consume_store_reads(1)?;122 self.consume_store_reads(1)?;123 let owner = T::CrossAccountId::from_eth(owner);123 let owner = T::CrossAccountId::from_eth(owner);124 let balance = <Balance<T>>::get((self.id, self.1, owner));124 let balance = <Balance<T>>::get((self.id, self.1, owner));129 /// @param to The address to transfer to.129 /// @param to The address to transfer to.130 /// @param amount The amount to be transferred.130 /// @param amount The amount to be transferred.131 #[weight(<CommonWeights<T>>::transfer())]131 #[weight(<CommonWeights<T>>::transfer())]132 fn transfer(&mut self, caller: caller, to: address, amount: U256) -> Result<bool> {132 fn transfer(&mut self, caller: caller, to: Address, amount: U256) -> Result<bool> {133 let caller = T::CrossAccountId::from_eth(caller);133 let caller = T::CrossAccountId::from_eth(caller);134 let to = T::CrossAccountId::from_eth(to);134 let to = T::CrossAccountId::from_eth(to);135 let amount = amount.try_into().map_err(|_| "amount overflow")?;135 let amount = amount.try_into().map_err(|_| "amount overflow")?;150 fn transfer_from(150 fn transfer_from(151 &mut self,151 &mut self,152 caller: caller,152 caller: caller,153 from: address,153 from: Address,154 to: address,154 to: Address,155 amount: U256,155 amount: U256,156 ) -> Result<bool> {156 ) -> Result<bool> {157 let caller = T::CrossAccountId::from_eth(caller);157 let caller = T::CrossAccountId::from_eth(caller);175 /// @param spender The address which will spend the funds.175 /// @param spender The address which will spend the funds.176 /// @param amount The amount of tokens to be spent.176 /// @param amount The amount of tokens to be spent.177 #[weight(<SelfWeightOf<T>>::approve())]177 #[weight(<SelfWeightOf<T>>::approve())]178 fn approve(&mut self, caller: caller, spender: address, amount: U256) -> Result<bool> {178 fn approve(&mut self, caller: caller, spender: Address, amount: U256) -> Result<bool> {179 let caller = T::CrossAccountId::from_eth(caller);179 let caller = T::CrossAccountId::from_eth(caller);180 let spender = T::CrossAccountId::from_eth(spender);180 let spender = T::CrossAccountId::from_eth(spender);181 let amount = amount.try_into().map_err(|_| "amount overflow")?;181 let amount = amount.try_into().map_err(|_| "amount overflow")?;189 /// @param owner address The address which owns the funds.189 /// @param owner address The address which owns the funds.190 /// @param spender address The address which will spend the funds.190 /// @param spender address The address which will spend the funds.191 /// @return A uint256 specifying the amount of tokens still available for the spender.191 /// @return A uint256 specifying the amount of tokens still available for the spender.192 fn allowance(&self, owner: address, spender: address) -> Result<U256> {192 fn allowance(&self, owner: Address, spender: Address) -> Result<U256> {193 self.consume_store_reads(1)?;193 self.consume_store_reads(1)?;194 let owner = T::CrossAccountId::from_eth(owner);194 let owner = T::CrossAccountId::from_eth(owner);195 let spender = T::CrossAccountId::from_eth(spender);195 let spender = T::CrossAccountId::from_eth(spender);209 /// @param amount The amount that will be burnt.209 /// @param amount The amount that will be burnt.210 #[weight(<SelfWeightOf<T>>::burn_from())]210 #[weight(<SelfWeightOf<T>>::burn_from())]211 #[solidity(hide)]211 #[solidity(hide)]212 fn burn_from(&mut self, caller: caller, from: address, amount: U256) -> Result<bool> {212 fn burn_from(&mut self, caller: caller, from: Address, amount: U256) -> Result<bool> {213 let caller = T::CrossAccountId::from_eth(caller);213 let caller = T::CrossAccountId::from_eth(caller);214 let from = T::CrossAccountId::from_eth(from);214 let from = T::CrossAccountId::from_eth(from);215 let amount = amount.try_into().map_err(|_| "amount overflow")?;215 let amount = amount.try_into().map_err(|_| "amount overflow")?;pallets/unique/src/eth/mod.rsdiffbeforeafterboth93 collection_mode: CollectionMode,93 collection_mode: CollectionMode,94 description: string,94 description: string,95 token_prefix: string,95 token_prefix: string,96) -> Result<address> {96) -> Result<Address> {97 let (caller, name, description, token_prefix) =97 let (caller, name, description, token_prefix) =98 convert_data::<T>(caller, name, description, token_prefix)?;98 convert_data::<T>(caller, name, description, token_prefix)?;99 let data = CreateCollectionData {99 let data = CreateCollectionData {154 name: string,154 name: string,155 description: string,155 description: string,156 token_prefix: string,156 token_prefix: string,157 ) -> Result<address> {157 ) -> Result<Address> {158 let (caller, name, description, token_prefix) =158 let (caller, name, description, token_prefix) =159 convert_data::<T>(caller, name, description, token_prefix)?;159 convert_data::<T>(caller, name, description, token_prefix)?;160 let data = CreateCollectionData {160 let data = CreateCollectionData {193 name: string,193 name: string,194 description: string,194 description: string,195 token_prefix: string,195 token_prefix: string,196 ) -> Result<address> {196 ) -> Result<Address> {197 create_collection_internal::<T>(197 create_collection_internal::<T>(198 caller,198 caller,199 value,199 value,213 name: string,213 name: string,214 description: string,214 description: string,215 token_prefix: string,215 token_prefix: string,216 ) -> Result<address> {216 ) -> Result<Address> {217 create_collection_internal::<T>(217 create_collection_internal::<T>(218 caller,218 caller,219 value,219 value,234 decimals: u8,234 decimals: u8,235 description: string,235 description: string,236 token_prefix: string,236 token_prefix: string,237 ) -> Result<address> {237 ) -> Result<Address> {238 create_collection_internal::<T>(238 create_collection_internal::<T>(239 caller,239 caller,240 value,240 value,249 fn make_collection_metadata_compatible(249 fn make_collection_metadata_compatible(250 &mut self,250 &mut self,251 caller: caller,251 caller: caller,252 collection: address,252 collection: Address,253 base_uri: string,253 base_uri: string,254 ) -> Result<()> {254 ) -> Result<()> {255 let caller = T::CrossAccountId::from_eth(caller);255 let caller = T::CrossAccountId::from_eth(caller);334 }334 }335335336 #[weight(<SelfWeightOf<T>>::destroy_collection())]336 #[weight(<SelfWeightOf<T>>::destroy_collection())]337 fn destroy_collection(&mut self, caller: caller, collection_address: address) -> Result<()> {337 fn destroy_collection(&mut self, caller: caller, collection_address: Address) -> Result<()> {338 let caller = T::CrossAccountId::from_eth(caller);338 let caller = T::CrossAccountId::from_eth(caller);339339340 let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)340 let collection_id = pallet_common::eth::map_eth_to_id(&collection_address)346 /// Check if a collection exists346 /// Check if a collection exists347 /// @param collectionAddress Address of the collection in question347 /// @param collectionAddress Address of the collection in question348 /// @return bool Does the collection exist?348 /// @return bool Does the collection exist?349 fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {349 fn is_collection_exist(&self, _caller: caller, collection_address: Address) -> Result<bool> {350 if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {350 if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {351 let collection_id = id;351 let collection_id = id;352 return Ok(<CollectionById<T>>::contains_key(collection_id));352 return Ok(<CollectionById<T>>::contains_key(collection_id));366 /// Returns address of a collection.366 /// Returns address of a collection.367 /// @param collectionId - CollectionId of the collection367 /// @param collectionId - CollectionId of the collection368 /// @return eth mirror address of the collection368 /// @return eth mirror address of the collection369 fn collection_address(&self, collection_id: u32) -> Result<address> {369 fn collection_address(&self, collection_id: u32) -> Result<Address> {370 Ok(collection_id_to_address(collection_id.into()))370 Ok(collection_id_to_address(collection_id.into()))371 }371 }372372373 /// Returns collectionId of a collection.373 /// Returns collectionId of a collection.374 /// @param collectionAddress - Eth address of the collection374 /// @param collectionAddress - Eth address of the collection375 /// @return collectionId of the collection375 /// @return collectionId of the collection376 fn collection_id(&self, collection_address: address) -> Result<u32> {376 fn collection_id(&self, collection_address: Address) -> Result<u32> {377 map_eth_to_id(&collection_address)377 map_eth_to_id(&collection_address)378 .map(|id| id.0)378 .map(|id| id.0)379 .ok_or(Error::Revert(format!(379 .ok_or(Error::Revert(format!(