difftreelog
merge develop
in: master
70 files changed
Cargo.lockdiffbeforeafterboth494049404941[[package]]4941[[package]]4942name = "nft"4942name = "nft"4943version = "3.0.0"4943version = "0.9.12"4944dependencies = [4944dependencies = [4945 "cumulus-client-cli",4945 "cumulus-client-cli",4946 "cumulus-client-collator",4946 "cumulus-client-collator",507650765077[[package]]5077[[package]]5078name = "nft-runtime"5078name = "nft-runtime"5079version = "3.0.0"5079version = "0.9.12"5080dependencies = [5080dependencies = [5081 "cumulus-pallet-aura-ext",5081 "cumulus-pallet-aura-ext",5082 "cumulus-pallet-dmp-queue",5082 "cumulus-pallet-dmp-queue",5109 "pallet-fungible",5109 "pallet-fungible",5110 "pallet-inflation",5110 "pallet-inflation",5111 "pallet-nft",5111 "pallet-nft",5112 "pallet-nft-charge-transaction",5113 "pallet-nft-transaction-payment",5112 "pallet-nft-transaction-payment",5114 "pallet-nonfungible",5113 "pallet-nonfungible",5115 "pallet-randomness-collective-flip",5114 "pallet-randomness-collective-flip",5116 "pallet-refungible",5115 "pallet-refungible",5117 "pallet-sudo",5116 "pallet-sudo",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",6076 "up-sponsorship",6076 "up-sponsorship",6077]6077]60786079[[package]]6080name = "pallet-nft-charge-transaction"6081version = "3.0.0"6082dependencies = [6083 "frame-benchmarking",6084 "frame-support",6085 "frame-system",6086 "pallet-balances",6087 "pallet-nft-transaction-payment",6088 "pallet-transaction-payment",6089 "parity-scale-codec",6090 "scale-info",6091 "serde",6092 "sp-core",6093 "sp-io",6094 "sp-runtime",6095 "sp-std",6096]609760786098[[package]]6079[[package]]6099name = "pallet-nft-transaction-payment"6080name = "pallet-nft-transaction-payment"6369 "sp-std",6350 "sp-std",6370]6351]63526353[[package]]6354name = "pallet-template-transaction-payment"6355version = "3.0.0"6356source = "git+https://github.com/UniqueNetwork/pallet-sponsoring#ab8b91e9350a31133f3a3e4f52a84c6de4108e95"6357dependencies = [6358 "frame-benchmarking",6359 "frame-support",6360 "frame-system",6361 "pallet-balances",6362 "pallet-transaction-payment",6363 "parity-scale-codec",6364 "scale-info",6365 "serde",6366 "sp-core",6367 "sp-io",6368 "sp-runtime",6369 "sp-std",6370 "up-sponsorship",6371]637163726372[[package]]6373[[package]]6373name = "pallet-timestamp"6374name = "pallet-timestamp"11847[[package]]11848[[package]]11848name = "up-sponsorship"11849name = "up-sponsorship"11849version = "0.1.0"11850version = "0.1.0"11851source = "git+https://github.com/UniqueNetwork/pallet-sponsoring#ab8b91e9350a31133f3a3e4f52a84c6de4108e95"11850dependencies = [11852dependencies = [11851 "impl-trait-for-tuples 0.2.1",11853 "impl-trait-for-tuples 0.2.1",11852]11854]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)**3838docker-compose-tests-parachain.ymldiffbeforeafterboth223services:3services:4 blockchain_nodes:4 blockchain_nodes:5 image: blockchain_nodes6 container_name: blockchain_nodes7 ports:8 - 9944:99449 - 9844:984410 - 9933:993311 build:5 build:12 context: ./6 context: ./13 dockerfile: Dockerfile-parachain7 dockerfile: Dockerfile-parachain17 - POLKA_VERSION=${POLKA_VERSION:?err}11 - POLKA_VERSION=${POLKA_VERSION:?err}18 - NFT_BRANCH=${NFT_BRANCH:?err}12 - NFT_BRANCH=${NFT_BRANCH:?err}19 volumes:13 volumes:20# - ./chain-data:/chain-data21 - ./launch-config.json:/polkadot-launch/launch-config.json14 - ./launch-config.json:/polkadot-launch/launch-config.json22 env_file:15 env_file:23 - ./.env16 - ./.env24 networks:25 - node_test_network26 #command: bash -c "yarn --cwd polkadot-launch start"27 #command: bash -c 'while true; do sleep 60; df -h; done'281729 integration_tests:18 integration_tests:30 container_name: integration_tests31 image: integration_tests32 build:19 build:33 context: tests/20 context: tests/34 dockerfile: Dockerfile-tests21 dockerfile: Dockerfile-tests37 volumes:24 volumes:38 - ./tests/src/config_docker.ts:/nft_parachain/src/config.ts25 - ./tests/src/config_docker.ts:/nft_parachain/src/config.ts39 - /home/ubuntu/mochawesome-report:/nft_parachain/mochawesome-report26 - /home/ubuntu/mochawesome-report:/nft_parachain/mochawesome-report40# command: bash -c 'while true; do sleep 20; df -h; done'41 networks:42 - node_test_network43 depends_on:27 depends_on:44 - blockchain_nodes28 - blockchain_nodes4546# unit_tests:47# container_name: unit_test48# image: nft_unit_test49# build:50# context: ./51# dockerfile: Dockerfile-unit52# container_name: unit_test53# networks:54# - node_test_network55 # command: bash -c 'while true; do sleep 20; df -h; done'56# command: bash -c 'cargo test'5758networks:59 node_test_network:60 name: node_test_network61 driver: bridge6229node/cli/Cargo.tomldiffbeforeafterboth233233234[dependencies.nft-runtime]234[dependencies.nft-runtime]235path = '../../runtime'235path = '../../runtime'236version = '3.0.0'236version = '0.9.12'237237238[dependencies.nft-data-structs]238[dependencies.nft-data-structs]239path = "../../primitives/nft"239path = "../../primitives/nft"251license = 'All Rights Reserved'251license = 'All Rights Reserved'252name = 'nft'252name = 'nft'253repository = 'https://github.com/usetech-llc/nft_private/'253repository = 'https://github.com/usetech-llc/nft_private/'254version = '3.0.0'254version = '0.9.12'255255256[[bin]]256[[bin]]257name = 'nft'257name = 'nft'pallets/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/contract-helpers/Cargo.tomldiffbeforeafterboth9package = 'parity-scale-codec'9package = 'parity-scale-codec'10version = '2.3.0'10version = '2.3.0'1112[dependencies.up-sponsorship]13default-features = false14path = '../../primitives/sponsorship'15version = '0.1.0'161117[dependencies]12[dependencies]18scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }13scale-info = { version = "1.0.0", default-features = false, features = ["derive"] }21pallet-contracts = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }16pallet-contracts = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }22sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }23sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }18sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }19up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 242025[features]21[features]26default = ["std"]22default = ["std"]pallets/evm-contract-helpers/Cargo.tomldiffbeforeafterboth15evm-coder = { default-features = false, path = '../../crates/evm-coder' }15evm-coder = { default-features = false, path = '../../crates/evm-coder' }16pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }16pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }17pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }17pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }18up-sponsorship = { default-features = false, path = '../../primitives/sponsorship' }18up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 19log = "0.4.14"19log = "0.4.14"202021[dependencies.codec]21[dependencies.codec]pallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth16pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }16pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }17fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }17fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }18pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }18pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12-weights" }19up-sponsorship = { default-features = false, path = '../../primitives/sponsorship' }19up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 202021[dependencies.codec]21[dependencies.codec]22default-features = false22default-features = falsepallets/fungible/src/lib.rsdiffbeforeafterboth132 .checked_sub(amount)132 .checked_sub(amount)133 .ok_or(<CommonError<T>>::TokenValueTooLow)?;133 .ok_or(<CommonError<T>>::TokenValueTooLow)?;134134135 if collection.access == AccessMode::WhiteList {135 if collection.access == AccessMode::AllowList {136 collection.check_allowlist(owner)?;136 collection.check_allowlist(owner)?;137 }137 }138138170 <CommonError<T>>::TransferNotAllowed,170 <CommonError<T>>::TransferNotAllowed,171 );171 );172172173 if collection.access == AccessMode::WhiteList {173 if collection.access == AccessMode::AllowList {174 collection.check_allowlist(from)?;174 collection.check_allowlist(from)?;175 collection.check_allowlist(to)?;175 collection.check_allowlist(to)?;176 }176 }302 spender: &T::CrossAccountId,302 spender: &T::CrossAccountId,303 amount: u128,303 amount: u128,304 ) -> DispatchResult {304 ) -> DispatchResult {305 if collection.access == AccessMode::WhiteList {305 if collection.access == AccessMode::AllowList {306 collection.check_allowlist(&owner)?;306 collection.check_allowlist(&owner)?;307 collection.check_allowlist(&spender)?;307 collection.check_allowlist(&spender)?;308 }308 }330 if spender.conv_eq(from) {330 if spender.conv_eq(from) {331 return Self::transfer(collection, from, to, amount);331 return Self::transfer(collection, from, to, amount);332 }332 }333 if collection.access == AccessMode::WhiteList {333 if collection.access == AccessMode::AllowList {334 // `from`, `to` checked in [`transfer`]334 // `from`, `to` checked in [`transfer`]335 collection.check_allowlist(spender)?;335 collection.check_allowlist(spender)?;336 }336 }361 if spender.conv_eq(from) {361 if spender.conv_eq(from) {362 return Self::burn(collection, from, amount);362 return Self::burn(collection, from, amount);363 }363 }364 if collection.access == AccessMode::WhiteList {364 if collection.access == AccessMode::AllowList {365 // `from` checked in [`burn`]365 // `from` checked in [`burn`]366 collection.check_allowlist(spender)?;366 collection.check_allowlist(spender)?;367 }367 }pallets/nft-charge-transaction/Cargo.tomldiffbeforeafterbothno changes
pallets/nft-charge-transaction/src/lib.rsdiffbeforeafterbothno changes
pallets/nft-transaction-payment/Cargo.tomldiffbeforeafterboth30sp-io = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }30sp-io = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }31sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }31sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }323233up-sponsorship = { default-features = false, path = "../../primitives/sponsorship", version = "0.1.0" }33up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 343435[features]35[features]36default = ['std']36default = ['std']pallets/nft/Cargo.tomldiffbeforeafterboth126path = '../../primitives/nft'126path = '../../primitives/nft'127version = '0.9.0'127version = '0.9.0'128129[dependencies.up-sponsorship]130default-features = false131path = '../../primitives/sponsorship'132version = '0.1.0'133134128135[dependencies]129[dependencies]140rlp = { default-features = false, version = "0.5.0" }134rlp = { default-features = false, version = "0.5.0" }141sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.12" }135sp-api = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.12" }136137up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 142138143evm-coder = { default-features = false, path = "../../crates/evm-coder" }139evm-coder = { default-features = false, path = "../../crates/evm-coder" }144pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }140pallet-evm-coder-substrate = { default-features = false, path = "../../pallets/evm-coder-substrate" }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.rsdiffbeforeafterboth177 <CommonError<T>>::NoPermission177 <CommonError<T>>::NoPermission178 );178 );179179180 if collection.access == AccessMode::WhiteList {180 if collection.access == AccessMode::AllowList {181 collection.check_allowlist(sender)?;181 collection.check_allowlist(sender)?;182 }182 }183183235 <CommonError<T>>::NoPermission235 <CommonError<T>>::NoPermission236 );236 );237237238 if collection.access == AccessMode::WhiteList {238 if collection.access == AccessMode::AllowList {239 collection.check_allowlist(from)?;239 collection.check_allowlist(from)?;240 collection.check_allowlist(to)?;240 collection.check_allowlist(to)?;241 }241 }442 token: TokenId,442 token: TokenId,443 spender: Option<&T::CrossAccountId>,443 spender: Option<&T::CrossAccountId>,444 ) -> DispatchResult {444 ) -> DispatchResult {445 if collection.access == AccessMode::WhiteList {445 if collection.access == AccessMode::AllowList {446 collection.check_allowlist(&sender)?;446 collection.check_allowlist(&sender)?;447 if let Some(spender) = spender {447 if let Some(spender) = spender {448 collection.check_allowlist(&spender)?;448 collection.check_allowlist(&spender)?;477 if spender.conv_eq(from) {477 if spender.conv_eq(from) {478 return Self::transfer(collection, from, to, token);478 return Self::transfer(collection, from, to, token);479 }479 }480 if collection.access == AccessMode::WhiteList {480 if collection.access == AccessMode::AllowList {481 // `from`, `to` checked in [`transfer`]481 // `from`, `to` checked in [`transfer`]482 collection.check_allowlist(spender)?;482 collection.check_allowlist(spender)?;483 }483 }505 if spender.conv_eq(from) {505 if spender.conv_eq(from) {506 return Self::burn(collection, from, token);506 return Self::burn(collection, from, token);507 }507 }508 if collection.access == AccessMode::WhiteList {508 if collection.access == AccessMode::AllowList {509 // `from` checked in [`burn`]509 // `from` checked in [`burn`]510 collection.check_allowlist(spender)?;510 collection.check_allowlist(spender)?;511 }511 }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 }482 token: TokenId,482 token: TokenId,483 amount: u128,483 amount: u128,484 ) -> DispatchResult {484 ) -> DispatchResult {485 if collection.access == AccessMode::WhiteList {485 if collection.access == AccessMode::AllowList {486 collection.check_allowlist(&sender)?;486 collection.check_allowlist(&sender)?;487 collection.check_allowlist(&spender)?;487 collection.check_allowlist(&spender)?;488 }488 }513 if spender.conv_eq(from) {513 if spender.conv_eq(from) {514 return Self::transfer(collection, from, to, token, amount);514 return Self::transfer(collection, from, to, token, amount);515 }515 }516 if collection.access == AccessMode::WhiteList {516 if collection.access == AccessMode::AllowList {517 // `from`, `to` checked in [`transfer`]517 // `from`, `to` checked in [`transfer`]518 collection.check_allowlist(spender)?;518 collection.check_allowlist(spender)?;519 }519 }546 if spender.conv_eq(from) {546 if spender.conv_eq(from) {547 return Self::burn(collection, from, token, amount);547 return Self::burn(collection, from, token, amount);548 }548 }549 if collection.access == AccessMode::WhiteList {549 if collection.access == AccessMode::AllowList {550 // `from` checked in [`burn`]550 // `from` checked in [`burn`]551 collection.check_allowlist(spender)?;551 collection.check_allowlist(spender)?;552 }552 }pallets/scheduler/Cargo.tomldiffbeforeafterboth20sp-io = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }20sp-io = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }21frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }21frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }222223up-sponsorship = { default-features = false, path = "../../primitives/sponsorship", version = "0.1.0" }23up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 24log = { version = "0.4.14", default-features = false }24log = { version = "0.4.14", default-features = false }252526[dev-dependencies]26[dev-dependencies]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 {primitives/sponsorship/Cargo.tomldiffbeforeafterbothno changes
primitives/sponsorship/src/lib.rsdiffbeforeafterbothno changes
runtime/Cargo.tomldiffbeforeafterboth10license = 'All Rights Reserved'10license = 'All Rights Reserved'11name = 'nft-runtime'11name = 'nft-runtime'12repository = 'https://github.com/usetech-llc/nft_private/'12repository = 'https://github.com/usetech-llc/nft_private/'13version = '3.0.0'13version = '0.9.12'141415[package.metadata.docs.rs]15[package.metadata.docs.rs]16targets = ['x86_64-unknown-linux-gnu']16targets = ['x86_64-unknown-linux-gnu']381pallet-unq-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }381pallet-unq-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }382# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }382# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }383pallet-nft-transaction-payment = { path = '../pallets/nft-transaction-payment', default-features = false, version = '3.0.0' }383pallet-nft-transaction-payment = { path = '../pallets/nft-transaction-payment', default-features = false, version = '3.0.0' }384pallet-nft-charge-transaction = { path = '../pallets/nft-charge-transaction', default-features = false, version = '3.0.0' }384pallet-nft-charge-transaction = {git = "https://github.com/UniqueNetwork/pallet-sponsoring", package = "pallet-template-transaction-payment", default-features = false, version = '3.0.0' }385pallet-evm-migration = { path = '../pallets/evm-migration', default-features = false }385pallet-evm-migration = { path = '../pallets/evm-migration', default-features = false }386pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }386pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }387pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }387pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }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.rsdiffbeforeafterboth147 spec_name: create_runtime_str!("opal"),147 spec_name: create_runtime_str!("opal"),148 impl_name: create_runtime_str!("opal"),148 impl_name: create_runtime_str!("opal"),149 authoring_version: 1,149 authoring_version: 1,150 spec_version: 912200,150 spec_version: 912202,151 impl_version: 1,151 impl_version: 1,152 apis: RUNTIME_API_VERSIONS,152 apis: RUNTIME_API_VERSIONS,153 transaction_version: 1,153 transaction_version: 1,827}827}828828829impl pallet_nft_charge_transaction::Config for Runtime {}829impl pallet_nft_charge_transaction::Config for Runtime {830 type SponsorshipHandler = pallet_nft::NftSponsorshipHandler<Runtime>;831}830832831// impl pallet_contract_helpers::Config for Runtime {833// impl pallet_contract_helpers::Config for Runtime {1363 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1365 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1364 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};1366 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};136513671366 let whitelist: Vec<TrackedStorageKey> = vec![1368 let allowlist: Vec<TrackedStorageKey> = vec![1367 // Block Number1369 // Block Number1368 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),1370 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),1369 // Total Issuance1371 // Total Issuance1377 ];1379 ];137813801379 let mut batches = Vec::<BenchmarkBatch>::new();1381 let mut batches = Vec::<BenchmarkBatch>::new();1380 let params = (&config, &whitelist);1382 let params = (&config, &allowlist);138113831382 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1384 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1383 add_benchmark!(params, batches, pallet_nft, Nft);1385 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/block-production.test.tsdiffbeforeafterboth7import {expect} from 'chai';7import {expect} from 'chai';8import {ApiPromise} from '@polkadot/api';8import {ApiPromise} from '@polkadot/api';9910const BLOCK_TIME_MS = 3000;10const BLOCK_TIME_MS = 12000;11const TOLERANCE_MS = 1000;11const TOLERANCE_MS = 3000;121213/* eslint no-async-promise-executor: "off" */13/* eslint no-async-promise-executor: "off" */14function getBlocks(api: ApiPromise): Promise<number[]> {14function getBlocks(api: ApiPromise): Promise<number[]> {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/admVsOwnerChanges.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 createItemExpectSuccess,8import privateKey from '../substrate/privateKey';9 normalizeAccountId,9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10 waitNewBlocks,10import {11} from '../util/helpers';11 createCollectionExpectSuccess,1212 createItemExpectSuccess,13chai.use(chaiAsPromised);13 normalizeAccountId,14const expect = chai.expect;14 waitNewBlocks,15let Alice: IKeyringPair;15} from '../util/helpers';16let Bob: IKeyringPair;1617let Ferdie: IKeyringPair;17chai.use(chaiAsPromised);1818const expect = chai.expect;19before(async () => {19let Alice: IKeyringPair;20 await usingApi(async () => {20let Bob: IKeyringPair;21 Alice = privateKey('//Alice');21let Ferdie: IKeyringPair;22 Bob = privateKey('//Bob');2223 Ferdie = privateKey('//Ferdie');23before(async () => {24 });24 await usingApi(async () => {25});25 Alice = privateKey('//Alice');2626 Bob = privateKey('//Bob');27describe('Admin vs Owner changes token: ', () => {27 Ferdie = privateKey('//Ferdie');28 // tslint:disable-next-line: max-line-length28 });29 it('The collection admin changes the owner of the token and in the same block the current owner transfers the token to another address ', async () => {29});303031 await usingApi(async (api) => {31describe('Admin vs Owner changes token: ', () => {32 const collectionId = await createCollectionExpectSuccess();32 // tslint:disable-next-line: max-line-length33 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));33 it('The collection admin changes the owner of the token and in the same block the current owner transfers the token to another address ', async () => {34 await submitTransactionAsync(Alice, changeAdminTxBob);3435 const changeAdminTxFerdie = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));35 await usingApi(async (api) => {36 await submitTransactionAsync(Bob, changeAdminTxFerdie);36 const collectionId = await createCollectionExpectSuccess();37 const itemId = await createItemExpectSuccess(Ferdie, collectionId, 'NFT');37 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));3838 await submitTransactionAsync(Alice, changeAdminTxBob);39 const changeOwner = api.tx.nft.transferFrom(normalizeAccountId(Ferdie.address), normalizeAccountId(Bob.address), collectionId, itemId, 1);39 const changeAdminTxFerdie = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));40 const approve = api.tx.nft.approve(normalizeAccountId(Bob.address), collectionId, itemId, 1);40 await submitTransactionAsync(Bob, changeAdminTxFerdie);41 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);41 const itemId = await createItemExpectSuccess(Ferdie, collectionId, 'NFT');42 await Promise.all([4243 changeOwner.signAndSend(Alice),43 const changeOwner = api.tx.nft.transferFrom(normalizeAccountId(Ferdie.address), normalizeAccountId(Bob.address), collectionId, itemId, 1);44 approve.signAndSend(Bob),44 const approve = api.tx.nft.approve(normalizeAccountId(Bob.address), collectionId, itemId, 1);45 sendItem.signAndSend(Ferdie),45 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);46 ]);46 await Promise.all([47 const itemBefore: any = await api.query.nft.nftItemList(collectionId, itemId);47 changeOwner.signAndSend(Alice),48 expect(itemBefore.owner).not.to.be.eq(Bob.address);48 approve.signAndSend(Bob),49 await waitNewBlocks(2);49 sendItem.signAndSend(Ferdie),50 });50 ]);51 });51 const itemBefore: any = await api.query.nft.nftItemList(collectionId, itemId);52});52 expect(itemBefore.owner).not.to.be.eq(Bob.address);5353 await waitNewBlocks(2);54 });55 });56});57*/tests/src/collision-tests/admVsOwnerData.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 createItemExpectSuccess,8import privateKey from '../substrate/privateKey';9 normalizeAccountId,9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10 waitNewBlocks,10import {11} from '../util/helpers';11 createCollectionExpectSuccess,1212 createItemExpectSuccess,13chai.use(chaiAsPromised);13 normalizeAccountId,14const expect = chai.expect;14 waitNewBlocks,15let Alice: IKeyringPair;15} from '../util/helpers';16let Bob: IKeyringPair;161717chai.use(chaiAsPromised);18before(async () => {18const expect = chai.expect;19 await usingApi(async () => {19let Alice: IKeyringPair;20 Alice = privateKey('//Alice');20let Bob: IKeyringPair;21 Bob = privateKey('//Bob');2122 });22before(async () => {23});23 await usingApi(async () => {2424 Alice = privateKey('//Alice');25describe('Admin vs Owner changes the data in the token: ', () => {25 Bob = privateKey('//Bob');26 it('The collection admin changes the data in the token and in the same block the token owner also changes the data in it ', async () => {26 });27 await usingApi(async (api) => {27});28 const AliceData = 1;2829 const BobData = 2;29describe('Admin vs Owner changes the data in the token: ', () => {30 const collectionId = await createCollectionExpectSuccess();30 it('The collection admin changes the data in the token and in the same block the token owner also changes the data in it ', async () => {31 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));31 await usingApi(async (api) => {32 await submitTransactionAsync(Alice, changeAdminTx);32 const AliceData = 1;33 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');33 const BobData = 2;34 //34 const collectionId = await createCollectionExpectSuccess();35 // tslint:disable-next-line: max-line-length35 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));36 const AliceTx = api.tx.nft.setVariableMetaData(collectionId, itemId, AliceData.toString());36 await submitTransactionAsync(Alice, changeAdminTx);37 // tslint:disable-next-line: max-line-length37 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');38 const BobTx = api.tx.nft.setVariableMetaData(collectionId, itemId, BobData.toString());38 //39 await Promise.all([39 // tslint:disable-next-line: max-line-length40 AliceTx.signAndSend(Alice),40 const AliceTx = api.tx.nft.setVariableMetaData(collectionId, itemId, AliceData.toString());41 BobTx.signAndSend(Bob),41 // tslint:disable-next-line: max-line-length42 ]);42 const BobTx = api.tx.nft.setVariableMetaData(collectionId, itemId, BobData.toString());43 const item: any = await api.query.nft.nftItemList(collectionId, itemId);43 await Promise.all([44 expect(item.variableData).not.to.be.eq(null); // Pseudo-random selection of one of two values44 AliceTx.signAndSend(Alice),45 await waitNewBlocks(2);45 BobTx.signAndSend(Bob),46 });46 ]);47 });47 const item: any = await api.query.nft.nftItemList(collectionId, itemId);48});48 expect(item.variableData).not.to.be.eq(null); // Pseudo-random selection of one of two values4949 await waitNewBlocks(2);50 });51 });52});53*/tests/src/collision-tests/admVsOwnerTake.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 createItemExpectSuccess,8import privateKey from '../substrate/privateKey';9 normalizeAccountId,9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10 waitNewBlocks,10import {11} from '../util/helpers';11 createCollectionExpectSuccess,1212 createItemExpectSuccess,13chai.use(chaiAsPromised);13 normalizeAccountId,14const expect = chai.expect;14 waitNewBlocks,15let Alice: IKeyringPair;15} from '../util/helpers';16let Bob: IKeyringPair;1617let Ferdie: IKeyringPair;17chai.use(chaiAsPromised);1818const expect = chai.expect;19before(async () => {19let Alice: IKeyringPair;20 await usingApi(async () => {20let Bob: IKeyringPair;21 Alice = privateKey('//Alice');21let Ferdie: IKeyringPair;22 Bob = privateKey('//Bob');2223 Ferdie = privateKey('//Ferdie');23before(async () => {24 });24 await usingApi(async () => {25});25 Alice = privateKey('//Alice');2626 Bob = privateKey('//Bob');27describe('Admin vs Owner take token: ', () => {27 Ferdie = privateKey('//Ferdie');28 // tslint:disable-next-line: max-line-length28 });29 it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {29});30 await usingApi(async (api) => {3031 const collectionId = await createCollectionExpectSuccess();31describe('Admin vs Owner take token: ', () => {32 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));32 // tslint:disable-next-line: max-line-length33 await submitTransactionAsync(Alice, changeAdminTx);33 it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {34 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');34 await usingApi(async (api) => {35 //35 const collectionId = await createCollectionExpectSuccess();36 const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);36 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));37 const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);37 await submitTransactionAsync(Alice, changeAdminTx);38 await Promise.all([38 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');39 sendItem.signAndSend(Bob),39 //40 burnItem.signAndSend(Alice),40 const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);41 ]);41 const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);42 await waitNewBlocks(2);42 await Promise.all([43 let itemBurn = false;43 sendItem.signAndSend(Bob),44 itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;44 burnItem.signAndSend(Alice),45 // tslint:disable-next-line: no-unused-expression45 ]);46 expect(itemBurn).to.be.null;46 await waitNewBlocks(2);47 await waitNewBlocks(2);47 let itemBurn = false;48 });48 itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;49 });49 // tslint:disable-next-line: no-unused-expression50});50 expect(itemBurn).to.be.null;5151 await waitNewBlocks(2);52 });53 });54});55*/tests/src/collision-tests/adminDestroyCollection.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 normalizeAccountId,8import privateKey from '../substrate/privateKey';9 waitNewBlocks,9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10} from '../util/helpers';10import {1111 createCollectionExpectSuccess,12chai.use(chaiAsPromised);12 normalizeAccountId,13const expect = chai.expect;13 waitNewBlocks,14let Alice: IKeyringPair;14} from '../util/helpers';15let Bob: IKeyringPair;1516let Ferdie: IKeyringPair;16chai.use(chaiAsPromised);1717const expect = chai.expect;18before(async () => {18let Alice: IKeyringPair;19 await usingApi(async () => {19let Bob: IKeyringPair;20 Alice = privateKey('//Alice');20let Ferdie: IKeyringPair;21 Bob = privateKey('//Bob');2122 Ferdie = privateKey('//Ferdie');22before(async () => {23 });23 await usingApi(async () => {24});24 Alice = privateKey('//Alice');2525 Bob = privateKey('//Bob');26describe('Deleting a collection while add address to whitelist: ', () => {26 Ferdie = privateKey('//Ferdie');27 // tslint:disable-next-line: max-line-length27 });28 it('Adding an address to the collection whitelist in a block by the admin, and deleting the collection by the owner ', async () => {28});29 await usingApi(async (api) => {2930 const collectionId = await createCollectionExpectSuccess();30describe('Deleting a collection while add address to allowlist: ', () => {31 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));31 // tslint:disable-next-line: max-line-length32 await submitTransactionAsync(Alice, changeAdminTx);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 waitNewBlocks(1);33 await usingApi(async (api) => {34 //34 const collectionId = await createCollectionExpectSuccess();35 const addWhitelistAdm = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Ferdie.address));35 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));36 const destroyCollection = api.tx.nft.destroyCollection(collectionId);36 await submitTransactionAsync(Alice, changeAdminTx);37 await Promise.all([37 await waitNewBlocks(1);38 addWhitelistAdm.signAndSend(Bob),38 //39 destroyCollection.signAndSend(Alice),39 const addAllowlistAdm = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(Ferdie.address));40 ]);40 const destroyCollection = api.tx.nft.destroyCollection(collectionId);41 await waitNewBlocks(1);41 await Promise.all([42 let whiteList = false;42 addAllowlistAdm.signAndSend(Bob),43 whiteList = (await api.query.nft.whiteList(collectionId, Ferdie.address)).toJSON() as boolean;43 destroyCollection.signAndSend(Alice),44 // tslint:disable-next-line: no-unused-expression44 ]);45 expect(whiteList).to.be.false;45 await waitNewBlocks(1);46 await waitNewBlocks(2);46 let allowList = false;47 });47 allowList = (await api.query.nft.allowList(collectionId, Ferdie.address)).toJSON() as boolean;48 });48 // tslint:disable-next-line: no-unused-expression49});49 expect(allowList).to.be.false;5050 await waitNewBlocks(2);51 });52 });53});54*/tests/src/collision-tests/adminLimitsOff.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 normalizeAccountId,8import privateKey from '../substrate/privateKey';9 waitNewBlocks,9import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';10} from '../util/helpers';10import {1111 createCollectionExpectSuccess,12chai.use(chaiAsPromised);12 normalizeAccountId,13const expect = chai.expect;13 waitNewBlocks,14let Alice: IKeyringPair;14} from '../util/helpers';15let Bob: IKeyringPair;1516let Ferdie: IKeyringPair;16chai.use(chaiAsPromised);17let Charlie: IKeyringPair;17const expect = chai.expect;18let Eve: IKeyringPair;18let Alice: IKeyringPair;19let Dave: IKeyringPair;19let Bob: IKeyringPair;2020let Ferdie: IKeyringPair;21before(async () => {21let Charlie: IKeyringPair;22 await usingApi(async () => {22let Eve: IKeyringPair;23 Alice = privateKey('//Alice');23let Dave: IKeyringPair;24 Bob = privateKey('//Bob');2425 Ferdie = privateKey('//Ferdie');25before(async () => {26 Charlie = privateKey('//Charlie');26 await usingApi(async () => {27 Eve = privateKey('//Eve');27 Alice = privateKey('//Alice');28 Dave = privateKey('//Dave');28 Bob = privateKey('//Bob');29 });29 Ferdie = privateKey('//Ferdie');30});30 Charlie = privateKey('//Charlie');3131 Eve = privateKey('//Eve');32describe('Admin limit exceeded collection: ', () => {32 Dave = privateKey('//Dave');33 // tslint:disable-next-line: max-line-length33 });34 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {34});35 await usingApi(async (api) => {3536 const collectionId = await createCollectionExpectSuccess();36describe('Admin limit exceeded collection: ', () => {3737 // tslint:disable-next-line: max-line-length38 const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();38 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {39 expect(chainAdminLimit).to.be.equal(5);39 await usingApi(async (api) => {4040 const collectionId = await createCollectionExpectSuccess();41 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));4142 await submitTransactionAsync(Alice, changeAdminTx1);42 const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();43 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));43 expect(chainAdminLimit).to.be.equal(5);44 await submitTransactionAsync(Alice, changeAdminTx2);4445 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));45 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));46 await submitTransactionAsync(Alice, changeAdminTx3);46 await submitTransactionAsync(Alice, changeAdminTx1);4747 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));48 const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));48 await submitTransactionAsync(Alice, changeAdminTx2);49 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));49 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));50 await Promise.all([50 await submitTransactionAsync(Alice, changeAdminTx3);51 addAdmOne.signAndSend(Bob),5152 addAdmTwo.signAndSend(Alice),52 const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));53 ]);53 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));54 await waitNewBlocks(2);54 await Promise.all([55 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));55 addAdmOne.signAndSend(Bob),56 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;56 addAdmTwo.signAndSend(Alice),5757 ]);58 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));58 await waitNewBlocks(2);59 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));59 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));60 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));60 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;61 expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));6162 await waitNewBlocks(2);62 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));63 });63 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));64 });64 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));65});65 expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));6666 await waitNewBlocks(2);67 });68 });69});70*/tests/src/collision-tests/adminRightsOff.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import BN from 'bn.js';2// substrate transactions are sequential, not parallel3import chai from 'chai';3// the order of execution is indeterminate4import chaiAsPromised from 'chai-as-promised';45import privateKey from '../substrate/privateKey';5import { IKeyringPair } from '@polkadot/types/types';6import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';6import BN from 'bn.js';7import {7import chai from 'chai';8 createCollectionExpectSuccess,8import chaiAsPromised from 'chai-as-promised';9 normalizeAccountId,9import privateKey from '../substrate/privateKey';10 waitNewBlocks,10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';11} from '../util/helpers';11import {1212 createCollectionExpectSuccess,13chai.use(chaiAsPromised);13 normalizeAccountId,14const expect = chai.expect;14 waitNewBlocks,15let Alice: IKeyringPair;15} from '../util/helpers';16let Bob: IKeyringPair;161717chai.use(chaiAsPromised);18before(async () => {18const expect = chai.expect;19 await usingApi(async () => {19let Alice: IKeyringPair;20 Alice = privateKey('//Alice');20let Bob: IKeyringPair;21 Bob = privateKey('//Bob');2122 });22before(async () => {23});23 await usingApi(async () => {2424 Alice = privateKey('//Alice');25describe('Deprivation of admin rights: ', () => {25 Bob = privateKey('//Bob');26 // tslint:disable-next-line: max-line-length26 });27 it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {27});28 await usingApi(async (api) => {2829 const collectionId = await createCollectionExpectSuccess();29describe('Deprivation of admin rights: ', () => {30 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));30 // tslint:disable-next-line: max-line-length31 await submitTransactionAsync(Alice, changeAdminTx);31 it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {32 await waitNewBlocks(1);32 await usingApi(async (api) => {33 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];33 const collectionId = await createCollectionExpectSuccess();34 const addItemAdm = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);34 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));35 const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));35 await submitTransactionAsync(Alice, changeAdminTx);36 await Promise.all([36 await waitNewBlocks(1);37 addItemAdm.signAndSend(Bob),37 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];38 removeAdm.signAndSend(Alice),38 const addItemAdm = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);39 ]);39 const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));40 await waitNewBlocks(2);40 await Promise.all([41 const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;41 addItemAdm.signAndSend(Bob),42 expect(itemsListIndex.toNumber()).to.be.equal(0);42 removeAdm.signAndSend(Alice),43 const adminList: any = (await api.query.nft.adminList(collectionId));43 ]);44 expect(adminList).not.to.be.contains(normalizeAccountId(Bob.address));44 await waitNewBlocks(2);45 await waitNewBlocks(2);45 const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;46 });46 expect(itemsListIndex.toNumber()).to.be.equal(0);47 });47 const adminList: any = (await api.query.nft.adminList(collectionId));48});48 expect(adminList).not.to.be.contains(normalizeAccountId(Bob.address));4949 await waitNewBlocks(2);50 });51 });52});53*/tests/src/collision-tests/setSponsorNewOwner.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 createCollectionExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 setCollectionSponsorExpectSuccess,8import privateKey from '../substrate/privateKey';9 waitNewBlocks,9import usingApi from '../substrate/substrate-api';10} from '../util/helpers';10import {1111 createCollectionExpectSuccess,12chai.use(chaiAsPromised);12 setCollectionSponsorExpectSuccess,13const expect = chai.expect;13 waitNewBlocks,14let Alice: IKeyringPair;14} from '../util/helpers';15let Bob: IKeyringPair;1516let Ferdie: IKeyringPair;16chai.use(chaiAsPromised);1717const expect = chai.expect;18before(async () => {18let Alice: IKeyringPair;19 await usingApi(async () => {19let Bob: IKeyringPair;20 Alice = privateKey('//Alice');20let Ferdie: IKeyringPair;21 Bob = privateKey('//Bob');2122 Ferdie = privateKey('//Ferdie');22before(async () => {23 });23 await usingApi(async () => {24});24 Alice = privateKey('//Alice');2525 Bob = privateKey('//Bob');26describe('Sponsored with new owner ', () => {26 Ferdie = privateKey('//Ferdie');27 // tslint:disable-next-line: max-line-length27 });28 it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {28});29 await usingApi(async (api) => {2930 const collectionId = await createCollectionExpectSuccess();30describe('Sponsored with new owner ', () => {31 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);31 // tslint:disable-next-line: max-line-length32 await waitNewBlocks(2);32 it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {33 const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);33 await usingApi(async (api) => {34 const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);34 const collectionId = await createCollectionExpectSuccess();35 await Promise.all([35 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);36 confirmSponsorship.signAndSend(Bob),36 await waitNewBlocks(2);37 changeCollectionOwner.signAndSend(Alice),37 const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);38 ]);38 const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);39 await waitNewBlocks(2);39 await Promise.all([40 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();40 confirmSponsorship.signAndSend(Bob),41 expect(collection.sponsorship.confirmed).to.be.eq(Bob.address);41 changeCollectionOwner.signAndSend(Alice),42 expect(collection.owner).to.be.eq(Ferdie.address);42 ]);43 await waitNewBlocks(2);43 await waitNewBlocks(2);44 });44 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();45 });45 expect(collection.sponsorship.confirmed).to.be.eq(Bob.address);46});46 expect(collection.owner).to.be.eq(Ferdie.address);4747 await waitNewBlocks(2);48 });49 });50});51*/tests/src/collision-tests/sponsorPayments.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import { alicesPublicKey, bobsPublicKey } from '../accounts';45import getBalance from '../substrate/get-balance';5import { IKeyringPair } from '@polkadot/types/types';6import privateKey from '../substrate/privateKey';6import chai from 'chai';7import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';7import chaiAsPromised from 'chai-as-promised';8import {8import { alicesPublicKey, bobsPublicKey } from '../accounts';9 confirmSponsorshipExpectSuccess,9import getBalance from '../substrate/get-balance';10 createCollectionExpectSuccess,10import privateKey from '../substrate/privateKey';11 createItemExpectSuccess,11import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';12 setCollectionSponsorExpectSuccess,12import {13 normalizeAccountId,13 confirmSponsorshipExpectSuccess,14 waitNewBlocks,14 createCollectionExpectSuccess,15} from '../util/helpers';15 createItemExpectSuccess,1616 setCollectionSponsorExpectSuccess,17chai.use(chaiAsPromised);17 normalizeAccountId,18const expect = chai.expect;18 waitNewBlocks,19let Alice: IKeyringPair;19} from '../util/helpers';20let Bob: IKeyringPair;202121chai.use(chaiAsPromised);22before(async () => {22const expect = chai.expect;23 await usingApi(async () => {23let Alice: IKeyringPair;24 Alice = privateKey('//Alice');24let Bob: IKeyringPair;25 Bob = privateKey('//Bob');2526 });26before(async () => {27});27 await usingApi(async () => {2828 Alice = privateKey('//Alice');29describe('Payment of commission if one block: ', () => {29 Bob = privateKey('//Bob');30 // tslint:disable-next-line: max-line-length30 });31 it('Payment of commission if one block contains transactions for payment from the sponsor\'s balance and his (sponsor\'s) exclusion from the collection ', async () => {31});32 await usingApi(async (api) => {3233 const collectionId = await createCollectionExpectSuccess();33describe('Payment of commission if one block: ', () => {34 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));34 // tslint:disable-next-line: max-line-length35 await submitTransactionAsync(Alice, changeAdminTxBob);35 it('Payment of commission if one block contains transactions for payment from the sponsor\'s balance and his (sponsor\'s) exclusion from the collection ', async () => {36 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');36 await usingApi(async (api) => {37 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);37 const collectionId = await createCollectionExpectSuccess();38 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');38 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));3939 await submitTransactionAsync(Alice, changeAdminTxBob);40 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);40 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');41 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);41 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);42 const revokeSponsor = api.tx.nft.removeCollectionSponsor(collectionId);42 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');43 await Promise.all([4344 sendItem.signAndSend(Bob),44 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);45 revokeSponsor.signAndSend(Alice),45 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);46 ]);46 const revokeSponsor = api.tx.nft.removeCollectionSponsor(collectionId);47 const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);47 await Promise.all([48 // tslint:disable-next-line:no-unused-expression48 sendItem.signAndSend(Bob),49 expect(alicesBalanceAfter === alicesBalanceBefore).to.be.true;49 revokeSponsor.signAndSend(Alice),50 // tslint:disable-next-line:no-unused-expression50 ]);51 expect(bobsBalanceAfter === bobsBalanceBefore).to.be.true;51 const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);52 await waitNewBlocks(2);52 // tslint:disable-next-line:no-unused-expression53 });53 expect(alicesBalanceAfter === alicesBalanceBefore).to.be.true;54 });54 // tslint:disable-next-line:no-unused-expression55});55 expect(bobsBalanceAfter === bobsBalanceBefore).to.be.true;5656 await waitNewBlocks(2);57 });58 });59});60*/tests/src/collision-tests/tokenLimitsOff.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import BN from 'bn.js';2// substrate transactions are sequential, not parallel3import chai from 'chai';3// the order of execution is indeterminate4import chaiAsPromised from 'chai-as-promised';45import privateKey from '../substrate/privateKey';5import { IKeyringPair } from '@polkadot/types/types';6import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';6import BN from 'bn.js';7import {7import chai from 'chai';8 addToWhiteListExpectSuccess,8import chaiAsPromised from 'chai-as-promised';9 createCollectionExpectSuccess,9import privateKey from '../substrate/privateKey';10 getCreateItemResult,10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';11 setMintPermissionExpectSuccess,11import {12 normalizeAccountId,12 addToAllowListExpectSuccess,13 waitNewBlocks,13 createCollectionExpectSuccess,14} from '../util/helpers';14 getCreateItemResult,1515 setMintPermissionExpectSuccess,16chai.use(chaiAsPromised);16 normalizeAccountId,17const expect = chai.expect;17 waitNewBlocks,18let Alice: IKeyringPair;18} from '../util/helpers';19let Bob: IKeyringPair;1920let Ferdie: IKeyringPair;20chai.use(chaiAsPromised);2121const expect = chai.expect;22const accountTokenOwnershipLimit = 4;22let Alice: IKeyringPair;23const sponsoredMintSize = 4294967295;23let Bob: IKeyringPair;24const tokenLimit = 4;24let Ferdie: IKeyringPair;25const sponsorTimeout = 14400;2526const ownerCanTransfer = false;26const accountTokenOwnershipLimit = 4;27const ownerCanDestroy = false;27const sponsoredMintSize = 4294967295;2828const tokenLimit = 4;29before(async () => {29const sponsorTimeout = 14400;30 await usingApi(async () => {30const ownerCanTransfer = false;31 Alice = privateKey('//Alice');31const ownerCanDestroy = false;32 Bob = privateKey('//Bob');3233 Ferdie = privateKey('//Ferdie');33before(async () => {34 });34 await usingApi(async () => {35});35 Alice = privateKey('//Alice');3636 Bob = privateKey('//Bob');37describe('Token limit exceeded collection: ', () => {37 Ferdie = privateKey('//Ferdie');38 // tslint:disable-next-line: max-line-length38 });39 it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {39});40 await usingApi(async (api) => {4041 const collectionId = await createCollectionExpectSuccess();41describe('Token limit exceeded collection: ', () => {42 await setMintPermissionExpectSuccess(Alice, collectionId, true);42 // tslint:disable-next-line: max-line-length43 await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);43 it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {44 await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);44 await usingApi(async (api) => {45 const setCollectionLim = api.tx.nft.setCollectionLimits(45 const collectionId = await createCollectionExpectSuccess();46 collectionId,46 await setMintPermissionExpectSuccess(Alice, collectionId, true);47 {47 await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);48 accountTokenOwnershipLimit,48 await addToAllowListExpectSuccess(Alice, collectionId, Bob.address);49 sponsoredMintSize,49 const setCollectionLim = api.tx.nft.setCollectionLimits(50 tokenLimit,50 collectionId,51 // tslint:disable-next-line: object-literal-sort-keys51 {52 sponsorTimeout,52 accountTokenOwnershipLimit,53 ownerCanTransfer,53 sponsoredMintSize,54 ownerCanDestroy,54 tokenLimit,55 },55 // tslint:disable-next-line: object-literal-sort-keys56 );56 sponsorTimeout,57 const subTx = await submitTransactionAsync(Alice, setCollectionLim);57 ownerCanTransfer,58 const subTxTesult = getCreateItemResult(subTx);58 ownerCanDestroy,59 // tslint:disable-next-line:no-unused-expression59 },60 expect(subTxTesult.success).to.be.true;60 );61 await waitNewBlocks(2);61 const subTx = await submitTransactionAsync(Alice, setCollectionLim);6262 const subTxTesult = getCreateItemResult(subTx);63 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];63 // tslint:disable-next-line:no-unused-expression64 const mintItemOne = api.tx.nft64 expect(subTxTesult.success).to.be.true;65 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);65 await waitNewBlocks(2);66 const mintItemTwo = api.tx.nft6667 .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);67 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];68 await Promise.all([68 const mintItemOne = api.tx.nft69 mintItemOne.signAndSend(Ferdie),69 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);70 mintItemTwo.signAndSend(Bob),70 const mintItemTwo = api.tx.nft71 ]);71 .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);72 await waitNewBlocks(2);72 await Promise.all([73 const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;73 mintItemOne.signAndSend(Ferdie),74 expect(itemsListIndexAfter.toNumber()).to.be.equal(3);74 mintItemTwo.signAndSend(Bob),75 // TokenLimit = 4. The first transaction is successful. The second should fail.75 ]);76 await waitNewBlocks(2);76 await waitNewBlocks(2);77 });77 const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;78 });78 expect(itemsListIndexAfter.toNumber()).to.be.equal(3);79});79 // TokenLimit = 4. The first transaction is successful. The second should fail.80 await waitNewBlocks(2);81 });82 });83});84*/8085tests/src/collision-tests/turnsOffMinting.test.tsdiffbeforeafterboth1import { IKeyringPair } from '@polkadot/types/types';1/* broken by design2import chai from 'chai';2// substrate transactions are sequential, not parallel3import chaiAsPromised from 'chai-as-promised';3// the order of execution is indeterminate4import privateKey from '../substrate/privateKey';45import usingApi from '../substrate/substrate-api';5import { IKeyringPair } from '@polkadot/types/types';6import {6import chai from 'chai';7 addToWhiteListExpectSuccess,7import chaiAsPromised from 'chai-as-promised';8 createCollectionExpectSuccess,8import privateKey from '../substrate/privateKey';9 setMintPermissionExpectSuccess,9import usingApi from '../substrate/substrate-api';10 normalizeAccountId,10import {11 waitNewBlocks,11 addToAllowListExpectSuccess,12} from '../util/helpers';12 createCollectionExpectSuccess,1313 setMintPermissionExpectSuccess,14chai.use(chaiAsPromised);14 normalizeAccountId,15const expect = chai.expect;15 waitNewBlocks,16let Alice: IKeyringPair;16} from '../util/helpers';17let Ferdie: IKeyringPair;171818chai.use(chaiAsPromised);19before(async () => {19const expect = chai.expect;20 await usingApi(async () => {20let Alice: IKeyringPair;21 Alice = privateKey('//Alice');21let Ferdie: IKeyringPair;22 Ferdie = privateKey('//Ferdie');2223 });23before(async () => {24});24 await usingApi(async () => {2525 Alice = privateKey('//Alice');26describe('Turns off minting mode: ', () => {26 Ferdie = privateKey('//Ferdie');27 // tslint:disable-next-line: max-line-length27 });28 it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {28});29 await usingApi(async (api) => {2930 const collectionId = await createCollectionExpectSuccess();30describe('Turns off minting mode: ', () => {31 await setMintPermissionExpectSuccess(Alice, collectionId, true);31 // tslint:disable-next-line: max-line-length32 await addToWhiteListExpectSuccess(Alice, collectionId, Ferdie.address);32 it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {3333 await usingApi(async (api) => {34 const mintItem = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');34 const collectionId = await createCollectionExpectSuccess();35 const offMinting = api.tx.nft.setMintPermission(collectionId, false);35 await setMintPermissionExpectSuccess(Alice, collectionId, true);36 await Promise.all([36 await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);37 mintItem.signAndSend(Ferdie),3738 offMinting.signAndSend(Alice),38 const mintItem = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');39 ]);39 const offMinting = api.tx.nft.setMintPermission(collectionId, false);40 let itemList = false;40 await Promise.all([41 itemList = (await (api.query.nft.nftItemList(collectionId, mintItem))).toJSON() as boolean;41 mintItem.signAndSend(Ferdie),42 // tslint:disable-next-line: no-unused-expression42 offMinting.signAndSend(Alice),43 expect(itemList).to.be.null;43 ]);44 await waitNewBlocks(2);44 let itemList = false;45 });45 itemList = (await (api.query.nft.nftItemList(collectionId, mintItem))).toJSON() as boolean;46 });46 // tslint:disable-next-line: no-unused-expression47});47 expect(itemList).to.be.null;4848 await waitNewBlocks(2);49 });50 });51});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);643643104710471048export async function setPublicAccessModeExpectSuccess(1048export async function setPublicAccessModeExpectSuccess(1049 sender: IKeyringPair, collectionId: number,1049 sender: IKeyringPair, collectionId: number,1050 accessMode: 'Normal' | 'WhiteList',1050 accessMode: 'Normal' | 'AllowList',1051) {1051) {1052 await usingApi(async (api) => {1052 await usingApi(async (api) => {10531053106810681069export async function setPublicAccessModeExpectFail(1069export async function setPublicAccessModeExpectFail(1070 sender: IKeyringPair, collectionId: number,1070 sender: IKeyringPair, collectionId: number,1071 accessMode: 'Normal' | 'WhiteList',1071 accessMode: 'Normal' | 'AllowList',1072) {1072) {1073 await usingApi(async (api) => {1073 await usingApi(async (api) => {107410741083 });1083 });1084}1084}108510851086export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1086export async function enableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1087 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');1087 await setPublicAccessModeExpectSuccess(sender, collectionId, 'AllowList');1088}1088}108910891090export async function enableWhiteListExpectFail(sender: IKeyringPair, collectionId: number) {1090export async function enableAllowListExpectFail(sender: IKeyringPair, collectionId: number) {1091 await setPublicAccessModeExpectFail(sender, collectionId, 'WhiteList');1091 await setPublicAccessModeExpectFail(sender, collectionId, 'AllowList');1092}1092}109310931094export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {1094export async function disableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1095 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1095 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1096}1096}109710971137 });1137 });1138}1138}113911391140export async function isWhitelisted(collectionId: number, address: string | CrossAccountId) {1140export async function isAllowlisted(collectionId: number, address: string | CrossAccountId) {1141 return await usingApi(async (api) => {1141 return await usingApi(async (api) => {1142 return (await api.query.common.allowlist(collectionId, normalizeAccountId(address))).toJSON();1142 return (await api.query.common.allowlist(collectionId, normalizeAccountId(address))).toJSON();1143 });1143 });1144}1144}114511451146export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1146export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1147 await usingApi(async (api) => {1147 await usingApi(async (api) => {1148 expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.false;1148 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.false;114911491150 // Run the transaction1150 // Run the transaction1151 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));1151 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1152 const events = await submitTransactionAsync(sender, tx);1152 const events = await submitTransactionAsync(sender, tx);1153 const result = getGenericResult(events);1153 const result = getGenericResult(events);1154 expect(result.success).to.be.true;1154 expect(result.success).to.be.true;115511551156 expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.true;1156 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.true;1157 });1157 });1158}1158}115911591160export async function addToWhiteListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1160export async function addToAllowListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1161 await usingApi(async (api) => {1161 await usingApi(async (api) => {116211621163 expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.true;1163 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.true;116411641165 // Run the transaction1165 // Run the transaction1166 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));1166 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1167 const events = await submitTransactionAsync(sender, tx);1167 const events = await submitTransactionAsync(sender, tx);1168 const result = getGenericResult(events);1168 const result = getGenericResult(events);1169 expect(result.success).to.be.true;1169 expect(result.success).to.be.true;117011701171 expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.true;1171 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.true;1172 });1172 });1173}1173}117411741175export async function addToWhiteListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1175export async function addToAllowListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1176 await usingApi(async (api) => {1176 await usingApi(async (api) => {117711771178 // Run the transaction1178 // Run the transaction1179 const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));1179 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1180 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1180 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1181 const result = getGenericResult(events);1181 const result = getGenericResult(events);118211821186 });1186 });1187}1187}118811881189export async function removeFromWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1189export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1190 await usingApi(async (api) => {1190 await usingApi(async (api) => {1191 // Run the transaction1191 // Run the transaction1192 const tx = api.tx.nft.removeFromWhiteList(collectionId, normalizeAccountId(address));1192 const tx = api.tx.nft.removeFromAllowList(collectionId, normalizeAccountId(address));1193 const events = await submitTransactionAsync(sender, tx);1193 const events = await submitTransactionAsync(sender, tx);1194 const result = getGenericResult(events);1194 const result = getGenericResult(events);119511951199 });1199 });1200}1200}120112011202export async function removeFromWhiteListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1202export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1203 await usingApi(async (api) => {1203 await usingApi(async (api) => {1204 // Run the transaction1204 // Run the transaction1205 const tx = api.tx.nft.removeFromWhiteList(collectionId, normalizeAccountId(address));1205 const tx = api.tx.nft.removeFromAllowList(collectionId, normalizeAccountId(address));1206 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1206 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1207 const result = getGenericResult(events);1207 const result = getGenericResult(events);12081208tests/src/whiteLists.test.tsdiffbeforeafterbothno changes