difftreelog
chore fix code review requests
in: master
36 files changed
client/rpc/src/lib.rsdiffbeforeafterboth248 ) -> Result<Option<String>>;248 ) -> Result<Option<String>>;249249250 /// Get whether an operator is approved by a given owner.250 /// Get whether an operator is approved by a given owner.251 #[method(name = "unique_isApprovedForAll")]251 #[method(name = "unique_allowanceForAll")]252 fn is_approved_for_all(252 fn allowance_for_all(253 &self,253 &self,254 collection: CollectionId,254 collection: CollectionId,255 owner: CrossAccountId,255 owner: CrossAccountId,579 pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);579 pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);580 pass_method!(total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<String> => |o| o.map(|number| number.to_string()) , unique_api);580 pass_method!(total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<String> => |o| o.map(|number| number.to_string()) , unique_api);581 pass_method!(token_owners(collection: CollectionId, token: TokenId) -> Vec<CrossAccountId>, unique_api);581 pass_method!(token_owners(collection: CollectionId, token: TokenId) -> Vec<CrossAccountId>, unique_api);582 pass_method!(is_approved_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> bool, unique_api);582 pass_method!(allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> bool, unique_api);583}583}584584585impl<C, Block, BlockNumber, CrossAccountId, AccountId>585impl<C, Block, BlockNumber, CrossAccountId, AccountId>pallets/common/src/lib.rsdiffbeforeafterboth1535 fn token_owner() -> Weight;1535 fn token_owner() -> Weight;153615361537 /// The price of setting approval for all1537 /// The price of setting approval for all1538 fn set_approval_for_all() -> Weight;1538 fn set_allowance_for_all() -> Weight;1539}1539}154015401541/// Weight info extension trait for refungible pallet.1541/// Weight info extension trait for refungible pallet.1844 /// Get extension for RFT collection.1844 /// Get extension for RFT collection.1845 fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>>;1845 fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>>;184618461847 /// An operator is allowed to transfer all tokens of the sender on their behalf.1847 /// The `operator` is allowed to transfer all tokens of the `owner` on their behalf.1848 /// * `owner` - Token owner1848 /// * `owner` - Token owner1849 /// * `operator` - Operator1849 /// * `operator` - Operator1850 /// * `approve` - Should operator status be granted or revoked?1850 /// * `approve` - Should operator status be granted or revoked?1851 fn set_approval_for_all(1851 fn set_allowance_for_all(1852 &self,1852 &self,1853 owner: T::CrossAccountId,1853 owner: T::CrossAccountId,1854 operator: T::CrossAccountId,1854 operator: T::CrossAccountId,1855 approve: bool,1855 approve: bool,1856 ) -> DispatchResultWithPostInfo;1856 ) -> DispatchResultWithPostInfo;185718571858 /// Tells whether the given `owner` approves the `operator`.1858 /// Tells whether the given `owner` approves the `operator`.1859 fn is_approved_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool;1859 fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool;1860}1860}186118611862/// Extension for RFT collection.1862/// Extension for RFT collection.pallets/fungible/src/common.rsdiffbeforeafterboth108 Weight::zero()108 Weight::zero()109 }109 }110110111 fn set_approval_for_all() -> Weight {111 fn set_allowance_for_all() -> Weight {112 Weight::zero()112 Weight::zero()113 }113 }114}114}429 <TotalSupply<T>>::try_get(self.id).ok()429 <TotalSupply<T>>::try_get(self.id).ok()430 }430 }431431432 fn set_approval_for_all(432 fn set_allowance_for_all(433 &self,433 &self,434 _owner: T::CrossAccountId,434 _owner: T::CrossAccountId,435 _operator: T::CrossAccountId,435 _operator: T::CrossAccountId,438 fail!(<Error<T>>::SettingApprovalForAllNotAllowed)438 fail!(<Error<T>>::SettingApprovalForAllNotAllowed)439 }439 }440440441 fn is_approved_for_all(&self, _owner: T::CrossAccountId, _operator: T::CrossAccountId) -> bool {441 fn allowance_for_all(&self, _owner: T::CrossAccountId, _operator: T::CrossAccountId) -> bool {442 false442 false443 }443 }444}444}pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth223223224 }: {collection.token_owner(item)}224 }: {collection.token_owner(item)}225225226 set_approval_for_all {226 set_allowance_for_all {227 bench_init!{227 bench_init!{228 owner: sub; collection: collection(owner);228 owner: sub; collection: collection(owner);229 operator: cross_from_sub(owner); owner: cross_sub;229 operator: cross_from_sub(owner); owner: cross_sub;230 };230 };231 }: {<Pallet<T>>::set_approval_for_all(&collection, &owner, &operator, true)}231 }: {<Pallet<T>>::set_allowance_for_all(&collection, &owner, &operator, true)}232232233 is_approved_for_all {233 allowance_for_all {234 bench_init!{234 bench_init!{235 owner: sub; collection: collection(owner);235 owner: sub; collection: collection(owner);236 operator: cross_from_sub(owner); owner: cross_sub;236 operator: cross_from_sub(owner); owner: cross_sub;237 };237 };238 }: {<Pallet<T>>::is_approved_for_all(&collection, &owner, &operator)}238 }: {<Pallet<T>>::allowance_for_all(&collection, &owner, &operator)}239}239}240240pallets/nonfungible/src/common.rsdiffbeforeafterboth123 <SelfWeightOf<T>>::token_owner()123 <SelfWeightOf<T>>::token_owner()124 }124 }125125126 fn set_approval_for_all() -> Weight {126 fn set_allowance_for_all() -> Weight {127 <SelfWeightOf<T>>::set_approval_for_all()127 <SelfWeightOf<T>>::set_allowance_for_all()128 }128 }129}129}130130517 }517 }518 }518 }519519520 fn set_approval_for_all(520 fn set_allowance_for_all(521 &self,521 &self,522 owner: T::CrossAccountId,522 owner: T::CrossAccountId,523 operator: T::CrossAccountId,523 operator: T::CrossAccountId,524 approve: bool,524 approve: bool,525 ) -> DispatchResultWithPostInfo {525 ) -> DispatchResultWithPostInfo {526 with_weight(526 with_weight(527 <Pallet<T>>::set_approval_for_all(self, &owner, &operator, approve),527 <Pallet<T>>::set_allowance_for_all(self, &owner, &operator, approve),528 <CommonWeights<T>>::set_approval_for_all(),528 <CommonWeights<T>>::set_allowance_for_all(),529 )529 )530 }530 }531531532 fn is_approved_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {532 fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {533 <Pallet<T>>::is_approved_for_all(self, &owner, &operator)533 <Pallet<T>>::allowance_for_all(self, &owner, &operator)534 }534 }535}535}536536pallets/nonfungible/src/erc.rsdiffbeforeafterboth472 /// @notice Sets or unsets the approval of a given operator.472 /// @notice Sets or unsets the approval of a given operator.473 /// The `operator` is allowed to transfer all tokens of the `caller` on their behalf.473 /// The `operator` is allowed to transfer all tokens of the `caller` on their behalf.474 /// @param operator Operator474 /// @param operator Operator475 /// @param approved Is operator enabled or disabled475 /// @param approved Should operator status be granted or revoked?476 #[weight(<SelfWeightOf<T>>::set_approval_for_all())]476 #[weight(<SelfWeightOf<T>>::set_allowance_for_all())]477 fn set_approval_for_all(477 fn set_approval_for_all(478 &mut self,478 &mut self,479 caller: caller,479 caller: caller,483 let caller = T::CrossAccountId::from_eth(caller);483 let caller = T::CrossAccountId::from_eth(caller);484 let operator = T::CrossAccountId::from_eth(operator);484 let operator = T::CrossAccountId::from_eth(operator);485485486 <Pallet<T>>::set_approval_for_all(self, &caller, &operator, approved)486 <Pallet<T>>::set_allowance_for_all(self, &caller, &operator, approved)487 .map_err(dispatch_to_evm::<T>)?;487 .map_err(dispatch_to_evm::<T>)?;488 Ok(())488 Ok(())489 }489 }494 Err("not implemented".into())494 Err("not implemented".into())495 }495 }496496497 /// @notice Tells whether an operator is approved by a given owner.497 /// @notice Tells whether the given `owner` approves the `operator`.498 #[weight(<SelfWeightOf<T>>::is_approved_for_all())]498 #[weight(<SelfWeightOf<T>>::allowance_for_all())]499 fn is_approved_for_all(&self, owner: address, operator: address) -> Result<bool> {499 fn is_approved_for_all(&self, owner: address, operator: address) -> Result<bool> {500 let owner = T::CrossAccountId::from_eth(owner);500 let owner = T::CrossAccountId::from_eth(owner);501 let operator = T::CrossAccountId::from_eth(operator);501 let operator = T::CrossAccountId::from_eth(operator);502502503 Ok(<Pallet<T>>::is_approved_for_all(self, &owner, &operator))503 Ok(<Pallet<T>>::allowance_for_all(self, &owner, &operator))504 }504 }505505506 /// @notice Returns collection helper contract address506 /// @notice Returns collection helper contract addresspallets/nonfungible/src/lib.rsdiffbeforeafterboth274274275 /// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.275 /// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.276 #[pallet::storage]276 #[pallet::storage]277 pub type WalletOperator<T: Config> = StorageNMap<277 pub type CollectionAllowance<T: Config> = StorageNMap<278 Key = (278 Key = (279 Key<Twox64Concat, CollectionId>,279 Key<Twox64Concat, CollectionId>,280 Key<Blake2_128Concat, T::CrossAccountId>,280 Key<Blake2_128Concat, T::CrossAccountId>,450 <TokensBurnt<T>>::remove(id);450 <TokensBurnt<T>>::remove(id);451 let _ = <Allowance<T>>::clear_prefix((id,), u32::MAX, None);451 let _ = <Allowance<T>>::clear_prefix((id,), u32::MAX, None);452 let _ = <AccountBalance<T>>::clear_prefix((id,), u32::MAX, None);452 let _ = <AccountBalance<T>>::clear_prefix((id,), u32::MAX, None);453 let _ = <WalletOperator<T>>::clear_prefix((id,), u32::MAX, None);453 let _ = <CollectionAllowance<T>>::clear_prefix((id,), u32::MAX, None);454 Ok(())454 Ok(())455 }455 }4564561206 if <Allowance<T>>::get((collection.id, token)).as_ref() == Some(spender) {1206 if <Allowance<T>>::get((collection.id, token)).as_ref() == Some(spender) {1207 return Ok(());1207 return Ok(());1208 }1208 }1209 if <WalletOperator<T>>::get((collection.id, from, spender)) == Some(true) {1209 if <CollectionAllowance<T>>::get((collection.id, from, spender)) {1210 return Ok(());1210 return Ok(());1211 }1211 }1212 ensure!(1212 ensure!(134513451346 /// Sets or unsets the approval of a given operator.1346 /// Sets or unsets the approval of a given operator.1347 ///1347 ///1348 /// An operator is allowed to transfer all token pieces of the sender on their behalf.1348 /// The `operator` is allowed to transfer all token pieces of the `owner` on their behalf.1349 /// - `owner`: Token owner1349 /// - `owner`: Token owner1350 /// - `operator`: Operator1350 /// - `operator`: Operator1351 /// - `approve`: Is operator enabled or disabled1351 /// - `approve`: Should operator status be granted or revoked?1352 pub fn set_approval_for_all(1352 pub fn set_allowance_for_all(1353 collection: &NonfungibleHandle<T>,1353 collection: &NonfungibleHandle<T>,1354 owner: &T::CrossAccountId,1354 owner: &T::CrossAccountId,1355 operator: &T::CrossAccountId,1355 operator: &T::CrossAccountId,136413641365 // =========1365 // =========136613661367 <WalletOperator<T>>::insert((collection.id, owner, operator), approve);1367 <CollectionAllowance<T>>::insert((collection.id, owner, operator), approve);1368 <PalletEvm<T>>::deposit_log(1368 <PalletEvm<T>>::deposit_log(1369 ERC721Events::ApprovalForAll {1369 ERC721Events::ApprovalForAll {1370 owner: *owner.as_eth(),1370 owner: *owner.as_eth(),1382 Ok(())1382 Ok(())1383 }1383 }138413841385 /// Tells whether an operator is approved by a given owner.1385 /// Tells whether the given `owner` approves the `operator`.1386 pub fn is_approved_for_all(1386 pub fn allowance_for_all(1387 collection: &NonfungibleHandle<T>,1387 collection: &NonfungibleHandle<T>,1388 owner: &T::CrossAccountId,1388 owner: &T::CrossAccountId,1389 operator: &T::CrossAccountId,1389 operator: &T::CrossAccountId,1390 ) -> bool {1390 ) -> bool {1391 <WalletOperator<T>>::get((collection.id, owner, operator)).unwrap_or(false)1391 <CollectionAllowance<T>>::get((collection.id, owner, operator))1392 }1392 }1393}1393}13941394pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth1021 }1021 }102210221023 /// @notice Sets or unsets the approval of a given operator.1023 /// @notice Sets or unsets the approval of a given operator.1024 /// An operator is allowed to transfer all tokens of the sender on their behalf.1024 /// The `operator` is allowed to transfer all tokens of the `caller` on their behalf.1025 /// @param operator Operator1025 /// @param operator Operator1026 /// @param approved Is operator enabled or disabled1026 /// @param approved Should operator status be granted or revoked?1027 /// @dev EVM selector for this function is: 0xa22cb465,1027 /// @dev EVM selector for this function is: 0xa22cb465,1028 /// or in textual repr: setApprovalForAll(address,bool)1028 /// or in textual repr: setApprovalForAll(address,bool)1029 function setApprovalForAll(address operator, bool approved) public {1029 function setApprovalForAll(address operator, bool approved) public {1043 return 0x0000000000000000000000000000000000000000;1043 return 0x0000000000000000000000000000000000000000;1044 }1044 }104510451046 /// @notice Tells whether an operator is approved by a given owner.1046 /// @notice Tells whether the given `owner` approves the `operator`.1047 /// @dev EVM selector for this function is: 0xe985e9c5,1047 /// @dev EVM selector for this function is: 0xe985e9c5,1048 /// or in textual repr: isApprovedForAll(address,address)1048 /// or in textual repr: isApprovedForAll(address,address)1049 function isApprovedForAll(address owner, address operator) public view returns (bool) {1049 function isApprovedForAll(address owner, address operator) public view returns (bool) {pallets/nonfungible/src/weights.rsdiffbeforeafterboth48 fn set_token_properties(b: u32, ) -> Weight;48 fn set_token_properties(b: u32, ) -> Weight;49 fn delete_token_properties(b: u32, ) -> Weight;49 fn delete_token_properties(b: u32, ) -> Weight;50 fn token_owner() -> Weight;50 fn token_owner() -> Weight;51 fn set_approval_for_all() -> Weight;51 fn set_allowance_for_all() -> Weight;52 fn is_approved_for_all() -> Weight;52 fn allowance_for_all() -> Weight;53}53}545455/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.55/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.199 .saturating_add(T::DbWeight::get().reads(1 as u64))199 .saturating_add(T::DbWeight::get().reads(1 as u64))200 }200 }201 // Storage: Nonfungible WalletOperator (r:0 w:1)201 // Storage: Nonfungible WalletOperator (r:0 w:1)202 fn set_approval_for_all() -> Weight {202 fn set_allowance_for_all() -> Weight {203 Weight::from_ref_time(16_231_000 as u64)203 Weight::from_ref_time(16_231_000 as u64)204 .saturating_add(T::DbWeight::get().writes(1 as u64))204 .saturating_add(T::DbWeight::get().writes(1 as u64))205 }205 }206 // Storage: Nonfungible WalletOperator (r:1 w:0)206 // Storage: Nonfungible WalletOperator (r:1 w:0)207 fn is_approved_for_all() -> Weight {207 fn allowance_for_all() -> Weight {208 Weight::from_ref_time(6_161_000 as u64)208 Weight::from_ref_time(6_161_000 as u64)209 .saturating_add(T::DbWeight::get().reads(1 as u64))209 .saturating_add(T::DbWeight::get().reads(1 as u64))210 }210 }356 .saturating_add(RocksDbWeight::get().reads(1 as u64))356 .saturating_add(RocksDbWeight::get().reads(1 as u64))357 }357 }358 // Storage: Nonfungible WalletOperator (r:0 w:1)358 // Storage: Nonfungible WalletOperator (r:0 w:1)359 fn set_approval_for_all() -> Weight {359 fn set_allowance_for_all() -> Weight {360 Weight::from_ref_time(16_231_000 as u64)360 Weight::from_ref_time(16_231_000 as u64)361 .saturating_add(RocksDbWeight::get().writes(1 as u64))361 .saturating_add(RocksDbWeight::get().writes(1 as u64))362 }362 }363 // Storage: Nonfungible WalletOperator (r:1 w:0)363 // Storage: Nonfungible WalletOperator (r:1 w:0)364 fn is_approved_for_all() -> Weight {364 fn allowance_for_all() -> Weight {365 Weight::from_ref_time(6_161_000 as u64)365 Weight::from_ref_time(6_161_000 as u64)366 .saturating_add(RocksDbWeight::get().reads(1 as u64))366 .saturating_add(RocksDbWeight::get().reads(1 as u64))367 }367 }pallets/refungible/src/benchmarking.rsdiffbeforeafterboth291 let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;291 let item = create_max_item(&collection, &sender, [(owner.clone(), 100)])?;292 }: {<Pallet<T>>::token_owner(collection.id, item)}292 }: {<Pallet<T>>::token_owner(collection.id, item)}293293294 set_approval_for_all {294 set_allowance_for_all {295 bench_init!{295 bench_init!{296 owner: sub; collection: collection(owner);296 owner: sub; collection: collection(owner);297 operator: cross_from_sub(owner); owner: cross_sub;297 operator: cross_from_sub(owner); owner: cross_sub;298 };298 };299 }: {<Pallet<T>>::set_approval_for_all(&collection, &owner, &operator, true)}299 }: {<Pallet<T>>::set_allowance_for_all(&collection, &owner, &operator, true)}300300301 is_approved_for_all {301 allowance_for_all {302 bench_init!{302 bench_init!{303 owner: sub; collection: collection(owner);303 owner: sub; collection: collection(owner);304 operator: cross_from_sub(owner); owner: cross_sub;304 operator: cross_from_sub(owner); owner: cross_sub;305 };305 };306 }: {<Pallet<T>>::is_approved_for_all(&collection, &owner, &operator)}306 }: {<Pallet<T>>::allowance_for_all(&collection, &owner, &operator)}307}307}308308pallets/refungible/src/common.rsdiffbeforeafterboth153 <SelfWeightOf<T>>::token_owner()153 <SelfWeightOf<T>>::token_owner()154 }154 }155155156 fn set_approval_for_all() -> Weight {156 fn set_allowance_for_all() -> Weight {157 <SelfWeightOf<T>>::set_approval_for_all()157 <SelfWeightOf<T>>::set_allowance_for_all()158 }158 }159}159}160160521 <Pallet<T>>::total_pieces(self.id, token)521 <Pallet<T>>::total_pieces(self.id, token)522 }522 }523523524 fn set_approval_for_all(524 fn set_allowance_for_all(525 &self,525 &self,526 owner: T::CrossAccountId,526 owner: T::CrossAccountId,527 operator: T::CrossAccountId,527 operator: T::CrossAccountId,528 approve: bool,528 approve: bool,529 ) -> DispatchResultWithPostInfo {529 ) -> DispatchResultWithPostInfo {530 with_weight(530 with_weight(531 <Pallet<T>>::set_approval_for_all(self, &owner, &operator, approve),531 <Pallet<T>>::set_allowance_for_all(self, &owner, &operator, approve),532 <CommonWeights<T>>::set_approval_for_all(),532 <CommonWeights<T>>::set_allowance_for_all(),533 )533 )534 }534 }535535536 fn is_approved_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {536 fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {537 <Pallet<T>>::is_approved_for_all(self, &owner, &operator)537 <Pallet<T>>::allowance_for_all(self, &owner, &operator)538 }538 }539}539}540540pallets/refungible/src/erc.rsdiffbeforeafterboth462 }462 }463463464 /// @notice Sets or unsets the approval of a given operator.464 /// @notice Sets or unsets the approval of a given operator.465 /// An operator is allowed to transfer all tokens of the sender on their behalf.465 /// The `operator` is allowed to transfer all token pieces of the `caller` on their behalf.466 /// @param operator Operator466 /// @param operator Operator467 /// @param approved Is operator enabled or disabled467 /// @param approved Should operator status be granted or revoked?468 #[weight(<SelfWeightOf<T>>::set_approval_for_all())]468 #[weight(<SelfWeightOf<T>>::set_allowance_for_all())]469 fn set_approval_for_all(469 fn set_approval_for_all(470 &mut self,470 &mut self,471 caller: caller,471 caller: caller,475 let caller = T::CrossAccountId::from_eth(caller);475 let caller = T::CrossAccountId::from_eth(caller);476 let operator = T::CrossAccountId::from_eth(operator);476 let operator = T::CrossAccountId::from_eth(operator);477477478 <Pallet<T>>::set_approval_for_all(self, &caller, &operator, approved)478 <Pallet<T>>::set_allowance_for_all(self, &caller, &operator, approved)479 .map_err(dispatch_to_evm::<T>)?;479 .map_err(dispatch_to_evm::<T>)?;480 Ok(())480 Ok(())481 }481 }486 Err("not implemented".into())486 Err("not implemented".into())487 }487 }488488489 /// @notice Tells whether an operator is approved by a given owner.489 /// @notice Tells whether the given `owner` approves the `operator`.490 #[weight(<SelfWeightOf<T>>::is_approved_for_all())]490 #[weight(<SelfWeightOf<T>>::allowance_for_all())]491 fn is_approved_for_all(&self, owner: address, operator: address) -> Result<bool> {491 fn is_approved_for_all(&self, owner: address, operator: address) -> Result<bool> {492 let owner = T::CrossAccountId::from_eth(owner);492 let owner = T::CrossAccountId::from_eth(owner);493 let operator = T::CrossAccountId::from_eth(operator);493 let operator = T::CrossAccountId::from_eth(operator);494494495 Ok(<Pallet<T>>::is_approved_for_all(self, &owner, &operator))495 Ok(<Pallet<T>>::allowance_for_all(self, &owner, &operator))496 }496 }497497498 /// @notice Returns collection helper contract address498 /// @notice Returns collection helper contract addresspallets/refungible/src/lib.rsdiffbeforeafterboth275275276 /// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.276 /// Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.277 #[pallet::storage]277 #[pallet::storage]278 pub type WalletOperator<T: Config> = StorageNMap<278 pub type CollectionAllowance<T: Config> = StorageNMap<279 Key = (279 Key = (280 Key<Twox64Concat, CollectionId>,280 Key<Twox64Concat, CollectionId>,281 Key<Blake2_128Concat, T::CrossAccountId>,281 Key<Blake2_128Concat, T::CrossAccountId>,282 Key<Blake2_128Concat, T::CrossAccountId>,282 Key<Blake2_128Concat, T::CrossAccountId>,283 ),283 ),284 Value = bool,284 Value = bool,285 QueryKind = OptionQuery,285 QueryKind = ValueQuery,286 >;286 >;287287288 #[pallet::hooks]288 #[pallet::hooks]1174 let allowance =1174 let allowance =1175 <Allowance<T>>::get((collection.id, token, from, &spender)).checked_sub(amount);1175 <Allowance<T>>::get((collection.id, token, from, &spender)).checked_sub(amount);117611761177 // Allowance if any would be reduced if spender is also wallet operator1177 // Allowance (if any) would be reduced if spender is also wallet operator1178 if <WalletOperator<T>>::get((collection.id, from, spender)) == Some(true) {1178 if <CollectionAllowance<T>>::get((collection.id, from, spender)) {1179 return Ok(allowance);1179 return Ok(allowance);1180 }1180 }11811181140814081409 /// Sets or unsets the approval of a given operator.1409 /// Sets or unsets the approval of a given operator.1410 ///1410 ///1411 /// An operator is allowed to transfer all tokens of the sender on their behalf.1411 /// The `operator` is allowed to transfer all token pieces of the `owner` on their behalf.1412 /// - `owner`: Token owner1412 /// - `owner`: Token owner1413 /// - `operator`: Operator1413 /// - `operator`: Operator1414 /// - `approve`: Is operator enabled or disabled1414 /// - `approve`: Should operator status be granted or revoked?1415 pub fn set_approval_for_all(1415 pub fn set_allowance_for_all(1416 collection: &RefungibleHandle<T>,1416 collection: &RefungibleHandle<T>,1417 owner: &T::CrossAccountId,1417 owner: &T::CrossAccountId,1418 operator: &T::CrossAccountId,1418 operator: &T::CrossAccountId,142714271428 // =========1428 // =========142914291430 <WalletOperator<T>>::insert((collection.id, owner, operator), approve);1430 <CollectionAllowance<T>>::insert((collection.id, owner, operator), approve);1431 <PalletEvm<T>>::deposit_log(1431 <PalletEvm<T>>::deposit_log(1432 ERC721Events::ApprovalForAll {1432 ERC721Events::ApprovalForAll {1433 owner: *owner.as_eth(),1433 owner: *owner.as_eth(),1445 Ok(())1445 Ok(())1446 }1446 }144714471448 /// Tells whether an operator is approved by a given owner.1448 /// Tells whether the given `owner` approves the `operator`.1449 pub fn is_approved_for_all(1449 pub fn allowance_for_all(1450 collection: &RefungibleHandle<T>,1450 collection: &RefungibleHandle<T>,1451 owner: &T::CrossAccountId,1451 owner: &T::CrossAccountId,1452 operator: &T::CrossAccountId,1452 operator: &T::CrossAccountId,1453 ) -> bool {1453 ) -> bool {1454 <WalletOperator<T>>::get((collection.id, owner, operator)).unwrap_or(false)1454 <CollectionAllowance<T>>::get((collection.id, owner, operator))1455 }1455 }1456}1456}14571457pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth1018 }1018 }101910191020 /// @notice Sets or unsets the approval of a given operator.1020 /// @notice Sets or unsets the approval of a given operator.1021 /// An operator is allowed to transfer all tokens of the sender on their behalf.1021 /// The `operator` is allowed to transfer all token pieces of the `caller` on their behalf.1022 /// @param operator Operator1022 /// @param operator Operator1023 /// @param approved Is operator enabled or disabled1023 /// @param approved Should operator status be granted or revoked?1024 /// @dev EVM selector for this function is: 0xa22cb465,1024 /// @dev EVM selector for this function is: 0xa22cb465,1025 /// or in textual repr: setApprovalForAll(address,bool)1025 /// or in textual repr: setApprovalForAll(address,bool)1026 function setApprovalForAll(address operator, bool approved) public {1026 function setApprovalForAll(address operator, bool approved) public {1040 return 0x0000000000000000000000000000000000000000;1040 return 0x0000000000000000000000000000000000000000;1041 }1041 }104210421043 /// @notice Tells whether an operator is approved by a given owner.1043 /// @notice Tells whether the given `owner` approves the `operator`.1044 /// @dev EVM selector for this function is: 0xe985e9c5,1044 /// @dev EVM selector for this function is: 0xe985e9c5,1045 /// or in textual repr: isApprovedForAll(address,address)1045 /// or in textual repr: isApprovedForAll(address,address)1046 function isApprovedForAll(address owner, address operator) public view returns (bool) {1046 function isApprovedForAll(address owner, address operator) public view returns (bool) {pallets/refungible/src/weights.rsdiffbeforeafterboth55 fn delete_token_properties(b: u32, ) -> Weight;55 fn delete_token_properties(b: u32, ) -> Weight;56 fn repartition_item() -> Weight;56 fn repartition_item() -> Weight;57 fn token_owner() -> Weight;57 fn token_owner() -> Weight;58 fn set_approval_for_all() -> Weight;58 fn set_allowance_for_all() -> Weight;59 fn is_approved_for_all() -> Weight;59 fn allowance_for_all() -> Weight;60}60}616162/// Weights for pallet_refungible using the Substrate node and recommended hardware.62/// Weights for pallet_refungible using the Substrate node and recommended hardware.263 .saturating_add(T::DbWeight::get().reads(2 as u64))263 .saturating_add(T::DbWeight::get().reads(2 as u64))264 }264 }265 // Storage: Refungible WalletOperator (r:0 w:1)265 // Storage: Refungible WalletOperator (r:0 w:1)266 fn set_approval_for_all() -> Weight {266 fn set_allowance_for_all() -> Weight {267 Weight::from_ref_time(16_150_000 as u64)267 Weight::from_ref_time(16_150_000 as u64)268 .saturating_add(T::DbWeight::get().writes(1 as u64))268 .saturating_add(T::DbWeight::get().writes(1 as u64))269 }269 }270 // Storage: Refungible WalletOperator (r:1 w:0)270 // Storage: Refungible WalletOperator (r:1 w:0)271 fn is_approved_for_all() -> Weight {271 fn allowance_for_all() -> Weight {272 Weight::from_ref_time(5_901_000 as u64)272 Weight::from_ref_time(5_901_000 as u64)273 .saturating_add(T::DbWeight::get().reads(1 as u64))273 .saturating_add(T::DbWeight::get().reads(1 as u64))274 }274 }477 .saturating_add(RocksDbWeight::get().reads(2 as u64))477 .saturating_add(RocksDbWeight::get().reads(2 as u64))478 }478 }479 // Storage: Refungible WalletOperator (r:0 w:1)479 // Storage: Refungible WalletOperator (r:0 w:1)480 fn set_approval_for_all() -> Weight {480 fn set_allowance_for_all() -> Weight {481 Weight::from_ref_time(16_150_000 as u64)481 Weight::from_ref_time(16_150_000 as u64)482 .saturating_add(RocksDbWeight::get().writes(1 as u64))482 .saturating_add(RocksDbWeight::get().writes(1 as u64))483 }483 }484 // Storage: Refungible WalletOperator (r:1 w:0)484 // Storage: Refungible WalletOperator (r:1 w:0)485 fn is_approved_for_all() -> Weight {485 fn allowance_for_all() -> Weight {486 Weight::from_ref_time(5_901_000 as u64)486 Weight::from_ref_time(5_901_000 as u64)487 .saturating_add(RocksDbWeight::get().reads(1 as u64))487 .saturating_add(RocksDbWeight::get().reads(1 as u64))488 }488 }pallets/unique/src/eth/mod.rsdiffbeforeafterboth36use sp_std::vec;36use sp_std::vec;37use up_data_structs::{37use up_data_structs::{38 CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,38 CollectionDescription, CollectionMode, CollectionName, CollectionTokenPrefix,39 CreateCollectionData, CollectionId,39 CreateCollectionData,40};40};414142use crate::{weights::WeightInfo, Config, SelfWeightOf};42use crate::{weights::WeightInfo, Config, SelfWeightOf};pallets/unique/src/lib.rsdiffbeforeafterboth112911291130 /// Sets or unsets the approval of a given operator.1130 /// Sets or unsets the approval of a given operator.1131 ///1131 ///1132 /// An operator is allowed to transfer all tokens of the sender on their behalf.1132 /// The `operator` is allowed to transfer all tokens of the `owner` on their behalf.1133 ///1133 ///1134 /// # Arguments1134 /// # Arguments1135 ///1135 ///1136 /// * `owner`: Token owner1136 /// * `owner`: Token owner1137 /// * `operator`: Operator1137 /// * `operator`: Operator1138 /// * `approve`: Is operator enabled or disabled1138 /// * `approve`: Should operator status be granted or revoked?1139 #[weight = T::CommonWeightInfo::set_approval_for_all()]1139 #[weight = T::CommonWeightInfo::set_allowance_for_all()]1140 pub fn set_approval_for_all(1140 pub fn set_allowance_for_all(1141 origin,1141 origin,1142 collection_id: CollectionId,1142 collection_id: CollectionId,1143 operator: T::CrossAccountId,1143 operator: T::CrossAccountId,1144 approve: bool,1144 approve: bool,1145 ) -> DispatchResultWithPostInfo {1145 ) -> DispatchResultWithPostInfo {1146 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1146 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1147 dispatch_tx::<T, _>(collection_id, |d| {1147 dispatch_tx::<T, _>(collection_id, |d| {1148 d.set_approval_for_all(sender, operator, approve)1148 d.set_allowance_for_all(sender, operator, approve)1149 })1149 })1150 }1150 }1151 }1151 }primitives/rpc/src/lib.rsdiffbeforeafterboth134 fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;134 fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;135135136 /// Get whether an operator is approved by a given owner.136 /// Get whether an operator is approved by a given owner.137 fn is_approved_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool>;137 fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool>;138 }138 }139}139}140140runtime/common/runtime_apis.rsdiffbeforeafterboth188 dispatch_unique_runtime!(collection.total_pieces(token_id))188 dispatch_unique_runtime!(collection.total_pieces(token_id))189 }189 }190190191 fn is_approved_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool, DispatchError> {191 fn allowance_for_all(collection: CollectionId, owner: CrossAccountId, operator: CrossAccountId) -> Result<bool, DispatchError> {192 dispatch_unique_runtime!(collection.is_approved_for_all(owner, operator))192 dispatch_unique_runtime!(collection.allowance_for_all(owner, operator))193 }193 }194 }194 }195195runtime/common/weights.rsdiffbeforeafterboth121 max_weight_of!(token_owner())121 max_weight_of!(token_owner())122 }122 }123123124 fn set_approval_for_all() -> Weight {124 fn set_allowance_for_all() -> Weight {125 max_weight_of!(set_approval_for_all())125 max_weight_of!(set_allowance_for_all())126 }126 }127}127}128128tests/src/approve.test.tsdiffbeforeafterboth617617618 itSub('[nft] Enable and disable approval', async ({helper}) => {618 itSub('[nft] Enable and disable approval', async ({helper}) => {619 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});619 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});620 await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});620621 const checkBeforeApproval = await helper.nft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});621 const checkBeforeApproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});622 expect(checkBeforeApproval).to.be.false;622 expect(checkBeforeApproval).to.be.false;623623 await helper.nft.setApprovalForAll(alice, collectionId, {Substrate: bob.address}, true);624 await helper.nft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, true);624 const checkAfterApproval = await helper.nft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});625 const checkAfterApproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});625 expect(checkAfterApproval).to.be.true;626 expect(checkAfterApproval).to.be.true;627626 await helper.nft.setApprovalForAll(alice, collectionId, {Substrate: bob.address}, false);628 await helper.nft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, false);627 const checkAfterDisapproval = await helper.nft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});629 const checkAfterDisapproval = await helper.nft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});628 expect(checkAfterDisapproval).to.be.false;630 expect(checkAfterDisapproval).to.be.false;629 });631 });630632631 itSub.ifWithPallets('[rft] Enable and disable approval', [Pallets.ReFungible], async ({helper}) => {633 itSub.ifWithPallets('[rft] Enable and disable approval', [Pallets.ReFungible], async ({helper}) => {632 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});634 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});635633 const checkBeforeApproval = await helper.rft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});636 const checkBeforeApproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});634 expect(checkBeforeApproval).to.be.false;637 expect(checkBeforeApproval).to.be.false;638635 await helper.rft.setApprovalForAll(alice, collectionId, {Substrate: bob.address}, true);639 await helper.rft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, true);636 const checkAfterApproval = await helper.rft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});640 const checkAfterApproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});637 expect(checkAfterApproval).to.be.true;641 expect(checkAfterApproval).to.be.true;642 638 await helper.rft.setApprovalForAll(alice, collectionId, {Substrate: bob.address}, false);643 await helper.rft.setAllowanceForAll(alice, collectionId, {Substrate: bob.address}, false);639 const checkAfterDisapproval = await helper.rft.isApprovedForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});644 const checkAfterDisapproval = await helper.rft.allowanceForAll(collectionId, {Substrate: alice.address}, {Substrate: bob.address});640 expect(checkAfterDisapproval).to.be.false;645 expect(checkAfterDisapproval).to.be.false;641 });646 });642});647});tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth672 function approve(address approved, uint256 tokenId) external;672 function approve(address approved, uint256 tokenId) external;673673674 /// @notice Sets or unsets the approval of a given operator.674 /// @notice Sets or unsets the approval of a given operator.675 /// An operator is allowed to transfer all tokens of the sender on their behalf.675 /// The `operator` is allowed to transfer all tokens of the `caller` on their behalf.676 /// @param operator Operator676 /// @param operator Operator677 /// @param approved Is operator enabled or disabled677 /// @param approved Should operator status be granted or revoked?678 /// @dev EVM selector for this function is: 0xa22cb465,678 /// @dev EVM selector for this function is: 0xa22cb465,679 /// or in textual repr: setApprovalForAll(address,bool)679 /// or in textual repr: setApprovalForAll(address,bool)680 function setApprovalForAll(address operator, bool approved) external;680 function setApprovalForAll(address operator, bool approved) external;684 /// or in textual repr: getApproved(uint256)684 /// or in textual repr: getApproved(uint256)685 function getApproved(uint256 tokenId) external view returns (address);685 function getApproved(uint256 tokenId) external view returns (address);686686687 /// @notice Tells whether an operator is approved by a given owner.687 /// @notice Tells whether the given `owner` approves the `operator`.688 /// @dev EVM selector for this function is: 0xe985e9c5,688 /// @dev EVM selector for this function is: 0xe985e9c5,689 /// or in textual repr: isApprovedForAll(address,address)689 /// or in textual repr: isApprovedForAll(address,address)690 function isApprovedForAll(address owner, address operator) external view returns (bool);690 function isApprovedForAll(address owner, address operator) external view returns (bool);tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth669 function approve(address approved, uint256 tokenId) external;669 function approve(address approved, uint256 tokenId) external;670670671 /// @notice Sets or unsets the approval of a given operator.671 /// @notice Sets or unsets the approval of a given operator.672 /// An operator is allowed to transfer all tokens of the sender on their behalf.672 /// The `operator` is allowed to transfer all token pieces of the `caller` on their behalf.673 /// @param operator Operator673 /// @param operator Operator674 /// @param approved Is operator enabled or disabled674 /// @param approved Should operator status be granted or revoked?675 /// @dev EVM selector for this function is: 0xa22cb465,675 /// @dev EVM selector for this function is: 0xa22cb465,676 /// or in textual repr: setApprovalForAll(address,bool)676 /// or in textual repr: setApprovalForAll(address,bool)677 function setApprovalForAll(address operator, bool approved) external;677 function setApprovalForAll(address operator, bool approved) external;681 /// or in textual repr: getApproved(uint256)681 /// or in textual repr: getApproved(uint256)682 function getApproved(uint256 tokenId) external view returns (address);682 function getApproved(uint256 tokenId) external view returns (address);683683684 /// @notice Tells whether an operator is approved by a given owner.684 /// @notice Tells whether the given `owner` approves the `operator`.685 /// @dev EVM selector for this function is: 0xe985e9c5,685 /// @dev EVM selector for this function is: 0xe985e9c5,686 /// or in textual repr: isApprovedForAll(address,address)686 /// or in textual repr: isApprovedForAll(address,address)687 function isApprovedForAll(address owner, address operator) external view returns (bool);687 function isApprovedForAll(address owner, address operator) external view returns (bool);tests/src/eth/nonFungible.test.tsdiffbeforeafterboth935 let donor: IKeyringPair;935 let donor: IKeyringPair;936 let minter: IKeyringPair;936 let minter: IKeyringPair;937 let alice: IKeyringPair;937 let alice: IKeyringPair;938 let bob: IKeyringPair;939938940 before(async function() {939 before(async function() {941 await usingEthPlaygrounds(async (helper, privateKey) => {940 await usingEthPlaygrounds(async (helper, privateKey) => {942 donor = await privateKey({filename: __filename});941 donor = await privateKey({filename: __filename});943 [minter, alice, bob] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);942 [minter, alice] = await helper.arrange.createAccounts([100n, 100n], donor);944 });943 });945 });944 });946945947 itEth('[negative] Cant perform burn without approval', async ({helper}) => {946 itEth('[negative] Cant perform burn without approval', async ({helper}) => {948 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});947 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});949948950 const owner = bob;949 const owner = await helper.eth.createAccountWithBalance(donor, 100n);951 const spender = await helper.eth.createAccountWithBalance(donor, 100n);950 const spender = await helper.eth.createAccountWithBalance(donor, 100n);952951953 const token = await collection.mintToken(minter, {Substrate: owner.address});952 const token = await collection.mintToken(minter, {Ethereum: owner});954953955 const address = helper.ethAddress.fromCollectionId(collection.collectionId);954 const address = helper.ethAddress.fromCollectionId(collection.collectionId);956 const contract = helper.ethNativeContract.collection(address, 'nft');955 const contract = helper.ethNativeContract.collection(address, 'nft');957956958 {959 const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);957 const ownerCross = helper.ethCrossAccount.fromAddress(owner);958 await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;959960 await contract.methods.setApprovalForAll(spender, true).send({from: owner});961 await contract.methods.setApprovalForAll(spender, false).send({from: owner});962960 await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;963 await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;961 }962 });964 });963965964 itEth('[negative] Cant perform transfer without approval', async ({helper}) => {966 itEth('[negative] Cant perform transfer without approval', async ({helper}) => {965 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});967 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});966 const owner = bob;968 const receiver = alice;969967 const receiver = alice;970 const owner = await helper.eth.createAccountWithBalance(donor, 100n);968969 const spender = await helper.eth.createAccountWithBalance(donor, 100n);971 const spender = await helper.eth.createAccountWithBalance(donor, 100n);970972971 const token = await collection.mintToken(minter, {Substrate: owner.address});973 const token = await collection.mintToken(minter, {Ethereum: owner});972974973 const address = helper.ethAddress.fromCollectionId(collection.collectionId);975 const address = helper.ethAddress.fromCollectionId(collection.collectionId);974 const contract = helper.ethNativeContract.collection(address, 'nft');976 const contract = helper.ethNativeContract.collection(address, 'nft');975977976 {977 const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);978 const ownerCross = helper.ethCrossAccount.fromAddress(owner);978 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);979 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);980981 await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;982983 await contract.methods.setApprovalForAll(spender, true).send({from: owner});984 await contract.methods.setApprovalForAll(spender, false).send({from: owner});985 979 await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;986 await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;980 }981 });987 });982});988});983989tests/src/eth/reFungible.test.tsdiffbeforeafterboth750 const address = helper.ethAddress.fromCollectionId(collection.collectionId);750 const address = helper.ethAddress.fromCollectionId(collection.collectionId);751 const contract = helper.ethNativeContract.collection(address, 'rft');751 const contract = helper.ethNativeContract.collection(address, 'rft');752752753 {754 const ownerCross = helper.ethCrossAccount.fromAddress(owner);753 const ownerCross = helper.ethCrossAccount.fromAddress(owner);754755 await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;756757 await contract.methods.setApprovalForAll(spender, true).send({from: owner});758 await contract.methods.setApprovalForAll(spender, false).send({from: owner});759755 await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;760 await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;756 }757 });761 });758762759 itEth('[negative] Cant perform transfer without approval', async ({helper}) => {763 itEth('[negative] Cant perform transfer without approval', async ({helper}) => {768 const address = helper.ethAddress.fromCollectionId(collection.collectionId);772 const address = helper.ethAddress.fromCollectionId(collection.collectionId);769 const contract = helper.ethNativeContract.collection(address, 'rft');773 const contract = helper.ethNativeContract.collection(address, 'rft');770774771 {772 const ownerCross = helper.ethCrossAccount.fromAddress(owner);775 const ownerCross = helper.ethCrossAccount.fromAddress(owner);773 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);776 const recieverCross = helper.ethCrossAccount.fromKeyringPair(receiver);777 778 await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;779780 await contract.methods.setApprovalForAll(spender, true).send({from: owner});781 await contract.methods.setApprovalForAll(spender, false).send({from: owner});782 774 await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;783 await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;775 }776 });784 });777});785});778786tests/src/interfaces/augment-api-events.tsdiffbeforeafterboth106 * Amount pieces of token owned by `sender` was approved for `spender`.106 * Amount pieces of token owned by `sender` was approved for `spender`.107 **/107 **/108 Approved: AugmentedEvent<ApiType, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr, u128]>;108 Approved: AugmentedEvent<ApiType, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr, u128]>;109 /**109 /**110 * Amount pieces of token owned by `sender` was approved for `spender`.110 * A `sender` approves operations on all owned tokens for `spender`.111 **/111 **/112 ApprovedForAll: AugmentedEvent<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr, bool]>;112 ApprovedForAll: AugmentedEvent<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr, bool]>;113 /**113 /**114 * New collection was created114 * New collection was createdtests/src/interfaces/augment-api-query.tsdiffbeforeafterboth405 * Allowance set by a token owner for another user to perform one of certain transactions on a token.405 * Allowance set by a token owner for another user to perform one of certain transactions on a token.406 **/406 **/407 allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;407 allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;408 /**409 * Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.410 **/411 collectionAllowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;408 /**412 /**409 * Used to enumerate tokens owned by account.413 * Used to enumerate tokens owned by account.410 **/414 **/441 * Total amount of minted tokens in a collection.445 * Total amount of minted tokens in a collection.442 **/446 **/443 tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;447 tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;444 /**445 * Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.446 **/447 walletOperator: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<Option<bool>>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;448 /**448 /**449 * Generic query449 * Generic query450 **/450 **/624 * Amount of token pieces owned by account.624 * Amount of token pieces owned by account.625 **/625 **/626 balance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr]>;626 balance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, u32, PalletEvmAccountBasicCrossAccountIdRepr]>;627 /**628 * Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.629 **/630 collectionAllowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<bool>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;627 /**631 /**628 * Used to enumerate tokens owned by account.632 * Used to enumerate tokens owned by account.629 **/633 **/648 * Total amount of pieces for token652 * Total amount of pieces for token649 **/653 **/650 totalSupply: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u128>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;654 totalSupply: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u128>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;651 /**652 * Operator set by a wallet owner that could perform certain transactions on all tokens in the wallet.653 **/654 walletOperator: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<Option<bool>>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletEvmAccountBasicCrossAccountIdRepr, PalletEvmAccountBasicCrossAccountIdRepr]>;655 /**655 /**656 * Generic query656 * Generic query657 **/657 **/tests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth683 * Get the amount of currently possible sponsored transactions on a token for the fee to be taken off a sponsor683 * Get the amount of currently possible sponsored transactions on a token for the fee to be taken off a sponsor684 **/684 **/685 allowance: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, sender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, spender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;685 allowance: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, sender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, spender: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;686 /**687 * Tells whether the given `owner` approves the `operator`.688 **/689 allowanceForAll: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, owner: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, operator: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<bool>>>;686 /**690 /**687 * Check if a user is allowed to operate within a collection691 * Check if a user is allowed to operate within a collection688 **/692 **/719 * Get effective collection limits723 * Get effective collection limits720 **/724 **/721 effectiveCollectionLimits: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<UpDataStructsCollectionLimits>>>;725 effectiveCollectionLimits: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<UpDataStructsCollectionLimits>>>;722 /**723 * Tells whether an operator is approved by a given owner.724 **/725 isApprovedForAll: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, owner: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, operator: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<bool>>>;726 /**726 /**727 * Get the last token ID created in a collection727 * Get the last token ID created in a collection728 **/728 **/tests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth1544 * * `amount`: New number of parts/pieces into which the token shall be partitioned.1544 * * `amount`: New number of parts/pieces into which the token shall be partitioned.1545 **/1545 **/1546 repartition: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u128]>;1546 repartition: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u128]>;1547 /**1547 /**1548 * Sets or unsets the approval of a given operator.1548 * Sets or unsets the approval of a given operator.1549 * 1549 * 1550 * An operator is allowed to transfer all tokens of the sender on their behalf.1550 * The `operator` is allowed to transfer all tokens of the `owner` on their behalf.1551 * 1551 * 1552 * # Arguments1552 * # Arguments1553 * 1553 * 1554 * * `owner`: Token owner1554 * * `owner`: Token owner1555 * * `operator`: Operator1555 * * `operator`: Operator1556 * * `approve`: Is operator enabled or disabled1556 * * `approve`: Should operator status be granted or revoked?1557 **/1557 **/1558 setApprovalForAll: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, operator: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, bool]>;1558 setAllowanceForAll: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, operator: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletEvmAccountBasicCrossAccountIdRepr, bool]>;1559 /**1559 /**1560 * Set specific limits of a collection. Empty, or None fields mean chain default.1560 * Set specific limits of a collection. Empty, or None fields mean chain default.1561 * 1561 * tests/src/interfaces/default/types.tsdiffbeforeafterboth2312 readonly tokenId: u32;2312 readonly tokenId: u32;2313 readonly amount: u128;2313 readonly amount: u128;2314 } & Struct;2314 } & Struct;2315 readonly isSetApprovalForAll: boolean;2315 readonly isSetAllowanceForAll: boolean;2316 readonly asSetApprovalForAll: {2316 readonly asSetAllowanceForAll: {2317 readonly collectionId: u32;2317 readonly collectionId: u32;2318 readonly operator: PalletEvmAccountBasicCrossAccountIdRepr;2318 readonly operator: PalletEvmAccountBasicCrossAccountIdRepr;2319 readonly approve: bool;2319 readonly approve: bool;2320 } & Struct;2320 } & Struct;2321 readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetApprovalForAll';2321 readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetAllowanceForAll';2322}2322}232323232324/** @name PalletUniqueError */2324/** @name PalletUniqueError */tests/src/interfaces/lookup.tsdiffbeforeafterboth2305 tokenId: 'u32',2305 tokenId: 'u32',2306 amount: 'u128',2306 amount: 'u128',2307 },2307 },2308 set_approval_for_all: {2308 set_allowance_for_all: {2309 collectionId: 'u32',2309 collectionId: 'u32',2310 operator: 'PalletEvmAccountBasicCrossAccountIdRepr',2310 operator: 'PalletEvmAccountBasicCrossAccountIdRepr',2311 approve: 'bool'2311 approve: 'bool'tests/src/interfaces/types-lookup.tsdiffbeforeafterboth2541 readonly tokenId: u32;2541 readonly tokenId: u32;2542 readonly amount: u128;2542 readonly amount: u128;2543 } & Struct;2543 } & Struct;2544 readonly isSetApprovalForAll: boolean;2544 readonly isSetAllowanceForAll: boolean;2545 readonly asSetApprovalForAll: {2545 readonly asSetAllowanceForAll: {2546 readonly collectionId: u32;2546 readonly collectionId: u32;2547 readonly operator: PalletEvmAccountBasicCrossAccountIdRepr;2547 readonly operator: PalletEvmAccountBasicCrossAccountIdRepr;2548 readonly approve: bool;2548 readonly approve: bool;2549 } & Struct;2549 } & Struct;2550 readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetApprovalForAll';2550 readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition' | 'SetAllowanceForAll';2551 }2551 }255225522553 /** @name UpDataStructsCollectionMode (240) */2553 /** @name UpDataStructsCollectionMode (240) */tests/src/interfaces/unique/definitions.tsdiffbeforeafterboth175 [collectionParam, tokenParam], 175 [collectionParam, tokenParam], 176 'Option<u128>',176 'Option<u128>',177 ),177 ),178 isApprovedForAll: fun(178 allowanceForAll: fun(179 'Tells whether an operator is approved by a given owner.', 179 'Tells whether the given `owner` approves the `operator`.', 180 [collectionParam, crossAccountParam('owner'), crossAccountParam('operator')], 180 [collectionParam, crossAccountParam('owner'), crossAccountParam('operator')], 181 'Option<bool>',181 'Option<bool>',182 ),182 ),tests/src/util/playgrounds/unique.tsdiffbeforeafterboth1414 return null;1414 return null;1415 }1415 }141614161417 /**1417 /**1418 * Tells whether an operator is approved by a given owner.1418 * Tells whether the given `owner` approves the `operator`.1419 * @param collectionId ID of collection1419 * @param collectionId ID of collection1420 * @param owner owner address1420 * @param owner owner address1421 * @param operator operator addrees1421 * @param operator operator addrees1422 * @returns true if operator is enabled1422 * @returns true if operator is enabled1423 */1423 */1424 async isApprovedForAll(collectionId: number, owner: ICrossAccountId, operator: ICrossAccountId): Promise<boolean> {1424 async allowanceForAll(collectionId: number, owner: ICrossAccountId, operator: ICrossAccountId): Promise<boolean> {1425 return (await this.helper.callRpc('api.rpc.unique.isApprovedForAll', [collectionId, owner, operator])).toJSON();1425 return (await this.helper.callRpc('api.rpc.unique.allowanceForAll', [collectionId, owner, operator])).toJSON();1426 }1426 }142714271428 /** Sets or unsets the approval of a given operator.1428 /** Sets or unsets the approval of a given operator.1429 * An operator is allowed to transfer all tokens of the sender on their behalf.1429 * The `operator` is allowed to transfer all tokens of the `caller` on their behalf.1430 * @param operator Operator1430 * @param operator Operator1431 * @param approved Is operator enabled or disabled1431 * @param approved Should operator status be granted or revoked?1432 * @returns ```true``` if extrinsic success, otherwise ```false```1432 * @returns ```true``` if extrinsic success, otherwise ```false```1433 */1433 */1434 async setApprovalForAll(signer: TSigner, collectionId: number, operator: ICrossAccountId, approved: boolean): Promise<boolean> {1434 async setAllowanceForAll(signer: TSigner, collectionId: number, operator: ICrossAccountId, approved: boolean): Promise<boolean> {1435 const result = await this.helper.executeExtrinsic(1435 const result = await this.helper.executeExtrinsic(1436 signer,1436 signer,1437 'api.tx.unique.setApprovalForAll', [collectionId, operator, approved],1437 'api.tx.unique.setAllowanceForAll', [collectionId, operator, approved],1438 true,1438 true,1439 );1439 );1440 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'ApprovedForAll');1440 return this.helper.util.findCollectionInEvents(result.result.events, collectionId, 'common', 'ApprovedForAll');