difftreelog
Merge branch 'develop' into fix/tests
in: master
49 files changed
Cargo.lockdiffbeforeafterboth5114 "pallet-randomness-collective-flip",5114 "pallet-randomness-collective-flip",5115 "pallet-refungible",5115 "pallet-refungible",5116 "pallet-sudo",5116 "pallet-sudo",5117 "pallet-template-charge-transaction",5117 "pallet-template-transaction-payment",5118 "pallet-timestamp",5118 "pallet-timestamp",5119 "pallet-transaction-payment",5119 "pallet-transaction-payment",5120 "pallet-transaction-payment-rpc-runtime-api",5120 "pallet-transaction-payment-rpc-runtime-api",6350]6350]635163516352[[package]]6352[[package]]6353name = "pallet-template-charge-transaction"6353name = "pallet-template-transaction-payment"6354version = "3.0.0"6354version = "3.0.0"6355source = "git+https://github.com/UniqueNetwork/pallet-sponsoring#e5d3354ab68face1b2ef709dc7f629803f56598d"6355source = "git+https://github.com/UniqueNetwork/pallet-sponsoring#ab8b91e9350a31133f3a3e4f52a84c6de4108e95"6356dependencies = [6356dependencies = [6357 "frame-benchmarking",6357 "frame-benchmarking",6358 "frame-support",6358 "frame-support",11696source = "registry+https://github.com/rust-lang/crates.io-index"11696source = "registry+https://github.com/rust-lang/crates.io-index"11697checksum = "1f559b464de2e2bdabcac6a210d12e9b5a5973c251e102c44c585c71d51bd78e"11697checksum = "1f559b464de2e2bdabcac6a210d12e9b5a5973c251e102c44c585c71d51bd78e"11698dependencies = [11698dependencies = [11699 "cfg-if 0.1.10",11699 "cfg-if 1.0.0",11700 "rand 0.8.4",11700 "rand 0.8.4",11701 "static_assertions",11701 "static_assertions",11702]11702]11847[[package]]11847[[package]]11848name = "up-sponsorship"11848name = "up-sponsorship"11849version = "0.1.0"11849version = "0.1.0"11850source = "git+https://github.com/UniqueNetwork/pallet-sponsoring#e5d3354ab68face1b2ef709dc7f629803f56598d"11850source = "git+https://github.com/UniqueNetwork/pallet-sponsoring#ab8b91e9350a31133f3a3e4f52a84c6de4108e95"11851dependencies = [11851dependencies = [11852 "impl-trait-for-tuples 0.2.1",11852 "impl-trait-for-tuples 0.2.1",11853]11853]README.mddiffbeforeafterboth41 - Re-Fungible Token Mode41 - Re-Fungible Token Mode42 - Off-Chain Schema to store token image URLs42 - Off-Chain Schema to store token image URLs43 - Alternative economic model43 - Alternative economic model44 - White Lists and Public Mint Permission44 - Allow Lists and Public Mint Permission45- Use example: [SubstraPunks Game](https://github.com/usetech-llc/substrapunks), fully hosted on IPFS and NFT Testnet45- Use example: [SubstraPunks Game](https://github.com/usetech-llc/substrapunks), fully hosted on IPFS and NFT Testnet46 Blockchain.46 Blockchain.4747doc/builders_walk_through.mddiffbeforeafterboth1736. Now select your "ZERO BALANCE" address in the drop-down list and repeat searching and adding the collection for this address.1736. Now select your "ZERO BALANCE" address in the drop-down list and repeat searching and adding the collection for this address.1747. Transfer token back to your main address. Observe that despite the zero balance, the transfer is successful.1747. Transfer token back to your main address. Observe that despite the zero balance, the transfer is successful.175175176### White Lists and Public Mint Permission176### Allow Lists and Public Mint Permission177177178We did not complete these features in time by Hackusama deadline, but because they are important for security of the network, we completed them after the deadline anyway. They can be seen in branch [feature/white_list](https://github.com/usetech-llc/nft_parachain/tree/feature/white_list). Here are the permalinks to essential functions:178We did not complete these features in time by Hackusama deadline, but because they are important for security of the network, we completed them after the deadline anyway. They can be seen in branch [feature/allow_list](https://github.com/usetech-llc/nft_parachain/tree/feature/allow_list). Here are the permalinks to essential functions:179179180[white_lists](https://github.com/usetech-llc/nft_parachain/blob/b7c59f0085ed2bc1922e937adf68ef4174a8ba36/pallets/nft/src/lib.rs#L659)180[allow_lists](https://github.com/usetech-llc/nft_parachain/blob/b7c59f0085ed2bc1922e937adf68ef4174a8ba36/pallets/nft/src/lib.rs#L659)181181182[mint_permission](https://github.com/usetech-llc/nft_parachain/blob/b7c59f0085ed2bc1922e937adf68ef4174a8ba36/pallets/nft/src/lib.rs#L373)182[mint_permission](https://github.com/usetech-llc/nft_parachain/blob/b7c59f0085ed2bc1922e937adf68ef4174a8ba36/pallets/nft/src/lib.rs#L373)183183doc/economic_model.mddiffbeforeafterboth404041Set the collection sponsor address. The sponsorship needs to be confirmed by sending a ConfirmSponsorship transaction41Set the collection sponsor address. The sponsorship needs to be confirmed by sending a ConfirmSponsorship transaction42from that address. Also, the protection measures need to be in place so that sponsor account cannot be depleted by42from that address. Also, the protection measures need to be in place so that sponsor account cannot be depleted by43malicious users. White listing is one of the measured. It can be enabled with SetPublicAccessMode method.43malicious users. Allow listing is one of the measured. It can be enabled with SetPublicAccessMode method.444445##### List of transactions45##### List of transactions464667 Further, the logic is similar to limiting by token as above. If only one of the limits (by token or by address)67 Further, the logic is similar to limiting by token as above. If only one of the limits (by token or by address)68 indicates that fee should be paid by the user, the fee is paid by the user.68 indicates that fee should be paid by the user, the fee is paid by the user.69- A pallet method (SetCollectionRateLimits) will be added to set these parameters and enable rate limiting.69- A pallet method (SetCollectionRateLimits) will be added to set these parameters and enable rate limiting.70- One idea to consider is deposits that must be made by an address in order to become white listed (instead of admin70- One idea to consider is deposits that must be made by an address in order to become allow listed (instead of admin71 review).71 review).727273#### Permissions73#### Permissions173173174#### Description174#### Description175175176Toggle between normal and white list access for the methods with access for “Anyone”. If White List mode is enabled,176Toggle between normal and allow list access for the methods with access for “Anyone”. If Allow List mode is enabled,177AddToWhiteList and RemoveFromWhiteList methods can be called to add to and remove addresses from the white list.177AddToAllowList and RemoveFromAllowList methods can be called to add to and remove addresses from the allow list.178178179White list mode is the property of collection. If it is turned on, all public operations such as token transfers, for179Allow list mode is the property of collection. If it is turned on, all public operations such as token transfers, for180example, which normally have “Anyone” permission, become white listed, i.e. are only available to collection owner,180example, which normally have “Anyone” permission, become allow listed, i.e. are only available to collection owner,181admins, and addresses from the white list. White lists can be helpful for rate limiting of transfers when collection181admins, and addresses from the allow list. Allow lists can be helpful for rate limiting of transfers when collection182sponsoring is enabled.182sponsoring is enabled.183183184#### Permissions184#### Permissions190- CollectionID: ID of the Collection to set access mode for190- CollectionID: ID of the Collection to set access mode for191- Mode191- Mode192 - 0 = Normal192 - 0 = Normal193 - 1 = White list193 - 1 = Allow list194194195### AddToWhiteList195### AddToAllowList196196197#### Description197#### Description198198199Add an address to white list.199Add an address to allow list.200200201#### Permissions201#### Permissions202202208- CollectionID: ID of the Collection208- CollectionID: ID of the Collection209- Address209- Address210210211### RemoveFromWhiteList211### RemoveFromAllowList212212213#### Description213#### Description214214215Remove an address from white list.215Remove an address from allow list.216216217#### Permissions217#### Permissions218218doc/hackusama_walk_through.mddiffbeforeafterboth187 address.187 address.1887. Transfer token back to your main address. Observe that despite the zero balance, the transfer is successful.1887. Transfer token back to your main address. Observe that despite the zero balance, the transfer is successful.189189190### White Lists and Public Mint Permission190### Allow Lists and Public Mint Permission191191192We did not complete these features in time by Hackusama deadline, but because they are important for security of the192We did not complete these features in time by Hackusama deadline, but because they are important for security of the193network, we completed them after the deadline anyway. They can be seen in branch193network, we completed them after the deadline anyway. They can be seen in branch194[feature/white_list](https://github.com/usetech-llc/nft_parachain/tree/feature/white_list). Here are the permalinks to194[feature/allow_list](https://github.com/usetech-llc/nft_parachain/tree/feature/allow_list). Here are the permalinks to195essential functions:195essential functions:196196197[white_lists](https://github.com/usetech-llc/nft_parachain/blob/b7c59f0085ed2bc1922e937adf68ef4174a8ba36/pallets/nft/src/lib.rs#L659)197[allow_lists](https://github.com/usetech-llc/nft_parachain/blob/b7c59f0085ed2bc1922e937adf68ef4174a8ba36/pallets/nft/src/lib.rs#L659)198198199[mint_permission](https://github.com/usetech-llc/nft_parachain/blob/b7c59f0085ed2bc1922e937adf68ef4174a8ba36/pallets/nft/src/lib.rs#L373)199[mint_permission](https://github.com/usetech-llc/nft_parachain/blob/b7c59f0085ed2bc1922e937adf68ef4174a8ba36/pallets/nft/src/lib.rs#L373)200200doc/milestone_1.mddiffbeforeafterboth1## Milestone 11## Milestone 1223**User Paid Fees and Sponsored. Finish/Debug white listing and spam/DOS protection**3**User Paid Fees and Sponsored. Finish/Debug allow listing and spam/DOS protection**445Implementation of two models 5Implementation of two models 6If collection sponsor is set and confirmed for collection instance that means Sponsored Economic Model has chosen. Otherwise default economic model User Paid Fees is set.6If collection sponsor is set and confirmed for collection instance that means Sponsored Economic Model has chosen. Otherwise default economic model User Paid Fees is set.7For Sponsored Economic Model exists timeouts for token transactions. For every NFT type timeouts defined separately. Timeouts and white list limits together prevented spam and malicious actions.7For Sponsored Economic Model exists timeouts for token transactions. For every NFT type timeouts defined separately. Timeouts and allow list limits together prevented spam and malicious actions.889Set sponsor9Set sponsor10`nft`.`set_collection_sponsor`10`nft`.`set_collection_sponsor`11Confirm sponsor11Confirm sponsor12`nft`.`confirm_sponsorship`12`nft`.`confirm_sponsorship`131314A white list mode presented by collection property `access` and can be enabled with `set_public_access_mode`. Rules provide spam/DOS protection14A allow list mode presented by collection property `access` and can be enabled with `set_public_access_mode`. Rules provide spam/DOS protection15While collection in the white list mode rules below are active:15While collection in the allow list mode rules below are active:16Owner can add address to white list16Owner can add address to allow list17Admin can add address to white list17Admin can add address to allow list18Non-privileged user cannot add address to white list18Non-privileged user cannot add address to allow list19Owner can remove address from white list19Owner can remove address from allow list20Admin can remove address from white list20Admin can remove address from allow list21Non-privileged user cannot remove address from white list21Non-privileged user cannot remove address from allow list22If Public Access mode is set to WhiteList, tokens can’t be transferred from a non-whitelisted address with transfer or transferFrom22If Public Access mode is set to AllowList, tokens can’t be transferred from a non-allowlisted address with transfer or transferFrom23If Public Access mode is set to WhiteList, tokens can’t be transferred to a non-whitelisted address with transfer or transferFrom23If Public Access mode is set to AllowList, tokens can’t be transferred to a non-allowlisted address with transfer or transferFrom24If Public Access mode is set to WhiteList, tokens can’t be destroyed by a non-whitelisted address (even if it owned them before enabling WhiteList mode)24If Public Access mode is set to AllowList, tokens can’t be destroyed by a non-allowlisted address (even if it owned them before enabling AllowList mode)25If Public Access mode is set to WhiteList, token transfers can’t be Approved by a non-whitelisted address (see Approve method).25If Public Access mode is set to AllowList, token transfers can’t be Approved by a non-allowlisted address (see Approve method).26If Public Access mode is set to WhiteList, tokens can be transferred to a whitelisted address with transfer or transferFrom26If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transfer or transferFrom27If Public Access mode is set to WhiteList, tokens can be transferred from a whitelisted address with transfer or transferFrom 27If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transfer or transferFrom 28If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by owner.28If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by owner.29If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by admin.29If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by admin.30If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and white listed address.30If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and allow listed address.31If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-white listed address.31If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-allow listed address.32If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by owner.32If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by owner.33If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by admin.33If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by admin.34If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-white listed address.34If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-allow listed address.35If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by non-privileged and white listed address.35If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by non-privileged and allow listed address.363637**Add missing custom types (CollectionMode, FungibleItemType, ReFungibleItemType)**37**Add missing custom types (CollectionMode, FungibleItemType, ReFungibleItemType)**3838pallets/common/src/lib.rsdiffbeforeafterboth260 NoPermission,260 NoPermission,261 /// Collection is not in mint mode.261 /// Collection is not in mint mode.262 PublicMintingNotAllowed,262 PublicMintingNotAllowed,263 /// Address is not in white list.263 /// Address is not in allow list.264 AddressNotInAllowlist,264 AddressNotInAllowlist,265265266 /// Collection name can not be longer than 63 char.266 /// Collection name can not be longer than 63 char.pallets/fungible/src/lib.rsdiffbeforeafterboth123 .checked_sub(amount)123 .checked_sub(amount)124 .ok_or(<CommonError<T>>::TokenValueTooLow)?;124 .ok_or(<CommonError<T>>::TokenValueTooLow)?;125125126 if collection.access == AccessMode::WhiteList {126 if collection.access == AccessMode::AllowList {127 collection.check_allowlist(owner)?;127 collection.check_allowlist(owner)?;128 }128 }129129161 <CommonError<T>>::TransferNotAllowed,161 <CommonError<T>>::TransferNotAllowed,162 );162 );163163164 if collection.access == AccessMode::WhiteList {164 if collection.access == AccessMode::AllowList {165 collection.check_allowlist(from)?;165 collection.check_allowlist(from)?;166 collection.check_allowlist(to)?;166 collection.check_allowlist(to)?;167 }167 }307 spender: &T::CrossAccountId,307 spender: &T::CrossAccountId,308 amount: u128,308 amount: u128,309 ) -> DispatchResult {309 ) -> DispatchResult {310 if collection.access == AccessMode::WhiteList {310 if collection.access == AccessMode::AllowList {311 collection.check_allowlist(&owner)?;311 collection.check_allowlist(&owner)?;312 collection.check_allowlist(&spender)?;312 collection.check_allowlist(&spender)?;313 }313 }335 if spender.conv_eq(from) {335 if spender.conv_eq(from) {336 return Self::transfer(collection, from, to, amount);336 return Self::transfer(collection, from, to, amount);337 }337 }338 if collection.access == AccessMode::WhiteList {338 if collection.access == AccessMode::AllowList {339 // `from`, `to` checked in [`transfer`]339 // `from`, `to` checked in [`transfer`]340 collection.check_allowlist(spender)?;340 collection.check_allowlist(spender)?;341 }341 }366 if spender.conv_eq(from) {366 if spender.conv_eq(from) {367 return Self::burn(collection, from, amount);367 return Self::burn(collection, from, amount);368 }368 }369 if collection.access == AccessMode::WhiteList {369 if collection.access == AccessMode::AllowList {370 // `from` checked in [`burn`]370 // `from` checked in [`burn`]371 collection.check_allowlist(spender)?;371 collection.check_allowlist(spender)?;372 }372 }pallets/nft/src/benchmarking.rsdiffbeforeafterboth55 let collection = create_nft_collection::<T>(caller.clone())?;55 let collection = create_nft_collection::<T>(caller.clone())?;56 }: _(RawOrigin::Signed(caller.clone()), collection)56 }: _(RawOrigin::Signed(caller.clone()), collection)575758 add_to_white_list {58 add_to_allow_list {59 let caller: T::AccountId = account("caller", 0, SEED);59 let caller: T::AccountId = account("caller", 0, SEED);60 let whitelist_account: T::AccountId = account("admin", 0, SEED);60 let allowlist_account: T::AccountId = account("admin", 0, SEED);61 let collection = create_nft_collection::<T>(caller.clone())?;61 let collection = create_nft_collection::<T>(caller.clone())?;62 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(whitelist_account))62 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(allowlist_account))636364 remove_from_white_list {64 remove_from_allow_list {65 let caller: T::AccountId = account("caller", 0, SEED);65 let caller: T::AccountId = account("caller", 0, SEED);66 let whitelist_account: T::AccountId = account("admin", 0, SEED);66 let allowlist_account: T::AccountId = account("admin", 0, SEED);67 let collection = create_nft_collection::<T>(caller.clone())?;67 let collection = create_nft_collection::<T>(caller.clone())?;68 <Pallet<T>>::add_to_white_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(whitelist_account.clone()))?;68 <Pallet<T>>::add_to_allow_list(RawOrigin::Signed(caller.clone()).into(), collection, T::CrossAccountId::from_sub(allowlist_account.clone()))?;69 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(whitelist_account))69 }: _(RawOrigin::Signed(caller.clone()), collection, T::CrossAccountId::from_sub(allowlist_account))707071 set_public_access_mode {71 set_public_access_mode {72 let caller: T::AccountId = account("caller", 0, SEED);72 let caller: T::AccountId = account("caller", 0, SEED);73 let collection = create_nft_collection::<T>(caller.clone())?;73 let collection = create_nft_collection::<T>(caller.clone())?;74 }: _(RawOrigin::Signed(caller.clone()), collection, AccessMode::WhiteList)74 }: _(RawOrigin::Signed(caller.clone()), collection, AccessMode::AllowList)757576 set_mint_permission {76 set_mint_permission {77 let caller: T::AccountId = account("caller", 0, SEED);77 let caller: T::AccountId = account("caller", 0, SEED);pallets/nft/src/lib.rsdiffbeforeafterboth256 Ok(())256 Ok(())257 }257 }258258259 /// Add an address to white list.259 /// Add an address to allow list.260 ///260 ///261 /// # Permissions261 /// # Permissions262 ///262 ///268 /// * collection_id.268 /// * collection_id.269 ///269 ///270 /// * address.270 /// * address.271 #[weight = <SelfWeightOf<T>>::add_to_white_list()]271 #[weight = <SelfWeightOf<T>>::add_to_allow_list()]272 #[transactional]272 #[transactional]273 pub fn add_to_white_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{273 pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{274274275 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);275 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);276 let collection = <CollectionHandle<T>>::try_get(collection_id)?;276 let collection = <CollectionHandle<T>>::try_get(collection_id)?;285 Ok(())285 Ok(())286 }286 }287287288 /// Remove an address from white list.288 /// Remove an address from allow list.289 ///289 ///290 /// # Permissions290 /// # Permissions291 ///291 ///297 /// * collection_id.297 /// * collection_id.298 ///298 ///299 /// * address.299 /// * address.300 #[weight = <SelfWeightOf<T>>::remove_from_white_list()]300 #[weight = <SelfWeightOf<T>>::remove_from_allow_list()]301 #[transactional]301 #[transactional]302 pub fn remove_from_white_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{302 pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{303303304 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);304 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);305 let collection = <CollectionHandle<T>>::try_get(collection_id)?;305 let collection = <CollectionHandle<T>>::try_get(collection_id)?;314 Ok(())314 Ok(())315 }315 }316316317 /// Toggle between normal and white list access for the methods with access for `Anyone`.317 /// Toggle between normal and allow list access for the methods with access for `Anyone`.318 ///318 ///319 /// # Permissions319 /// # Permissions320 ///320 ///339 }339 }340340341 /// Allows Anyone to create tokens if:341 /// Allows Anyone to create tokens if:342 /// * White List is enabled, and342 /// * Allow List is enabled, and343 /// * Address is added to white list, and343 /// * Address is added to allow list, and344 /// * This method was called with True parameter344 /// * This method was called with True parameter345 ///345 ///346 /// # Permissions346 /// # Permissions502 /// * Collection Owner.502 /// * Collection Owner.503 /// * Collection Admin.503 /// * Collection Admin.504 /// * Anyone if504 /// * Anyone if505 /// * White List is enabled, and505 /// * Allow List is enabled, and506 /// * Address is added to white list, and506 /// * Address is added to allow list, and507 /// * MintPermission is enabled (see SetMintPermission method)507 /// * MintPermission is enabled (see SetMintPermission method)508 ///508 ///509 /// # Arguments509 /// # Arguments528 /// * Collection Owner.528 /// * Collection Owner.529 /// * Collection Admin.529 /// * Collection Admin.530 /// * Anyone if530 /// * Anyone if531 /// * White List is enabled, and531 /// * Allow List is enabled, and532 /// * Address is added to white list, and532 /// * Address is added to allow list, and533 /// * MintPermission is enabled (see SetMintPermission method)533 /// * MintPermission is enabled (see SetMintPermission method)534 ///534 ///535 /// # Arguments535 /// # Argumentspallets/nft/src/tests.rsdiffbeforeafterboth460}460}461461462#[test]462#[test]463fn nft_approve_and_transfer_from_white_list() {463fn nft_approve_and_transfer_from_allow_list() {464 new_test_ext().execute_with(|| {464 new_test_ext().execute_with(|| {465 let collection_id = create_test_collection(&CollectionMode::NFT, 1);465 let collection_id = create_test_collection(&CollectionMode::NFT, 1);466466485 assert_ok!(TemplateModule::set_public_access_mode(485 assert_ok!(TemplateModule::set_public_access_mode(486 origin1.clone(),486 origin1.clone(),487 1,487 1,488 AccessMode::WhiteList488 AccessMode::AllowList489 ));489 ));490 assert_ok!(TemplateModule::add_to_white_list(490 assert_ok!(TemplateModule::add_to_allow_list(491 origin1.clone(),491 origin1.clone(),492 1,492 1,493 account(1)493 account(1)494 ));494 ));495 assert_ok!(TemplateModule::add_to_white_list(495 assert_ok!(TemplateModule::add_to_allow_list(496 origin1.clone(),496 origin1.clone(),497 1,497 1,498 account(2)498 account(2)499 ));499 ));500 assert_ok!(TemplateModule::add_to_white_list(500 assert_ok!(TemplateModule::add_to_allow_list(501 origin1.clone(),501 origin1.clone(),502 1,502 1,503 account(3)503 account(3)549 assert_ok!(TemplateModule::set_public_access_mode(549 assert_ok!(TemplateModule::set_public_access_mode(550 origin1.clone(),550 origin1.clone(),551 1,551 1,552 AccessMode::WhiteList552 AccessMode::AllowList553 ));553 ));554 assert_ok!(TemplateModule::add_to_white_list(554 assert_ok!(TemplateModule::add_to_allow_list(555 origin1.clone(),555 origin1.clone(),556 1,556 1,557 account(1)557 account(1)558 ));558 ));559 assert_ok!(TemplateModule::add_to_white_list(559 assert_ok!(TemplateModule::add_to_allow_list(560 origin1.clone(),560 origin1.clone(),561 1,561 1,562 account(2)562 account(2)563 ));563 ));564 assert_ok!(TemplateModule::add_to_white_list(564 assert_ok!(TemplateModule::add_to_allow_list(565 origin1.clone(),565 origin1.clone(),566 1,566 1,567 account(3)567 account(3)609 assert_ok!(TemplateModule::set_public_access_mode(609 assert_ok!(TemplateModule::set_public_access_mode(610 origin1.clone(),610 origin1.clone(),611 1,611 1,612 AccessMode::WhiteList612 AccessMode::AllowList613 ));613 ));614 assert_ok!(TemplateModule::add_to_white_list(614 assert_ok!(TemplateModule::add_to_allow_list(615 origin1.clone(),615 origin1.clone(),616 1,616 1,617 account(1)617 account(1)618 ));618 ));619 assert_ok!(TemplateModule::add_to_white_list(619 assert_ok!(TemplateModule::add_to_allow_list(620 origin1.clone(),620 origin1.clone(),621 1,621 1,622 account(2)622 account(2)623 ));623 ));624 assert_ok!(TemplateModule::add_to_white_list(624 assert_ok!(TemplateModule::add_to_allow_list(625 origin1.clone(),625 origin1.clone(),626 1,626 1,627 account(3)627 account(3)765 assert_ok!(TemplateModule::set_public_access_mode(765 assert_ok!(TemplateModule::set_public_access_mode(766 origin1.clone(),766 origin1.clone(),767 collection_id,767 collection_id,768 AccessMode::WhiteList768 AccessMode::AllowList769 ));769 ));770 assert_ok!(TemplateModule::add_to_white_list(770 assert_ok!(TemplateModule::add_to_allow_list(771 origin1.clone(),771 origin1.clone(),772 1,772 1,773 account(1)773 account(1)952 assert_ok!(TemplateModule::set_public_access_mode(952 assert_ok!(TemplateModule::set_public_access_mode(953 origin1.clone(),953 origin1.clone(),954 1,954 1,955 AccessMode::WhiteList955 AccessMode::AllowList956 ));956 ));957 assert_ok!(TemplateModule::add_to_white_list(957 assert_ok!(TemplateModule::add_to_allow_list(958 origin1.clone(),958 origin1.clone(),959 1,959 1,960 account(1)960 account(1)961 ));961 ));962 assert_ok!(TemplateModule::add_to_white_list(962 assert_ok!(TemplateModule::add_to_allow_list(963 origin1.clone(),963 origin1.clone(),964 1,964 1,965 account(2)965 account(2)966 ));966 ));967 assert_ok!(TemplateModule::add_to_white_list(origin1, 1, account(3)));967 assert_ok!(TemplateModule::add_to_allow_list(origin1, 1, account(3)));968968969 assert_ok!(TemplateModule::transfer_from(969 assert_ok!(TemplateModule::transfer_from(970 origin2,970 origin2,987// #region987// #region988988989#[test]989#[test]990fn owner_can_add_address_to_white_list() {990fn owner_can_add_address_to_allow_list() {991 new_test_ext().execute_with(|| {991 new_test_ext().execute_with(|| {992 let collection_id = create_test_collection(&CollectionMode::NFT, 1);992 let collection_id = create_test_collection(&CollectionMode::NFT, 1);993993994 let origin1 = Origin::signed(1);994 let origin1 = Origin::signed(1);995 assert_ok!(TemplateModule::add_to_white_list(995 assert_ok!(TemplateModule::add_to_allow_list(996 origin1,996 origin1,997 collection_id,997 collection_id,998 account(2)998 account(2)999 ));999 ));1000 assert!(TemplateModule::white_list(collection_id, 2));1000 assert!(TemplateModule::allow_list(collection_id, 2));1001 });1001 });1002}1002}100310031004#[test]1004#[test]1005fn admin_can_add_address_to_white_list() {1005fn admin_can_add_address_to_allow_list() {1006 new_test_ext().execute_with(|| {1006 new_test_ext().execute_with(|| {1007 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1007 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1008 let origin1 = Origin::signed(1);1008 let origin1 = Origin::signed(1);1013 collection_id,1013 collection_id,1014 account(2)1014 account(2)1015 ));1015 ));1016 assert_ok!(TemplateModule::add_to_white_list(1016 assert_ok!(TemplateModule::add_to_allow_list(1017 origin2,1017 origin2,1018 collection_id,1018 collection_id,1019 account(3)1019 account(3)1020 ));1020 ));1021 assert!(TemplateModule::white_list(collection_id, 3));1021 assert!(TemplateModule::allow_list(collection_id, 3));1022 });1022 });1023}1023}102410241025#[test]1025#[test]1026fn nonprivileged_user_cannot_add_address_to_white_list() {1026fn nonprivileged_user_cannot_add_address_to_allow_list() {1027 new_test_ext().execute_with(|| {1027 new_test_ext().execute_with(|| {1028 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1028 let collection_id = create_test_collection(&CollectionMode::NFT, 1);102910291030 let origin2 = Origin::signed(2);1030 let origin2 = Origin::signed(2);1031 assert_noop!(1031 assert_noop!(1032 TemplateModule::add_to_white_list(origin2, collection_id, account(3)),1032 TemplateModule::add_to_allow_list(origin2, collection_id, account(3)),1033 Error::<Test>::NoPermission1033 Error::<Test>::NoPermission1034 );1034 );1035 });1035 });1036}1036}103710371038#[test]1038#[test]1039fn nobody_can_add_address_to_white_list_of_nonexisting_collection() {1039fn nobody_can_add_address_to_allow_list_of_nonexisting_collection() {1040 new_test_ext().execute_with(|| {1040 new_test_ext().execute_with(|| {1041 let origin1 = Origin::signed(1);1041 let origin1 = Origin::signed(1);104210421043 assert_noop!(1043 assert_noop!(1044 TemplateModule::add_to_white_list(origin1, 1, account(2)),1044 TemplateModule::add_to_allow_list(origin1, 1, account(2)),1045 Error::<Test>::CollectionNotFound1045 Error::<Test>::CollectionNotFound1046 );1046 );1047 });1047 });1048}1048}104910491050#[test]1050#[test]1051fn nobody_can_add_address_to_white_list_of_deleted_collection() {1051fn nobody_can_add_address_to_allow_list_of_deleted_collection() {1052 new_test_ext().execute_with(|| {1052 new_test_ext().execute_with(|| {1053 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1053 let collection_id = create_test_collection(&CollectionMode::NFT, 1);105410541058 collection_id1058 collection_id1059 ));1059 ));1060 assert_noop!(1060 assert_noop!(1061 TemplateModule::add_to_white_list(origin1, collection_id, account(2)),1061 TemplateModule::add_to_allow_list(origin1, collection_id, account(2)),1062 Error::<Test>::CollectionNotFound1062 Error::<Test>::CollectionNotFound1063 );1063 );1064 });1064 });1065}1065}106610661067// If address is already added to white list, nothing happens1067// If address is already added to allow list, nothing happens1068#[test]1068#[test]1069fn address_is_already_added_to_white_list() {1069fn address_is_already_added_to_allow_list() {1070 new_test_ext().execute_with(|| {1070 new_test_ext().execute_with(|| {1071 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1071 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1072 let origin1 = Origin::signed(1);1072 let origin1 = Origin::signed(1);107310731074 assert_ok!(TemplateModule::add_to_white_list(1074 assert_ok!(TemplateModule::add_to_allow_list(1075 origin1.clone(),1075 origin1.clone(),1076 collection_id,1076 collection_id,1077 account(2)1077 account(2)1078 ));1078 ));1079 assert_ok!(TemplateModule::add_to_white_list(1079 assert_ok!(TemplateModule::add_to_allow_list(1080 origin1,1080 origin1,1081 collection_id,1081 collection_id,1082 account(2)1082 account(2)1083 ));1083 ));1084 assert!(TemplateModule::white_list(collection_id, 2));1084 assert!(TemplateModule::allow_list(collection_id, 2));1085 });1085 });1086}1086}108710871088#[test]1088#[test]1089fn owner_can_remove_address_from_white_list() {1089fn owner_can_remove_address_from_allow_list() {1090 new_test_ext().execute_with(|| {1090 new_test_ext().execute_with(|| {1091 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1091 let collection_id = create_test_collection(&CollectionMode::NFT, 1);109210921093 let origin1 = Origin::signed(1);1093 let origin1 = Origin::signed(1);1094 assert_ok!(TemplateModule::add_to_white_list(1094 assert_ok!(TemplateModule::add_to_allow_list(1095 origin1.clone(),1095 origin1.clone(),1096 collection_id,1096 collection_id,1097 account(2)1097 account(2)1098 ));1098 ));1099 assert_ok!(TemplateModule::remove_from_white_list(1099 assert_ok!(TemplateModule::remove_from_allow_list(1100 origin1,1100 origin1,1101 collection_id,1101 collection_id,1102 account(2)1102 account(2)1103 ));1103 ));1104 assert!(!TemplateModule::white_list(collection_id, 2));1104 assert!(!TemplateModule::allow_list(collection_id, 2));1105 });1105 });1106}1106}110711071108#[test]1108#[test]1109fn admin_can_remove_address_from_white_list() {1109fn admin_can_remove_address_from_allow_list() {1110 new_test_ext().execute_with(|| {1110 new_test_ext().execute_with(|| {1111 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1111 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1112 let origin1 = Origin::signed(1);1112 let origin1 = Origin::signed(1);1118 account(2)1118 account(2)1119 ));1119 ));112011201121 assert_ok!(TemplateModule::add_to_white_list(1121 assert_ok!(TemplateModule::add_to_allow_list(1122 origin1,1122 origin1,1123 collection_id,1123 collection_id,1124 account(3)1124 account(3)1125 ));1125 ));1126 assert_ok!(TemplateModule::remove_from_white_list(1126 assert_ok!(TemplateModule::remove_from_allow_list(1127 origin2,1127 origin2,1128 collection_id,1128 collection_id,1129 account(3)1129 account(3)1130 ));1130 ));1131 assert!(!TemplateModule::white_list(collection_id, 3));1131 assert!(!TemplateModule::allow_list(collection_id, 3));1132 });1132 });1133}1133}113411341135#[test]1135#[test]1136fn nonprivileged_user_cannot_remove_address_from_white_list() {1136fn nonprivileged_user_cannot_remove_address_from_allow_list() {1137 new_test_ext().execute_with(|| {1137 new_test_ext().execute_with(|| {1138 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1138 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1139 let origin1 = Origin::signed(1);1139 let origin1 = Origin::signed(1);1140 let origin2 = Origin::signed(2);1140 let origin2 = Origin::signed(2);114111411142 assert_ok!(TemplateModule::add_to_white_list(1142 assert_ok!(TemplateModule::add_to_allow_list(1143 origin1,1143 origin1,1144 collection_id,1144 collection_id,1145 account(2)1145 account(2)1146 ));1146 ));1147 assert_noop!(1147 assert_noop!(1148 TemplateModule::remove_from_white_list(origin2, collection_id, account(2)),1148 TemplateModule::remove_from_allow_list(origin2, collection_id, account(2)),1149 Error::<Test>::NoPermission1149 Error::<Test>::NoPermission1150 );1150 );1151 assert!(TemplateModule::white_list(collection_id, 2));1151 assert!(TemplateModule::allow_list(collection_id, 2));1152 });1152 });1153}1153}115411541155#[test]1155#[test]1156fn nobody_can_remove_address_from_white_list_of_nonexisting_collection() {1156fn nobody_can_remove_address_from_allow_list_of_nonexisting_collection() {1157 new_test_ext().execute_with(|| {1157 new_test_ext().execute_with(|| {1158 let origin1 = Origin::signed(1);1158 let origin1 = Origin::signed(1);115911591160 assert_noop!(1160 assert_noop!(1161 TemplateModule::remove_from_white_list(origin1, 1, account(2)),1161 TemplateModule::remove_from_allow_list(origin1, 1, account(2)),1162 Error::<Test>::CollectionNotFound1162 Error::<Test>::CollectionNotFound1163 );1163 );1164 });1164 });1165}1165}116611661167#[test]1167#[test]1168fn nobody_can_remove_address_from_white_list_of_deleted_collection() {1168fn nobody_can_remove_address_from_allow_list_of_deleted_collection() {1169 new_test_ext().execute_with(|| {1169 new_test_ext().execute_with(|| {1170 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1170 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1171 let origin1 = Origin::signed(1);1171 let origin1 = Origin::signed(1);1172 let origin2 = Origin::signed(2);1172 let origin2 = Origin::signed(2);117311731174 assert_ok!(TemplateModule::add_to_white_list(1174 assert_ok!(TemplateModule::add_to_allow_list(1175 origin1.clone(),1175 origin1.clone(),1176 collection_id,1176 collection_id,1177 account(2)1177 account(2)1178 ));1178 ));1179 assert_ok!(TemplateModule::destroy_collection(origin1, collection_id));1179 assert_ok!(TemplateModule::destroy_collection(origin1, collection_id));1180 assert_noop!(1180 assert_noop!(1181 TemplateModule::remove_from_white_list(origin2, collection_id, account(2)),1181 TemplateModule::remove_from_allow_list(origin2, collection_id, account(2)),1182 Error::<Test>::CollectionNotFound1182 Error::<Test>::CollectionNotFound1183 );1183 );1184 assert!(!TemplateModule::white_list(collection_id, 2));1184 assert!(!TemplateModule::allow_list(collection_id, 2));1185 });1185 });1186}1186}118711871188// If address is already removed from white list, nothing happens1188// If address is already removed from allow list, nothing happens1189#[test]1189#[test]1190fn address_is_already_removed_from_white_list() {1190fn address_is_already_removed_from_allow_list() {1191 new_test_ext().execute_with(|| {1191 new_test_ext().execute_with(|| {1192 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1192 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1193 let origin1 = Origin::signed(1);1193 let origin1 = Origin::signed(1);119411941195 assert_ok!(TemplateModule::add_to_white_list(1195 assert_ok!(TemplateModule::add_to_allow_list(1196 origin1.clone(),1196 origin1.clone(),1197 collection_id,1197 collection_id,1198 account(2)1198 account(2)1199 ));1199 ));1200 assert_ok!(TemplateModule::remove_from_white_list(1200 assert_ok!(TemplateModule::remove_from_allow_list(1201 origin1.clone(),1201 origin1.clone(),1202 collection_id,1202 collection_id,1203 account(2)1203 account(2)1204 ));1204 ));1205 assert_ok!(TemplateModule::remove_from_white_list(1205 assert_ok!(TemplateModule::remove_from_allow_list(1206 origin1,1206 origin1,1207 collection_id,1207 collection_id,1208 account(2)1208 account(2)1209 ));1209 ));1210 assert!(!TemplateModule::white_list(collection_id, 2));1210 assert!(!TemplateModule::allow_list(collection_id, 2));1211 });1211 });1212}1212}121312131214// If Public Access mode is set to WhiteList, tokens can’t be transferred from a non-whitelisted address with transfer or transferFrom (2 tests)1214// If Public Access mode is set to AllowList, tokens can’t be transferred from a non-allowlisted address with transfer or transferFrom (2 tests)1215#[test]1215#[test]1216fn white_list_test_1() {1216fn allow_list_test_1() {1217 new_test_ext().execute_with(|| {1217 new_test_ext().execute_with(|| {1218 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1218 let collection_id = create_test_collection(&CollectionMode::NFT, 1);121912191225 assert_ok!(TemplateModule::set_public_access_mode(1225 assert_ok!(TemplateModule::set_public_access_mode(1226 origin1.clone(),1226 origin1.clone(),1227 collection_id,1227 collection_id,1228 AccessMode::WhiteList1228 AccessMode::AllowList1229 ));1229 ));1230 assert_ok!(TemplateModule::add_to_white_list(1230 assert_ok!(TemplateModule::add_to_allow_list(1231 origin1.clone(),1231 origin1.clone(),1232 collection_id,1232 collection_id,1233 account(2)1233 account(2)1234 ));1234 ));123512351236 assert_noop!(1236 assert_noop!(1237 TemplateModule::transfer(origin1, account(3), 1, 1, 1),1237 TemplateModule::transfer(origin1, account(3), 1, 1, 1),1238 Error::<Test>::AddresNotInWhiteList1238 Error::<Test>::AddresNotInAllowList1239 );1239 );1240 });1240 });1241}1241}124212421243#[test]1243#[test]1244fn white_list_test_2() {1244fn allow_list_test_2() {1245 new_test_ext().execute_with(|| {1245 new_test_ext().execute_with(|| {1246 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1246 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1247 let origin1 = Origin::signed(1);1247 let origin1 = Origin::signed(1);1252 assert_ok!(TemplateModule::set_public_access_mode(1252 assert_ok!(TemplateModule::set_public_access_mode(1253 origin1.clone(),1253 origin1.clone(),1254 collection_id,1254 collection_id,1255 AccessMode::WhiteList1255 AccessMode::AllowList1256 ));1256 ));1257 assert_ok!(TemplateModule::add_to_white_list(1257 assert_ok!(TemplateModule::add_to_allow_list(1258 origin1.clone(),1258 origin1.clone(),1259 1,1259 1,1260 account(1)1260 account(1)1261 ));1261 ));1262 assert_ok!(TemplateModule::add_to_white_list(1262 assert_ok!(TemplateModule::add_to_allow_list(1263 origin1.clone(),1263 origin1.clone(),1264 1,1264 1,1265 account(2)1265 account(2)1275 ));1275 ));1276 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);1276 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);127712771278 assert_ok!(TemplateModule::remove_from_white_list(1278 assert_ok!(TemplateModule::remove_from_allow_list(1279 origin1.clone(),1279 origin1.clone(),1280 1,1280 1,1281 account(1)1281 account(1)1282 ));1282 ));128312831284 assert_noop!(1284 assert_noop!(1285 TemplateModule::transfer_from(origin1, account(1), account(3), 1, 1, 1),1285 TemplateModule::transfer_from(origin1, account(1), account(3), 1, 1, 1),1286 Error::<Test>::AddresNotInWhiteList1286 Error::<Test>::AddresNotInAllowList1287 );1287 );1288 });1288 });1289}1289}129012901291// If Public Access mode is set to WhiteList, tokens can’t be transferred to a non-whitelisted address with transfer or transferFrom (2 tests)1291// If Public Access mode is set to AllowList, tokens can’t be transferred to a non-allowlisted address with transfer or transferFrom (2 tests)1292#[test]1292#[test]1293fn white_list_test_3() {1293fn allow_list_test_3() {1294 new_test_ext().execute_with(|| {1294 new_test_ext().execute_with(|| {1295 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1295 let collection_id = create_test_collection(&CollectionMode::NFT, 1);129612961302 assert_ok!(TemplateModule::set_public_access_mode(1302 assert_ok!(TemplateModule::set_public_access_mode(1303 origin1.clone(),1303 origin1.clone(),1304 collection_id,1304 collection_id,1305 AccessMode::WhiteList1305 AccessMode::AllowList1306 ));1306 ));1307 assert_ok!(TemplateModule::add_to_white_list(1307 assert_ok!(TemplateModule::add_to_allow_list(1308 origin1.clone(),1308 origin1.clone(),1309 1,1309 1,1310 account(1)1310 account(1)1311 ));1311 ));131213121313 assert_noop!(1313 assert_noop!(1314 TemplateModule::transfer(origin1, account(3), 1, 1, 1),1314 TemplateModule::transfer(origin1, account(3), 1, 1, 1),1315 Error::<Test>::AddresNotInWhiteList1315 Error::<Test>::AddresNotInAllowList1316 );1316 );1317 });1317 });1318}1318}131913191320#[test]1320#[test]1321fn white_list_test_4() {1321fn allow_list_test_4() {1322 new_test_ext().execute_with(|| {1322 new_test_ext().execute_with(|| {1323 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1323 let collection_id = create_test_collection(&CollectionMode::NFT, 1);132413241330 assert_ok!(TemplateModule::set_public_access_mode(1330 assert_ok!(TemplateModule::set_public_access_mode(1331 origin1.clone(),1331 origin1.clone(),1332 collection_id,1332 collection_id,1333 AccessMode::WhiteList1333 AccessMode::AllowList1334 ));1334 ));1335 assert_ok!(TemplateModule::add_to_white_list(1335 assert_ok!(TemplateModule::add_to_allow_list(1336 origin1.clone(),1336 origin1.clone(),1337 collection_id,1337 collection_id,1338 account(1)1338 account(1)1339 ));1339 ));1340 assert_ok!(TemplateModule::add_to_white_list(1340 assert_ok!(TemplateModule::add_to_allow_list(1341 origin1.clone(),1341 origin1.clone(),1342 collection_id,1342 collection_id,1343 account(2)1343 account(2)1353 ));1353 ));1354 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);1354 assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);135513551356 assert_ok!(TemplateModule::remove_from_white_list(1356 assert_ok!(TemplateModule::remove_from_allow_list(1357 origin1.clone(),1357 origin1.clone(),1358 collection_id,1358 collection_id,1359 account(2)1359 account(2)1360 ));1360 ));136113611362 assert_noop!(1362 assert_noop!(1363 TemplateModule::transfer_from(origin1, account(1), account(3), 1, 1, 1),1363 TemplateModule::transfer_from(origin1, account(1), account(3), 1, 1, 1),1364 Error::<Test>::AddresNotInWhiteList1364 Error::<Test>::AddresNotInAllowList1365 );1365 );1366 });1366 });1367}1367}136813681369// If Public Access mode is set to WhiteList, tokens can’t be destroyed by a non-whitelisted address (even if it owned them before enabling WhiteList mode)1369// If Public Access mode is set to AllowList, tokens can’t be destroyed by a non-allowlisted address (even if it owned them before enabling AllowList mode)1370#[test]1370#[test]1371fn white_list_test_5() {1371fn allow_list_test_5() {1372 new_test_ext().execute_with(|| {1372 new_test_ext().execute_with(|| {1373 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1373 let collection_id = create_test_collection(&CollectionMode::NFT, 1);137413741380 assert_ok!(TemplateModule::set_public_access_mode(1380 assert_ok!(TemplateModule::set_public_access_mode(1381 origin1.clone(),1381 origin1.clone(),1382 collection_id,1382 collection_id,1383 AccessMode::WhiteList1383 AccessMode::AllowList1384 ));1384 ));1385 assert_noop!(1385 assert_noop!(1386 TemplateModule::burn_item(origin1.clone(), 1, 1, 5),1386 TemplateModule::burn_item(origin1.clone(), 1, 1, 5),1387 Error::<Test>::AddresNotInWhiteList1387 Error::<Test>::AddresNotInAllowList1388 );1388 );1389 });1389 });1390}1390}139113911392// If Public Access mode is set to WhiteList, token transfers can’t be Approved by a non-whitelisted address (see Approve method).1392// If Public Access mode is set to AllowList, token transfers can’t be Approved by a non-allowlisted address (see Approve method).1393#[test]1393#[test]1394fn white_list_test_6() {1394fn allow_list_test_6() {1395 new_test_ext().execute_with(|| {1395 new_test_ext().execute_with(|| {1396 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1396 let collection_id = create_test_collection(&CollectionMode::NFT, 1);139713971403 assert_ok!(TemplateModule::set_public_access_mode(1403 assert_ok!(TemplateModule::set_public_access_mode(1404 origin1.clone(),1404 origin1.clone(),1405 collection_id,1405 collection_id,1406 AccessMode::WhiteList1406 AccessMode::AllowList1407 ));1407 ));140814081409 // do approve1409 // do approve1410 assert_noop!(1410 assert_noop!(1411 TemplateModule::approve(origin1, account(1), 1, 1, 5),1411 TemplateModule::approve(origin1, account(1), 1, 1, 5),1412 Error::<Test>::AddresNotInWhiteList1412 Error::<Test>::AddresNotInAllowList1413 );1413 );1414 });1414 });1415}1415}141614161417// If Public Access mode is set to WhiteList, tokens can be transferred from a whitelisted address with transfer or transferFrom (2 tests) and1417// If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transfer or transferFrom (2 tests) and1418// tokens can be transferred from a whitelisted address with transfer or transferFrom (2 tests)1418// tokens can be transferred from a allowlisted address with transfer or transferFrom (2 tests)1419#[test]1419#[test]1420fn white_list_test_7() {1420fn allow_list_test_7() {1421 new_test_ext().execute_with(|| {1421 new_test_ext().execute_with(|| {1422 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1422 let collection_id = create_test_collection(&CollectionMode::NFT, 1);142314231429 assert_ok!(TemplateModule::set_public_access_mode(1429 assert_ok!(TemplateModule::set_public_access_mode(1430 origin1.clone(),1430 origin1.clone(),1431 collection_id,1431 collection_id,1432 AccessMode::WhiteList1432 AccessMode::AllowList1433 ));1433 ));1434 assert_ok!(TemplateModule::add_to_white_list(1434 assert_ok!(TemplateModule::add_to_allow_list(1435 origin1.clone(),1435 origin1.clone(),1436 collection_id,1436 collection_id,1437 account(1)1437 account(1)1438 ));1438 ));1439 assert_ok!(TemplateModule::add_to_white_list(1439 assert_ok!(TemplateModule::add_to_allow_list(1440 origin1.clone(),1440 origin1.clone(),1441 collection_id,1441 collection_id,1442 account(2)1442 account(2)1447}1447}144814481449#[test]1449#[test]1450fn white_list_test_8() {1450fn allow_list_test_8() {1451 new_test_ext().execute_with(|| {1451 new_test_ext().execute_with(|| {1452 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1452 let collection_id = create_test_collection(&CollectionMode::NFT, 1);145314531459 assert_ok!(TemplateModule::set_public_access_mode(1459 assert_ok!(TemplateModule::set_public_access_mode(1460 origin1.clone(),1460 origin1.clone(),1461 collection_id,1461 collection_id,1462 AccessMode::WhiteList1462 AccessMode::AllowList1463 ));1463 ));1464 assert_ok!(TemplateModule::add_to_white_list(1464 assert_ok!(TemplateModule::add_to_allow_list(1465 origin1.clone(),1465 origin1.clone(),1466 collection_id,1466 collection_id,1467 account(1)1467 account(1)1468 ));1468 ));1469 assert_ok!(TemplateModule::add_to_white_list(1469 assert_ok!(TemplateModule::add_to_allow_list(1470 origin1.clone(),1470 origin1.clone(),1471 collection_id,1471 collection_id,1472 account(2)1472 account(2)1493 });1493 });1494}1494}149514951496// If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by owner.1496// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by owner.1497#[test]1497#[test]1498fn white_list_test_9() {1498fn allow_list_test_9() {1499 new_test_ext().execute_with(|| {1499 new_test_ext().execute_with(|| {1500 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1500 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1501 let origin1 = Origin::signed(1);1501 let origin1 = Origin::signed(1);150215021503 assert_ok!(TemplateModule::set_public_access_mode(1503 assert_ok!(TemplateModule::set_public_access_mode(1504 origin1.clone(),1504 origin1.clone(),1505 collection_id,1505 collection_id,1506 AccessMode::WhiteList1506 AccessMode::AllowList1507 ));1507 ));1508 assert_ok!(TemplateModule::set_mint_permission(1508 assert_ok!(TemplateModule::set_mint_permission(1509 origin1,1509 origin1,1516 });1516 });1517}1517}151815181519// If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by admin.1519// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by admin.1520#[test]1520#[test]1521fn white_list_test_10() {1521fn allow_list_test_10() {1522 new_test_ext().execute_with(|| {1522 new_test_ext().execute_with(|| {1523 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1523 let collection_id = create_test_collection(&CollectionMode::NFT, 1);152415241528 assert_ok!(TemplateModule::set_public_access_mode(1528 assert_ok!(TemplateModule::set_public_access_mode(1529 origin1.clone(),1529 origin1.clone(),1530 collection_id,1530 collection_id,1531 AccessMode::WhiteList1531 AccessMode::AllowList1532 ));1532 ));1533 assert_ok!(TemplateModule::set_mint_permission(1533 assert_ok!(TemplateModule::set_mint_permission(1534 origin1.clone(),1534 origin1.clone(),1551 });1551 });1552}1552}155315531554// If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and white listed address.1554// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and allow listed address.1555#[test]1555#[test]1556fn white_list_test_11() {1556fn allow_list_test_11() {1557 new_test_ext().execute_with(|| {1557 new_test_ext().execute_with(|| {1558 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1558 let collection_id = create_test_collection(&CollectionMode::NFT, 1);155915591563 assert_ok!(TemplateModule::set_public_access_mode(1563 assert_ok!(TemplateModule::set_public_access_mode(1564 origin1.clone(),1564 origin1.clone(),1565 collection_id,1565 collection_id,1566 AccessMode::WhiteList1566 AccessMode::AllowList1567 ));1567 ));1568 assert_ok!(TemplateModule::set_mint_permission(1568 assert_ok!(TemplateModule::set_mint_permission(1569 origin1.clone(),1569 origin1.clone(),1570 collection_id,1570 collection_id,1571 false1571 false1572 ));1572 ));1573 assert_ok!(TemplateModule::add_to_white_list(1573 assert_ok!(TemplateModule::add_to_allow_list(1574 origin1,1574 origin1,1575 collection_id,1575 collection_id,1576 account(2)1576 account(2)1583 });1583 });1584}1584}158515851586// If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-white listed address.1586// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-allow listed address.1587#[test]1587#[test]1588fn white_list_test_12() {1588fn allow_list_test_12() {1589 new_test_ext().execute_with(|| {1589 new_test_ext().execute_with(|| {1590 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1590 let collection_id = create_test_collection(&CollectionMode::NFT, 1);159115911595 assert_ok!(TemplateModule::set_public_access_mode(1595 assert_ok!(TemplateModule::set_public_access_mode(1596 origin1.clone(),1596 origin1.clone(),1597 collection_id,1597 collection_id,1598 AccessMode::WhiteList1598 AccessMode::AllowList1599 ));1599 ));1600 assert_ok!(TemplateModule::set_mint_permission(1600 assert_ok!(TemplateModule::set_mint_permission(1601 origin1,1601 origin1,1610 });1610 });1611}1611}161216121613// If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by owner.1613// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by owner.1614#[test]1614#[test]1615fn white_list_test_13() {1615fn allow_list_test_13() {1616 new_test_ext().execute_with(|| {1616 new_test_ext().execute_with(|| {1617 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1617 let collection_id = create_test_collection(&CollectionMode::NFT, 1);161816181621 assert_ok!(TemplateModule::set_public_access_mode(1621 assert_ok!(TemplateModule::set_public_access_mode(1622 origin1.clone(),1622 origin1.clone(),1623 collection_id,1623 collection_id,1624 AccessMode::WhiteList1624 AccessMode::AllowList1625 ));1625 ));1626 assert_ok!(TemplateModule::set_mint_permission(1626 assert_ok!(TemplateModule::set_mint_permission(1627 origin1,1627 origin1,1634 });1634 });1635}1635}163616361637// If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by admin.1637// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by admin.1638#[test]1638#[test]1639fn white_list_test_14() {1639fn allow_list_test_14() {1640 new_test_ext().execute_with(|| {1640 new_test_ext().execute_with(|| {1641 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1641 let collection_id = create_test_collection(&CollectionMode::NFT, 1);164216421646 assert_ok!(TemplateModule::set_public_access_mode(1646 assert_ok!(TemplateModule::set_public_access_mode(1647 origin1.clone(),1647 origin1.clone(),1648 collection_id,1648 collection_id,1649 AccessMode::WhiteList1649 AccessMode::AllowList1650 ));1650 ));1651 assert_ok!(TemplateModule::set_mint_permission(1651 assert_ok!(TemplateModule::set_mint_permission(1652 origin1.clone(),1652 origin1.clone(),1669 });1669 });1670}1670}167116711672// If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-white listed address.1672// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-allow listed address.1673#[test]1673#[test]1674fn white_list_test_15() {1674fn allow_list_test_15() {1675 new_test_ext().execute_with(|| {1675 new_test_ext().execute_with(|| {1676 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1676 let collection_id = create_test_collection(&CollectionMode::NFT, 1);167716771681 assert_ok!(TemplateModule::set_public_access_mode(1681 assert_ok!(TemplateModule::set_public_access_mode(1682 origin1.clone(),1682 origin1.clone(),1683 collection_id,1683 collection_id,1684 AccessMode::WhiteList1684 AccessMode::AllowList1685 ));1685 ));1686 assert_ok!(TemplateModule::set_mint_permission(1686 assert_ok!(TemplateModule::set_mint_permission(1687 origin1,1687 origin1,169116911692 assert_noop!(1692 assert_noop!(1693 TemplateModule::create_item(origin2, 1, account(2), default_nft_data().into()),1693 TemplateModule::create_item(origin2, 1, account(2), default_nft_data().into()),1694 Error::<Test>::AddresNotInWhiteList1694 Error::<Test>::AddresNotInAllowList1695 );1695 );1696 });1696 });1697}1697}169816981699// If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by non-privileged and white listed address.1699// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by non-privileged and allow listed address.1700#[test]1700#[test]1701fn white_list_test_16() {1701fn allow_list_test_16() {1702 new_test_ext().execute_with(|| {1702 new_test_ext().execute_with(|| {1703 let collection_id = create_test_collection(&CollectionMode::NFT, 1);1703 let collection_id = create_test_collection(&CollectionMode::NFT, 1);170417041708 assert_ok!(TemplateModule::set_public_access_mode(1708 assert_ok!(TemplateModule::set_public_access_mode(1709 origin1.clone(),1709 origin1.clone(),1710 collection_id,1710 collection_id,1711 AccessMode::WhiteList1711 AccessMode::AllowList1712 ));1712 ));1713 assert_ok!(TemplateModule::set_mint_permission(1713 assert_ok!(TemplateModule::set_mint_permission(1714 origin1.clone(),1714 origin1.clone(),1715 collection_id,1715 collection_id,1716 true1716 true1717 ));1717 ));1718 assert_ok!(TemplateModule::add_to_white_list(1718 assert_ok!(TemplateModule::add_to_allow_list(1719 origin1,1719 origin1,1720 collection_id,1720 collection_id,1721 account(2)1721 account(2)2056 collection_id,2056 collection_id,2057 true2057 true2058 ));2058 ));2059 assert_ok!(TemplateModule::add_to_white_list(2059 assert_ok!(TemplateModule::add_to_allow_list(2060 origin1.clone(),2060 origin1.clone(),2061 collection_id,2061 collection_id,2062 account(1)2062 account(1)2124 collection_id,2124 collection_id,2125 true2125 true2126 ));2126 ));2127 assert_ok!(TemplateModule::add_to_white_list(2127 assert_ok!(TemplateModule::add_to_allow_list(2128 origin2.clone(),2128 origin2.clone(),2129 collection_id,2129 collection_id,2130 account(1)2130 account(1)2177 collection_id,2177 collection_id,2178 true2178 true2179 ));2179 ));2180 assert_ok!(TemplateModule::add_to_white_list(2180 assert_ok!(TemplateModule::add_to_allow_list(2181 origin2.clone(),2181 origin2.clone(),2182 collection_id,2182 collection_id,2183 account(1)2183 account(1)pallets/nft/src/weights.rsdiffbeforeafterboth33pub trait WeightInfo {33pub trait WeightInfo {34 fn create_collection() -> Weight;34 fn create_collection() -> Weight;35 fn destroy_collection() -> Weight;35 fn destroy_collection() -> Weight;36 fn add_to_white_list() -> Weight;36 fn add_to_allow_list() -> Weight;37 fn remove_from_white_list() -> Weight;37 fn remove_from_allow_list() -> Weight;38 fn set_public_access_mode() -> Weight;38 fn set_public_access_mode() -> Weight;39 fn set_mint_permission() -> Weight;39 fn set_mint_permission() -> Weight;40 fn change_collection_owner() -> Weight;40 fn change_collection_owner() -> Weight;75 }75 }76 // Storage: Common CollectionById (r:1 w:0)76 // Storage: Common CollectionById (r:1 w:0)77 // Storage: Common Allowlist (r:0 w:1)77 // Storage: Common Allowlist (r:0 w:1)78 fn add_to_white_list() -> Weight {78 fn add_to_allow_list() -> Weight {79 (6_629_000 as Weight)79 (6_629_000 as Weight)80 .saturating_add(T::DbWeight::get().reads(1 as Weight))80 .saturating_add(T::DbWeight::get().reads(1 as Weight))81 .saturating_add(T::DbWeight::get().writes(1 as Weight))81 .saturating_add(T::DbWeight::get().writes(1 as Weight))82 }82 }83 // Storage: Common CollectionById (r:1 w:0)83 // Storage: Common CollectionById (r:1 w:0)84 // Storage: Common Allowlist (r:0 w:1)84 // Storage: Common Allowlist (r:0 w:1)85 fn remove_from_white_list() -> Weight {85 fn remove_from_allow_list() -> Weight {86 (6_596_000 as Weight)86 (6_596_000 as Weight)87 .saturating_add(T::DbWeight::get().reads(1 as Weight))87 .saturating_add(T::DbWeight::get().reads(1 as Weight))88 .saturating_add(T::DbWeight::get().writes(1 as Weight))88 .saturating_add(T::DbWeight::get().writes(1 as Weight))205 }205 }206 // Storage: Common CollectionById (r:1 w:0)206 // Storage: Common CollectionById (r:1 w:0)207 // Storage: Common Allowlist (r:0 w:1)207 // Storage: Common Allowlist (r:0 w:1)208 fn add_to_white_list() -> Weight {208 fn add_to_allow_list() -> Weight {209 (6_629_000 as Weight)209 (6_629_000 as Weight)210 .saturating_add(RocksDbWeight::get().reads(1 as Weight))210 .saturating_add(RocksDbWeight::get().reads(1 as Weight))211 .saturating_add(RocksDbWeight::get().writes(1 as Weight))211 .saturating_add(RocksDbWeight::get().writes(1 as Weight))212 }212 }213 // Storage: Common CollectionById (r:1 w:0)213 // Storage: Common CollectionById (r:1 w:0)214 // Storage: Common Allowlist (r:0 w:1)214 // Storage: Common Allowlist (r:0 w:1)215 fn remove_from_white_list() -> Weight {215 fn remove_from_allow_list() -> Weight {216 (6_596_000 as Weight)216 (6_596_000 as Weight)217 .saturating_add(RocksDbWeight::get().reads(1 as Weight))217 .saturating_add(RocksDbWeight::get().reads(1 as Weight))218 .saturating_add(RocksDbWeight::get().writes(1 as Weight))218 .saturating_add(RocksDbWeight::get().writes(1 as Weight))pallets/nonfungible/src/lib.rsdiffbeforeafterboth169 <CommonError<T>>::NoPermission169 <CommonError<T>>::NoPermission170 );170 );171171172 if collection.access == AccessMode::WhiteList {172 if collection.access == AccessMode::AllowList {173 collection.check_allowlist(sender)?;173 collection.check_allowlist(sender)?;174 }174 }175175228 <CommonError<T>>::NoPermission228 <CommonError<T>>::NoPermission229 );229 );230230231 if collection.access == AccessMode::WhiteList {231 if collection.access == AccessMode::AllowList {232 collection.check_allowlist(from)?;232 collection.check_allowlist(from)?;233 collection.check_allowlist(to)?;233 collection.check_allowlist(to)?;234 }234 }449 token: TokenId,449 token: TokenId,450 spender: Option<&T::CrossAccountId>,450 spender: Option<&T::CrossAccountId>,451 ) -> DispatchResult {451 ) -> DispatchResult {452 if collection.access == AccessMode::WhiteList {452 if collection.access == AccessMode::AllowList {453 collection.check_allowlist(&sender)?;453 collection.check_allowlist(&sender)?;454 if let Some(spender) = spender {454 if let Some(spender) = spender {455 collection.check_allowlist(&spender)?;455 collection.check_allowlist(&spender)?;484 if spender.conv_eq(from) {484 if spender.conv_eq(from) {485 return Self::transfer(collection, from, to, token);485 return Self::transfer(collection, from, to, token);486 }486 }487 if collection.access == AccessMode::WhiteList {487 if collection.access == AccessMode::AllowList {488 // `from`, `to` checked in [`transfer`]488 // `from`, `to` checked in [`transfer`]489 collection.check_allowlist(spender)?;489 collection.check_allowlist(spender)?;490 }490 }512 if spender.conv_eq(from) {512 if spender.conv_eq(from) {513 return Self::burn(collection, from, token);513 return Self::burn(collection, from, token);514 }514 }515 if collection.access == AccessMode::WhiteList {515 if collection.access == AccessMode::AllowList {516 // `from` checked in [`burn`]516 // `from` checked in [`burn`]517 collection.check_allowlist(spender)?;517 collection.check_allowlist(spender)?;518 }518 }pallets/refungible/src/lib.rsdiffbeforeafterboth272 <CommonError<T>>::TransferNotAllowed272 <CommonError<T>>::TransferNotAllowed273 );273 );274274275 if collection.access == AccessMode::WhiteList {275 if collection.access == AccessMode::AllowList {276 collection.check_allowlist(from)?;276 collection.check_allowlist(from)?;277 collection.check_allowlist(to)?;277 collection.check_allowlist(to)?;278 }278 }483 token: TokenId,483 token: TokenId,484 amount: u128,484 amount: u128,485 ) -> DispatchResult {485 ) -> DispatchResult {486 if collection.access == AccessMode::WhiteList {486 if collection.access == AccessMode::AllowList {487 collection.check_allowlist(&sender)?;487 collection.check_allowlist(&sender)?;488 collection.check_allowlist(&spender)?;488 collection.check_allowlist(&spender)?;489 }489 }514 if spender.conv_eq(from) {514 if spender.conv_eq(from) {515 return Self::transfer(collection, from, to, token, amount);515 return Self::transfer(collection, from, to, token, amount);516 }516 }517 if collection.access == AccessMode::WhiteList {517 if collection.access == AccessMode::AllowList {518 // `from`, `to` checked in [`transfer`]518 // `from`, `to` checked in [`transfer`]519 collection.check_allowlist(spender)?;519 collection.check_allowlist(spender)?;520 }520 }547 if spender.conv_eq(from) {547 if spender.conv_eq(from) {548 return Self::burn(collection, from, token, amount);548 return Self::burn(collection, from, token, amount);549 }549 }550 if collection.access == AccessMode::WhiteList {550 if collection.access == AccessMode::AllowList {551 // `from` checked in [`burn`]551 // `from` checked in [`burn`]552 collection.check_allowlist(spender)?;552 collection.check_allowlist(spender)?;553 }553 }primitives/nft/src/lib.rsdiffbeforeafterboth142#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]142#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]143pub enum AccessMode {143pub enum AccessMode {144 Normal,144 Normal,145 WhiteList,145 AllowList,146}146}147impl Default for AccessMode {147impl Default for AccessMode {148 fn default() -> Self {148 fn default() -> Self {runtime/src/chain_extension.rsdiffbeforeafterboth75}75}767677#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]77#[derive(Debug, PartialEq, Encode, Decode, MaxEncodedLen)]78pub struct NFTExtToggleWhiteList<AccountId> {78pub struct NFTExtToggleAllowList<AccountId> {79 pub collection_id: u32,79 pub collection_id: u32,80 pub address: AccountId,80 pub address: AccountId,81 pub whitelisted: bool,81 pub allowlisted: bool,82}82}838384/// The chain Extension of NFT pallet84/// The chain Extension of NFT pallet211 Ok(RetVal::Converging(0))211 Ok(RetVal::Converging(0))212 }212 }213 6 => {213 6 => {214 // Toggle whitelist214 // Toggle allowlist215 let mut env = env.buf_in_buf_out();215 let mut env = env.buf_in_buf_out();216 let input: NFTExtToggleWhiteList<AccountIdOf<C>> = env.read_as()?;216 let input: NFTExtToggleAllowList<AccountIdOf<C>> = env.read_as()?;217 env.charge_weight(NftWeightInfoOf::<C>::add_to_white_list())?;217 env.charge_weight(NftWeightInfoOf::<C>::add_to_allow_list())?;218218219 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;219 let collection = pallet_nft::Module::<C>::get_collection(input.collection_id)?;220220221 pallet_nft::Module::<C>::toggle_white_list_internal(221 pallet_nft::Module::<C>::toggle_allow_list_internal(222 &C::CrossAccountId::from_sub(env.ext().address().clone()),222 &C::CrossAccountId::from_sub(env.ext().address().clone()),223 &collection,223 &collection,224 &C::CrossAccountId::from_sub(input.address),224 &C::CrossAccountId::from_sub(input.address),225 input.whitelisted,225 input.allowlisted,226 )?;226 )?;227227228 collection.submit_logs()?;228 collection.submit_logs()?;runtime/src/lib.rsdiffbeforeafterboth1340 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1340 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1341 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};1341 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};134213421343 let whitelist: Vec<TrackedStorageKey> = vec![1343 let allowlist: Vec<TrackedStorageKey> = vec![1344 // Block Number1344 // Block Number1345 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),1345 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),1346 // Total Issuance1346 // Total Issuance1354 ];1354 ];135513551356 let mut batches = Vec::<BenchmarkBatch>::new();1356 let mut batches = Vec::<BenchmarkBatch>::new();1357 let params = (&config, &whitelist);1357 let params = (&config, &allowlist);135813581359 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1359 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1360 add_benchmark!(params, batches, pallet_nft, Nft);1360 add_benchmark!(params, batches, pallet_nft, Nft);smart_contracs/transfer/lib.rsdiffbeforeafterboth75 #[ink(extension = 5, returns_result = false)]75 #[ink(extension = 5, returns_result = false)]76 fn set_variable_meta_data(collection_id: u32, item_id: u32, data: Vec<u8>);76 fn set_variable_meta_data(collection_id: u32, item_id: u32, data: Vec<u8>);77 #[ink(extension = 6, returns_result = false)]77 #[ink(extension = 6, returns_result = false)]78 fn toggle_white_list(collection_id: u32, address: DefaultAccountId, whitelisted: bool);78 fn toggle_allow_list(collection_id: u32, address: DefaultAccountId, allowlisted: bool);79}79}808081#[ink::contract(env = crate::NftEnvironment, dynamic_storage_allocator = true)]81#[ink::contract(env = crate::NftEnvironment, dynamic_storage_allocator = true)]135 .set_variable_meta_data(collection_id, item_id, data);135 .set_variable_meta_data(collection_id, item_id, data);136 }136 }137 #[ink(message)]137 #[ink(message)]138 pub fn toggle_white_list(&mut self, collection_id: u32, address: AccountId, whitelisted: bool) {138 pub fn toggle_allow_list(&mut self, collection_id: u32, address: AccountId, allowlisted: bool) {139 let _ = self.env()139 let _ = self.env()140 .extension()140 .extension()141 .toggle_white_list(collection_id, address, whitelisted);141 .toggle_allow_list(collection_id, address, allowlisted);142 }142 }143143144 }144 }tests/package.jsondiffbeforeafterboth42 "testConfirmSponsorship": "mocha --timeout 9999999 -r ts-node/register ./**/confirmSponsorship.test.ts",42 "testConfirmSponsorship": "mocha --timeout 9999999 -r ts-node/register ./**/confirmSponsorship.test.ts",43 "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",43 "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",44 "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",44 "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",45 "testRemoveFromWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromWhiteList.test.ts",45 "testRemoveFromAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromAllowList.test.ts",46 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",46 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",47 "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",47 "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",48 "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",48 "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",51 "testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",51 "testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",52 "testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",52 "testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",53 "testCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",53 "testCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",54 "testToggleContractWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/toggleContractWhiteList.test.ts",54 "testToggleContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/toggleContractAllowList.test.ts",55 "testAddToContractWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/addToContractWhiteList.test.ts",55 "testAddToContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/addToContractAllowList.test.ts",56 "testTransfer": "mocha --timeout 9999999 -r ts-node/register ./**/transfer.test.ts",56 "testTransfer": "mocha --timeout 9999999 -r ts-node/register ./**/transfer.test.ts",57 "testBurnItem": "mocha --timeout 9999999 -r ts-node/register ./**/burnItem.test.ts",57 "testBurnItem": "mocha --timeout 9999999 -r ts-node/register ./**/burnItem.test.ts",58 "testSetMintPermission": "mocha --timeout 9999999 -r ts-node/register ./**/setMintPermission.test.ts",58 "testSetMintPermission": "mocha --timeout 9999999 -r ts-node/register ./**/setMintPermission.test.ts",59 "testCreditFeesToTreasury": "mocha --timeout 9999999 -r ts-node/register ./**/creditFeesToTreasury.test.ts",59 "testCreditFeesToTreasury": "mocha --timeout 9999999 -r ts-node/register ./**/creditFeesToTreasury.test.ts",60 "testEnableContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/enableContractSponsoring.test.ts",60 "testEnableContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/enableContractSponsoring.test.ts",61 "testRemoveFromContractWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromContractWhiteList.test.ts",61 "testRemoveFromContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromContractAllowList.test.ts",62 "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts",62 "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts",63 "testSetOffchainSchema": "mocha --timeout 9999999 -r ts-node/register ./**/setOffchainSchema.test.ts",63 "testSetOffchainSchema": "mocha --timeout 9999999 -r ts-node/register ./**/setOffchainSchema.test.ts",64 "testOverflow": "mocha --timeout 9999999 -r ts-node/register ./**/overflow.test.ts",64 "testOverflow": "mocha --timeout 9999999 -r ts-node/register ./**/overflow.test.ts",tests/src/addToAllowList.test.tsdiffbeforeafterbothno changes
tests/src/addToContractAllowList.test.tsdiffbeforeafterbothno changes
tests/src/addToContractWhiteList.test.tsdiffbeforeafterbothno changes
tests/src/addToWhiteList.test.tsdiffbeforeafterbothno changes
tests/src/allowLists.test.tsdiffbeforeafterbothno changes
tests/src/change-collection-owner.test.tsdiffbeforeafterboth12 setCollectionSponsorExpectSuccess,12 setCollectionSponsorExpectSuccess,13 confirmSponsorshipExpectSuccess,13 confirmSponsorshipExpectSuccess,14 removeCollectionSponsorExpectSuccess,14 removeCollectionSponsorExpectSuccess,15 enableWhiteListExpectSuccess,15 enableAllowListExpectSuccess,16 setMintPermissionExpectSuccess,16 setMintPermissionExpectSuccess,17 destroyCollectionExpectSuccess,17 destroyCollectionExpectSuccess,18 setCollectionSponsorExpectFailure,18 setCollectionSponsorExpectFailure,19 confirmSponsorshipExpectFailure,19 confirmSponsorshipExpectFailure,20 removeCollectionSponsorExpectFailure,20 removeCollectionSponsorExpectFailure,21 enableWhiteListExpectFail,21 enableAllowListExpectFail,22 setMintPermissionExpectFailure,22 setMintPermissionExpectFailure,23 destroyCollectionExpectFailure,23 destroyCollectionExpectFailure,24 setPublicAccessModeExpectSuccess,24 setPublicAccessModeExpectSuccess,104 );104 );105 await submitTransactionAsync(bob, tx1);105 await submitTransactionAsync(bob, tx1);106106107 await setPublicAccessModeExpectSuccess(bob, collectionId, 'WhiteList');107 await setPublicAccessModeExpectSuccess(bob, collectionId, 'AllowList');108 await enableWhiteListExpectSuccess(bob, collectionId);108 await enableAllowListExpectSuccess(bob, collectionId);109 await setMintPermissionExpectSuccess(bob, collectionId, true);109 await setMintPermissionExpectSuccess(bob, collectionId, true);110 await destroyCollectionExpectSuccess(collectionId, '//Bob');110 await destroyCollectionExpectSuccess(collectionId, '//Bob');111 });111 });225 );225 );226 await expect(submitTransactionExpectFailAsync(alice, tx1)).to.be.rejected;226 await expect(submitTransactionExpectFailAsync(alice, tx1)).to.be.rejected;227227228 await enableWhiteListExpectFail(alice, collectionId);228 await enableAllowListExpectFail(alice, collectionId);229 await setMintPermissionExpectFailure(alice, collectionId, true);229 await setMintPermissionExpectFailure(alice, collectionId, true);230 await destroyCollectionExpectFailure(collectionId, '//Alice');230 await destroyCollectionExpectFailure(collectionId, '//Alice');231 });231 });tests/src/collision-tests/adminDestroyCollection.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';8import privateKey from '../substrate/privateKey';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import {10import {11 createCollectionExpectSuccess,11 createCollectionExpectSuccess,12 normalizeAccountId,12 normalizeAccountId,13 waitNewBlocks,13 waitNewBlocks,14} from '../util/helpers';14} from '../util/helpers';151516chai.use(chaiAsPromised);16chai.use(chaiAsPromised);17const expect = chai.expect;17const expect = chai.expect;18let Alice: IKeyringPair;18let Alice: IKeyringPair;19let Bob: IKeyringPair;19let Bob: IKeyringPair;20let Ferdie: IKeyringPair;20let Ferdie: IKeyringPair;212122before(async () => {22before(async () => {23 await usingApi(async () => {23 await usingApi(async () => {24 Alice = privateKey('//Alice');24 Alice = privateKey('//Alice');25 Bob = privateKey('//Bob');25 Bob = privateKey('//Bob');26 Ferdie = privateKey('//Ferdie');26 Ferdie = privateKey('//Ferdie');27 });27 });28});28});292930describe('Deleting a collection while add address to whitelist: ', () => {30describe('Deleting a collection while add address to allowlist: ', () => {31 // tslint:disable-next-line: max-line-length31 // tslint:disable-next-line: max-line-length32 it('Adding an address to the collection whitelist in a block by the admin, and deleting the collection by the owner ', async () => {32 it('Adding an address to the collection allowlist in a block by the admin, and deleting the collection by the owner ', async () => {33 await usingApi(async (api) => {33 await usingApi(async (api) => {34 const collectionId = await createCollectionExpectSuccess();34 const collectionId = await createCollectionExpectSuccess();35 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));35 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));36 await submitTransactionAsync(Alice, changeAdminTx);36 await submitTransactionAsync(Alice, changeAdminTx);37 await waitNewBlocks(1);37 await waitNewBlocks(1);38 //38 //39 const addWhitelistAdm = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Ferdie.address));39 const addAllowlistAdm = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(Ferdie.address));40 const destroyCollection = api.tx.nft.destroyCollection(collectionId);40 const destroyCollection = api.tx.nft.destroyCollection(collectionId);41 await Promise.all([41 await Promise.all([42 addWhitelistAdm.signAndSend(Bob),42 addAllowlistAdm.signAndSend(Bob),43 destroyCollection.signAndSend(Alice),43 destroyCollection.signAndSend(Alice),44 ]);44 ]);45 await waitNewBlocks(1);45 await waitNewBlocks(1);46 let whiteList = false;46 let allowList = false;47 whiteList = (await api.query.nft.whiteList(collectionId, Ferdie.address)).toJSON() as boolean;47 allowList = (await api.query.nft.allowList(collectionId, Ferdie.address)).toJSON() as boolean;48 // tslint:disable-next-line: no-unused-expression48 // tslint:disable-next-line: no-unused-expression49 expect(whiteList).to.be.false;49 expect(allowList).to.be.false;50 await waitNewBlocks(2);50 await waitNewBlocks(2);51 });51 });52 });52 });53});53});54*/54*/tests/src/collision-tests/tokenLimitsOff.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import BN from 'bn.js';6import BN from 'bn.js';7import chai from 'chai';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';9import privateKey from '../substrate/privateKey';9import privateKey from '../substrate/privateKey';10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';11import {11import {12 addToWhiteListExpectSuccess,12 addToAllowListExpectSuccess,13 createCollectionExpectSuccess,13 createCollectionExpectSuccess,14 getCreateItemResult,14 getCreateItemResult,15 setMintPermissionExpectSuccess,15 setMintPermissionExpectSuccess,16 normalizeAccountId,16 normalizeAccountId,17 waitNewBlocks,17 waitNewBlocks,18} from '../util/helpers';18} from '../util/helpers';191920chai.use(chaiAsPromised);20chai.use(chaiAsPromised);21const expect = chai.expect;21const expect = chai.expect;22let Alice: IKeyringPair;22let Alice: IKeyringPair;23let Bob: IKeyringPair;23let Bob: IKeyringPair;24let Ferdie: IKeyringPair;24let Ferdie: IKeyringPair;252526const accountTokenOwnershipLimit = 4;26const accountTokenOwnershipLimit = 4;27const sponsoredMintSize = 4294967295;27const sponsoredMintSize = 4294967295;28const tokenLimit = 4;28const tokenLimit = 4;29const sponsorTimeout = 14400;29const sponsorTimeout = 14400;30const ownerCanTransfer = false;30const ownerCanTransfer = false;31const ownerCanDestroy = false;31const ownerCanDestroy = false;323233before(async () => {33before(async () => {34 await usingApi(async () => {34 await usingApi(async () => {35 Alice = privateKey('//Alice');35 Alice = privateKey('//Alice');36 Bob = privateKey('//Bob');36 Bob = privateKey('//Bob');37 Ferdie = privateKey('//Ferdie');37 Ferdie = privateKey('//Ferdie');38 });38 });39});39});404041describe('Token limit exceeded collection: ', () => {41describe('Token limit exceeded collection: ', () => {42 // tslint:disable-next-line: max-line-length42 // tslint:disable-next-line: max-line-length43 it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {43 it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {44 await usingApi(async (api) => {44 await usingApi(async (api) => {45 const collectionId = await createCollectionExpectSuccess();45 const collectionId = await createCollectionExpectSuccess();46 await setMintPermissionExpectSuccess(Alice, collectionId, true);46 await setMintPermissionExpectSuccess(Alice, collectionId, true);47 await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);47 await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);48 await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);48 await addToAllowListExpectSuccess(Alice, collectionId, Bob.address);49 const setCollectionLim = api.tx.nft.setCollectionLimits(49 const setCollectionLim = api.tx.nft.setCollectionLimits(50 collectionId,50 collectionId,51 {51 {52 accountTokenOwnershipLimit,52 accountTokenOwnershipLimit,53 sponsoredMintSize,53 sponsoredMintSize,54 tokenLimit,54 tokenLimit,55 // tslint:disable-next-line: object-literal-sort-keys55 // tslint:disable-next-line: object-literal-sort-keys56 sponsorTimeout,56 sponsorTimeout,57 ownerCanTransfer,57 ownerCanTransfer,58 ownerCanDestroy,58 ownerCanDestroy,59 },59 },60 );60 );61 const subTx = await submitTransactionAsync(Alice, setCollectionLim);61 const subTx = await submitTransactionAsync(Alice, setCollectionLim);62 const subTxTesult = getCreateItemResult(subTx);62 const subTxTesult = getCreateItemResult(subTx);63 // tslint:disable-next-line:no-unused-expression63 // tslint:disable-next-line:no-unused-expression64 expect(subTxTesult.success).to.be.true;64 expect(subTxTesult.success).to.be.true;65 await waitNewBlocks(2);65 await waitNewBlocks(2);666667 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];67 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];68 const mintItemOne = api.tx.nft68 const mintItemOne = api.tx.nft69 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);69 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);70 const mintItemTwo = api.tx.nft70 const mintItemTwo = api.tx.nft71 .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);71 .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);72 await Promise.all([72 await Promise.all([73 mintItemOne.signAndSend(Ferdie),73 mintItemOne.signAndSend(Ferdie),74 mintItemTwo.signAndSend(Bob),74 mintItemTwo.signAndSend(Bob),75 ]);75 ]);76 await waitNewBlocks(2);76 await waitNewBlocks(2);77 const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;77 const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;78 expect(itemsListIndexAfter.toNumber()).to.be.equal(3);78 expect(itemsListIndexAfter.toNumber()).to.be.equal(3);79 // TokenLimit = 4. The first transaction is successful. The second should fail.79 // TokenLimit = 4. The first transaction is successful. The second should fail.80 await waitNewBlocks(2);80 await waitNewBlocks(2);81 });81 });82 });82 });83});83});84*/84*/8585tests/src/collision-tests/turnsOffMinting.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';8import privateKey from '../substrate/privateKey';9import usingApi from '../substrate/substrate-api';9import usingApi from '../substrate/substrate-api';10import {10import {11 addToWhiteListExpectSuccess,11 addToAllowListExpectSuccess,12 createCollectionExpectSuccess,12 createCollectionExpectSuccess,13 setMintPermissionExpectSuccess,13 setMintPermissionExpectSuccess,14 normalizeAccountId,14 normalizeAccountId,15 waitNewBlocks,15 waitNewBlocks,16} from '../util/helpers';16} from '../util/helpers';171718chai.use(chaiAsPromised);18chai.use(chaiAsPromised);19const expect = chai.expect;19const expect = chai.expect;20let Alice: IKeyringPair;20let Alice: IKeyringPair;21let Ferdie: IKeyringPair;21let Ferdie: IKeyringPair;222223before(async () => {23before(async () => {24 await usingApi(async () => {24 await usingApi(async () => {25 Alice = privateKey('//Alice');25 Alice = privateKey('//Alice');26 Ferdie = privateKey('//Ferdie');26 Ferdie = privateKey('//Ferdie');27 });27 });28});28});292930describe('Turns off minting mode: ', () => {30describe('Turns off minting mode: ', () => {31 // tslint:disable-next-line: max-line-length31 // tslint:disable-next-line: max-line-length32 it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {32 it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {33 await usingApi(async (api) => {33 await usingApi(async (api) => {34 const collectionId = await createCollectionExpectSuccess();34 const collectionId = await createCollectionExpectSuccess();35 await setMintPermissionExpectSuccess(Alice, collectionId, true);35 await setMintPermissionExpectSuccess(Alice, collectionId, true);36 await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);36 await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);373738 const mintItem = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');38 const mintItem = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');39 const offMinting = api.tx.nft.setMintPermission(collectionId, false);39 const offMinting = api.tx.nft.setMintPermission(collectionId, false);40 await Promise.all([40 await Promise.all([41 mintItem.signAndSend(Ferdie),41 mintItem.signAndSend(Ferdie),42 offMinting.signAndSend(Alice),42 offMinting.signAndSend(Alice),43 ]);43 ]);44 let itemList = false;44 let itemList = false;45 itemList = (await (api.query.nft.nftItemList(collectionId, mintItem))).toJSON() as boolean;45 itemList = (await (api.query.nft.nftItemList(collectionId, mintItem))).toJSON() as boolean;46 // tslint:disable-next-line: no-unused-expression46 // tslint:disable-next-line: no-unused-expression47 expect(itemList).to.be.null;47 expect(itemList).to.be.null;48 await waitNewBlocks(2);48 await waitNewBlocks(2);49 });49 });50 });50 });51});51});52*/52*/tests/src/confirmSponsorship.test.tsdiffbeforeafterboth15 createItemExpectSuccess,15 createItemExpectSuccess,16 findUnusedAddress,16 findUnusedAddress,17 getGenericResult,17 getGenericResult,18 enableWhiteListExpectSuccess,18 enableAllowListExpectSuccess,19 enablePublicMintingExpectSuccess,19 enablePublicMintingExpectSuccess,20 addToWhiteListExpectSuccess,20 addToAllowListExpectSuccess,21 normalizeAccountId,21 normalizeAccountId,22 addCollectionAdminExpectSuccess,22 addCollectionAdminExpectSuccess,23} from './util/helpers';23} from './util/helpers';144 await setCollectionSponsorExpectSuccess(collectionId, bob.address);144 await setCollectionSponsorExpectSuccess(collectionId, bob.address);145 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');145 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');146146147 // Enable collection white list147 // Enable collection allow list148 await enableWhiteListExpectSuccess(alice, collectionId);148 await enableAllowListExpectSuccess(alice, collectionId);149149150 // Enable public minting150 // Enable public minting151 await enablePublicMintingExpectSuccess(alice, collectionId);151 await enablePublicMintingExpectSuccess(alice, collectionId);157 // Find unused address157 // Find unused address158 const zeroBalance = await findUnusedAddress(api);158 const zeroBalance = await findUnusedAddress(api);159159160 // Add zeroBalance address to white list160 // Add zeroBalance address to allow list161 await addToWhiteListExpectSuccess(alice, collectionId, zeroBalance.address);161 await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);162162163 // Mint token using unused address as signer163 // Mint token using unused address as signer164 await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);164 await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);285 await setCollectionSponsorExpectSuccess(collectionId, bob.address);285 await setCollectionSponsorExpectSuccess(collectionId, bob.address);286 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');286 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');287287288 // Enable collection white list288 // Enable collection allow list289 await enableWhiteListExpectSuccess(alice, collectionId);289 await enableAllowListExpectSuccess(alice, collectionId);290290291 // Enable public minting291 // Enable public minting292 await enablePublicMintingExpectSuccess(alice, collectionId);292 await enablePublicMintingExpectSuccess(alice, collectionId);295 // Find unused address295 // Find unused address296 const zeroBalance = await findUnusedAddress(api);296 const zeroBalance = await findUnusedAddress(api);297297298 // Add zeroBalance address to white list298 // Add zeroBalance address to allow list299 await addToWhiteListExpectSuccess(alice, collectionId, zeroBalance.address);299 await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);300300301 // Mint token using unused address as signer - gets sponsored301 // Mint token using unused address as signer - gets sponsored302 await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);302 await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);tests/src/contracts.test.tsdiffbeforeafterboth16} from './util/contracthelpers';16} from './util/contracthelpers';171718import {18import {19 addToWhiteListExpectSuccess,19 addToAllowListExpectSuccess,20 approveExpectSuccess,20 approveExpectSuccess,21 createCollectionExpectSuccess,21 createCollectionExpectSuccess,22 createItemExpectSuccess,22 createItemExpectSuccess,23 enablePublicMintingExpectSuccess,23 enablePublicMintingExpectSuccess,24 enableWhiteListExpectSuccess,24 enableAllowListExpectSuccess,25 getGenericResult,25 getGenericResult,26 normalizeAccountId,26 normalizeAccountId,27 isWhitelisted,27 isAllowlisted,28 transferFromExpectSuccess,28 transferFromExpectSuccess,29 getTokenOwner,29 getTokenOwner,30} from './util/helpers';30} from './util/helpers';96 const collectionId = await createCollectionExpectSuccess();96 const collectionId = await createCollectionExpectSuccess();97 const [contract] = await deployTransferContract(api);97 const [contract] = await deployTransferContract(api);98 await enablePublicMintingExpectSuccess(alice, collectionId);98 await enablePublicMintingExpectSuccess(alice, collectionId);99 await enableWhiteListExpectSuccess(alice, collectionId);99 await enableAllowListExpectSuccess(alice, collectionId);100 await addToWhiteListExpectSuccess(alice, collectionId, contract.address);100 await addToAllowListExpectSuccess(alice, collectionId, contract.address);101 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);101 await addToAllowListExpectSuccess(alice, collectionId, bob.address);102102103 const transferTx = contract.tx.createItem(value, gasLimit, bob.address, collectionId, {Nft: {const_data: '0x010203', variable_data: '0x020304'}});103 const transferTx = contract.tx.createItem(value, gasLimit, bob.address, collectionId, {Nft: {const_data: '0x010203', variable_data: '0x020304'}});104 const events = await submitTransactionAsync(alice, transferTx);104 const events = await submitTransactionAsync(alice, transferTx);124 const collectionId = await createCollectionExpectSuccess();124 const collectionId = await createCollectionExpectSuccess();125 const [contract] = await deployTransferContract(api);125 const [contract] = await deployTransferContract(api);126 await enablePublicMintingExpectSuccess(alice, collectionId);126 await enablePublicMintingExpectSuccess(alice, collectionId);127 await enableWhiteListExpectSuccess(alice, collectionId);127 await enableAllowListExpectSuccess(alice, collectionId);128 await addToWhiteListExpectSuccess(alice, collectionId, contract.address);128 await addToAllowListExpectSuccess(alice, collectionId, contract.address);129 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);129 await addToAllowListExpectSuccess(alice, collectionId, bob.address);130130131 const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [131 const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [132 {Nft: {const_data: '0x010203', variable_data: '0x020304'}},132 {Nft: {const_data: '0x010203', variable_data: '0x020304'}},218 });218 });219 });219 });220220221 it('ToggleWhiteList CE', async () => {221 it('ToggleAllowList CE', async () => {222 await usingApi(async api => {222 await usingApi(async api => {223 const alice = privateKey('//Alice');223 const alice = privateKey('//Alice');224 const bob = privateKey('//Bob');224 const bob = privateKey('//Bob');228 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);228 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);229 await submitTransactionAsync(alice, changeAdminTx);229 await submitTransactionAsync(alice, changeAdminTx);230230231 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;231 expect(await isAllowlisted(collectionId, bob.address)).to.be.false;232232233 {233 {234 const transferTx = contract.tx.toggleWhiteList(value, gasLimit, collectionId, bob.address, true);234 const transferTx = contract.tx.toggleAllowList(value, gasLimit, collectionId, bob.address, true);235 const events = await submitTransactionAsync(alice, transferTx);235 const events = await submitTransactionAsync(alice, transferTx);236 const result = getGenericResult(events);236 const result = getGenericResult(events);237 expect(result.success).to.be.true;237 expect(result.success).to.be.true;238238239 expect(await isWhitelisted(collectionId, bob.address)).to.be.true;239 expect(await isAllowlisted(collectionId, bob.address)).to.be.true;240 }240 }241 {241 {242 const transferTx = contract.tx.toggleWhiteList(value, gasLimit, collectionId, bob.address, false);242 const transferTx = contract.tx.toggleAllowList(value, gasLimit, collectionId, bob.address, false);243 const events = await submitTransactionAsync(alice, transferTx);243 const events = await submitTransactionAsync(alice, transferTx);244 const result = getGenericResult(events);244 const result = getGenericResult(events);245 expect(result.success).to.be.true;245 expect(result.success).to.be.true;246246247 expect(await isWhitelisted(collectionId, bob.address)).to.be.false;247 expect(await isAllowlisted(collectionId, bob.address)).to.be.false;248 }248 }249 });249 });250 });250 });tests/src/eth/allowlist.test.tsdiffbeforeafterboth24 expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;24 expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;25 });25 });262627 itWeb3('Non-whitelisted user can\'t call contract with allowlist enabled', async ({api, web3}) => {27 itWeb3('Non-allowlisted user can\'t call contract with allowlist enabled', async ({api, web3}) => {28 const owner = await createEthAccountWithBalance(api, web3);28 const owner = await createEthAccountWithBalance(api, web3);29 const flipper = await deployFlipper(web3, owner);29 const flipper = await deployFlipper(web3, owner);30 const caller = await createEthAccountWithBalance(api, web3);30 const caller = await createEthAccountWithBalance(api, web3);35 await flipper.methods.flip().send({from: caller});35 await flipper.methods.flip().send({from: caller});36 expect(await flipper.methods.getValue().call()).to.be.true;36 expect(await flipper.methods.getValue().call()).to.be.true;373738 // Tx will be reverted if user is not in whitelist38 // Tx will be reverted if user is not in allowlist39 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});39 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});40 await expect(flipper.methods.flip().send({from: caller})).to.rejected;40 await expect(flipper.methods.flip().send({from: caller})).to.rejected;41 expect(await flipper.methods.getValue().call()).to.be.true;41 expect(await flipper.methods.getValue().call()).to.be.true;tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth32 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;32 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;33 });33 });343435 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should decrease (whitelisted)', async ({api, web3}) => {35 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should decrease (allowlisted)', async ({api, web3}) => {36 const alice = privateKey('//Alice');36 const alice = privateKey('//Alice');373738 const owner = await createEthAccountWithBalance(api, web3);38 const owner = await createEthAccountWithBalance(api, web3);62 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);62 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);63 });63 });646465 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should not decrease (non-whitelisted)', async ({api, web3}) => {65 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should not decrease (non-allowlisted)', async ({api, web3}) => {66 const alice = privateKey('//Alice');66 const alice = privateKey('//Alice');676768 const owner = await createEthAccountWithBalance(api, web3);68 const owner = await createEthAccountWithBalance(api, web3);158 expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');158 expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');159 });159 });160160161 itWeb3('If whitelist mode is off and sponsorship is on, sponsorship does not work', async ({api, web3}) => {161 itWeb3('If allowlist mode is off and sponsorship is on, sponsorship does not work', async ({api, web3}) => {162 const alice = privateKey('//Alice');162 const alice = privateKey('//Alice');163163164 const owner = await createEthAccountWithBalance(api, web3);164 const owner = await createEthAccountWithBalance(api, web3);tests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth52 * Can't transfer tokens to ethereum zero address52 * Can't transfer tokens to ethereum zero address53 **/53 **/54 AddressIsZero: AugmentedError<ApiType>;54 AddressIsZero: AugmentedError<ApiType>;55 /**55 /**56 * Address is not in white list.56 * Address is not in allow list.57 **/57 **/58 AddressNotInAllowlist: AugmentedError<ApiType>;58 AddressNotInAllowlist: AugmentedError<ApiType>;59 /**59 /**60 * Tried to approve more than owned60 * Tried to approve more than ownedtests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth218 * * new_admin_id: Address of new admin to add.218 * * new_admin_id: Address of new admin to add.219 **/219 **/220 addCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newAdminId: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;220 addCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newAdminId: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;221 /**221 /**222 * Add an address to white list.222 * Add an address to allow list.223 * 223 * 224 * # Permissions224 * # Permissions225 * 225 * 226 * * Collection Owner226 * * Collection Owner227 * * Collection Admin227 * * Collection Admin228 * 228 * 229 * # Arguments229 * # Arguments230 * 230 * 231 * * collection_id.231 * * collection_id.232 * 232 * 233 * * address.233 * * address.234 **/234 **/235 addToWhiteList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;235 addToAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;236 /**236 /**237 * Set, change, or remove approved address to transfer the ownership of the NFT.237 * Set, change, or remove approved address to transfer the ownership of the NFT.238 * 238 * 328 * * mode: [CollectionMode] collection type and type dependent data.328 * * mode: [CollectionMode] collection type and type dependent data.329 **/329 **/330 createCollection: AugmentedSubmittable<(collectionName: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], collectionDescription: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], tokenPrefix: Bytes | string | Uint8Array, mode: NftDataStructsCollectionMode | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<u16>, Vec<u16>, Bytes, NftDataStructsCollectionMode]>;330 createCollection: AugmentedSubmittable<(collectionName: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], collectionDescription: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], tokenPrefix: Bytes | string | Uint8Array, mode: NftDataStructsCollectionMode | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<u16>, Vec<u16>, Bytes, NftDataStructsCollectionMode]>;331 /**331 /**332 * This method creates a concrete instance of NFT Collection created with CreateCollection method.332 * This method creates a concrete instance of NFT Collection created with CreateCollection method.333 * 333 * 334 * # Permissions334 * # Permissions335 * 335 * 336 * * Collection Owner.336 * * Collection Owner.337 * * Collection Admin.337 * * Collection Admin.338 * * Anyone if338 * * Anyone if339 * * White List is enabled, and339 * * Allow List is enabled, and340 * * Address is added to white list, and340 * * Address is added to allow list, and341 * * MintPermission is enabled (see SetMintPermission method)341 * * MintPermission is enabled (see SetMintPermission method)342 * 342 * 343 * # Arguments343 * # Arguments344 * 344 * 345 * * collection_id: ID of the collection.345 * * collection_id: ID of the collection.346 * 346 * 347 * * owner: Address, initial owner of the NFT.347 * * owner: Address, initial owner of the NFT.348 * 348 * 349 * * data: Token data to store on chain.349 * * data: Token data to store on chain.350 **/350 **/351 createItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, data: NftDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, NftDataStructsCreateItemData]>;351 createItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, data: NftDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, NftDataStructsCreateItemData]>;352 /**352 /**353 * This method creates multiple items in a collection created with CreateCollection method.353 * This method creates multiple items in a collection created with CreateCollection method.354 * 354 * 355 * # Permissions355 * # Permissions356 * 356 * 357 * * Collection Owner.357 * * Collection Owner.358 * * Collection Admin.358 * * Collection Admin.359 * * Anyone if359 * * Anyone if360 * * White List is enabled, and360 * * Allow List is enabled, and361 * * Address is added to white list, and361 * * Address is added to allow list, and362 * * MintPermission is enabled (see SetMintPermission method)362 * * MintPermission is enabled (see SetMintPermission method)363 * 363 * 364 * # Arguments364 * # Arguments365 * 365 * 366 * * collection_id: ID of the collection.366 * * collection_id: ID of the collection.367 * 367 * 368 * * itemsData: Array items properties. Each property is an array of bytes itself, see [create_item].368 * * itemsData: Array items properties. Each property is an array of bytes itself, see [create_item].369 * 369 * 370 * * owner: Address, initial owner of the NFT.370 * * owner: Address, initial owner of the NFT.371 **/371 **/372 createMultipleItems: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemsData: Vec<NftDataStructsCreateItemData> | (NftDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, Vec<NftDataStructsCreateItemData>]>;372 createMultipleItems: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemsData: Vec<NftDataStructsCreateItemData> | (NftDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, Vec<NftDataStructsCreateItemData>]>;373 /**373 /**374 * **DANGEROUS**: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.374 * **DANGEROUS**: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.409 * * collection_id.409 * * collection_id.410 **/410 **/411 removeCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;411 removeCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;412 /**412 /**413 * Remove an address from white list.413 * Remove an address from allow list.414 * 414 * 415 * # Permissions415 * # Permissions416 * 416 * 417 * * Collection Owner417 * * Collection Owner418 * * Collection Admin418 * * Collection Admin419 * 419 * 420 * # Arguments420 * # Arguments421 * 421 * 422 * * collection_id.422 * * collection_id.423 * 423 * 424 * * address.424 * * address.425 **/425 **/426 removeFromWhiteList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;426 removeFromAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;427 setCollectionLimits: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newLimit: NftDataStructsCollectionLimits | { accountTokenOwnershipLimit?: any; sponsoredDataSize?: any; sponsoredDataRateLimit?: any; tokenLimit?: any; sponsorTransferTimeout?: any; ownerCanTransfer?: any; ownerCanDestroy?: any; transfersEnabled?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsCollectionLimits]>;427 setCollectionLimits: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newLimit: NftDataStructsCollectionLimits | { accountTokenOwnershipLimit?: any; sponsoredDataSize?: any; sponsoredDataRateLimit?: any; tokenLimit?: any; sponsorTransferTimeout?: any; ownerCanTransfer?: any; ownerCanDestroy?: any; transfersEnabled?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsCollectionLimits]>;428 /**428 /**429 * # Permissions429 * # Permissions466 * * value: New flag value.466 * * value: New flag value.467 **/467 **/468 setMetaUpdatePermissionFlag: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, value: NftDataStructsMetaUpdatePermission | 'ItemOwner' | 'Admin' | 'None' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsMetaUpdatePermission]>;468 setMetaUpdatePermissionFlag: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, value: NftDataStructsMetaUpdatePermission | 'ItemOwner' | 'Admin' | 'None' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsMetaUpdatePermission]>;469 /**469 /**470 * Allows Anyone to create tokens if:470 * Allows Anyone to create tokens if:471 * * White List is enabled, and471 * * Allow List is enabled, and472 * * Address is added to white list, and472 * * Address is added to allow list, and473 * * This method was called with True parameter473 * * This method was called with True parameter474 * 474 * 475 * # Permissions475 * # Permissions476 * * Collection Owner476 * * Collection Owner477 * 477 * 478 * # Arguments478 * # Arguments479 * 479 * 480 * * collection_id.480 * * collection_id.481 * 481 * 482 * * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.482 * * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.483 **/483 **/484 setMintPermission: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mintPermission: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;484 setMintPermission: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mintPermission: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;485 /**485 /**486 * Set off-chain data schema.486 * Set off-chain data schema.497 * * schema: String representing the offchain data schema.497 * * schema: String representing the offchain data schema.498 **/498 **/499 setOffchainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;499 setOffchainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;500 /**500 /**501 * Toggle between normal and white list access for the methods with access for `Anyone`.501 * Toggle between normal and allow list access for the methods with access for `Anyone`.502 * 502 * 503 * # Permissions503 * # Permissions504 * 504 * 505 * * Collection Owner.505 * * Collection Owner.506 * 506 * 507 * # Arguments507 * # Arguments508 * 508 * 509 * * collection_id.509 * * collection_id.510 * 510 * 511 * * mode: [AccessMode]511 * * mode: [AccessMode]512 **/512 **/513 setPublicAccessMode: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mode: NftDataStructsAccessMode | 'Normal' | 'WhiteList' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsAccessMode]>;513 setPublicAccessMode: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mode: NftDataStructsAccessMode | 'Normal' | 'AllowList' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsAccessMode]>;514 /**514 /**515 * Set schema standard515 * Set schema standard516 * ImageURL516 * ImageURLtests/src/interfaces/nft/definitions.tsdiffbeforeafterboth91 },91 },92 },92 },93 NftDataStructsAccessMode: {93 NftDataStructsAccessMode: {94 _enum: ['Normal', 'WhiteList'],94 _enum: ['Normal', 'AllowList'],95 },95 },96 NftDataStructsSchemaVersion: mkDummy('SchemaVersion'),96 NftDataStructsSchemaVersion: mkDummy('SchemaVersion'),9797tests/src/interfaces/nft/types.tsdiffbeforeafterboth7/** @name NftDataStructsAccessMode */7/** @name NftDataStructsAccessMode */8export interface NftDataStructsAccessMode extends Enum {8export interface NftDataStructsAccessMode extends Enum {9 readonly isNormal: boolean;9 readonly isNormal: boolean;10 readonly isWhiteList: boolean;10 readonly isAllowList: boolean;11}11}121213/** @name NftDataStructsCollection */13/** @name NftDataStructsCollection */tests/src/metadataUpdate.test.tsdiffbeforeafterboth12 createItemExpectSuccess,12 createItemExpectSuccess,13 createCollectionExpectSuccess,13 createCollectionExpectSuccess,14 enablePublicMintingExpectSuccess,14 enablePublicMintingExpectSuccess,15 enableWhiteListExpectSuccess,15 enableAllowListExpectSuccess,16 setMetadataUpdatePermissionFlagExpectSuccess,16 setMetadataUpdatePermissionFlagExpectSuccess,17 setVariableMetaDataExpectSuccess,17 setVariableMetaDataExpectSuccess,18 setMintPermissionExpectSuccess,18 setMintPermissionExpectSuccess,19 addToWhiteListExpectSuccess,19 addToAllowListExpectSuccess,20 addCollectionAdminExpectSuccess,20 addCollectionAdminExpectSuccess,21 setVariableMetaDataExpectFailure,21 setVariableMetaDataExpectFailure,22 setMetadataUpdatePermissionFlagExpectFailure,22 setMetadataUpdatePermissionFlagExpectFailure,53 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'ItemOwner');53 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'ItemOwner');545455 await setMintPermissionExpectSuccess(alice, nftCollectionId, true);55 await setMintPermissionExpectSuccess(alice, nftCollectionId, true);56 await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);56 await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address);57 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);57 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);585859 await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data);59 await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data);92 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin');92 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin');939394 await setMintPermissionExpectSuccess(alice, nftCollectionId, true);94 await setMintPermissionExpectSuccess(alice, nftCollectionId, true);95 await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);95 await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address);96 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);96 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);979798 await setVariableMetaDataExpectSuccess(bob, nftCollectionId, newNftTokenId, data);98 await setVariableMetaDataExpectSuccess(bob, nftCollectionId, newNftTokenId, data);112 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin');112 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin');113113114 await setMintPermissionExpectSuccess(alice, nftCollectionId, true);114 await setMintPermissionExpectSuccess(alice, nftCollectionId, true);115 await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);115 await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address);116 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);116 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);117117118 await setVariableMetaDataExpectSuccess(bob, nftCollectionId, newNftTokenId, data);118 await setVariableMetaDataExpectSuccess(bob, nftCollectionId, newNftTokenId, data);129 // nft129 // nft130 const nftCollectionId = await createCollectionExpectSuccess();130 const nftCollectionId = await createCollectionExpectSuccess();131 await enablePublicMintingExpectSuccess(alice, nftCollectionId);131 await enablePublicMintingExpectSuccess(alice, nftCollectionId);132 await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);132 await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address);133 await enableWhiteListExpectSuccess(alice, nftCollectionId);133 await enableAllowListExpectSuccess(alice, nftCollectionId);134 const newNftTokenId = await createItemExpectSuccess(bob, nftCollectionId, 'NFT');134 const newNftTokenId = await createItemExpectSuccess(bob, nftCollectionId, 'NFT');135 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin');135 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin');136136169 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None');169 await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None');170170171 await setMintPermissionExpectSuccess(alice, nftCollectionId, true);171 await setMintPermissionExpectSuccess(alice, nftCollectionId, true);172 await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);172 await addToAllowListExpectSuccess(alice, nftCollectionId, bob.address);173 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);173 await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);174174175 await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data);175 await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data);tests/src/mintModes.test.tsdiffbeforeafterboth7import privateKey from './substrate/privateKey';7import privateKey from './substrate/privateKey';8import usingApi from './substrate/substrate-api';8import usingApi from './substrate/substrate-api';9import {9import {10 addToWhiteListExpectSuccess,10 addToAllowListExpectSuccess,11 createCollectionExpectSuccess,11 createCollectionExpectSuccess,12 createItemExpectFailure,12 createItemExpectFailure,13 createItemExpectSuccess,13 createItemExpectSuccess,14 enableWhiteListExpectSuccess,14 enableAllowListExpectSuccess,15 setMintPermissionExpectSuccess,15 setMintPermissionExpectSuccess,16 addCollectionAdminExpectSuccess,16 addCollectionAdminExpectSuccess,17 disableWhiteListExpectSuccess,17 disableAllowListExpectSuccess,18} from './util/helpers';18} from './util/helpers';191920describe('Integration Test public minting', () => {20describe('Integration Test public minting', () => {28 });28 });29 });29 });303031 it('If the AllowList mode is enabled, then the address added to the whitelist and not the owner or administrator can create tokens', async () => {31 it('If the AllowList mode is enabled, then the address added to the allowlist and not the owner or administrator can create tokens', async () => {32 await usingApi(async () => {32 await usingApi(async () => {33 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});33 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});34 await enableWhiteListExpectSuccess(alice, collectionId);34 await enableAllowListExpectSuccess(alice, collectionId);35 await setMintPermissionExpectSuccess(alice, collectionId, true);35 await setMintPermissionExpectSuccess(alice, collectionId, true);36 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);36 await addToAllowListExpectSuccess(alice, collectionId, bob.address);373738 await createItemExpectSuccess(bob, collectionId, 'NFT');38 await createItemExpectSuccess(bob, collectionId, 'NFT');39 });39 });40 });40 });414142 it('If the AllowList mode is enabled, address not included in whitelist that is regular user cannot create tokens', async () => {42 it('If the AllowList mode is enabled, address not included in allowlist that is regular user cannot create tokens', async () => {43 await usingApi(async () => {43 await usingApi(async () => {44 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});44 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});45 await enableWhiteListExpectSuccess(alice, collectionId);45 await enableAllowListExpectSuccess(alice, collectionId);46 await setMintPermissionExpectSuccess(alice, collectionId, true);46 await setMintPermissionExpectSuccess(alice, collectionId, true);47 await createItemExpectFailure(bob, collectionId, 'NFT');47 await createItemExpectFailure(bob, collectionId, 'NFT');48 });48 });49 });49 });505051 it('If the AllowList mode is enabled, address not included in whitelist that is admin can create tokens', async () => {51 it('If the AllowList mode is enabled, address not included in allowlist that is admin can create tokens', async () => {52 await usingApi(async () => {52 await usingApi(async () => {53 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});53 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});54 await enableWhiteListExpectSuccess(alice, collectionId);54 await enableAllowListExpectSuccess(alice, collectionId);55 await setMintPermissionExpectSuccess(alice, collectionId, true);55 await setMintPermissionExpectSuccess(alice, collectionId, true);56 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);56 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);57 await createItemExpectSuccess(bob, collectionId, 'NFT');57 await createItemExpectSuccess(bob, collectionId, 'NFT');58 });58 });59 });59 });606061 it('If the AllowList mode is enabled, address not included in whitelist that is owner can create tokens', async () => {61 it('If the AllowList mode is enabled, address not included in allowlist that is owner can create tokens', async () => {62 await usingApi(async () => {62 await usingApi(async () => {63 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});63 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});64 await enableWhiteListExpectSuccess(alice, collectionId);64 await enableAllowListExpectSuccess(alice, collectionId);65 await setMintPermissionExpectSuccess(alice, collectionId, true);65 await setMintPermissionExpectSuccess(alice, collectionId, true);66 await createItemExpectSuccess(alice, collectionId, 'NFT');66 await createItemExpectSuccess(alice, collectionId, 'NFT');67 });67 });70 it('If the AllowList mode is disabled, owner can create tokens', async () => {70 it('If the AllowList mode is disabled, owner can create tokens', async () => {71 await usingApi(async () => {71 await usingApi(async () => {72 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});72 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});73 await disableWhiteListExpectSuccess(alice, collectionId);73 await disableAllowListExpectSuccess(alice, collectionId);74 await setMintPermissionExpectSuccess(alice, collectionId, true);74 await setMintPermissionExpectSuccess(alice, collectionId, true);75 await createItemExpectSuccess(alice, collectionId, 'NFT');75 await createItemExpectSuccess(alice, collectionId, 'NFT');76 });76 });79 it('If the AllowList mode is disabled, collection admin can create tokens', async () => {79 it('If the AllowList mode is disabled, collection admin can create tokens', async () => {80 await usingApi(async () => {80 await usingApi(async () => {81 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});81 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});82 await disableWhiteListExpectSuccess(alice, collectionId);82 await disableAllowListExpectSuccess(alice, collectionId);83 await setMintPermissionExpectSuccess(alice, collectionId, true);83 await setMintPermissionExpectSuccess(alice, collectionId, true);84 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);84 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);85 await createItemExpectSuccess(bob, collectionId, 'NFT');85 await createItemExpectSuccess(bob, collectionId, 'NFT');89 it('If the AllowList mode is disabled, regular user can`t create tokens', async () => {89 it('If the AllowList mode is disabled, regular user can`t create tokens', async () => {90 await usingApi(async () => {90 await usingApi(async () => {91 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});91 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});92 await disableWhiteListExpectSuccess(alice, collectionId);92 await disableAllowListExpectSuccess(alice, collectionId);93 await setMintPermissionExpectSuccess(alice, collectionId, true);93 await setMintPermissionExpectSuccess(alice, collectionId, true);94 await createItemExpectFailure(bob, collectionId, 'NFT');94 await createItemExpectFailure(bob, collectionId, 'NFT');95 });95 });110 it('Address that is the not owner or not admin cannot create tokens', async () => {110 it('Address that is the not owner or not admin cannot create tokens', async () => {111 await usingApi(async () => {111 await usingApi(async () => {112 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});112 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});113 await enableWhiteListExpectSuccess(alice, collectionId);113 await enableAllowListExpectSuccess(alice, collectionId);114 await setMintPermissionExpectSuccess(alice, collectionId, false);114 await setMintPermissionExpectSuccess(alice, collectionId, false);115 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);115 await addToAllowListExpectSuccess(alice, collectionId, bob.address);116 await createItemExpectFailure(bob, collectionId, 'NFT');116 await createItemExpectFailure(bob, collectionId, 'NFT');117 });117 });118 });118 });119119120 it('Address that is collection owner can create tokens', async () => {120 it('Address that is collection owner can create tokens', async () => {121 await usingApi(async () => {121 await usingApi(async () => {122 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});122 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});123 await disableWhiteListExpectSuccess(alice, collectionId);123 await disableAllowListExpectSuccess(alice, collectionId);124 await setMintPermissionExpectSuccess(alice, collectionId, false);124 await setMintPermissionExpectSuccess(alice, collectionId, false);125 await createItemExpectSuccess(alice, collectionId, 'NFT');125 await createItemExpectSuccess(alice, collectionId, 'NFT');126 });126 });129 it('Address that is admin can create tokens', async () => {129 it('Address that is admin can create tokens', async () => {130 await usingApi(async () => {130 await usingApi(async () => {131 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});131 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});132 await disableWhiteListExpectSuccess(alice, collectionId);132 await disableAllowListExpectSuccess(alice, collectionId);133 await setMintPermissionExpectSuccess(alice, collectionId, false);133 await setMintPermissionExpectSuccess(alice, collectionId, false);134 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);134 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);135 await createItemExpectSuccess(bob, collectionId, 'NFT');135 await createItemExpectSuccess(bob, collectionId, 'NFT');tests/src/removeFromAllowList.test.tsdiffbeforeafterbothno changes
tests/src/removeFromContractAllowList.test.tsdiffbeforeafterbothno changes
tests/src/removeFromContractWhiteList.test.tsdiffbeforeafterbothno changes
tests/src/removeFromWhiteList.test.tsdiffbeforeafterbothno changes
tests/src/setMintPermission.test.tsdiffbeforeafterboth7import privateKey from './substrate/privateKey';7import privateKey from './substrate/privateKey';8import usingApi from './substrate/substrate-api';8import usingApi from './substrate/substrate-api';9import {9import {10 addToWhiteListExpectSuccess,10 addToAllowListExpectSuccess,11 createCollectionExpectSuccess,11 createCollectionExpectSuccess,12 createItemExpectFailure,12 createItemExpectFailure,13 createItemExpectSuccess,13 createItemExpectSuccess,14 destroyCollectionExpectSuccess,14 destroyCollectionExpectSuccess,15 enableWhiteListExpectSuccess,15 enableAllowListExpectSuccess,16 findNotExistingCollection,16 findNotExistingCollection,17 setMintPermissionExpectFailure,17 setMintPermissionExpectFailure,18 setMintPermissionExpectSuccess,18 setMintPermissionExpectSuccess,30 });30 });31 });31 });323233 it('ensure white-listed non-privileged address can mint tokens', async () => {33 it('ensure allow-listed non-privileged address can mint tokens', async () => {34 await usingApi(async () => {34 await usingApi(async () => {35 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});35 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});36 await enableWhiteListExpectSuccess(alice, collectionId);36 await enableAllowListExpectSuccess(alice, collectionId);37 await setMintPermissionExpectSuccess(alice, collectionId, true);37 await setMintPermissionExpectSuccess(alice, collectionId, true);38 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);38 await addToAllowListExpectSuccess(alice, collectionId, bob.address);393940 await createItemExpectSuccess(bob, collectionId, 'NFT');40 await createItemExpectSuccess(bob, collectionId, 'NFT');41 });41 });888889 it('fails when not collection owner tries to set mint status', async () => {89 it('fails when not collection owner tries to set mint status', async () => {90 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});90 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});91 await enableWhiteListExpectSuccess(alice, collectionId);91 await enableAllowListExpectSuccess(alice, collectionId);92 await setMintPermissionExpectFailure(bob, collectionId, true);92 await setMintPermissionExpectFailure(bob, collectionId, true);93 });93 });9494100 });100 });101 });101 });102102103 it('ensure non-white-listed non-privileged address can\'t mint tokens', async () => {103 it('ensure non-allow-listed non-privileged address can\'t mint tokens', async () => {104 await usingApi(async () => {104 await usingApi(async () => {105 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});105 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});106 await enableWhiteListExpectSuccess(alice, collectionId);106 await enableAllowListExpectSuccess(alice, collectionId);107 await setMintPermissionExpectSuccess(alice, collectionId, true);107 await setMintPermissionExpectSuccess(alice, collectionId, true);108108109 await createItemExpectFailure(bob, collectionId, 'NFT');109 await createItemExpectFailure(bob, collectionId, 'NFT');tests/src/setPublicAccessMode.test.tsdiffbeforeafterboth11import privateKey from './substrate/privateKey';11import privateKey from './substrate/privateKey';12import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';12import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';13import {13import {14 addToWhiteListExpectSuccess,14 addToAllowListExpectSuccess,15 createCollectionExpectSuccess,15 createCollectionExpectSuccess,16 createItemExpectSuccess,16 createItemExpectSuccess,17 destroyCollectionExpectSuccess,17 destroyCollectionExpectSuccess,18 enablePublicMintingExpectSuccess,18 enablePublicMintingExpectSuccess,19 enableWhiteListExpectSuccess,19 enableAllowListExpectSuccess,20 normalizeAccountId,20 normalizeAccountId,21 addCollectionAdminExpectSuccess,21 addCollectionAdminExpectSuccess,22} from './util/helpers';22} from './util/helpers';35 });35 });36 });36 });373738 it('Run extrinsic with collection id parameters, set the whitelist mode for the collection', async () => {38 it('Run extrinsic with collection id parameters, set the allowlist mode for the collection', async () => {39 await usingApi(async () => {39 await usingApi(async () => {40 const collectionId: number = await createCollectionExpectSuccess();40 const collectionId: number = await createCollectionExpectSuccess();41 await enableWhiteListExpectSuccess(alice, collectionId);41 await enableAllowListExpectSuccess(alice, collectionId);42 await enablePublicMintingExpectSuccess(alice, collectionId);42 await enablePublicMintingExpectSuccess(alice, collectionId);43 await addToWhiteListExpectSuccess(alice, collectionId, bob.address);43 await addToAllowListExpectSuccess(alice, collectionId, bob.address);44 await createItemExpectSuccess(bob, collectionId, 'NFT', bob.address);44 await createItemExpectSuccess(bob, collectionId, 'NFT', bob.address);45 });45 });46 });46 });474748 it('Whitelisted collection limits', async () => {48 it('Allowlisted collection limits', async () => {49 await usingApi(async (api: ApiPromise) => {49 await usingApi(async (api: ApiPromise) => {50 const collectionId = await createCollectionExpectSuccess();50 const collectionId = await createCollectionExpectSuccess();51 await enableWhiteListExpectSuccess(alice, collectionId);51 await enableAllowListExpectSuccess(alice, collectionId);52 await enablePublicMintingExpectSuccess(alice, collectionId);52 await enablePublicMintingExpectSuccess(alice, collectionId);53 const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(bob.address), 'NFT');53 const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(bob.address), 'NFT');54 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;54 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;61 await usingApi(async (api: ApiPromise) => {61 await usingApi(async (api: ApiPromise) => {62 // tslint:disable-next-line: radix62 // tslint:disable-next-line: radix63 const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;63 const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;64 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');64 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');65 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;65 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;66 });66 });67 });67 });71 // tslint:disable-next-line: no-bitwise71 // tslint:disable-next-line: no-bitwise72 const collectionId = await createCollectionExpectSuccess();72 const collectionId = await createCollectionExpectSuccess();73 await destroyCollectionExpectSuccess(collectionId);73 await destroyCollectionExpectSuccess(collectionId);74 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');74 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');75 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;75 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;76 });76 });77 });77 });787879 it('Re-set the list mode already set in quantity', async () => {79 it('Re-set the list mode already set in quantity', async () => {80 await usingApi(async () => {80 await usingApi(async () => {81 const collectionId: number = await createCollectionExpectSuccess();81 const collectionId: number = await createCollectionExpectSuccess();82 await enableWhiteListExpectSuccess(alice, collectionId);82 await enableAllowListExpectSuccess(alice, collectionId);83 await enableWhiteListExpectSuccess(alice, collectionId);83 await enableAllowListExpectSuccess(alice, collectionId);84 });84 });85 });85 });868687 it('Execute method not on behalf of the collection owner', async () => {87 it('Execute method not on behalf of the collection owner', async () => {88 await usingApi(async (api: ApiPromise) => {88 await usingApi(async (api: ApiPromise) => {89 // tslint:disable-next-line: no-bitwise89 // tslint:disable-next-line: no-bitwise90 const collectionId = await createCollectionExpectSuccess();90 const collectionId = await createCollectionExpectSuccess();91 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');91 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');92 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;92 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;93 });93 });94 });94 });106 // tslint:disable-next-line: no-bitwise106 // tslint:disable-next-line: no-bitwise107 const collectionId = await createCollectionExpectSuccess();107 const collectionId = await createCollectionExpectSuccess();108 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);108 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);109 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');109 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');110 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;110 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;111 });111 });112 });112 });tests/src/toggleContractAllowList.test.tsdiffbeforeafterbothno changes
tests/src/toggleContractWhiteList.test.tsdiffbeforeafterbothno changes
tests/src/transfer_contract/metadata.jsondiffbeforeafterboth323 }323 }324 },324 },325 {325 {326 "name": "whitelisted",326 "name": "allowlisted",327 "type": {327 "type": {328 "displayName": [328 "displayName": [329 "bool"329 "bool"335 "docs": [],335 "docs": [],336 "mutates": true,336 "mutates": true,337 "name": [337 "name": [338 "toggle_white_list"338 "toggle_allow_list"339 ],339 ],340 "payable": false,340 "payable": false,341 "returnType": null,341 "returnType": null,tests/src/util/helpers.tsdiffbeforeafterboth597 });597 });598}598}599599600export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value = true) {600export async function toggleContractAllowlistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value = true) {601 await usingApi(async (api) => {601 await usingApi(async (api) => {602 const tx = api.tx.nft.toggleContractWhiteList(contractAddress, value);602 const tx = api.tx.nft.toggleContractAllowList(contractAddress, value);603 const events = await submitTransactionAsync(sender, tx);603 const events = await submitTransactionAsync(sender, tx);604 const result = getGenericResult(events);604 const result = getGenericResult(events);605605606 expect(result.success).to.be.true;606 expect(result.success).to.be.true;607 });607 });608}608}609609610export async function isWhitelistedInContract(contractAddress: AccountId | string, user: string) {610export async function isAllowlistedInContract(contractAddress: AccountId | string, user: string) {611 let whitelisted = false;611 let allowlisted = false;612 await usingApi(async (api) => {612 await usingApi(async (api) => {613 whitelisted = (await api.query.nft.contractWhiteList(contractAddress, user)).toJSON() as boolean;613 allowlisted = (await api.query.nft.contractAllowList(contractAddress, user)).toJSON() as boolean;614 });614 });615 return whitelisted;615 return allowlisted;616}616}617617618export async function addToContractWhiteListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {618export async function addToContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {619 await usingApi(async (api) => {619 await usingApi(async (api) => {620 const tx = api.tx.nft.addToContractWhiteList(contractAddress.toString(), user.toString());620 const tx = api.tx.nft.addToContractAllowList(contractAddress.toString(), user.toString());621 const events = await submitTransactionAsync(sender, tx);621 const events = await submitTransactionAsync(sender, tx);622 const result = getGenericResult(events);622 const result = getGenericResult(events);623623624 expect(result.success).to.be.true;624 expect(result.success).to.be.true;625 });625 });626}626}627627628export async function removeFromContractWhiteListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {628export async function removeFromContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {629 await usingApi(async (api) => {629 await usingApi(async (api) => {630 const tx = api.tx.nft.removeFromContractWhiteList(contractAddress.toString(), user.toString());630 const tx = api.tx.nft.removeFromContractAllowList(contractAddress.toString(), user.toString());631 const events = await submitTransactionAsync(sender, tx);631 const events = await submitTransactionAsync(sender, tx);632 const result = getGenericResult(events);632 const result = getGenericResult(events);633633634 expect(result.success).to.be.true;634 expect(result.success).to.be.true;635 });635 });636}636}637637638export async function removeFromContractWhiteListExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {638export async function removeFromContractAllowListExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {639 await usingApi(async (api) => {639 await usingApi(async (api) => {640 const tx = api.tx.nft.removeFromContractWhiteList(contractAddress.toString(), user.toString());640 const tx = api.tx.nft.removeFromContractAllowList(contractAddress.toString(), user.toString());641 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;641 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;642 const result = getGenericResult(events);642 const result = getGenericResult(events);643643104810481049export async function setPublicAccessModeExpectSuccess(1049export async function setPublicAccessModeExpectSuccess(1050 sender: IKeyringPair, collectionId: number,1050 sender: IKeyringPair, collectionId: number,1051 accessMode: 'Normal' | 'WhiteList',1051 accessMode: 'Normal' | 'AllowList',1052) {1052) {1053 await usingApi(async (api) => {1053 await usingApi(async (api) => {10541054106910691070export async function setPublicAccessModeExpectFail(1070export async function setPublicAccessModeExpectFail(1071 sender: IKeyringPair, collectionId: number,1071 sender: IKeyringPair, collectionId: number,1072 accessMode: 'Normal' | 'WhiteList',1072 accessMode: 'Normal' | 'AllowList',1073) {1073) {1074 await usingApi(async (api) => {1074 await usingApi(async (api) => {107510751084 });1084 });1085}1085}108610861087export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1087export async function enableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1088 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');1088 await setPublicAccessModeExpectSuccess(sender, collectionId, 'AllowList');1089}1089}109010901091export async function enableWhiteListExpectFail(sender: IKeyringPair, collectionId: number) {1091export async function enableAllowListExpectFail(sender: IKeyringPair, collectionId: number) {1092 await setPublicAccessModeExpectFail(sender, collectionId, 'WhiteList');1092 await setPublicAccessModeExpectFail(sender, collectionId, 'AllowList');1093}1093}109410941095export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1095export async function disableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1096 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1096 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1097}1097}109810981138 });1138 });1139}1139}114011401141export async function isWhitelisted(collectionId: number, address: string | CrossAccountId) {1141export async function isAllowlisted(collectionId: number, address: string | CrossAccountId) {1142 return await usingApi(async (api) => {1142 return await usingApi(async (api) => {1143 return (await api.query.common.allowlist(collectionId, normalizeAccountId(address))).toJSON();1143 return (await api.query.common.allowlist(collectionId, normalizeAccountId(address))).toJSON();1144 });1144 });1145}1145}114611461147export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1147export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1148 await usingApi(async (api) => {1148 await usingApi(async (api) => {1149 expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.false;1149 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.false;115011501151 // Run the transaction1151 // Run the transaction1152 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));1152 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1153 const events = await submitTransactionAsync(sender, tx);1153 const events = await submitTransactionAsync(sender, tx);1154 const result = getGenericResult(events);1154 const result = getGenericResult(events);1155 expect(result.success).to.be.true;1155 expect(result.success).to.be.true;115611561157 expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.true;1157 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.true;1158 });1158 });1159}1159}116011601161export async function addToWhiteListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1161export async function addToAllowListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1162 await usingApi(async (api) => {1162 await usingApi(async (api) => {116311631164 expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.true;1164 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.true;116511651166 // Run the transaction1166 // Run the transaction1167 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));1167 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1168 const events = await submitTransactionAsync(sender, tx);1168 const events = await submitTransactionAsync(sender, tx);1169 const result = getGenericResult(events);1169 const result = getGenericResult(events);1170 expect(result.success).to.be.true;1170 expect(result.success).to.be.true;117111711172 expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.true;1172 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.true;1173 });1173 });1174}1174}117511751176export async function addToWhiteListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1176export async function addToAllowListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1177 await usingApi(async (api) => {1177 await usingApi(async (api) => {117811781179 // Run the transaction1179 // Run the transaction1180 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));1180 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1181 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1181 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1182 const result = getGenericResult(events);1182 const result = getGenericResult(events);118311831187 });1187 });1188}1188}118911891190export async function removeFromWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1190export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1191 await usingApi(async (api) => {1191 await usingApi(async (api) => {1192 // Run the transaction1192 // Run the transaction1193 const tx = api.tx.nft.removeFromWhiteList(collectionId, normalizeAccountId(address));1193 const tx = api.tx.nft.removeFromAllowList(collectionId, normalizeAccountId(address));1194 const events = await submitTransactionAsync(sender, tx);1194 const events = await submitTransactionAsync(sender, tx);1195 const result = getGenericResult(events);1195 const result = getGenericResult(events);119611961200 });1200 });1201}1201}120212021203export async function removeFromWhiteListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1203export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1204 await usingApi(async (api) => {1204 await usingApi(async (api) => {1205 // Run the transaction1205 // Run the transaction1206 const tx = api.tx.nft.removeFromWhiteList(collectionId, normalizeAccountId(address));1206 const tx = api.tx.nft.removeFromAllowList(collectionId, normalizeAccountId(address));1207 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1207 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1208 const result = getGenericResult(events);1208 const result = getGenericResult(events);12091209tests/src/whiteLists.test.tsdiffbeforeafterbothno changes