git.delta.rocks / unique-network / refs/commits / e0a717015a56

difftreelog

chore fix code review requests

Grigoriy Simonov2022-12-06parent: #cd0ba0d.patch.diff
in: master

36 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
248 ) -> Result<Option<String>>;248 ) -> Result<Option<String>>;
249249
250 /// 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}
584584
585impl<C, Block, BlockNumber, CrossAccountId, AccountId>585impl<C, Block, BlockNumber, CrossAccountId, AccountId>
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
1535 fn token_owner() -> Weight;1535 fn token_owner() -> Weight;
15361536
1537 /// The price of setting approval for all1537 /// The price of setting approval for all
1538 fn set_approval_for_all() -> Weight;1538 fn set_allowance_for_all() -> Weight;
1539}1539}
15401540
1541/// 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>>;
18461846
1847 /// 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 owner
1849 /// * `operator` - Operator1849 /// * `operator` - Operator
1850 /// * `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;
18571857
1858 /// 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}
18611861
1862/// Extension for RFT collection.1862/// Extension for RFT collection.
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
108 Weight::zero()108 Weight::zero()
109 }109 }
110110
111 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 }
431431
432 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 }
440440
441 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 false
443 }443 }
444}444}
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
223223
224 }: {collection.token_owner(item)}224 }: {collection.token_owner(item)}
225225
226 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)}
232232
233 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}
240240
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
123 <SelfWeightOf<T>>::token_owner()123 <SelfWeightOf<T>>::token_owner()
124 }124 }
125125
126 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}
130130
517 }517 }
518 }518 }
519519
520 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 }
531531
532 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}
536536
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
472 /// @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 Operator
475 /// @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);
485485
486 <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 }
496496
497 /// @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);
502502
503 Ok(<Pallet<T>>::is_approved_for_all(self, &owner, &operator))503 Ok(<Pallet<T>>::allowance_for_all(self, &owner, &operator))
504 }504 }
505505
506 /// @notice Returns collection helper contract address506 /// @notice Returns collection helper contract address
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
274274
275 /// 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 }
456456
1206 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!(
13451345
1346 /// 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 owner
1350 /// - `operator`: Operator1350 /// - `operator`: Operator
1351 /// - `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,
13641364
1365 // =========1365 // =========
13661366
1367 <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 }
13841384
1385 /// 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}
13941394
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
1021 }1021 }
10221022
1023 /// @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 Operator
1026 /// @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 }
10451045
1046 /// @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) {
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
48 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}
5454
55/// 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 }
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
291 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)}
293293
294 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)}
300300
301 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}
308308
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
153 <SelfWeightOf<T>>::token_owner()153 <SelfWeightOf<T>>::token_owner()
154 }154 }
155155
156 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}
160160
521 <Pallet<T>>::total_pieces(self.id, token)521 <Pallet<T>>::total_pieces(self.id, token)
522 }522 }
523523
524 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 }
535535
536 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}
540540
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
462 }462 }
463463
464 /// @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 Operator
467 /// @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);
477477
478 <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 }
488488
489 /// @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);
494494
495 Ok(<Pallet<T>>::is_approved_for_all(self, &owner, &operator))495 Ok(<Pallet<T>>::allowance_for_all(self, &owner, &operator))
496 }496 }
497497
498 /// @notice Returns collection helper contract address498 /// @notice Returns collection helper contract address
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
275275
276 /// 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 >;
287287
288 #[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);
11761176
1177 // Allowance if any would be reduced if spender is also wallet operator1177 // Allowance (if any) would be reduced if spender is also wallet operator
1178 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 }
11811181
14081408
1409 /// 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 owner
1413 /// - `operator`: Operator1413 /// - `operator`: Operator
1414 /// - `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,
14271427
1428 // =========1428 // =========
14291429
1430 <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 }
14471447
1448 /// 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}
14571457
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
1018 }1018 }
10191019
1020 /// @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 Operator
1023 /// @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 }
10421042
1043 /// @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) {
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
55 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}
6161
62/// 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 }
modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
36use 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};
4141
42use crate::{weights::WeightInfo, Config, SelfWeightOf};42use crate::{weights::WeightInfo, Config, SelfWeightOf};
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
11291129
1130 /// 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 /// # Arguments
1135 ///1135 ///
1136 /// * `owner`: Token owner1136 /// * `owner`: Token owner
1137 /// * `operator`: Operator1137 /// * `operator`: Operator
1138 /// * `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 }
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
134 fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;134 fn token_owners(collection: CollectionId, token: TokenId) -> Result<Vec<CrossAccountId>>;
135135
136 /// 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}
140140
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
188 dispatch_unique_runtime!(collection.total_pieces(token_id))188 dispatch_unique_runtime!(collection.total_pieces(token_id))
189 }189 }
190190
191 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 }
195195
modifiedruntime/common/weights.rsdiffbeforeafterboth
121 max_weight_of!(token_owner())121 max_weight_of!(token_owner())
122 }122 }
123123
124 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}
128128
modifiedtests/src/approve.test.tsdiffbeforeafterboth
617617
618 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});620
621 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;
623
623 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;
627
626 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 });
630632
631 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'});
635
633 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;
638
635 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});
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
672 function approve(address approved, uint256 tokenId) external;672 function approve(address approved, uint256 tokenId) external;
673673
674 /// @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 Operator
677 /// @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);
686686
687 /// @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);
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
669 function approve(address approved, uint256 tokenId) external;669 function approve(address approved, uint256 tokenId) external;
670670
671 /// @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 Operator
674 /// @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);
683683
684 /// @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);
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
935 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;
939938
940 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 });
946945
947 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'});
949948
950 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);
952951
953 const token = await collection.mintToken(minter, {Substrate: owner.address});952 const token = await collection.mintToken(minter, {Ethereum: owner});
954953
955 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');
957956
958 {
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;
959
960 await contract.methods.setApprovalForAll(spender, true).send({from: owner});
961 await contract.methods.setApprovalForAll(spender, false).send({from: owner});
962
960 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 });
963965
964 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;
969
967 const receiver = alice;970 const owner = await helper.eth.createAccountWithBalance(donor, 100n);
968
969 const spender = await helper.eth.createAccountWithBalance(donor, 100n);971 const spender = await helper.eth.createAccountWithBalance(donor, 100n);
970972
971 const token = await collection.mintToken(minter, {Substrate: owner.address});973 const token = await collection.mintToken(minter, {Ethereum: owner});
972974
973 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');
975977
976 {
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);
980
981 await expect(contract.methods.transferFromCross(ownerCross, recieverCross, token.tokenId).send({from: spender})).to.be.rejected;
982
983 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});
983989
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
750 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');
752752
753 {
754 const ownerCross = helper.ethCrossAccount.fromAddress(owner);753 const ownerCross = helper.ethCrossAccount.fromAddress(owner);
754
755 await expect(contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender})).to.be.rejected;
756
757 await contract.methods.setApprovalForAll(spender, true).send({from: owner});
758 await contract.methods.setApprovalForAll(spender, false).send({from: owner});
759
755 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 });
758762
759 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');
770774
771 {
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;
779
780 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});
778786
modifiedtests/src/interfaces/augment-api-events.tsdiffbeforeafterboth
106 * 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 created
modifiedtests/src/interfaces/augment-api-query.tsdiffbeforeafterboth
405 * 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 query
450 **/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 token
649 **/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 query
657 **/657 **/
modifiedtests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth
683 * 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 sponsor
684 **/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 collection
688 **/692 **/
719 * Get effective collection limits723 * Get effective collection limits
720 **/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 collection
728 **/728 **/
modifiedtests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth
1544 * * `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 * # Arguments
1553 * 1553 *
1554 * * `owner`: Token owner1554 * * `owner`: Token owner
1555 * * `operator`: Operator1555 * * `operator`: Operator
1556 * * `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 *
modifiedtests/src/interfaces/default/types.tsdiffbeforeafterboth
2312 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}
23232323
2324/** @name PalletUniqueError */2324/** @name PalletUniqueError */
modifiedtests/src/interfaces/lookup.tsdiffbeforeafterboth
2305 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'
modifiedtests/src/interfaces/types-lookup.tsdiffbeforeafterboth
2541 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 }
25522552
2553 /** @name UpDataStructsCollectionMode (240) */2553 /** @name UpDataStructsCollectionMode (240) */
modifiedtests/src/interfaces/unique/definitions.tsdiffbeforeafterboth
175 [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 ),
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
1414 return null;1414 return null;
1415 }1415 }
14161416
1417 /**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 collection
1420 * @param owner owner address1420 * @param owner owner address
1421 * @param operator operator addrees1421 * @param operator operator addrees
1422 * @returns true if operator is enabled1422 * @returns true if operator is enabled
1423 */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 }
14271427
1428 /** 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 Operator
1431 * @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');