difftreelog
rename: unique brand
in: master
111 files changed
.envdiffbeforeafterboth1RUST_TOOLCHAIN=nightly-2021-06-281RUST_TOOLCHAIN=nightly-2021-06-282RUST_C=1.55.0-nightly2RUST_C=1.55.0-nightly3POLKA_VERSION=v0.9.123POLKA_VERSION=v0.9.124NFT_BRANCH=develop4UNIQUE_BRANCH=develop5USER=***5USER=***6PASS=***6PASS=***77Dockerfile-parachaindiffbeforeafterboth5ARG RUST_TOOLCHAIN=nightly-2021-06-285ARG RUST_TOOLCHAIN=nightly-2021-06-286#ARG RUST_C=1.55.0-nightly6#ARG RUST_C=1.55.0-nightly7ARG POLKA_VERSION=v0.9.127ARG POLKA_VERSION=v0.9.128ARG NFT_BRANCH=develop8ARG UNIQUE_BRANCH=develop9910#ARG USER=***10#ARG USER=***11#ARG PASS=***11#ARG PASS=***14ENV RUST_TOOLCHAIN $RUST_TOOLCHAIN14ENV RUST_TOOLCHAIN $RUST_TOOLCHAIN15#ENV RUST_C $RUST_C15#ENV RUST_C $RUST_C16ENV POLKA_VERSION $POLKA_VERSION16ENV POLKA_VERSION $POLKA_VERSION17ENV NFT_BRANCH $NFT_BRANCH17ENV UNIQUE_BRANCH $UNIQUE_BRANCH1818191920#RUN echo $RUST_TOOLCHAIN20#RUN echo $RUST_TOOLCHAIN21#RUN echo $RUST_C21#RUN echo $RUST_C22#RUN echo $POLKA_VERSION22#RUN echo $POLKA_VERSION23#RUN echo $NFT_BRANCH23#RUN echo $UNIQUE_BRANCH242425ENV CARGO_HOME="/cargo-home"25ENV CARGO_HOME="/cargo-home"26ENV PATH="/cargo-home/bin:$PATH"26ENV PATH="/cargo-home/bin:$PATH"404041RUN cargo install cargo-chef41RUN cargo install cargo-chef424243RUN mkdir nft_parachain43RUN mkdir unique_parachain44WORKDIR /nft_parachain44WORKDIR /unique_parachain454546# ===== Chef =====46# ===== Chef =====47FROM rust-builder as chef47FROM rust-builder as chef52# ===== BUILD ======52# ===== BUILD ======53FROM rust-builder as builder53FROM rust-builder as builder545455RUN mkdir nft_parachain55RUN mkdir unique_parachain56WORKDIR /nft_parachain56WORKDIR /unique_parachain575758COPY --from=chef /nft_parachain/recipe.json recipe.json58COPY --from=chef /unique_parachain/recipe.json recipe.json59ARG PROFILE=release59ARG PROFILE=release60RUN cargo chef cook "--$PROFILE" --recipe-path recipe.json60RUN cargo chef cook "--$PROFILE" --recipe-path recipe.json616167# ===== BUILD POLKADOT =====67# ===== BUILD POLKADOT =====68FROM rust-builder as builder-polkadot68FROM rust-builder as builder-polkadot696970RUN mkdir nft_parachain70RUN mkdir unique_parachain71WORKDIR /nft_parachain71WORKDIR /unique_parachain727273RUN git clone -b $POLKA_VERSION --depth 1 https://github.com/paritytech/polkadot.git && \73RUN git clone -b $POLKA_VERSION --depth 1 https://github.com/paritytech/polkadot.git && \74 cd polkadot && \74 cd polkadot && \98 npm install --global yarn && \98 npm install --global yarn && \99 yarn99 yarn100100101COPY --from=builder /nft_parachain/target/$PROFILE/nft /unique-chain/target/$PROFILE/101COPY --from=builder /unique_parachain/target/$PROFILE/unique-collator /unique-chain/target/$PROFILE/102COPY --from=builder-polkadot /nft_parachain/polkadot/target/$PROFILE/polkadot /polkadot/target/$PROFILE/102COPY --from=builder-polkadot /unique_parachain/polkadot/target/$PROFILE/polkadot /polkadot/target/$PROFILE/103103104CMD export NVM_DIR="$HOME/.nvm" && \104CMD export NVM_DIR="$HOME/.nvm" && \105 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \105 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \Makefilediffbeforeafterboth4 @echo "evm_stubs - recompile contract stubs"4 @echo "evm_stubs - recompile contract stubs"5 @echo "bench - run frame-benchmarking"5 @echo "bench - run frame-benchmarking"6 @echo " bench-evm-migration"6 @echo " bench-evm-migration"7 @echo " bench-nft"7 @echo " bench-unique"889.PHONY: regenerate_solidity9.PHONY: regenerate_solidity10regenerate_solidity:10regenerate_solidity:41bench-evm-migration:41bench-evm-migration:42 make _bench PALLET=evm-migration42 make _bench PALLET=evm-migration434344.PHONY: bench-nft44.PHONY: bench-unique45bench-nft:45bench-unique:46 make _bench PALLET=nft46 make _bench PALLET=unique474748.PHONY: bench-fungible48.PHONY: bench-fungible49bench-fungible:49bench-fungible:58 make _bench PALLET=nonfungible58 make _bench PALLET=nonfungible595960.PHONY: bench60.PHONY: bench61bench: bench-evm-migration bench-nft bench-fungible bench-refungible bench-nonfungible61bench: bench-evm-migration bench-unique bench-fungible bench-refungible bench-nonfungible6262README.mddiffbeforeafterboth11223# NFT Parachain3# Unique Parachain445## Project Description5## Project Description667The NFT Pallet is the core of NFT functionality. Like ERC-721 standard in Ethereum ecosystem, this pallet provides the7The Unique Pallet is the core of NFT functionality. Like ERC-721 standard in Ethereum ecosystem, this pallet provides the8basement for creating collections of unique non-divisible things, also called Non Fungible Tokens (NFTs), minting NFT of8basement for creating collections of unique non-divisible things, also called Non Fungible Tokens (NFTs), minting NFT of9a given Collection, and managing their ownership.9a given Collection, and managing their ownership.101011The pallet also enables storing NFT properties. Though (according to ERC-721) NFT properties belong to logic of a11The pallet also enables storing NFT properties. Though (according to ERC-721) NFT properties belong to logic of a12concrete application that operates a Collection, so purposefully the NFT Tracking Module does not have any knowledge12concrete application that operates a Collection, so purposefully the NFT Tracking Module does not have any knowledge13about properties except their byte size leaving application logic out to be controlled by Smart Contracts.13about properties except their byte size leaving application logic out to be controlled by Smart Contracts.141415The NFT Chain also provides:15The Unique Chain also provides:161617- Smart Contracts Pallet and example smart contract that interacts with NFT Runtime17- Smart Contracts Pallet and example smart contract that interacts with Unique Runtime18- ERC-1155 Functionality (currently PoC as Re-Fungible tokens, i.e. items that are still unique, but that can be split18- ERC-1155 Functionality (currently PoC as Re-Fungible tokens, i.e. items that are still unique, but that can be split19 between multiple users)19 between multiple users)20- Variety of economic options for dapp producers to choose from to create freemium games and other ways to attract20- Variety of economic options for dapp producers to choose from to create freemium games and other ways to attract21 users. As a step one, we implemented an economic model when a collection sponsor can be set to pay for collection21 users. As a step one, we implemented an economic model when a collection sponsor can be set to pay for collection22 Transfer transactions.22 Transfer transactions.232324Wider NFT Ecosystem (most of it was developed during Hackusama):24Wider Unique Ecosystem (most of it was developed during Hackusama):252526- [SubstraPunks Game hosted on IPFS](https://github.com/usetech-llc/substrapunks)26- [SubstraPunks Game hosted on IPFS](https://github.com/usetech-llc/substrapunks)27- [NFT Wallet and UI](https://uniqueapps.usetech.com/#/nft)27- [Unique Wallet and UI](https://uniqueapps.usetech.com/#/nft)28- [NFT Asset for Unity Framework](https://github.com/usetech-llc/nft_unity)28- [NFT Asset for Unity Framework](https://github.com/usetech-llc/nft_unity)292930Please see our [walk-thorugh instructions](doc/hackusama_walk_through.md) to try everything out!30Please see our [walk-thorugh instructions](doc/hackusama_walk_through.md) to try everything out!34During the Kusama Hackaphon the following changes were made:34During the Kusama Hackaphon the following changes were made:353536- Enabled Smart Contracts Pallet36- Enabled Smart Contracts Pallet37- Enabled integration between Smart Contracts and NFT Pallet (required special edition of RC4 Substrate version)37- Enabled integration between Smart Contracts and Unique Pallet (required special edition of RC4 Substrate version)38- Fixed misc. bugs in NFT Pallet38- Fixed misc. bugs in Unique Pallet39- Deployed NFT TestNet. Public node available at wss://unique.usetech.com, custom UI types - see below in this README.39- Deployed Unique TestNet. Public node available at wss://unique.usetech.com, custom UI types - see below in this README.40- New Features:40- New Features:41 - 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 - Allow 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 Unique Testnet46 Blockchain.46 Blockchain.474748## Application Development48## Application Development515152## Building52## Building535354Building NFT chain requires special versions of Rust and toolchain. We don't use the most recent versions of everything54Building Unique chain requires special versions of Rust and toolchain. We don't use the most recent versions of everything55so that we can keep the builds stable.55so that we can keep the builds stable.5656571. Install Rust:571. Install Rust:168168169```169```1701701713. Export genesis state and runtime wasm from NFT parachain:1713. Export genesis state and runtime wasm from Unique parachain:172172173Run from this project root:173Run from this project root:174```174```175./target/release/nft export-genesis-state --parachain-id 2000 > ./resources/para-2000-genesis175./target/release/unique-collator export-genesis-state --parachain-id 2000 > ./resources/para-2000-genesis176./target/release/nft export-genesis-wasm > ./resources/para-2000-wasm176./target/release/unique-collator export-genesis-wasm > ./resources/para-2000-wasm177```177```1781781794. Run two parachain nodes:1794. Run two parachain nodes:182182183Run from this project root:183Run from this project root:184```184```185./target/release/nft --alice --collator --force-authoring --base-path ./tmp/parachain-alice --parachain-id 2000 --port 40333 --ws-port 9844 -- --execution wasm --chain ../polkadot/rococo-custom-4.json --port 30343 --ws-port 9977185./target/release/unique-collator --alice --collator --force-authoring --base-path ./tmp/parachain-alice --parachain-id 2000 --port 40333 --ws-port 9844 -- --execution wasm --chain ../polkadot/rococo-custom-4.json --port 30343 --ws-port 9977186./target/release/nft --bob --collator --force-authoring --parachain-id 2000 --base-path ./tmp/parachain/bob --port 40334 --ws-port 9845 -- --execution wasm --chain ../polkadot/rococo-custom-4.json --port 30344 --ws-port 9978 --bootnodes /ip4/127.0.0.1/tcp/50556/p2p/12D3KooWN1ah2bFQSysEFnwZqcmcVpDDR8UedXyo6xfzV1zDNMNg186./target/release/unique-collator --bob --collator --force-authoring --parachain-id 2000 --base-path ./tmp/parachain/bob --port 40334 --ws-port 9845 -- --execution wasm --chain ../polkadot/rococo-custom-4.json --port 30344 --ws-port 9978 --bootnodes /ip4/127.0.0.1/tcp/50556/p2p/12D3KooWN1ah2bFQSysEFnwZqcmcVpDDR8UedXyo6xfzV1zDNMNg187```187```1881881894. Reserve parachain ID as described here: https://substrate.dev/cumulus-workshop/#/en/2-relay-chain/2-reserve1894. Reserve parachain ID as described here: https://substrate.dev/cumulus-workshop/#/en/2-relay-chain/2-reserve218218219Run benchmark219Run benchmark220```bash220```bash221target/release/nft benchmark --chain dev --pallet "pallet_nft" --extrinsic "*" --repeat 1221target/release/unique-collator benchmark --chain dev --pallet "pallet_unique" --extrinsic "*" --repeat 1222```222```223223224## UI custom types224## UI custom typesclient/rpc/Cargo.tomldiffbeforeafterboth556[dependencies]6[dependencies]7pallet-common = { default-features = false, path = '../../pallets/common' }7pallet-common = { default-features = false, path = '../../pallets/common' }8nft-data-structs = { default-features = false, path = '../../primitives/nft' }8up-data-structs = { default-features = false, path = '../../primitives/data-structs' }9up-rpc = { path = "../../primitives/rpc" }9up-rpc = { path = "../../primitives/rpc" }10codec = { package = "parity-scale-codec", version = "2.0.0" }10codec = { package = "parity-scale-codec", version = "2.0.0" }11jsonrpc-core = "18.0.0"11jsonrpc-core = "18.0.0"client/rpc/src/lib.rsdiffbeforeafterboth3use codec::Decode;3use codec::Decode;4use jsonrpc_core::{Error as RpcError, ErrorCode, Result};4use jsonrpc_core::{Error as RpcError, ErrorCode, Result};5use jsonrpc_derive::rpc;5use jsonrpc_derive::rpc;6use nft_data_structs::{Collection, CollectionId, CollectionStats, TokenId};6use up_data_structs::{Collection, CollectionId, CollectionStats, TokenId};7use sp_api::{BlockId, BlockT, ProvideRuntimeApi};7use sp_api::{BlockId, BlockT, ProvideRuntimeApi};8use sp_blockchain::HeaderBackend;8use sp_blockchain::HeaderBackend;9use up_rpc::NftApi as NftRuntimeApi;9use up_rpc::UniqueApi as UniqueRuntimeApi;101011#[rpc]11#[rpc]12pub trait NftApi<BlockHash, CrossAccountId, AccountId> {12pub trait UniqueApi<BlockHash, CrossAccountId, AccountId> {13 #[rpc(name = "nft_accountTokens")]13 #[rpc(name = "unique_accountTokens")]14 fn account_tokens(14 fn account_tokens(15 &self,15 &self,16 collection: CollectionId,16 collection: CollectionId,17 account: CrossAccountId,17 account: CrossAccountId,18 at: Option<BlockHash>,18 at: Option<BlockHash>,19 ) -> Result<Vec<TokenId>>;19 ) -> Result<Vec<TokenId>>;20 #[rpc(name = "nft_tokenExists")]20 #[rpc(name = "unique_tokenExists")]21 fn token_exists(21 fn token_exists(22 &self,22 &self,23 collection: CollectionId,23 collection: CollectionId,24 token: TokenId,24 token: TokenId,25 at: Option<BlockHash>,25 at: Option<BlockHash>,26 ) -> Result<bool>;26 ) -> Result<bool>;272728 #[rpc(name = "nft_tokenOwner")]28 #[rpc(name = "unique_tokenOwner")]29 fn token_owner(29 fn token_owner(30 &self,30 &self,31 collection: CollectionId,31 collection: CollectionId,32 token: TokenId,32 token: TokenId,33 at: Option<BlockHash>,33 at: Option<BlockHash>,34 ) -> Result<CrossAccountId>;34 ) -> Result<CrossAccountId>;35 #[rpc(name = "nft_constMetadata")]35 #[rpc(name = "unique_constMetadata")]36 fn const_metadata(36 fn const_metadata(37 &self,37 &self,38 collection: CollectionId,38 collection: CollectionId,39 token: TokenId,39 token: TokenId,40 at: Option<BlockHash>,40 at: Option<BlockHash>,41 ) -> Result<Vec<u8>>;41 ) -> Result<Vec<u8>>;42 #[rpc(name = "nft_variableMetadata")]42 #[rpc(name = "unique_variableMetadata")]43 fn variable_metadata(43 fn variable_metadata(44 &self,44 &self,45 collection: CollectionId,45 collection: CollectionId,46 token: TokenId,46 token: TokenId,47 at: Option<BlockHash>,47 at: Option<BlockHash>,48 ) -> Result<Vec<u8>>;48 ) -> Result<Vec<u8>>;494950 #[rpc(name = "nft_collectionTokens")]50 #[rpc(name = "unique_collectionTokens")]51 fn collection_tokens(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;51 fn collection_tokens(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;52 #[rpc(name = "nft_accountBalance")]52 #[rpc(name = "unique_accountBalance")]53 fn account_balance(53 fn account_balance(54 &self,54 &self,55 collection: CollectionId,55 collection: CollectionId,56 account: CrossAccountId,56 account: CrossAccountId,57 at: Option<BlockHash>,57 at: Option<BlockHash>,58 ) -> Result<u32>;58 ) -> Result<u32>;59 #[rpc(name = "nft_balance")]59 #[rpc(name = "unique_balance")]60 fn balance(60 fn balance(61 &self,61 &self,62 collection: CollectionId,62 collection: CollectionId,63 account: CrossAccountId,63 account: CrossAccountId,64 token: TokenId,64 token: TokenId,65 at: Option<BlockHash>,65 at: Option<BlockHash>,66 ) -> Result<String>;66 ) -> Result<String>;67 #[rpc(name = "nft_allowance")]67 #[rpc(name = "unique_allowance")]68 fn allowance(68 fn allowance(69 &self,69 &self,70 collection: CollectionId,70 collection: CollectionId,74 at: Option<BlockHash>,74 at: Option<BlockHash>,75 ) -> Result<String>;75 ) -> Result<String>;767677 #[rpc(name = "nft_adminlist")]77 #[rpc(name = "unique_adminlist")]78 fn adminlist(78 fn adminlist(79 &self,79 &self,80 collection: CollectionId,80 collection: CollectionId,81 at: Option<BlockHash>,81 at: Option<BlockHash>,82 ) -> Result<Vec<CrossAccountId>>;82 ) -> Result<Vec<CrossAccountId>>;83 #[rpc(name = "nft_allowlist")]83 #[rpc(name = "unique_allowlist")]84 fn allowlist(84 fn allowlist(85 &self,85 &self,86 collection: CollectionId,86 collection: CollectionId,87 at: Option<BlockHash>,87 at: Option<BlockHash>,88 ) -> Result<Vec<CrossAccountId>>;88 ) -> Result<Vec<CrossAccountId>>;89 #[rpc(name = "nft_allowed")]89 #[rpc(name = "unique_allowed")]90 fn allowed(90 fn allowed(91 &self,91 &self,92 collection: CollectionId,92 collection: CollectionId,93 user: CrossAccountId,93 user: CrossAccountId,94 at: Option<BlockHash>,94 at: Option<BlockHash>,95 ) -> Result<bool>;95 ) -> Result<bool>;96 #[rpc(name = "nft_lastTokenId")]96 #[rpc(name = "unique_lastTokenId")]97 fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;97 fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;98 #[rpc(name = "nft_collectionById")]98 #[rpc(name = "unique_collectionById")]99 fn collection_by_id(99 fn collection_by_id(100 &self,100 &self,101 collection: CollectionId,101 collection: CollectionId,102 at: Option<BlockHash>,102 at: Option<BlockHash>,103 ) -> Result<Option<Collection<AccountId>>>;103 ) -> Result<Option<Collection<AccountId>>>;104 #[rpc(name = "nft_collectionStats")]104 #[rpc(name = "unique_collectionStats")]105 fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;105 fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;106}106}107107108pub struct Nft<C, P> {108pub struct Unique<C, P> {109 client: Arc<C>,109 client: Arc<C>,110 _marker: std::marker::PhantomData<P>,110 _marker: std::marker::PhantomData<P>,111}111}112112113impl<C, P> Nft<C, P> {113impl<C, P> Unique<C, P> {114 pub fn new(client: Arc<C>) -> Self {114 pub fn new(client: Arc<C>) -> Self {115 Self {115 Self {116 client,116 client,154 };154 };155}155}156156157impl<C, Block, CrossAccountId, AccountId> NftApi<<Block as BlockT>::Hash, CrossAccountId, AccountId>157impl<C, Block, CrossAccountId, AccountId> UniqueApi<<Block as BlockT>::Hash, CrossAccountId, AccountId>158 for Nft<C, Block>158 for Unique<C, Block>159where159where160 Block: BlockT,160 Block: BlockT,161 AccountId: Decode,161 AccountId: Decode,162 C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,162 C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,163 C::Api: NftRuntimeApi<Block, CrossAccountId, AccountId>,163 C::Api: UniqueRuntimeApi<Block, CrossAccountId, AccountId>,164 CrossAccountId: pallet_common::account::CrossAccountId<AccountId>,164 CrossAccountId: pallet_common::account::CrossAccountId<AccountId>,165{165{166 pass_method!(account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>);166 pass_method!(account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>);docker-compose-tests-parachain.ymldiffbeforeafterboth9 - RUST_TOOLCHAIN=${RUST_TOOLCHAIN:?err}9 - RUST_TOOLCHAIN=${RUST_TOOLCHAIN:?err}10 - RUST_C=${RUST_C:?err}10 - RUST_C=${RUST_C:?err}11 - POLKA_VERSION=${POLKA_VERSION:?err}11 - POLKA_VERSION=${POLKA_VERSION:?err}12 - NFT_BRANCH=${NFT_BRANCH:?err}12 - UNIQUE_BRANCH=${UNIQUE_BRANCH:?err}13 volumes:13 volumes:14 - ./launch-config.json:/polkadot-launch/launch-config.json14 - ./launch-config.json:/polkadot-launch/launch-config.json15 env_file:15 env_file:22 environment:22 environment:23 RPC_URL: http://blockchain_nodes:9933/23 RPC_URL: http://blockchain_nodes:9933/24 volumes:24 volumes:25 - ./tests/src/config_docker.ts:/nft_parachain/src/config.ts25 - ./tests/src/config_docker.ts:/unique_parachain/src/config.ts26 - /home/ubuntu/mochawesome-report:/nft_parachain/mochawesome-report26 - /home/ubuntu/mochawesome-report:/unique_parachain/mochawesome-report27 depends_on:27 depends_on:28 - blockchain_nodes28 - blockchain_nodes2929launch-config.jsondiffbeforeafterboth55 },55 },56 "parachains": [56 "parachains": [57 {57 {58 "bin": "../unique-chain/target/release/nft",58 "bin": "../unique-chain/target/release/unique-collator",59 "id": "2000",59 "id": "2000",60 "balance": "1000000000000000000000",60 "balance": "1000000000000000000000",61 "nodes": [61 "nodes": [node/cli/Cargo.tomldiffbeforeafterboth231################################################################################231################################################################################232# Local dependencies232# Local dependencies233233234[dependencies.nft-runtime]234[dependencies.unique-runtime]235path = '../../runtime'235path = '../../runtime'236version = '0.9.12'237236238[dependencies.nft-data-structs]237[dependencies.up-data-structs]239path = "../../primitives/nft"238path = "../../primitives/data-structs"240default-features = false239default-features = false241240242################################################################################241################################################################################245[package]244[package]246authors = ['Unique Network <support@uniquenetwork.io>']245authors = ['Unique Network <support@uniquenetwork.io>']247build = 'build.rs'246build = 'build.rs'248description = 'Substrate node nft'247description = 'Unique Node'249edition = '2018'248edition = '2018'250homepage = 'https://unique.network'249homepage = 'https://unique.network'251license = 'All Rights Reserved'250license = 'All Rights Reserved'252name = 'nft'251name = 'unique-node'253repository = 'https://github.com/usetech-llc/nft_private/'252repository = 'https://github.com/UniqueNetwork/unique-chain'254version = '0.9.12'253version = '0.9.12'255254256[[bin]]255[[bin]]257name = 'nft'256name = 'unique-collator'257path = "src/main.rs"258258259[package.metadata.docs.rs]259[package.metadata.docs.rs]260targets = ['x86_64-unknown-linux-gnu']260targets = ['x86_64-unknown-linux-gnu']276fp-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }276fp-rpc = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }277pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }277pallet-ethereum = { git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }278278279nft-rpc = { path = "../rpc" }279unique-rpc = { path = "../rpc" }280280281[features]281[features]282default = []282default = []283runtime-benchmarks = [283runtime-benchmarks = [284 'nft-runtime/runtime-benchmarks',284 'unique-runtime/runtime-benchmarks',285 'polkadot-service/runtime-benchmarks',285 'polkadot-service/runtime-benchmarks',286]286]287287node/cli/src/chain_spec.rsdiffbeforeafterboth4//4//556use cumulus_primitives_core::ParaId;6use cumulus_primitives_core::ParaId;7use nft_runtime::*;7use unique_runtime::*;8use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};8use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};9use sc_service::ChainType;9use sc_service::ChainType;10use sp_core::{sr25519, Pair, Public};10use sp_core::{sr25519, Pair, Public};15use serde_json::map::Map;15use serde_json::map::Map;161617/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.17/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.18pub type ChainSpec = sc_service::GenericChainSpec<nft_runtime::GenesisConfig, Extensions>;18pub type ChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;191920/// Helper function to generate a crypto pair from seed20/// Helper function to generate a crypto pair from seed21pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {21pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {151 id: ParaId,151 id: ParaId,152) -> GenesisConfig {152) -> GenesisConfig {153 GenesisConfig {153 GenesisConfig {154 system: nft_runtime::SystemConfig {154 system: unique_runtime::SystemConfig {155 code: nft_runtime::WASM_BINARY155 code: unique_runtime::WASM_BINARY156 .expect("WASM binary was not build, please build it!")156 .expect("WASM binary was not build, please build it!")157 .to_vec(),157 .to_vec(),158 changes_trie_config: Default::default(),158 changes_trie_config: Default::default(),167 treasury: Default::default(),167 treasury: Default::default(),168 sudo: SudoConfig { key: root_key },168 sudo: SudoConfig { key: root_key },169 vesting: VestingConfig { vesting: vec![] },169 vesting: VestingConfig { vesting: vec![] },170 parachain_info: nft_runtime::ParachainInfoConfig { parachain_id: id },170 parachain_info: unique_runtime::ParachainInfoConfig { parachain_id: id },171 aura: nft_runtime::AuraConfig {171 aura: unique_runtime::AuraConfig {172 authorities: initial_authorities,172 authorities: initial_authorities,173 },173 },174 aura_ext: Default::default(),174 aura_ext: Default::default(),node/cli/src/command.rsdiffbeforeafterboth24use cumulus_primitives_core::ParaId;24use cumulus_primitives_core::ParaId;25use cumulus_client_service::genesis::generate_genesis_block;25use cumulus_client_service::genesis::generate_genesis_block;26use log::info;26use log::info;27use nft_runtime::Block;27use unique_runtime::Block;28use polkadot_parachain::primitives::AccountIdConversion;28use polkadot_parachain::primitives::AccountIdConversion;29use sc_cli::{29use sc_cli::{30 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,30 ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,88 }88 }898990 fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {90 fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {91 &nft_runtime::VERSION91 &unique_runtime::VERSION92 }92 }93}93}9494node/cli/src/service.rsdiffbeforeafterboth13use futures::StreamExt;13use futures::StreamExt;141415// Local Runtime Types15// Local Runtime Types16use nft_runtime::RuntimeApi;16use unique_runtime::RuntimeApi;171718// Cumulus Imports18// Cumulus Imports19use cumulus_client_consensus_aura::{build_aura_consensus, BuildAuraConsensusParams, SlotProportion};19use cumulus_client_consensus_aura::{build_aura_consensus, BuildAuraConsensusParams, SlotProportion};54 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;54 type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;555556 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {56 fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {57 nft_runtime::api::dispatch(method, data)57 unique_runtime::api::dispatch(method, data)58 }58 }595960 fn native_version() -> sc_executor::NativeVersion {60 fn native_version() -> sc_executor::NativeVersion {61 nft_runtime::native_version()61 unique_runtime::native_version()62 }62 }63}63}646468 .as_ref()68 .as_ref()69 .map(|base_path| base_path.config_dir(config.chain_spec.id()))69 .map(|base_path| base_path.config_dir(config.chain_spec.id()))70 .unwrap_or_else(|| {70 .unwrap_or_else(|| {71 BasePath::from_project("", "", "nft").config_dir(config.chain_spec.id())71 BasePath::from_project("", "", "unique").config_dir(config.chain_spec.id())72 });72 });73 let database_dir = config_dir.join("frontier").join("db");73 let database_dir = config_dir.join("frontier").join("db");7474291291292 let rpc_frontier_backend = frontier_backend.clone();292 let rpc_frontier_backend = frontier_backend.clone();293 let rpc_extensions_builder = Box::new(move |deny_unsafe, _| {293 let rpc_extensions_builder = Box::new(move |deny_unsafe, _| {294 let full_deps = nft_rpc::FullDeps {294 let full_deps = unique_rpc::FullDeps {295 backend: rpc_frontier_backend.clone(),295 backend: rpc_frontier_backend.clone(),296 deny_unsafe,296 deny_unsafe,297 client: rpc_client.clone(),297 client: rpc_client.clone(),307 max_past_logs: 10000,307 max_past_logs: 10000,308 };308 };309309310 Ok(nft_rpc::create_full::<_, _, _, _, RuntimeApi, _>(310 Ok(unique_rpc::create_full::<_, _, _, _, RuntimeApi, _>(311 full_deps,311 full_deps,312 subscription_executor.clone(),312 subscription_executor.clone(),313 ))313 ))node/rpc/Cargo.tomldiffbeforeafterboth1[package]1[package]2name = "nft-rpc"2name = "unique-rpc"3version = "3.3.1"3version = "0.1.0"4authors = ['Unique Network <support@uniquenetwork.io>']4authors = ['Unique Network <support@uniquenetwork.io>']5license = 'All Rights Reserved'5license = 'All Rights Reserved'6edition = "2018"6edition = "2018"48fc-db = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }48fc-db = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }49fc-mapping-sync = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }49fc-mapping-sync = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }505051pallet-nft = { path = "../../pallets/nft" }51pallet-unique = { path = "../../pallets/unique" }52uc-rpc = { path = "../../client/rpc" }52uc-rpc = { path = "../../client/rpc" }53up-rpc = { path = "../../primitives/rpc" }53up-rpc = { path = "../../primitives/rpc" }54nft-runtime = { path = "../../runtime" }54unique-runtime = { path = "../../runtime" }555556[features]56[features]57std = []57std = []node/rpc/src/lib.rsdiffbeforeafterboth1use nft_runtime::{Hash, AccountId, CrossAccountId, Index, opaque::Block, BlockNumber, Balance};1use unique_runtime::{Hash, AccountId, CrossAccountId, Index, opaque::Block, BlockNumber, Balance};2use fc_rpc::{2use fc_rpc::{3 EthBlockDataCache, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override, StorageOverride,3 EthBlockDataCache, OverrideHandle, RuntimeApiStorageOverride, SchemaV1Override, StorageOverride,4};4};100where100where101 Block: sp_api::BlockT,101 Block: sp_api::BlockT,102 C: ProvideRuntimeApi<Block>,102 C: ProvideRuntimeApi<Block>,103 C::Api: up_rpc::NftApi<Block, CrossAccountId, AccountId>,103 C::Api: up_rpc::UniqueApi<Block, CrossAccountId, AccountId>,104{104{105 fn code(&self, block: &sp_api::BlockId<Block>, account: sp_core::H160) -> Option<Vec<u8>> {105 fn code(&self, block: &sp_api::BlockId<Block>, account: sp_core::H160) -> Option<Vec<u8>> {106 use up_rpc::NftApi;106 use up_rpc::UniqueApi;107 self.client107 self.client108 .runtime_api()108 .runtime_api()109 .eth_contract_code(block, account)109 .eth_contract_code(block, account)127 // C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,127 // C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,128 C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,128 C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,129 C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,129 C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,130 C::Api: up_rpc::NftApi<Block, CrossAccountId, AccountId>,130 C::Api: up_rpc::UniqueApi<Block, CrossAccountId, AccountId>,131 B: sc_client_api::Backend<Block> + Send + Sync + 'static,131 B: sc_client_api::Backend<Block> + Send + Sync + 'static,132 B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,132 B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,133 SC: SelectChain<Block> + 'static,133 SC: SelectChain<Block> + 'static,139 EthPubSubApiServer, EthSigner, HexEncodedIdProvider, NetApi, NetApiServer, Web3Api,139 EthPubSubApiServer, EthSigner, HexEncodedIdProvider, NetApi, NetApiServer, Web3Api,140 Web3ApiServer,140 Web3ApiServer,141 };141 };142 use uc_rpc::{NftApi, Nft};142 use uc_rpc::{UniqueApi, Unique};143 // use pallet_contracts_rpc::{Contracts, ContractsApi};143 // use pallet_contracts_rpc::{Contracts, ContractsApi};144 use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};144 use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};145 use substrate_frame_rpc_system::{FullSystem, SystemApi};145 use substrate_frame_rpc_system::{FullSystem, SystemApi};195 client.clone(),195 client.clone(),196 pool.clone(),196 pool.clone(),197 graph,197 graph,198 nft_runtime::TransactionConverter,198 unique_runtime::TransactionConverter,199 network.clone(),199 network.clone(),200 signers,200 signers,201 overrides.clone(),201 overrides.clone(),204 max_past_logs,204 max_past_logs,205 block_data_cache.clone(),205 block_data_cache.clone(),206 )));206 )));207 io.extend_with(NftApi::to_delegate(Nft::new(client.clone())));207 io.extend_with(UniqueApi::to_delegate(Unique::new(client.clone())));208208209 if let Some(filter_pool) = filter_pool {209 if let Some(filter_pool) = filter_pool {210 io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new(210 io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new(pallets/common/Cargo.tomldiffbeforeafterboth16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }18up-evm-mapping = { default-features = false, path = '../../primitives/evm-mapping' }18up-evm-mapping = { default-features = false, path = '../../primitives/evm-mapping' }19nft-data-structs = { default-features = false, path = '../../primitives/nft' }19up-data-structs = { default-features = false, path = '../../primitives/data-structs' }20pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }20pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }21evm-coder = { default-features = false, path = '../../crates/evm-coder' }21evm-coder = { default-features = false, path = '../../crates/evm-coder' }22pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }22pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }33 "sp-runtime/std",33 "sp-runtime/std",34 "sp-std/std",34 "sp-std/std",35 "up-evm-mapping/std",35 "up-evm-mapping/std",36 "nft-data-structs/std",36 "up-data-structs/std",37 "pallet-evm/std",37 "pallet-evm/std",38]38]39runtime-benchmarks = []39runtime-benchmarks = []pallets/common/src/benchmarking.rsdiffbeforeafterboth1use sp_std::vec::Vec;1use sp_std::vec::Vec;2use crate::{Config, CollectionHandle};2use crate::{Config, CollectionHandle};3use nft_data_structs::{3use up_data_structs::{4 CollectionMode, Collection, CollectionId, MAX_COLLECTION_NAME_LENGTH,4 CollectionMode, Collection, CollectionId, MAX_COLLECTION_NAME_LENGTH,5 MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, OFFCHAIN_SCHEMA_LIMIT,5 MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, OFFCHAIN_SCHEMA_LIMIT,6 VARIABLE_ON_CHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT,6 VARIABLE_ON_CHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT,pallets/common/src/eth.rsdiffbeforeafterboth1use nft_data_structs::{CollectionId, TokenId};1use up_data_structs::{CollectionId, TokenId};2use sp_core::H160;2use sp_core::H160;334// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 14// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 1pallets/common/src/lib.rsdiffbeforeafterboth8 ensure, fail,8 ensure, fail,9 traits::{Imbalance, Get, Currency},9 traits::{Imbalance, Get, Currency},10};10};11use nft_data_structs::{11use up_data_structs::{12 COLLECTION_NUMBER_LIMIT, Collection, CollectionId, CreateItemData, ExistenceRequirement,12 COLLECTION_NUMBER_LIMIT, Collection, CollectionId, CreateItemData, ExistenceRequirement,13 MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,13 MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,14 COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, Pays, PostDispatchInfo, TokenId, Weight,14 COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, Pays, PostDispatchInfo, TokenId, Weight,143 use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};143 use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};144 use account::CrossAccountId;144 use account::CrossAccountId;145 use frame_support::traits::Currency;145 use frame_support::traits::Currency;146 use nft_data_structs::TokenId;146 use up_data_structs::TokenId;147 use scale_info::TypeInfo;147 use scale_info::TypeInfo;148148149 #[pallet::config]149 #[pallet::config]pallets/evm-migration/src/weights.rsdiffbeforeafterboth7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1287//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128889// Executed Command:9// Executed Command:10// target/release/nft10// target/release/unique-collator11// benchmark11// benchmark12// --pallet12// --pallet13// pallet-evm-migration13// pallet-evm-migrationpallets/fungible/Cargo.tomldiffbeforeafterboth16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }18pallet-common = { default-features = false, path = '../common' }18pallet-common = { default-features = false, path = '../common' }19nft-data-structs = { default-features = false, path = '../../primitives/nft' }19up-data-structs = { default-features = false, path = '../../primitives/data-structs' }20evm-coder = { default-features = false, path = '../../crates/evm-coder' }20evm-coder = { default-features = false, path = '../../crates/evm-coder' }21pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }21pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }22ethereum = { git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }22ethereum = { git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }32 "frame-system/std",32 "frame-system/std",33 "sp-runtime/std",33 "sp-runtime/std",34 "sp-std/std",34 "sp-std/std",35 "nft-data-structs/std",35 "up-data-structs/std",36 "pallet-common/std",36 "pallet-common/std",37 "evm-coder/std",37 "evm-coder/std",38 "ethereum/std",38 "ethereum/std",pallets/fungible/src/benchmarking.rsdiffbeforeafterboth4use sp_std::prelude::*;4use sp_std::prelude::*;5use pallet_common::benchmarking::create_collection_raw;5use pallet_common::benchmarking::create_collection_raw;6use frame_benchmarking::{benchmarks, account};6use frame_benchmarking::{benchmarks, account};7use nft_data_structs::{CollectionMode};7use up_data_structs::{CollectionMode};8use pallet_common::bench_init;8use pallet_common::bench_init;9910const SEED: u32 = 1;10const SEED: u32 = 1;pallets/fungible/src/common.rsdiffbeforeafterboth1use core::marker::PhantomData;1use core::marker::PhantomData;223use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};3use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};4use nft_data_structs::TokenId;4use up_data_structs::TokenId;5use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};5use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};6use sp_runtime::ArithmeticError;6use sp_runtime::ArithmeticError;7use sp_std::{vec::Vec, vec};7use sp_std::{vec::Vec, vec};51 &self,51 &self,52 sender: T::CrossAccountId,52 sender: T::CrossAccountId,53 to: T::CrossAccountId,53 to: T::CrossAccountId,54 data: nft_data_structs::CreateItemData,54 data: up_data_structs::CreateItemData,55 ) -> DispatchResultWithPostInfo {55 ) -> DispatchResultWithPostInfo {56 match data {56 match data {57 nft_data_structs::CreateItemData::Fungible(data) => with_weight(57 up_data_structs::CreateItemData::Fungible(data) => with_weight(58 <Pallet<T>>::create_item(self, &sender, (to, data.value)),58 <Pallet<T>>::create_item(self, &sender, (to, data.value)),59 <CommonWeights<T>>::create_item(),59 <CommonWeights<T>>::create_item(),60 ),60 ),66 &self,66 &self,67 sender: T::CrossAccountId,67 sender: T::CrossAccountId,68 to: T::CrossAccountId,68 to: T::CrossAccountId,69 data: Vec<nft_data_structs::CreateItemData>,69 data: Vec<up_data_structs::CreateItemData>,70 ) -> DispatchResultWithPostInfo {70 ) -> DispatchResultWithPostInfo {71 let mut sum: u128 = 0;71 let mut sum: u128 = 0;72 for data in data {72 for data in data {73 match data {73 match data {74 nft_data_structs::CreateItemData::Fungible(data) => {74 up_data_structs::CreateItemData::Fungible(data) => {75 sum = sum75 sum = sum76 .checked_add(data.value)76 .checked_add(data.value)77 .ok_or(ArithmeticError::Overflow)?;77 .ok_or(ArithmeticError::Overflow)?;pallets/fungible/src/erc.rsdiffbeforeafterboth1use core::char::{REPLACEMENT_CHARACTER, decode_utf16};1use core::char::{REPLACEMENT_CHARACTER, decode_utf16};2use core::convert::TryInto;2use core::convert::TryInto;3use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*};3use evm_coder::{ToLog, execution::*, generate_stubgen, solidity_interface, types::*};4use nft_data_structs::CollectionMode;4use up_data_structs::CollectionMode;5use pallet_common::erc::CommonEvmHandler;5use pallet_common::erc::CommonEvmHandler;6use sp_core::{H160, U256};6use sp_core::{H160, U256};7use sp_std::vec::Vec;7use sp_std::vec::Vec;pallets/fungible/src/lib.rsdiffbeforeafterboth223use core::ops::Deref;3use core::ops::Deref;4use frame_support::{ensure};4use frame_support::{ensure};5use nft_data_structs::{AccessMode, Collection, CollectionId, TokenId};5use up_data_structs::{AccessMode, Collection, CollectionId, TokenId};6use pallet_common::{6use pallet_common::{7 Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, account::CrossAccountId,7 Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, account::CrossAccountId,8};8};25#[frame_support::pallet]25#[frame_support::pallet]26pub mod pallet {26pub mod pallet {27 use frame_support::{Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};27 use frame_support::{Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};28 use nft_data_structs::CollectionId;28 use up_data_structs::CollectionId;29 use super::weights::WeightInfo;29 use super::weights::WeightInfo;303031 #[pallet::error]31 #[pallet::error]pallets/fungible/src/weights.rsdiffbeforeafterboth7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1287//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128889// Executed Command:9// Executed Command:10// target/release/nft10// target/release/unique-collator11// benchmark11// benchmark12// --pallet12// --pallet13// pallet-fungible13// pallet-fungiblepallets/inflation/Cargo.tomldiffbeforeafterboth334[package]4[package]5authors = ['Unique Network <support@uniquenetwork.io>']5authors = ['Unique Network <support@uniquenetwork.io>']6description = 'Substrate node nft'6description = 'Unique Inflation Pallet'7edition = '2018'7edition = '2018'8homepage = 'https://unique.network'8homepage = 'https://unique.network'9license = 'All Rights Reserved'9license = 'All Rights Reserved'10name = 'pallet-inflation'10name = 'pallet-inflation'11repository = 'https://github.com/usetech-llc/nft_private/'11repository = 'https://github.com/UniqueNetwork/unique-chain'12version = '3.0.0'12version = '0.1.0'131314[package.metadata.docs.rs]14[package.metadata.docs.rs]15targets = ['x86_64-unknown-linux-gnu']15targets = ['x86_64-unknown-linux-gnu']pallets/nft/Cargo.tomldiffbeforeafterbothno changes
pallets/nft/src/benchmarking.rsdiffbeforeafterbothno changes
pallets/nft/src/common.rsdiffbeforeafterbothno changes
pallets/nft/src/dispatch.rsdiffbeforeafterbothno changes
pallets/nft/src/eth/mod.rsdiffbeforeafterbothno changes
pallets/nft/src/eth/sponsoring.rsdiffbeforeafterbothno changes
pallets/nft/src/lib.rsdiffbeforeafterbothno changes
pallets/nft/src/mock.rsdiffbeforeafterbothno changes
pallets/nft/src/sponsorship.rsdiffbeforeafterbothno changes
pallets/nft/src/tests.rsdiffbeforeafterbothno changes
pallets/nft/src/weights.rsdiffbeforeafterbothno changes
pallets/nonfungible/Cargo.tomldiffbeforeafterboth16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }18pallet-common = { default-features = false, path = '../common' }18pallet-common = { default-features = false, path = '../common' }19nft-data-structs = { default-features = false, path = '../../primitives/nft' }19up-data-structs = { default-features = false, path = '../../primitives/data-structs' }20evm-coder = { default-features = false, path = '../../crates/evm-coder' }20evm-coder = { default-features = false, path = '../../crates/evm-coder' }21pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }21pallet-evm-coder-substrate = { default-features = false, path = '../evm-coder-substrate' }22ethereum = { git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }22ethereum = { git = "https://github.com/purestake/ethereum", branch = "joshy-scale-info", default-features = false }32 "frame-system/std",32 "frame-system/std",33 "sp-runtime/std",33 "sp-runtime/std",34 "sp-std/std",34 "sp-std/std",35 "nft-data-structs/std",35 "up-data-structs/std",36 "pallet-common/std",36 "pallet-common/std",37 "evm-coder/std",37 "evm-coder/std",38 "ethereum/std",38 "ethereum/std",pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth4use sp_std::prelude::*;4use sp_std::prelude::*;5use pallet_common::benchmarking::{create_collection_raw, create_data};5use pallet_common::benchmarking::{create_collection_raw, create_data};6use frame_benchmarking::{benchmarks, account};6use frame_benchmarking::{benchmarks, account};7use nft_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH};7use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH};8use pallet_common::bench_init;8use pallet_common::bench_init;9use core::convert::TryInto;9use core::convert::TryInto;1010pallets/nonfungible/src/common.rsdiffbeforeafterboth1use core::marker::PhantomData;1use core::marker::PhantomData;223use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};3use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};4use nft_data_structs::TokenId;4use up_data_structs::TokenId;5use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};5use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};6use sp_runtime::DispatchError;6use sp_runtime::DispatchError;7use sp_std::vec::Vec;7use sp_std::vec::Vec;47}47}484849fn map_create_data<T: Config>(49fn map_create_data<T: Config>(50 data: nft_data_structs::CreateItemData,50 data: up_data_structs::CreateItemData,51 to: &T::CrossAccountId,51 to: &T::CrossAccountId,52) -> Result<CreateItemData<T>, DispatchError> {52) -> Result<CreateItemData<T>, DispatchError> {53 match data {53 match data {54 nft_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData {54 up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData {55 const_data: data.const_data,55 const_data: data.const_data,56 variable_data: data.variable_data,56 variable_data: data.variable_data,57 owner: to.clone(),57 owner: to.clone(),65 &self,65 &self,66 sender: T::CrossAccountId,66 sender: T::CrossAccountId,67 to: T::CrossAccountId,67 to: T::CrossAccountId,68 data: nft_data_structs::CreateItemData,68 data: up_data_structs::CreateItemData,69 ) -> DispatchResultWithPostInfo {69 ) -> DispatchResultWithPostInfo {70 with_weight(70 with_weight(71 <Pallet<T>>::create_item(self, &sender, map_create_data(data, &to)?),71 <Pallet<T>>::create_item(self, &sender, map_create_data(data, &to)?),77 &self,77 &self,78 sender: T::CrossAccountId,78 sender: T::CrossAccountId,79 to: T::CrossAccountId,79 to: T::CrossAccountId,80 data: Vec<nft_data_structs::CreateItemData>,80 data: Vec<up_data_structs::CreateItemData>,81 ) -> DispatchResultWithPostInfo {81 ) -> DispatchResultWithPostInfo {82 let data = data82 let data = data83 .into_iter()83 .into_iter()pallets/nonfungible/src/erc.rsdiffbeforeafterboth4};4};5use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*};5use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*};6use frame_support::BoundedVec;6use frame_support::BoundedVec;7use nft_data_structs::TokenId;7use up_data_structs::TokenId;8use pallet_evm_coder_substrate::dispatch_to_evm;8use pallet_evm_coder_substrate::dispatch_to_evm;9use sp_core::{H160, U256};9use sp_core::{H160, U256};10use sp_std::{vec::Vec, vec};10use sp_std::{vec::Vec, vec};pallets/nonfungible/src/lib.rsdiffbeforeafterboth223use erc::ERC721Events;3use erc::ERC721Events;4use frame_support::{BoundedVec, ensure};4use frame_support::{BoundedVec, ensure};5use nft_data_structs::{5use up_data_structs::{6 AccessMode, CUSTOM_DATA_LIMIT, Collection, CollectionId, CustomDataLimit, TokenId,6 AccessMode, CUSTOM_DATA_LIMIT, Collection, CollectionId, CustomDataLimit, TokenId,7};7};8use pallet_common::{8use pallet_common::{41pub mod pallet {41pub mod pallet {42 use super::*;42 use super::*;43 use frame_support::{Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};43 use frame_support::{Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};44 use nft_data_structs::{CollectionId, TokenId};44 use up_data_structs::{CollectionId, TokenId};45 use super::weights::WeightInfo;45 use super::weights::WeightInfo;464647 #[pallet::error]47 #[pallet::error]pallets/nonfungible/src/weights.rsdiffbeforeafterboth7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1287//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128889// Executed Command:9// Executed Command:10// target/release/nft10// target/release/unique-collator11// benchmark11// benchmark12// --pallet12// --pallet13// pallet-nonfungible13// pallet-nonfungiblepallets/refungible/Cargo.tomldiffbeforeafterboth16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }16sp-std = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }17sp-core = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }18pallet-common = { default-features = false, path = '../common' }18pallet-common = { default-features = false, path = '../common' }19nft-data-structs = { default-features = false, path = '../../primitives/nft' }19up-data-structs = { default-features = false, path = '../../primitives/data-structs' }20frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }20frame-benchmarking = { default-features = false, optional = true, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }21scale-info = { version = "1.0.0", default-features = false, features = [21scale-info = { version = "1.0.0", default-features = false, features = [22 "derive",22 "derive",29 "frame-system/std",29 "frame-system/std",30 "sp-runtime/std",30 "sp-runtime/std",31 "sp-std/std",31 "sp-std/std",32 "nft-data-structs/std",32 "up-data-structs/std",33 "pallet-common/std",33 "pallet-common/std",34 'frame-benchmarking/std',34 'frame-benchmarking/std',35]35]pallets/refungible/src/benchmarking.rsdiffbeforeafterboth4use sp_std::prelude::*;4use sp_std::prelude::*;5use pallet_common::benchmarking::{create_collection_raw, create_data};5use pallet_common::benchmarking::{create_collection_raw, create_data};6use frame_benchmarking::{benchmarks, account};6use frame_benchmarking::{benchmarks, account};7use nft_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH};7use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH};8use pallet_common::bench_init;8use pallet_common::bench_init;9use core::convert::TryInto;9use core::convert::TryInto;10use core::iter::IntoIterator;10use core::iter::IntoIterator;pallets/refungible/src/common.rsdiffbeforeafterboth223use sp_std::collections::btree_map::BTreeMap;3use sp_std::collections::btree_map::BTreeMap;4use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};4use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};5use nft_data_structs::TokenId;5use up_data_structs::TokenId;6use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};6use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};7use sp_runtime::DispatchError;7use sp_runtime::DispatchError;8use sp_std::vec::Vec;8use sp_std::vec::Vec;67}67}686869fn map_create_data<T: Config>(69fn map_create_data<T: Config>(70 data: nft_data_structs::CreateItemData,70 data: up_data_structs::CreateItemData,71 to: &T::CrossAccountId,71 to: &T::CrossAccountId,72) -> Result<CreateItemData<T>, DispatchError> {72) -> Result<CreateItemData<T>, DispatchError> {73 match data {73 match data {74 nft_data_structs::CreateItemData::ReFungible(data) => Ok(CreateItemData {74 up_data_structs::CreateItemData::ReFungible(data) => Ok(CreateItemData {75 const_data: data.const_data,75 const_data: data.const_data,76 variable_data: data.variable_data,76 variable_data: data.variable_data,77 users: {77 users: {89 &self,89 &self,90 sender: T::CrossAccountId,90 sender: T::CrossAccountId,91 to: T::CrossAccountId,91 to: T::CrossAccountId,92 data: nft_data_structs::CreateItemData,92 data: up_data_structs::CreateItemData,93 ) -> DispatchResultWithPostInfo {93 ) -> DispatchResultWithPostInfo {94 with_weight(94 with_weight(95 <Pallet<T>>::create_item(self, &sender, map_create_data(data, &to)?),95 <Pallet<T>>::create_item(self, &sender, map_create_data(data, &to)?),101 &self,101 &self,102 sender: T::CrossAccountId,102 sender: T::CrossAccountId,103 to: T::CrossAccountId,103 to: T::CrossAccountId,104 data: Vec<nft_data_structs::CreateItemData>,104 data: Vec<up_data_structs::CreateItemData>,105 ) -> DispatchResultWithPostInfo {105 ) -> DispatchResultWithPostInfo {106 let data = data106 let data = data107 .into_iter()107 .into_iter()pallets/refungible/src/erc.rsdiffbeforeafterboth1use nft_data_structs::TokenId;1use up_data_structs::TokenId;2use pallet_common::erc::CommonEvmHandler;2use pallet_common::erc::CommonEvmHandler;334use crate::{Config, RefungibleHandle};4use crate::{Config, RefungibleHandle};pallets/refungible/src/lib.rsdiffbeforeafterboth1#![cfg_attr(not(feature = "std"), no_std)]1#![cfg_attr(not(feature = "std"), no_std)]223use frame_support::{ensure, BoundedVec};3use frame_support::{ensure, BoundedVec};4use nft_data_structs::{4use up_data_structs::{5 AccessMode, CUSTOM_DATA_LIMIT, Collection, CollectionId, CustomDataLimit,5 AccessMode, CUSTOM_DATA_LIMIT, Collection, CollectionId, CustomDataLimit,6 MAX_REFUNGIBLE_PIECES, TokenId,6 MAX_REFUNGIBLE_PIECES, TokenId,7};7};37pub mod pallet {37pub mod pallet {38 use super::*;38 use super::*;39 use frame_support::{Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};39 use frame_support::{Blake2_128, Blake2_128Concat, Twox64Concat, pallet_prelude::*, storage::Key};40 use nft_data_structs::{CollectionId, TokenId};40 use up_data_structs::{CollectionId, TokenId};41 use super::weights::WeightInfo;41 use super::weights::WeightInfo;424243 #[pallet::error]43 #[pallet::error]pallets/refungible/src/weights.rsdiffbeforeafterboth7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1287//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128889// Executed Command:9// Executed Command:10// target/release/nft10// target/release/unique-collator11// benchmark11// benchmark12// --pallet12// --pallet13// pallet-refungible13// pallet-refungiblepallets/scheduler/Cargo.tomldiffbeforeafterboth1[package]1[package]2name = "pallet-unq-scheduler"2name = "pallet-unq-scheduler"3version = "3.0.0"3version = "0.1.0"4authors = ["Parity Technologies <admin@parity.io>"]4authors = ["Unique Network <support@uniquenetwork.io>"]5edition = "2018"5edition = "2018"6license = "Unlicense"6license = "All Rights Reserved"7homepage = "https://substrate.dev"7homepage = "https://unique.network"8repository = "https://github.com/paritytech/substrate/"8repository = "https://github.com/UniqueNetwork/unique-chain"9description = "FRAME example pallet"9description = "Unique Scheduler pallet"10readme = "README.md"10readme = "README.md"111112[dependencies]12[dependencies]pallets/unique/Cargo.tomldiffbeforeafterbothno changes
pallets/unique/src/benchmarking.rsdiffbeforeafterbothno changes
pallets/unique/src/common.rsdiffbeforeafterbothno changes
pallets/unique/src/dispatch.rsdiffbeforeafterbothno changes
pallets/unique/src/eth/mod.rsdiffbeforeafterbothno changes
pallets/unique/src/eth/sponsoring.rsdiffbeforeafterbothno changes
pallets/unique/src/lib.rsdiffbeforeafterbothno changes
pallets/unique/src/mock.rsdiffbeforeafterbothno changes
pallets/unique/src/sponsorship.rsdiffbeforeafterbothno changes
pallets/unique/src/tests.rsdiffbeforeafterbothno changes
pallets/unique/src/weights.rsdiffbeforeafterbothno changes
primitives/data-structs/Cargo.tomldiffbeforeafterbothno changes
primitives/data-structs/src/lib.rsdiffbeforeafterbothno changes
primitives/nft/Cargo.tomldiffbeforeafterbothno changes
primitives/nft/src/lib.rsdiffbeforeafterbothno changes
primitives/rpc/Cargo.tomldiffbeforeafterboth556[dependencies]6[dependencies]7pallet-common = { default-features = false, path = '../../pallets/common' }7pallet-common = { default-features = false, path = '../../pallets/common' }8nft-data-structs = { default-features = false, path = '../nft' }8up-data-structs = { default-features = false, path = '../data-structs' }9codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = [9codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = [10 "derive",10 "derive",11] }11] }23 "sp-api/std",23 "sp-api/std",24 "sp-runtime/std",24 "sp-runtime/std",25 "pallet-common/std",25 "pallet-common/std",26 "nft-data-structs/std",26 "up-data-structs/std",27]27]2828primitives/rpc/src/lib.rsdiffbeforeafterboth1#![cfg_attr(not(feature = "std"), no_std)]1#![cfg_attr(not(feature = "std"), no_std)]223use nft_data_structs::{CollectionId, TokenId, Collection, CollectionStats};3use up_data_structs::{CollectionId, TokenId, Collection, CollectionStats};4use sp_std::vec::Vec;4use sp_std::vec::Vec;5use sp_core::H160;5use sp_core::H160;6use codec::Decode;6use codec::Decode;778sp_api::decl_runtime_apis! {8sp_api::decl_runtime_apis! {9 pub trait NftApi<CrossAccountId, AccountId> where9 pub trait UniqueApi<CrossAccountId, AccountId> where10 AccountId: Decode,10 AccountId: Decode,11 CrossAccountId: pallet_common::account::CrossAccountId<AccountId>,11 CrossAccountId: pallet_common::account::CrossAccountId<AccountId>,12 {12 {runtime/Cargo.tomldiffbeforeafterboth4[package]4[package]5authors = ['Unique Network <support@uniquenetwork.io>']5authors = ['Unique Network <support@uniquenetwork.io>']6build = 'build.rs'6build = 'build.rs'7description = 'Substrate node nft'7description = 'Unique Runtime'8edition = '2018'8edition = '2018'9homepage = 'https://unique.network'9homepage = 'https://unique.network'10license = 'All Rights Reserved'10license = 'All Rights Reserved'11name = 'nft-runtime'11name = 'unique-runtime'12repository = 'https://github.com/usetech-llc/nft_private/'12repository = 'https://github.com/UniqueNetwork/unique-chain'13version = '0.9.12'13version = '0.9.12'141415[package.metadata.docs.rs]15[package.metadata.docs.rs]30 'pallet-fungible/runtime-benchmarks',30 'pallet-fungible/runtime-benchmarks',31 'pallet-refungible/runtime-benchmarks',31 'pallet-refungible/runtime-benchmarks',32 'pallet-nonfungible/runtime-benchmarks',32 'pallet-nonfungible/runtime-benchmarks',33 'pallet-nft/runtime-benchmarks',33 'pallet-unique/runtime-benchmarks',34 'pallet-inflation/runtime-benchmarks',34 'pallet-inflation/runtime-benchmarks',35 'pallet-xcm/runtime-benchmarks',35 'pallet-xcm/runtime-benchmarks',36 'sp-runtime/runtime-benchmarks',36 'sp-runtime/runtime-benchmarks',78 'pallet-fungible/std',78 'pallet-fungible/std',79 'pallet-refungible/std',79 'pallet-refungible/std',80 'pallet-nonfungible/std',80 'pallet-nonfungible/std',81 'pallet-nft/std',81 'pallet-unique/std',82 'pallet-unq-scheduler/std',82 'pallet-unq-scheduler/std',83 'pallet-nft-charge-transaction/std',83 'pallet-charge-transaction/std',84 'nft-data-structs/std',84 'up-data-structs/std',85 'sp-api/std',85 'sp-api/std',86 'sp-block-builder/std',86 'sp-block-builder/std',87 "sp-consensus-aura/std",87 "sp-consensus-aura/std",100100101 "orml-vesting/std",101 "orml-vesting/std",102]102]103limit-testing = ['pallet-nft/limit-testing', 'nft-data-structs/limit-testing']103limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']104104105################################################################################105################################################################################106# Substrate Dependencies106# Substrate Dependencies374 "derive",374 "derive",375] }375] }376derivative = "2.2.0"376derivative = "2.2.0"377pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }377pallet-unique = { path = '../pallets/unique', default-features = false }378up-rpc = { path = "../primitives/rpc", default-features = false }378up-rpc = { path = "../primitives/rpc", default-features = false }379up-evm-mapping = { path = "../primitives/evm-mapping", default-features = false }379up-evm-mapping = { path = "../primitives/evm-mapping", default-features = false }380pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }380pallet-inflation = { path = '../pallets/inflation', default-features = false }381nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }381up-data-structs = { path = '../primitives/data-structs', default-features = false }382pallet-common = { default-features = false, path = "../pallets/common" }382pallet-common = { default-features = false, path = "../pallets/common" }383pallet-fungible = { default-features = false, path = "../pallets/fungible" }383pallet-fungible = { default-features = false, path = "../pallets/fungible" }384pallet-refungible = { default-features = false, path = "../pallets/refungible" }384pallet-refungible = { default-features = false, path = "../pallets/refungible" }385pallet-nonfungible = { default-features = false, path = "../pallets/nonfungible" }385pallet-nonfungible = { default-features = false, path = "../pallets/nonfungible" }386pallet-unq-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }386pallet-unq-scheduler = { path = '../pallets/scheduler', default-features = false }387# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }387# pallet-contract-helpers = { path = '../pallets/contract-helpers', default-features = false, version = '0.1.0' }388pallet-nft-charge-transaction = { git = "https://github.com/UniqueNetwork/pallet-sponsoring", package = "pallet-template-transaction-payment", default-features = false, version = '3.0.0' }388pallet-charge-transaction = { git = "https://github.com/UniqueNetwork/pallet-sponsoring", package = "pallet-template-transaction-payment", default-features = false, version = '3.0.0' }389pallet-evm-migration = { path = '../pallets/evm-migration', default-features = false }389pallet-evm-migration = { path = '../pallets/evm-migration', default-features = false }390pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }390pallet-evm-contract-helpers = { path = '../pallets/evm-contract-helpers', default-features = false }391pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }391pallet-evm-transaction-payment = { path = '../pallets/evm-transaction-payment', default-features = false }runtime/src/lib.rsdiffbeforeafterboth53 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,53 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,54 },54 },55};55};56use nft_data_structs::*;56use up_data_structs::*;57// use pallet_contracts::weights::WeightInfo;57// use pallet_contracts::weights::WeightInfo;58// #[cfg(any(feature = "std", test))]58// #[cfg(any(feature = "std", test))]59use frame_system::{59use frame_system::{259 type Event = Event;259 type Event = Event;260 type OnMethodCall = (260 type OnMethodCall = (261 pallet_evm_migration::OnMethodCall<Self>,261 pallet_evm_migration::OnMethodCall<Self>,262 pallet_nft::NftErcSupport<Self>,262 pallet_unique::UniqueErcSupport<Self>,263 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,263 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,264 );264 );265 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;265 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;755 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;755 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;756}756}757757758/// Used for the pallet nft in `./nft.rs`759impl pallet_nft::Config for Runtime {758impl pallet_unique::Config for Runtime {760 type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;759 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;761}760}762761763parameter_types! {762parameter_types! {778// }777// }779778780type EvmSponsorshipHandler = (779type EvmSponsorshipHandler = (781 pallet_nft::NftEthSponsorshipHandler<Runtime>,780 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,782 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,781 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,783);782);784type SponsorshipHandler = (783type SponsorshipHandler = (785 pallet_nft::NftSponsorshipHandler<Runtime>,784 pallet_unique::UniqueSponsorshipHandler<Runtime>,786 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,785 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,787 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,786 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,788);787);806 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;805 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;807}806}808807809impl pallet_nft_charge_transaction::Config for Runtime {808impl pallet_charge_transaction::Config for Runtime {810 type SponsorshipHandler = SponsorshipHandler;809 type SponsorshipHandler = SponsorshipHandler;811}810}812811857856858 // Unique Pallets857 // Unique Pallets859 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,858 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,860 Nft: pallet_nft::{Pallet, Call, Storage} = 61,859 Unique: pallet_unique::{Pallet, Call, Storage} = 61,861 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,860 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,862 // free = 63861 // free = 63863 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,862 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,864 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,863 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,865 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,864 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,866 Fungible: pallet_fungible::{Pallet, Storage} = 67,865 Fungible: pallet_fungible::{Pallet, Storage} = 67,920 system::CheckEra<Runtime>,919 system::CheckEra<Runtime>,921 system::CheckNonce<Runtime>,920 system::CheckNonce<Runtime>,922 system::CheckWeight<Runtime>,921 system::CheckWeight<Runtime>,923 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,922 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,924 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,923 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,925);924);926/// Unchecked extrinsic type as expected by this runtime.925/// Unchecked extrinsic type as expected by this runtime.990 }989 }991}990}992991993macro_rules! dispatch_nft_runtime {992macro_rules! dispatch_unique_runtime {994 ($collection:ident.$method:ident($($name:ident),*)) => {{993 ($collection:ident.$method:ident($($name:ident),*)) => {{995 use pallet_nft::dispatch::Dispatched;994 use pallet_unique::dispatch::Dispatched;996995997 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::new($collection).unwrap());996 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::new($collection).unwrap());998 let dispatch = collection.as_dyn();997 let dispatch = collection.as_dyn();1001 }};1000 }};1002}1001}1003impl_runtime_apis! {1002impl_runtime_apis! {1004 impl up_rpc::NftApi<Block, CrossAccountId, AccountId>1003 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>1005 for Runtime1004 for Runtime1006 {1005 {1007 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId> {1006 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId> {1008 dispatch_nft_runtime!(collection.account_tokens(account))1007 dispatch_unique_runtime!(collection.account_tokens(account))1009 }1008 }1010 fn token_exists(collection: CollectionId, token: TokenId) -> bool {1009 fn token_exists(collection: CollectionId, token: TokenId) -> bool {1011 dispatch_nft_runtime!(collection.token_exists(token))1010 dispatch_unique_runtime!(collection.token_exists(token))1012 }1011 }101310121014 fn token_owner(collection: CollectionId, token: TokenId) -> CrossAccountId {1013 fn token_owner(collection: CollectionId, token: TokenId) -> CrossAccountId {1015 dispatch_nft_runtime!(collection.token_owner(token))1014 dispatch_unique_runtime!(collection.token_owner(token))1016 }1015 }1017 fn const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {1016 fn const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {1018 dispatch_nft_runtime!(collection.const_metadata(token))1017 dispatch_unique_runtime!(collection.const_metadata(token))1019 }1018 }1020 fn variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {1019 fn variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {1021 dispatch_nft_runtime!(collection.variable_metadata(token))1020 dispatch_unique_runtime!(collection.variable_metadata(token))1022 }1021 }102310221024 fn collection_tokens(collection: CollectionId) -> u32 {1023 fn collection_tokens(collection: CollectionId) -> u32 {1025 dispatch_nft_runtime!(collection.collection_tokens())1024 dispatch_unique_runtime!(collection.collection_tokens())1026 }1025 }1027 fn account_balance(collection: CollectionId, account: CrossAccountId) -> u32 {1026 fn account_balance(collection: CollectionId, account: CrossAccountId) -> u32 {1028 dispatch_nft_runtime!(collection.account_balance(account))1027 dispatch_unique_runtime!(collection.account_balance(account))1029 }1028 }1030 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> u128 {1029 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> u128 {1031 dispatch_nft_runtime!(collection.balance(account, token))1030 dispatch_unique_runtime!(collection.balance(account, token))1032 }1031 }1033 fn allowance(1032 fn allowance(1034 collection: CollectionId,1033 collection: CollectionId,1035 sender: CrossAccountId,1034 sender: CrossAccountId,1036 spender: CrossAccountId,1035 spender: CrossAccountId,1037 token: TokenId,1036 token: TokenId,1038 ) -> u128 {1037 ) -> u128 {1039 dispatch_nft_runtime!(collection.allowance(sender, spender, token))1038 dispatch_unique_runtime!(collection.allowance(sender, spender, token))1040 }1039 }104110401042 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {1041 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {1043 <pallet_nft::NftErcSupport<Runtime>>::get_code(&account)1042 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)1044 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))1043 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))1045 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))1044 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))1046 }1045 }1054 <pallet_common::Pallet<Runtime>>::allowed(collection, user)1053 <pallet_common::Pallet<Runtime>>::allowed(collection, user)1055 }1054 }1056 fn last_token_id(collection: CollectionId) -> TokenId {1055 fn last_token_id(collection: CollectionId) -> TokenId {1057 dispatch_nft_runtime!(collection.last_token_id())1056 dispatch_unique_runtime!(collection.last_token_id())1058 }1057 }1059 fn collection_by_id(collection: CollectionId) -> Option<Collection<AccountId>> {1058 fn collection_by_id(collection: CollectionId) -> Option<Collection<AccountId>> {1060 <pallet_common::CollectionById<Runtime>>::get(collection)1059 <pallet_common::CollectionById<Runtime>>::get(collection)1338 let mut list = Vec::<BenchmarkList>::new();1337 let mut list = Vec::<BenchmarkList>::new();133913381340 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);1339 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);1341 list_benchmark!(list, extra, pallet_nft, Nft);1340 list_benchmark!(list, extra, pallet_unique, Unique);1342 list_benchmark!(list, extra, pallet_inflation, Inflation);1341 list_benchmark!(list, extra, pallet_inflation, Inflation);1343 list_benchmark!(list, extra, pallet_fungible, Fungible);1342 list_benchmark!(list, extra, pallet_fungible, Fungible);1344 list_benchmark!(list, extra, pallet_refungible, Refungible);1343 list_benchmark!(list, extra, pallet_refungible, Refungible);1371 let params = (&config, &allowlist);1370 let params = (&config, &allowlist);137213711373 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1372 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1374 add_benchmark!(params, batches, pallet_nft, Nft);1373 add_benchmark!(params, batches, pallet_unique, Unique);1375 add_benchmark!(params, batches, pallet_inflation, Inflation);1374 add_benchmark!(params, batches, pallet_inflation, Inflation);1376 add_benchmark!(params, batches, pallet_fungible, Fungible);1375 add_benchmark!(params, batches, pallet_fungible, Fungible);1377 add_benchmark!(params, batches, pallet_refungible, Refungible);1376 add_benchmark!(params, batches, pallet_refungible, Refungible);tests/Dockerfile-testsdiffbeforeafterboth7RUN apt -y update; apt -y upgrade; apt -y install curl7RUN apt -y update; apt -y upgrade; apt -y install curl889910RUN mkdir nft_parachain10RUN mkdir unique_parachain11WORKDIR /nft_parachain11WORKDIR /unique_parachain121213RUN apt-get -y update && \13RUN apt-get -y update && \14 apt-get -y upgrade && \14 apt-get -y upgrade && \tests/package.jsondiffbeforeafterboth1{1{2 "name": "nfttests",2 "name": "unique-tests",3 "version": "1.0.0",3 "version": "1.0.0",4 "description": "Substrate Nft tests",4 "description": "Unique Chain Tests",5 "main": "",5 "main": "",6 "devDependencies": {6 "devDependencies": {7 "@polkadot/dev": "0.63.18",7 "@polkadot/dev": "0.63.18",tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth23 const collection = await queryCollectionExpectSuccess(api, collectionId);23 const collection = await queryCollectionExpectSuccess(api, collectionId);24 expect(collection.owner.toString()).to.be.equal(alice.address);24 expect(collection.owner.toString()).to.be.equal(alice.address);252526 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));26 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));27 await submitTransactionAsync(alice, changeAdminTx);27 await submitTransactionAsync(alice, changeAdminTx);282829 const adminListAfterAddAdmin = await getAdminList(api, collectionId);29 const adminListAfterAddAdmin = await getAdminList(api, collectionId);41 const collection = await queryCollectionExpectSuccess(api, collectionId);41 const collection = await queryCollectionExpectSuccess(api, collectionId);42 expect(collection.owner.toString()).to.be.equal(alice.address);42 expect(collection.owner.toString()).to.be.equal(alice.address);434344 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));44 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));45 await submitTransactionAsync(alice, changeAdminTx);45 await submitTransactionAsync(alice, changeAdminTx);464647 const adminListAfterAddAdmin = await getAdminList(api, collectionId);47 const adminListAfterAddAdmin = await getAdminList(api, collectionId);48 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));48 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));494950 const changeAdminTxCharlie = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(charlie.address));50 const changeAdminTxCharlie = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(charlie.address));51 await submitTransactionAsync(bob, changeAdminTxCharlie);51 await submitTransactionAsync(bob, changeAdminTxCharlie);52 const adminListAfterAddNewAdmin = await getAdminList(api, collectionId);52 const adminListAfterAddNewAdmin = await getAdminList(api, collectionId);53 expect(adminListAfterAddNewAdmin).to.be.deep.contains(normalizeAccountId(bob.address));53 expect(adminListAfterAddNewAdmin).to.be.deep.contains(normalizeAccountId(bob.address));63 const alice = privateKey('//Alice');63 const alice = privateKey('//Alice');64 const nonOwner = privateKey('//Bob_stash');64 const nonOwner = privateKey('//Bob_stash');656566 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(alice.address));66 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(alice.address));67 await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;67 await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;686869 const adminListAfterAddAdmin = await getAdminList(api, collectionId);69 const adminListAfterAddAdmin = await getAdminList(api, collectionId);80 const alice = privateKey('//Alice');80 const alice = privateKey('//Alice');81 const bob = privateKey('//Bob');81 const bob = privateKey('//Bob');828283 const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));83 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));84 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;84 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;858586 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)86 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)94 const alice = privateKey('//Alice');94 const alice = privateKey('//Alice');95 const bob = privateKey('//Bob');95 const bob = privateKey('//Bob');96 await destroyCollectionExpectSuccess(collectionId);96 await destroyCollectionExpectSuccess(collectionId);97 const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));97 const changeOwnerTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));98 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;98 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;9999100 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)100 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)125 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(accounts[i]));125 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(accounts[i]));126 }126 }127127128 const tx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(accounts[chainAdminLimit]));128 const tx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(accounts[chainAdminLimit]));129 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;129 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;130 });130 });131 });131 });tests/src/addToAllowList.test.tsdiffbeforeafterboth59 const collectionId = await getCreatedCollectionCount(api) + 1;59 const collectionId = await getCreatedCollectionCount(api) + 1;60 const bob = privateKey('//Bob');60 const bob = privateKey('//Bob');616162 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(bob.address));62 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(bob.address));63 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;63 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;64 });64 });65 });65 });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.addToAllowList(collectionId, normalizeAccountId(bob.address));74 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(bob.address));75 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;75 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;76 });76 });77 });77 });83 const collectionId = await createCollectionExpectSuccess();83 const collectionId = await createCollectionExpectSuccess();84 await enableAllowListExpectSuccess(alice, collectionId);84 await enableAllowListExpectSuccess(alice, collectionId);85 await enablePublicMintingExpectSuccess(alice, collectionId);85 await enablePublicMintingExpectSuccess(alice, collectionId);86 const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(ferdie.address), 'NFT');86 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(ferdie.address), 'NFT');87 await expect(submitTransactionExpectFailAsync(ferdie, tx)).to.be.rejected;87 await expect(submitTransactionExpectFailAsync(ferdie, tx)).to.be.rejected;88 });88 });89 });89 });tests/src/addToContractAllowList.test.tsdiffbeforeafterboth24 const bob = privateKey('//Bob');24 const bob = privateKey('//Bob');25 const [contract, deployer] = await deployFlipper(api);25 const [contract, deployer] = await deployFlipper(api);262627 const allowListedBefore = (await api.query.nft.contractAllowList(contract.address, bob.address)).toJSON();27 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();28 const addTx = api.tx.nft.addToContractAllowList(contract.address, bob.address);28 const addTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);29 const addEvents = await submitTransactionAsync(deployer, addTx);29 const addEvents = await submitTransactionAsync(deployer, addTx);30 const allowListedAfter = (await api.query.nft.contractAllowList(contract.address, bob.address)).toJSON();30 const allowListedAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();313132 expect(getGenericResult(addEvents).success).to.be.true;32 expect(getGenericResult(addEvents).success).to.be.true;33 expect(allowListedBefore).to.be.false;33 expect(allowListedBefore).to.be.false;40 const bob = privateKey('//Bob');40 const bob = privateKey('//Bob');41 const [contract, deployer] = await deployFlipper(api);41 const [contract, deployer] = await deployFlipper(api);424243 const allowListedBefore = (await api.query.nft.contractAllowList(contract.address, bob.address)).toJSON();43 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();44 const addTx = api.tx.nft.addToContractAllowList(contract.address, bob.address);44 const addTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);45 const addEvents = await submitTransactionAsync(deployer, addTx);45 const addEvents = await submitTransactionAsync(deployer, addTx);46 const allowListedAfter = (await api.query.nft.contractAllowList(contract.address, bob.address)).toJSON();46 const allowListedAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();47 const addAgainEvents = await submitTransactionAsync(deployer, addTx);47 const addAgainEvents = await submitTransactionAsync(deployer, addTx);48 const allowListedAgainAfter = (await api.query.nft.contractAllowList(contract.address, bob.address)).toJSON();48 const allowListedAgainAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();494950 expect(getGenericResult(addEvents).success).to.be.true;50 expect(getGenericResult(addEvents).success).to.be.true;51 expect(allowListedBefore).to.be.false;51 expect(allowListedBefore).to.be.false;64 const bob = privateKey('//Bob');64 const bob = privateKey('//Bob');65 const charlieGuineaPig = privateKey('//Charlie');65 const charlieGuineaPig = privateKey('//Charlie');666667 const allowListedBefore = (await api.query.nft.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();67 const allowListedBefore = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();68 const addTx = api.tx.nft.addToContractAllowList(charlieGuineaPig.address, bob.address);68 const addTx = api.tx.unique.addToContractAllowList(charlieGuineaPig.address, bob.address);69 await expect(submitTransactionExpectFailAsync(alice, addTx)).to.be.rejected;69 await expect(submitTransactionExpectFailAsync(alice, addTx)).to.be.rejected;70 const allowListedAfter = (await api.query.nft.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();70 const allowListedAfter = (await api.query.unique.contractAllowList(charlieGuineaPig.address, bob.address)).toJSON();717172 expect(allowListedBefore).to.be.false;72 expect(allowListedBefore).to.be.false;73 expect(allowListedAfter).to.be.false;73 expect(allowListedAfter).to.be.false;79 const bob = privateKey('//Bob');79 const bob = privateKey('//Bob');80 const [contract] = await deployFlipper(api);80 const [contract] = await deployFlipper(api);818182 const allowListedBefore = (await api.query.nft.contractAllowList(contract.address, bob.address)).toJSON();82 const allowListedBefore = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();83 const addTx = api.tx.nft.addToContractAllowList(contract.address, bob.address);83 const addTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);84 await expect(submitTransactionExpectFailAsync(bob, addTx)).to.be.rejected;84 await expect(submitTransactionExpectFailAsync(bob, addTx)).to.be.rejected;85 const allowListedAfter = (await api.query.nft.contractAllowList(contract.address, bob.address)).toJSON();85 const allowListedAfter = (await api.query.unique.contractAllowList(contract.address, bob.address)).toJSON();868687 expect(allowListedBefore).to.be.false;87 expect(allowListedBefore).to.be.false;88 expect(allowListedAfter).to.be.false;88 expect(allowListedAfter).to.be.false;tests/src/allowLists.test.tsdiffbeforeafterboth189 await enableAllowListExpectSuccess(alice, collectionId);189 await enableAllowListExpectSuccess(alice, collectionId);190190191 await usingApi(async (api) => {191 await usingApi(async (api) => {192 const tx = api.tx.nft.burnItem(collectionId, itemId, /*normalizeAccountId(Alice.address),*/ 11);192 const tx = api.tx.unique.burnItem(collectionId, itemId, /*normalizeAccountId(Alice.address),*/ 11);193 const badTransaction = async function () {193 const badTransaction = async function () {194 await submitTransactionExpectFailAsync(alice, tx);194 await submitTransactionExpectFailAsync(alice, tx);195 };195 };tests/src/burnItem.test.tsdiffbeforeafterboth40 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);40 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);414142 await usingApi(async (api) => {42 await usingApi(async (api) => {43 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);43 const tx = api.tx.unique.burnItem(collectionId, tokenId, 1);44 const events = await submitTransactionAsync(alice, tx);44 const events = await submitTransactionAsync(alice, tx);45 const result = getGenericResult(events);45 const result = getGenericResult(events);4646585859 await usingApi(async (api) => {59 await usingApi(async (api) => {60 // Destroy 1 of 1060 // Destroy 1 of 1061 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);61 const tx = api.tx.unique.burnItem(collectionId, tokenId, 1);62 const events = await submitTransactionAsync(alice, tx);62 const events = await submitTransactionAsync(alice, tx);63 const result = getGenericResult(events);63 const result = getGenericResult(events);646477 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);77 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);787879 await usingApi(async (api) => {79 await usingApi(async (api) => {80 const tx = api.tx.nft.burnItem(collectionId, tokenId, 100);80 const tx = api.tx.unique.burnItem(collectionId, tokenId, 100);81 const events = await submitTransactionAsync(alice, tx);81 const events = await submitTransactionAsync(alice, tx);82 const result = getGenericResult(events);82 const result = getGenericResult(events);8383979798 await usingApi(async (api) => {98 await usingApi(async (api) => {99 // Transfer 1/100 of the token to Bob99 // Transfer 1/100 of the token to Bob100 const transfertx = api.tx.nft.transfer(normalizeAccountId(bob.address), collectionId, tokenId, 1);100 const transfertx = api.tx.unique.transfer(normalizeAccountId(bob.address), collectionId, tokenId, 1);101 const events1 = await submitTransactionAsync(alice, transfertx);101 const events1 = await submitTransactionAsync(alice, transfertx);102 const result1 = getGenericResult(events1);102 const result1 = getGenericResult(events1);103103106 const aliceBalanceBefore = await getBalance(api, collectionId, alice.address, tokenId);106 const aliceBalanceBefore = await getBalance(api, collectionId, alice.address, tokenId);107107108 // Bob burns his portion108 // Bob burns his portion109 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);109 const tx = api.tx.unique.burnItem(collectionId, tokenId, 1);110 const events2 = await submitTransactionAsync(bob, tx);110 const events2 = await submitTransactionAsync(bob, tx);111 const result2 = getGenericResult(events2);111 const result2 = getGenericResult(events2);112112146 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);146 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);147147148 await usingApi(async (api) => {148 await usingApi(async (api) => {149 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);149 const tx = api.tx.unique.burnItem(collectionId, tokenId, 1);150 const events = await submitTransactionAsync(bob, tx);150 const events = await submitTransactionAsync(bob, tx);151 const result = getGenericResult(events);151 const result = getGenericResult(events);152152165165166 await usingApi(async (api) => {166 await usingApi(async (api) => {167 // Destroy 1 of 10167 // Destroy 1 of 10168 const tx = api.tx.nft.burnFrom(collectionId, normalizeAccountId(alice.address), tokenId, 1);168 const tx = api.tx.unique.burnFrom(collectionId, normalizeAccountId(alice.address), tokenId, 1);169 const events = await submitTransactionAsync(bob, tx);169 const events = await submitTransactionAsync(bob, tx);170 const result = getGenericResult(events);170 const result = getGenericResult(events);171171186 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);186 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);187187188 await usingApi(async (api) => {188 await usingApi(async (api) => {189 const tx = api.tx.nft.burnFrom(collectionId, normalizeAccountId(alice.address), tokenId, 100);189 const tx = api.tx.unique.burnFrom(collectionId, normalizeAccountId(alice.address), tokenId, 100);190 const events = await submitTransactionAsync(bob, tx);190 const events = await submitTransactionAsync(bob, tx);191 const result = getGenericResult(events);191 const result = getGenericResult(events);192 // Get alice balance192 // Get alice balance213 await destroyCollectionExpectSuccess(collectionId);213 await destroyCollectionExpectSuccess(collectionId);214214215 await usingApi(async (api) => {215 await usingApi(async (api) => {216 const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);216 const tx = api.tx.unique.burnItem(collectionId, tokenId, 0);217 const badTransaction = async function () {217 const badTransaction = async function () {218 await submitTransactionExpectFailAsync(alice, tx);218 await submitTransactionExpectFailAsync(alice, tx);219 };219 };228 const tokenId = 10;228 const tokenId = 10;229229230 await usingApi(async (api) => {230 await usingApi(async (api) => {231 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);231 const tx = api.tx.unique.burnItem(collectionId, tokenId, 1);232 const badTransaction = async function () {232 const badTransaction = async function () {233 await submitTransactionExpectFailAsync(alice, tx);233 await submitTransactionExpectFailAsync(alice, tx);234 };234 };243 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);243 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);244244245 await usingApi(async (api) => {245 await usingApi(async (api) => {246 const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);246 const tx = api.tx.unique.burnItem(collectionId, tokenId, 1);247 const badTransaction = async function () {247 const badTransaction = async function () {248 await submitTransactionExpectFailAsync(bob, tx);248 await submitTransactionExpectFailAsync(bob, tx);249 };249 };259259260 await usingApi(async (api) => {260 await usingApi(async (api) => {261261262 const burntx = api.tx.nft.burnItem(collectionId, tokenId, 1);262 const burntx = api.tx.unique.burnItem(collectionId, tokenId, 1);263 const events1 = await submitTransactionAsync(alice, burntx);263 const events1 = await submitTransactionAsync(alice, burntx);264 const result1 = getGenericResult(events1);264 const result1 = getGenericResult(events1);265 expect(result1.success).to.be.true;265 expect(result1.success).to.be.true;266266267 const tx = api.tx.nft.transfer(normalizeAccountId(bob.address), collectionId, tokenId, 1);267 const tx = api.tx.unique.transfer(normalizeAccountId(bob.address), collectionId, tokenId, 1);268 const badTransaction = async function () {268 const badTransaction = async function () {269 await submitTransactionExpectFailAsync(alice, tx);269 await submitTransactionExpectFailAsync(alice, tx);270 };270 };282282283 await usingApi(async (api) => {283 await usingApi(async (api) => {284 // Destroy 11 of 10284 // Destroy 11 of 10285 const tx = api.tx.nft.burnItem(collectionId, tokenId, 11);285 const tx = api.tx.unique.burnItem(collectionId, tokenId, 11);286 const badTransaction = async function () {286 const badTransaction = async function () {287 await submitTransactionExpectFailAsync(alice, tx);287 await submitTransactionExpectFailAsync(alice, tx);288 };288 };tests/src/change-collection-owner.test.tsdiffbeforeafterboth38 const collection =await queryCollectionExpectSuccess(api, collectionId);38 const collection =await queryCollectionExpectSuccess(api, collectionId);39 expect(collection.owner.toString()).to.be.deep.eq(alice.address);39 expect(collection.owner.toString()).to.be.deep.eq(alice.address);404041 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);41 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);42 await submitTransactionAsync(alice, changeOwnerTx);42 await submitTransactionAsync(alice, changeOwnerTx);434344 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);44 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);57 const collection = await queryCollectionExpectSuccess(api, collectionId);57 const collection = await queryCollectionExpectSuccess(api, collectionId);58 expect(collection.owner.toString()).to.be.deep.eq(alice.address);58 expect(collection.owner.toString()).to.be.deep.eq(alice.address);595960 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);60 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);61 await submitTransactionAsync(alice, changeOwnerTx);61 await submitTransactionAsync(alice, changeOwnerTx);626263 const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);63 const badChangeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, alice.address);64 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;64 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;656566 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);66 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);78 const collection = await queryCollectionExpectSuccess(api, collectionId);78 const collection = await queryCollectionExpectSuccess(api, collectionId);79 expect(collection.owner.toString()).to.be.deep.eq(alice.address);79 expect(collection.owner.toString()).to.be.deep.eq(alice.address);808081 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);81 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);82 await submitTransactionAsync(alice, changeOwnerTx);82 await submitTransactionAsync(alice, changeOwnerTx);838384 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);84 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);99 ownerCanTransfer: true,99 ownerCanTransfer: true,100 ownerCanDestroy: true,100 ownerCanDestroy: true,101 };101 };102 const tx1 = api.tx.nft.setCollectionLimits(102 const tx1 = api.tx.unique.setCollectionLimits(103 collectionId,103 collectionId,104 collectionLimits,104 collectionLimits,105 );105 );122 const collection = await queryCollectionExpectSuccess(api, collectionId);122 const collection = await queryCollectionExpectSuccess(api, collectionId);123 expect(collection.owner.toString()).to.be.deep.eq(alice.address);123 expect(collection.owner.toString()).to.be.deep.eq(alice.address);124124125 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);125 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);126 await submitTransactionAsync(alice, changeOwnerTx);126 await submitTransactionAsync(alice, changeOwnerTx);127127128 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);128 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);129 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);129 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);130130131 const changeOwnerTx2 = api.tx.nft.changeCollectionOwner(collectionId, charlie.address);131 const changeOwnerTx2 = api.tx.unique.changeCollectionOwner(collectionId, charlie.address);132 await submitTransactionAsync(bob, changeOwnerTx2);132 await submitTransactionAsync(bob, changeOwnerTx2);133133134 // ownership lost134 // ownership lost145 const alice = privateKey('//Alice');145 const alice = privateKey('//Alice');146 const bob = privateKey('//Bob');146 const bob = privateKey('//Bob');147147148 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);148 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);149 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;149 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;150150151 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);151 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);164164165 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);165 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);166166167 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);167 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);168 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;168 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;169169170 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);170 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);181 const alice = privateKey('//Alice');181 const alice = privateKey('//Alice');182 const bob = privateKey('//Bob');182 const bob = privateKey('//Bob');183183184 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);184 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);185 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;185 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;186186187 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)187 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)199 const collection = await queryCollectionExpectSuccess(api, collectionId);199 const collection = await queryCollectionExpectSuccess(api, collectionId);200 expect(collection.owner.toString()).to.be.deep.eq(alice.address);200 expect(collection.owner.toString()).to.be.deep.eq(alice.address);201201202 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);202 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);203 await submitTransactionAsync(alice, changeOwnerTx);203 await submitTransactionAsync(alice, changeOwnerTx);204204205 const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);205 const badChangeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, alice.address);206 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;206 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;207207208 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);208 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);220 ownerCanTransfer: true,220 ownerCanTransfer: true,221 ownerCanDestroy: true,221 ownerCanDestroy: true,222 };222 };223 const tx1 = api.tx.nft.setCollectionLimits(223 const tx1 = api.tx.unique.setCollectionLimits(224 collectionId,224 collectionId,225 collectionLimits,225 collectionLimits,226 );226 );tests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth29 await usingApi(async (api: ApiPromise) => {29 await usingApi(async (api: ApiPromise) => {30 const collectionID = await createCollectionExpectSuccess();30 const collectionID = await createCollectionExpectSuccess();31 const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');31 const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');32 const burnItem = api.tx.nft.burnItem(collectionID, itemID, 1);32 const burnItem = api.tx.unique.burnItem(collectionID, itemID, 1);33 const events = await submitTransactionAsync(alice, burnItem);33 const events = await submitTransactionAsync(alice, burnItem);34 const msg = JSON.stringify(nftEventMessage(events));34 const msg = JSON.stringify(nftEventMessage(events));35 expect(msg).to.be.contain(checkSection);35 expect(msg).to.be.contain(checkSection);tests/src/check-event/createCollectionEvent.test.tsdiffbeforeafterboth27 });27 });28 it('Check event from createCollection(): ', async () => {28 it('Check event from createCollection(): ', async () => {29 await usingApi(async (api: ApiPromise) => {29 await usingApi(async (api: ApiPromise) => {30 const tx = api.tx.nft.createCollection([0x31], [0x32], '0x33', 'NFT');30 const tx = api.tx.unique.createCollection([0x31], [0x32], '0x33', 'NFT');31 const events = await submitTransactionAsync(alice, tx);31 const events = await submitTransactionAsync(alice, tx);32 const msg = JSON.stringify(nftEventMessage(events));32 const msg = JSON.stringify(nftEventMessage(events));33 expect(msg).to.be.contain(checkSection);33 expect(msg).to.be.contain(checkSection);tests/src/check-event/createItemEvent.test.tsdiffbeforeafterboth28 it('Check event from createItem(): ', async () => {28 it('Check event from createItem(): ', async () => {29 await usingApi(async (api: ApiPromise) => {29 await usingApi(async (api: ApiPromise) => {30 const collectionID = await createCollectionExpectSuccess();30 const collectionID = await createCollectionExpectSuccess();31 const createItem = api.tx.nft.createItem(collectionID, normalizeAccountId(alice.address), 'NFT');31 const createItem = api.tx.unique.createItem(collectionID, normalizeAccountId(alice.address), 'NFT');32 const events = await submitTransactionAsync(alice, createItem);32 const events = await submitTransactionAsync(alice, createItem);33 const msg = JSON.stringify(nftEventMessage(events));33 const msg = JSON.stringify(nftEventMessage(events));34 expect(msg).to.be.contain(checkSection);34 expect(msg).to.be.contain(checkSection);tests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth29 await usingApi(async (api: ApiPromise) => {29 await usingApi(async (api: ApiPromise) => {30 const collectionID = await createCollectionExpectSuccess();30 const collectionID = await createCollectionExpectSuccess();31 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];31 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];32 const createMultipleItems = api.tx.nft.createMultipleItems(collectionID, normalizeAccountId(alice.address), args);32 const createMultipleItems = api.tx.unique.createMultipleItems(collectionID, normalizeAccountId(alice.address), args);33 const events = await submitTransactionAsync(alice, createMultipleItems);33 const events = await submitTransactionAsync(alice, createMultipleItems);34 const msg = JSON.stringify(nftEventMessage(events));34 const msg = JSON.stringify(nftEventMessage(events));35 expect(msg).to.be.contain(checkSection);35 expect(msg).to.be.contain(checkSection);tests/src/check-event/destroyCollectionEvent.test.tsdiffbeforeafterboth27 it('Check event from destroyCollection(): ', async () => {27 it('Check event from destroyCollection(): ', async () => {28 await usingApi(async (api: ApiPromise) => {28 await usingApi(async (api: ApiPromise) => {29 const collectionID = await createCollectionExpectSuccess();29 const collectionID = await createCollectionExpectSuccess();30 const destroyCollection = api.tx.nft.destroyCollection(collectionID);30 const destroyCollection = api.tx.unique.destroyCollection(collectionID);31 const events = await submitTransactionAsync(alice, destroyCollection);31 const events = await submitTransactionAsync(alice, destroyCollection);32 const msg = JSON.stringify(nftEventMessage(events));32 const msg = JSON.stringify(nftEventMessage(events));33 expect(msg).to.be.contain(checkTreasury);33 expect(msg).to.be.contain(checkTreasury);tests/src/check-event/transferEvent.test.tsdiffbeforeafterboth31 await usingApi(async (api: ApiPromise) => {31 await usingApi(async (api: ApiPromise) => {32 const collectionID = await createCollectionExpectSuccess();32 const collectionID = await createCollectionExpectSuccess();33 const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');33 const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');34 const transfer = api.tx.nft.transfer(normalizeAccountId(bob.address), collectionID, itemID, 1);34 const transfer = api.tx.unique.transfer(normalizeAccountId(bob.address), collectionID, itemID, 1);35 const events = await submitTransactionAsync(alice, transfer);35 const events = await submitTransactionAsync(alice, transfer);36 const msg = JSON.stringify(nftEventMessage(events));36 const msg = JSON.stringify(nftEventMessage(events));37 expect(msg).to.be.contain(checkSection);37 expect(msg).to.be.contain(checkSection);tests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth31 await usingApi(async (api: ApiPromise) => {31 await usingApi(async (api: ApiPromise) => {32 const collectionID = await createCollectionExpectSuccess();32 const collectionID = await createCollectionExpectSuccess();33 const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');33 const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');34 const transferFrom = api.tx.nft.transferFrom(normalizeAccountId(alice.address), normalizeAccountId(bob.address), collectionID, itemID, 1);34 const transferFrom = api.tx.unique.transferFrom(normalizeAccountId(alice.address), normalizeAccountId(bob.address), collectionID, itemID, 1);35 const events = await submitTransactionAsync(alice, transferFrom);35 const events = await submitTransactionAsync(alice, transferFrom);36 const msg = JSON.stringify(nftEventMessage(events));36 const msg = JSON.stringify(nftEventMessage(events));37 expect(msg).to.be.contain(checkSection);37 expect(msg).to.be.contain(checkSection);tests/src/collision-tests/admVsOwnerChanges.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';8import privateKey from '../substrate/privateKey';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import {10import {11 createCollectionExpectSuccess,11 createCollectionExpectSuccess,12 createItemExpectSuccess,12 createItemExpectSuccess,13 normalizeAccountId,13 normalizeAccountId,14 waitNewBlocks,14 waitNewBlocks,15} from '../util/helpers';15} from '../util/helpers';161617chai.use(chaiAsPromised);17chai.use(chaiAsPromised);18const expect = chai.expect;18const expect = chai.expect;19let Alice: IKeyringPair;19let Alice: IKeyringPair;20let Bob: IKeyringPair;20let Bob: IKeyringPair;21let Ferdie: IKeyringPair;21let Ferdie: IKeyringPair;222223before(async () => {23before(async () => {24 await usingApi(async () => {24 await usingApi(async () => {25 Alice = privateKey('//Alice');25 Alice = privateKey('//Alice');26 Bob = privateKey('//Bob');26 Bob = privateKey('//Bob');27 Ferdie = privateKey('//Ferdie');27 Ferdie = privateKey('//Ferdie');28 });28 });29});29});303031describe('Admin vs Owner changes token: ', () => {31describe('Admin vs Owner changes token: ', () => {32 // tslint:disable-next-line: max-line-length32 // tslint:disable-next-line: max-line-length33 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 () => {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 () => {343435 await usingApi(async (api) => {35 await usingApi(async (api) => {36 const collectionId = await createCollectionExpectSuccess();36 const collectionId = await createCollectionExpectSuccess();37 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));37 const changeAdminTxBob = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));38 await submitTransactionAsync(Alice, changeAdminTxBob);38 await submitTransactionAsync(Alice, changeAdminTxBob);39 const changeAdminTxFerdie = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));39 const changeAdminTxFerdie = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));40 await submitTransactionAsync(Bob, changeAdminTxFerdie);40 await submitTransactionAsync(Bob, changeAdminTxFerdie);41 const itemId = await createItemExpectSuccess(Ferdie, collectionId, 'NFT');41 const itemId = await createItemExpectSuccess(Ferdie, collectionId, 'NFT');424243 const changeOwner = api.tx.nft.transferFrom(normalizeAccountId(Ferdie.address), normalizeAccountId(Bob.address), collectionId, itemId, 1);43 const changeOwner = api.tx.unique.transferFrom(normalizeAccountId(Ferdie.address), normalizeAccountId(Bob.address), collectionId, itemId, 1);44 const approve = api.tx.nft.approve(normalizeAccountId(Bob.address), collectionId, itemId, 1);44 const approve = api.tx.unique.approve(normalizeAccountId(Bob.address), collectionId, itemId, 1);45 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);45 const sendItem = api.tx.unique.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);46 await Promise.all([46 await Promise.all([47 changeOwner.signAndSend(Alice),47 changeOwner.signAndSend(Alice),48 approve.signAndSend(Bob),48 approve.signAndSend(Bob),49 sendItem.signAndSend(Ferdie),49 sendItem.signAndSend(Ferdie),50 ]);50 ]);51 const itemBefore: any = await api.query.nft.nftItemList(collectionId, itemId);51 const itemBefore: any = await api.query.unique.nftItemList(collectionId, itemId);52 expect(itemBefore.owner).not.to.be.eq(Bob.address);52 expect(itemBefore.owner).not.to.be.eq(Bob.address);53 await waitNewBlocks(2);53 await waitNewBlocks(2);54 });54 });55 });55 });56});56});57*/57*/tests/src/collision-tests/admVsOwnerData.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';8import privateKey from '../substrate/privateKey';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import {10import {11 createCollectionExpectSuccess,11 createCollectionExpectSuccess,12 createItemExpectSuccess,12 createItemExpectSuccess,13 normalizeAccountId,13 normalizeAccountId,14 waitNewBlocks,14 waitNewBlocks,15} from '../util/helpers';15} from '../util/helpers';161617chai.use(chaiAsPromised);17chai.use(chaiAsPromised);18const expect = chai.expect;18const expect = chai.expect;19let Alice: IKeyringPair;19let Alice: IKeyringPair;20let Bob: IKeyringPair;20let Bob: IKeyringPair;212122before(async () => {22before(async () => {23 await usingApi(async () => {23 await usingApi(async () => {24 Alice = privateKey('//Alice');24 Alice = privateKey('//Alice');25 Bob = privateKey('//Bob');25 Bob = privateKey('//Bob');26 });26 });27});27});282829describe('Admin vs Owner changes the data in the token: ', () => {29describe('Admin vs Owner changes the data in the token: ', () => {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 () => {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 await usingApi(async (api) => {31 await usingApi(async (api) => {32 const AliceData = 1;32 const AliceData = 1;33 const BobData = 2;33 const BobData = 2;34 const collectionId = await createCollectionExpectSuccess();34 const collectionId = await createCollectionExpectSuccess();35 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));35 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));36 await submitTransactionAsync(Alice, changeAdminTx);36 await submitTransactionAsync(Alice, changeAdminTx);37 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');37 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');38 //38 //39 // tslint:disable-next-line: max-line-length39 // tslint:disable-next-line: max-line-length40 const AliceTx = api.tx.nft.setVariableMetaData(collectionId, itemId, AliceData.toString());40 const AliceTx = api.tx.unique.setVariableMetaData(collectionId, itemId, AliceData.toString());41 // tslint:disable-next-line: max-line-length41 // tslint:disable-next-line: max-line-length42 const BobTx = api.tx.nft.setVariableMetaData(collectionId, itemId, BobData.toString());42 const BobTx = api.tx.unique.setVariableMetaData(collectionId, itemId, BobData.toString());43 await Promise.all([43 await Promise.all([44 AliceTx.signAndSend(Alice),44 AliceTx.signAndSend(Alice),45 BobTx.signAndSend(Bob),45 BobTx.signAndSend(Bob),46 ]);46 ]);47 const item: any = await api.query.nft.nftItemList(collectionId, itemId);47 const item: any = await api.query.unique.nftItemList(collectionId, itemId);48 expect(item.variableData).not.to.be.eq(null); // Pseudo-random selection of one of two values48 expect(item.variableData).not.to.be.eq(null); // Pseudo-random selection of one of two values49 await waitNewBlocks(2);49 await waitNewBlocks(2);50 });50 });51 });51 });52});52});53*/53*/tests/src/collision-tests/admVsOwnerTake.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';8import privateKey from '../substrate/privateKey';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import {10import {11 createCollectionExpectSuccess,11 createCollectionExpectSuccess,12 createItemExpectSuccess,12 createItemExpectSuccess,13 normalizeAccountId,13 normalizeAccountId,14 waitNewBlocks,14 waitNewBlocks,15} from '../util/helpers';15} from '../util/helpers';161617chai.use(chaiAsPromised);17chai.use(chaiAsPromised);18const expect = chai.expect;18const expect = chai.expect;19let Alice: IKeyringPair;19let Alice: IKeyringPair;20let Bob: IKeyringPair;20let Bob: IKeyringPair;21let Ferdie: IKeyringPair;21let Ferdie: IKeyringPair;222223before(async () => {23before(async () => {24 await usingApi(async () => {24 await usingApi(async () => {25 Alice = privateKey('//Alice');25 Alice = privateKey('//Alice');26 Bob = privateKey('//Bob');26 Bob = privateKey('//Bob');27 Ferdie = privateKey('//Ferdie');27 Ferdie = privateKey('//Ferdie');28 });28 });29});29});303031describe('Admin vs Owner take token: ', () => {31describe('Admin vs Owner take token: ', () => {32 // tslint:disable-next-line: max-line-length32 // tslint:disable-next-line: max-line-length33 it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {33 it('The collection admin burns the token and in the same block the token owner performs a transaction on it ', async () => {34 await usingApi(async (api) => {34 await usingApi(async (api) => {35 const collectionId = await createCollectionExpectSuccess();35 const collectionId = await createCollectionExpectSuccess();36 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));36 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));37 await submitTransactionAsync(Alice, changeAdminTx);37 await submitTransactionAsync(Alice, changeAdminTx);38 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');38 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');39 //39 //40 const sendItem = api.tx.nft.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);40 const sendItem = api.tx.unique.transfer(normalizeAccountId(Ferdie.address), collectionId, itemId, 1);41 const burnItem = api.tx.nft.burnItem(collectionId, itemId, 1);41 const burnItem = api.tx.unique.burnItem(collectionId, itemId, 1);42 await Promise.all([42 await Promise.all([43 sendItem.signAndSend(Bob),43 sendItem.signAndSend(Bob),44 burnItem.signAndSend(Alice),44 burnItem.signAndSend(Alice),45 ]);45 ]);46 await waitNewBlocks(2);46 await waitNewBlocks(2);47 let itemBurn = false;47 let itemBurn = false;48 itemBurn = (await (api.query.nft.nftItemList(collectionId, itemId))).toJSON() as boolean;48 itemBurn = (await (api.query.unique.nftItemList(collectionId, itemId))).toJSON() as boolean;49 // tslint:disable-next-line: no-unused-expression49 // tslint:disable-next-line: no-unused-expression50 expect(itemBurn).to.be.null;50 expect(itemBurn).to.be.null;51 await waitNewBlocks(2);51 await waitNewBlocks(2);52 });52 });53 });53 });54});54});55*/55*/tests/src/collision-tests/adminDestroyCollection.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';8import privateKey from '../substrate/privateKey';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';9import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import {10import {11 createCollectionExpectSuccess,11 createCollectionExpectSuccess,12 normalizeAccountId,12 normalizeAccountId,13 waitNewBlocks,13 waitNewBlocks,14} from '../util/helpers';14} from '../util/helpers';151516chai.use(chaiAsPromised);16chai.use(chaiAsPromised);17const expect = chai.expect;17const expect = chai.expect;18let Alice: IKeyringPair;18let Alice: IKeyringPair;19let Bob: IKeyringPair;19let Bob: IKeyringPair;20let Ferdie: IKeyringPair;20let Ferdie: IKeyringPair;212122before(async () => {22before(async () => {23 await usingApi(async () => {23 await usingApi(async () => {24 Alice = privateKey('//Alice');24 Alice = privateKey('//Alice');25 Bob = privateKey('//Bob');25 Bob = privateKey('//Bob');26 Ferdie = privateKey('//Ferdie');26 Ferdie = privateKey('//Ferdie');27 });27 });28});28});292930describe('Deleting a collection while add address to allowlist: ', () => {30describe('Deleting a collection while add address to allowlist: ', () => {31 // tslint:disable-next-line: max-line-length31 // tslint:disable-next-line: max-line-length32 it('Adding an address to the collection allowlist in a block by the admin, and deleting the collection by the owner ', async () => {32 it('Adding an address to the collection allowlist in a block by the admin, and deleting the collection by the owner ', async () => {33 await usingApi(async (api) => {33 await usingApi(async (api) => {34 const collectionId = await createCollectionExpectSuccess();34 const collectionId = await createCollectionExpectSuccess();35 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));35 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));36 await submitTransactionAsync(Alice, changeAdminTx);36 await submitTransactionAsync(Alice, changeAdminTx);37 await waitNewBlocks(1);37 await waitNewBlocks(1);38 //38 //39 const addAllowlistAdm = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(Ferdie.address));39 const addAllowlistAdm = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(Ferdie.address));40 const destroyCollection = api.tx.nft.destroyCollection(collectionId);40 const destroyCollection = api.tx.unique.destroyCollection(collectionId);41 await Promise.all([41 await Promise.all([42 addAllowlistAdm.signAndSend(Bob),42 addAllowlistAdm.signAndSend(Bob),43 destroyCollection.signAndSend(Alice),43 destroyCollection.signAndSend(Alice),44 ]);44 ]);45 await waitNewBlocks(1);45 await waitNewBlocks(1);46 let allowList = false;46 let allowList = false;47 allowList = (await api.query.nft.allowList(collectionId, Ferdie.address)).toJSON() as boolean;47 allowList = (await api.query.unique.allowList(collectionId, Ferdie.address)).toJSON() as boolean;48 // tslint:disable-next-line: no-unused-expression48 // tslint:disable-next-line: no-unused-expression49 expect(allowList).to.be.false;49 expect(allowList).to.be.false;50 await waitNewBlocks(2);50 await waitNewBlocks(2);51 });51 });52 });52 });53});53});54*/54*/tests/src/collision-tests/adminLimitsOff.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';8import privateKey from '../substrate/privateKey';9import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';9import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';10import {10import {11 createCollectionExpectSuccess,11 createCollectionExpectSuccess,12 normalizeAccountId,12 normalizeAccountId,13 waitNewBlocks,13 waitNewBlocks,14} from '../util/helpers';14} from '../util/helpers';151516chai.use(chaiAsPromised);16chai.use(chaiAsPromised);17const expect = chai.expect;17const expect = chai.expect;18let Alice: IKeyringPair;18let Alice: IKeyringPair;19let Bob: IKeyringPair;19let Bob: IKeyringPair;20let Ferdie: IKeyringPair;20let Ferdie: IKeyringPair;21let Charlie: IKeyringPair;21let Charlie: IKeyringPair;22let Eve: IKeyringPair;22let Eve: IKeyringPair;23let Dave: IKeyringPair;23let Dave: IKeyringPair;242425before(async () => {25before(async () => {26 await usingApi(async () => {26 await usingApi(async () => {27 Alice = privateKey('//Alice');27 Alice = privateKey('//Alice');28 Bob = privateKey('//Bob');28 Bob = privateKey('//Bob');29 Ferdie = privateKey('//Ferdie');29 Ferdie = privateKey('//Ferdie');30 Charlie = privateKey('//Charlie');30 Charlie = privateKey('//Charlie');31 Eve = privateKey('//Eve');31 Eve = privateKey('//Eve');32 Dave = privateKey('//Dave');32 Dave = privateKey('//Dave');33 });33 });34});34});353536describe('Admin limit exceeded collection: ', () => {36describe('Admin limit exceeded collection: ', () => {37 // tslint:disable-next-line: max-line-length37 // tslint:disable-next-line: max-line-length38 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {38 it('In one block, the owner and admin add new admins to the collection more than the limit ', async () => {39 await usingApi(async (api) => {39 await usingApi(async (api) => {40 const collectionId = await createCollectionExpectSuccess();40 const collectionId = await createCollectionExpectSuccess();414142 const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();42 const chainAdminLimit = (api.consts.unique.collectionAdminsLimit as any).toNumber();43 expect(chainAdminLimit).to.be.equal(5);43 expect(chainAdminLimit).to.be.equal(5);444445 const changeAdminTx1 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));45 const changeAdminTx1 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Eve.address));46 await submitTransactionAsync(Alice, changeAdminTx1);46 await submitTransactionAsync(Alice, changeAdminTx1);47 const changeAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));47 const changeAdminTx2 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Dave.address));48 await submitTransactionAsync(Alice, changeAdminTx2);48 await submitTransactionAsync(Alice, changeAdminTx2);49 const changeAdminTx3 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));49 const changeAdminTx3 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));50 await submitTransactionAsync(Alice, changeAdminTx3);50 await submitTransactionAsync(Alice, changeAdminTx3);515152 const addAdmOne = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));52 const addAdmOne = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Ferdie.address));53 const addAdmTwo = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));53 const addAdmTwo = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));54 await Promise.all([54 await Promise.all([55 addAdmOne.signAndSend(Bob),55 addAdmOne.signAndSend(Bob),56 addAdmTwo.signAndSend(Alice),56 addAdmTwo.signAndSend(Alice),57 ]);57 ]);58 await waitNewBlocks(2);58 await waitNewBlocks(2);59 const changeAdminTx4 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));59 const changeAdminTx4 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Alice.address));60 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;60 await expect(submitTransactionExpectFailAsync(Alice, changeAdminTx4)).to.be.rejected;616162 const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));62 const adminListAfterAddAdmin: any = (await api.query.unique.adminList(collectionId));63 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));63 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Eve.address));64 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));64 expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Ferdie.address));65 expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));65 expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(Alice.address));66 await waitNewBlocks(2);66 await waitNewBlocks(2);67 });67 });68 });68 });69});69});70*/70*/tests/src/collision-tests/adminRightsOff.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import BN from 'bn.js';6import BN from 'bn.js';7import chai from 'chai';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';9import privateKey from '../substrate/privateKey';9import privateKey from '../substrate/privateKey';10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';11import {11import {12 createCollectionExpectSuccess,12 createCollectionExpectSuccess,13 normalizeAccountId,13 normalizeAccountId,14 waitNewBlocks,14 waitNewBlocks,15} from '../util/helpers';15} from '../util/helpers';161617chai.use(chaiAsPromised);17chai.use(chaiAsPromised);18const expect = chai.expect;18const expect = chai.expect;19let Alice: IKeyringPair;19let Alice: IKeyringPair;20let Bob: IKeyringPair;20let Bob: IKeyringPair;212122before(async () => {22before(async () => {23 await usingApi(async () => {23 await usingApi(async () => {24 Alice = privateKey('//Alice');24 Alice = privateKey('//Alice');25 Bob = privateKey('//Bob');25 Bob = privateKey('//Bob');26 });26 });27});27});282829describe('Deprivation of admin rights: ', () => {29describe('Deprivation of admin rights: ', () => {30 // tslint:disable-next-line: max-line-length30 // tslint:disable-next-line: max-line-length31 it('In the block, the collection admin adds a token or changes data, and the collection owner deprives the admin of rights ', async () => {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 usingApi(async (api) => {32 await usingApi(async (api) => {33 const collectionId = await createCollectionExpectSuccess();33 const collectionId = await createCollectionExpectSuccess();34 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));34 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));35 await submitTransactionAsync(Alice, changeAdminTx);35 await submitTransactionAsync(Alice, changeAdminTx);36 await waitNewBlocks(1);36 await waitNewBlocks(1);37 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];37 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];38 const addItemAdm = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);38 const addItemAdm = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);39 const removeAdm = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));39 const removeAdm = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));40 await Promise.all([40 await Promise.all([41 addItemAdm.signAndSend(Bob),41 addItemAdm.signAndSend(Bob),42 removeAdm.signAndSend(Alice),42 removeAdm.signAndSend(Alice),43 ]);43 ]);44 await waitNewBlocks(2);44 await waitNewBlocks(2);45 const itemsListIndex = await api.query.nft.itemListIndex(collectionId) as unknown as BN;45 const itemsListIndex = await api.query.unique.itemListIndex(collectionId) as unknown as BN;46 expect(itemsListIndex.toNumber()).to.be.equal(0);46 expect(itemsListIndex.toNumber()).to.be.equal(0);47 const adminList: any = (await api.query.nft.adminList(collectionId));47 const adminList: any = (await api.query.unique.adminList(collectionId));48 expect(adminList).not.to.be.contains(normalizeAccountId(Bob.address));48 expect(adminList).not.to.be.contains(normalizeAccountId(Bob.address));49 await waitNewBlocks(2);49 await waitNewBlocks(2);50 });50 });51 });51 });52});52});53*/53*/tests/src/collision-tests/setSponsorNewOwner.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';8import privateKey from '../substrate/privateKey';9import usingApi from '../substrate/substrate-api';9import usingApi from '../substrate/substrate-api';10import {10import {11 createCollectionExpectSuccess,11 createCollectionExpectSuccess,12 setCollectionSponsorExpectSuccess,12 setCollectionSponsorExpectSuccess,13 waitNewBlocks,13 waitNewBlocks,14} from '../util/helpers';14} from '../util/helpers';151516chai.use(chaiAsPromised);16chai.use(chaiAsPromised);17const expect = chai.expect;17const expect = chai.expect;18let Alice: IKeyringPair;18let Alice: IKeyringPair;19let Bob: IKeyringPair;19let Bob: IKeyringPair;20let Ferdie: IKeyringPair;20let Ferdie: IKeyringPair;212122before(async () => {22before(async () => {23 await usingApi(async () => {23 await usingApi(async () => {24 Alice = privateKey('//Alice');24 Alice = privateKey('//Alice');25 Bob = privateKey('//Bob');25 Bob = privateKey('//Bob');26 Ferdie = privateKey('//Ferdie');26 Ferdie = privateKey('//Ferdie');27 });27 });28});28});292930describe('Sponsored with new owner ', () => {30describe('Sponsored with new owner ', () => {31 // tslint:disable-next-line: max-line-length31 // tslint:disable-next-line: max-line-length32 it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {32 it('Confirmation of sponsorship of a collection in a block with a change in the owner of the collection: ', async () => {33 await usingApi(async (api) => {33 await usingApi(async (api) => {34 const collectionId = await createCollectionExpectSuccess();34 const collectionId = await createCollectionExpectSuccess();35 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);35 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);36 await waitNewBlocks(2);36 await waitNewBlocks(2);37 const confirmSponsorship = api.tx.nft.confirmSponsorship(collectionId);37 const confirmSponsorship = api.tx.unique.confirmSponsorship(collectionId);38 const changeCollectionOwner = api.tx.nft.changeCollectionOwner(collectionId, Ferdie.address);38 const changeCollectionOwner = api.tx.unique.changeCollectionOwner(collectionId, Ferdie.address);39 await Promise.all([39 await Promise.all([40 confirmSponsorship.signAndSend(Bob),40 confirmSponsorship.signAndSend(Bob),41 changeCollectionOwner.signAndSend(Alice),41 changeCollectionOwner.signAndSend(Alice),42 ]);42 ]);43 await waitNewBlocks(2);43 await waitNewBlocks(2);44 const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();44 const collection: any = (await api.query.unique.collectionById(collectionId)).toJSON();45 expect(collection.sponsorship.confirmed).to.be.eq(Bob.address);45 expect(collection.sponsorship.confirmed).to.be.eq(Bob.address);46 expect(collection.owner).to.be.eq(Ferdie.address);46 expect(collection.owner).to.be.eq(Ferdie.address);47 await waitNewBlocks(2);47 await waitNewBlocks(2);48 });48 });49 });49 });50});50});51*/51*/tests/src/collision-tests/sponsorPayments.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import { alicesPublicKey, bobsPublicKey } from '../accounts';8import { alicesPublicKey, bobsPublicKey } from '../accounts';9import getBalance from '../substrate/get-balance';9import getBalance from '../substrate/get-balance';10import privateKey from '../substrate/privateKey';10import privateKey from '../substrate/privateKey';11import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';11import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';12import {12import {13 confirmSponsorshipExpectSuccess,13 confirmSponsorshipExpectSuccess,14 createCollectionExpectSuccess,14 createCollectionExpectSuccess,15 createItemExpectSuccess,15 createItemExpectSuccess,16 setCollectionSponsorExpectSuccess,16 setCollectionSponsorExpectSuccess,17 normalizeAccountId,17 normalizeAccountId,18 waitNewBlocks,18 waitNewBlocks,19} from '../util/helpers';19} from '../util/helpers';202021chai.use(chaiAsPromised);21chai.use(chaiAsPromised);22const expect = chai.expect;22const expect = chai.expect;23let Alice: IKeyringPair;23let Alice: IKeyringPair;24let Bob: IKeyringPair;24let Bob: IKeyringPair;252526before(async () => {26before(async () => {27 await usingApi(async () => {27 await usingApi(async () => {28 Alice = privateKey('//Alice');28 Alice = privateKey('//Alice');29 Bob = privateKey('//Bob');29 Bob = privateKey('//Bob');30 });30 });31});31});323233describe('Payment of commission if one block: ', () => {33describe('Payment of commission if one block: ', () => {34 // tslint:disable-next-line: max-line-length34 // tslint:disable-next-line: max-line-length35 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 () => {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 await usingApi(async (api) => {36 await usingApi(async (api) => {37 const collectionId = await createCollectionExpectSuccess();37 const collectionId = await createCollectionExpectSuccess();38 const changeAdminTxBob = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));38 const changeAdminTxBob = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));39 await submitTransactionAsync(Alice, changeAdminTxBob);39 await submitTransactionAsync(Alice, changeAdminTxBob);40 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');40 const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');41 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);41 await setCollectionSponsorExpectSuccess(collectionId, Bob.address);42 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');42 await confirmSponsorshipExpectSuccess(collectionId, '//Bob');434344 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);44 const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);45 const sendItem = api.tx.nft.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);45 const sendItem = api.tx.unique.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);46 const revokeSponsor = api.tx.nft.removeCollectionSponsor(collectionId);46 const revokeSponsor = api.tx.unique.removeCollectionSponsor(collectionId);47 await Promise.all([47 await Promise.all([48 sendItem.signAndSend(Bob),48 sendItem.signAndSend(Bob),49 revokeSponsor.signAndSend(Alice),49 revokeSponsor.signAndSend(Alice),50 ]);50 ]);51 const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);51 const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);52 // tslint:disable-next-line:no-unused-expression52 // tslint:disable-next-line:no-unused-expression53 expect(alicesBalanceAfter === alicesBalanceBefore).to.be.true;53 expect(alicesBalanceAfter === alicesBalanceBefore).to.be.true;54 // tslint:disable-next-line:no-unused-expression54 // tslint:disable-next-line:no-unused-expression55 expect(bobsBalanceAfter === bobsBalanceBefore).to.be.true;55 expect(bobsBalanceAfter === bobsBalanceBefore).to.be.true;56 await waitNewBlocks(2);56 await waitNewBlocks(2);57 });57 });58 });58 });59});59});60*/60*/tests/src/collision-tests/tokenLimitsOff.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import BN from 'bn.js';6import BN from 'bn.js';7import chai from 'chai';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';9import privateKey from '../substrate/privateKey';9import privateKey from '../substrate/privateKey';10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';10import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';11import {11import {12 addToAllowListExpectSuccess,12 addToAllowListExpectSuccess,13 createCollectionExpectSuccess,13 createCollectionExpectSuccess,14 getCreateItemResult,14 getCreateItemResult,15 setMintPermissionExpectSuccess,15 setMintPermissionExpectSuccess,16 normalizeAccountId,16 normalizeAccountId,17 waitNewBlocks,17 waitNewBlocks,18} from '../util/helpers';18} from '../util/helpers';191920chai.use(chaiAsPromised);20chai.use(chaiAsPromised);21const expect = chai.expect;21const expect = chai.expect;22let Alice: IKeyringPair;22let Alice: IKeyringPair;23let Bob: IKeyringPair;23let Bob: IKeyringPair;24let Ferdie: IKeyringPair;24let Ferdie: IKeyringPair;252526const accountTokenOwnershipLimit = 4;26const accountTokenOwnershipLimit = 4;27const sponsoredMintSize = 4294967295;27const sponsoredMintSize = 4294967295;28const tokenLimit = 4;28const tokenLimit = 4;29const sponsorTimeout = 14400;29const sponsorTimeout = 14400;30const ownerCanTransfer = false;30const ownerCanTransfer = false;31const ownerCanDestroy = false;31const ownerCanDestroy = false;323233before(async () => {33before(async () => {34 await usingApi(async () => {34 await usingApi(async () => {35 Alice = privateKey('//Alice');35 Alice = privateKey('//Alice');36 Bob = privateKey('//Bob');36 Bob = privateKey('//Bob');37 Ferdie = privateKey('//Ferdie');37 Ferdie = privateKey('//Ferdie');38 });38 });39});39});404041describe('Token limit exceeded collection: ', () => {41describe('Token limit exceeded collection: ', () => {42 // tslint:disable-next-line: max-line-length42 // tslint:disable-next-line: max-line-length43 it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {43 it('The number of tokens created in the collection from different addresses exceeds the allowed collection limit ', async () => {44 await usingApi(async (api) => {44 await usingApi(async (api) => {45 const collectionId = await createCollectionExpectSuccess();45 const collectionId = await createCollectionExpectSuccess();46 await setMintPermissionExpectSuccess(Alice, collectionId, true);46 await setMintPermissionExpectSuccess(Alice, collectionId, true);47 await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);47 await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);48 await addToAllowListExpectSuccess(Alice, collectionId, Bob.address);48 await addToAllowListExpectSuccess(Alice, collectionId, Bob.address);49 const setCollectionLim = api.tx.nft.setCollectionLimits(49 const setCollectionLim = api.tx.unique.setCollectionLimits(50 collectionId,50 collectionId,51 {51 {52 accountTokenOwnershipLimit,52 accountTokenOwnershipLimit,53 sponsoredMintSize,53 sponsoredMintSize,54 tokenLimit,54 tokenLimit,55 // tslint:disable-next-line: object-literal-sort-keys55 // tslint:disable-next-line: object-literal-sort-keys56 sponsorTimeout,56 sponsorTimeout,57 ownerCanTransfer,57 ownerCanTransfer,58 ownerCanDestroy,58 ownerCanDestroy,59 },59 },60 );60 );61 const subTx = await submitTransactionAsync(Alice, setCollectionLim);61 const subTx = await submitTransactionAsync(Alice, setCollectionLim);62 const subTxTesult = getCreateItemResult(subTx);62 const subTxTesult = getCreateItemResult(subTx);63 // tslint:disable-next-line:no-unused-expression63 // tslint:disable-next-line:no-unused-expression64 expect(subTxTesult.success).to.be.true;64 expect(subTxTesult.success).to.be.true;65 await waitNewBlocks(2);65 await waitNewBlocks(2);666667 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];67 const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];68 const mintItemOne = api.tx.nft68 const mintItemOne = api.tx.unique69 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);69 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);70 const mintItemTwo = api.tx.nft70 const mintItemTwo = api.tx.unique71 .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);71 .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);72 await Promise.all([72 await Promise.all([73 mintItemOne.signAndSend(Ferdie),73 mintItemOne.signAndSend(Ferdie),74 mintItemTwo.signAndSend(Bob),74 mintItemTwo.signAndSend(Bob),75 ]);75 ]);76 await waitNewBlocks(2);76 await waitNewBlocks(2);77 const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;77 const itemsListIndexAfter = await api.query.unique.itemListIndex(collectionId) as unknown as BN;78 expect(itemsListIndexAfter.toNumber()).to.be.equal(3);78 expect(itemsListIndexAfter.toNumber()).to.be.equal(3);79 // TokenLimit = 4. The first transaction is successful. The second should fail.79 // TokenLimit = 4. The first transaction is successful. The second should fail.80 await waitNewBlocks(2);80 await waitNewBlocks(2);81 });81 });82 });82 });83});83});84*/84*/8585tests/src/collision-tests/turnsOffMinting.test.tsdiffbeforeafterboth1/* broken by design1/* broken by design2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel3// the order of execution is indeterminate3// the order of execution is indeterminate445import { IKeyringPair } from '@polkadot/types/types';5import { IKeyringPair } from '@polkadot/types/types';6import chai from 'chai';6import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import privateKey from '../substrate/privateKey';8import privateKey from '../substrate/privateKey';9import usingApi from '../substrate/substrate-api';9import usingApi from '../substrate/substrate-api';10import {10import {11 addToAllowListExpectSuccess,11 addToAllowListExpectSuccess,12 createCollectionExpectSuccess,12 createCollectionExpectSuccess,13 setMintPermissionExpectSuccess,13 setMintPermissionExpectSuccess,14 normalizeAccountId,14 normalizeAccountId,15 waitNewBlocks,15 waitNewBlocks,16} from '../util/helpers';16} from '../util/helpers';171718chai.use(chaiAsPromised);18chai.use(chaiAsPromised);19const expect = chai.expect;19const expect = chai.expect;20let Alice: IKeyringPair;20let Alice: IKeyringPair;21let Ferdie: IKeyringPair;21let Ferdie: IKeyringPair;222223before(async () => {23before(async () => {24 await usingApi(async () => {24 await usingApi(async () => {25 Alice = privateKey('//Alice');25 Alice = privateKey('//Alice');26 Ferdie = privateKey('//Ferdie');26 Ferdie = privateKey('//Ferdie');27 });27 });28});28});292930describe('Turns off minting mode: ', () => {30describe('Turns off minting mode: ', () => {31 // tslint:disable-next-line: max-line-length31 // tslint:disable-next-line: max-line-length32 it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {32 it('The collection owner turns off minting mode and there are minting transactions in the same block ', async () => {33 await usingApi(async (api) => {33 await usingApi(async (api) => {34 const collectionId = await createCollectionExpectSuccess();34 const collectionId = await createCollectionExpectSuccess();35 await setMintPermissionExpectSuccess(Alice, collectionId, true);35 await setMintPermissionExpectSuccess(Alice, collectionId, true);36 await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);36 await addToAllowListExpectSuccess(Alice, collectionId, Ferdie.address);373738 const mintItem = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');38 const mintItem = api.tx.unique.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');39 const offMinting = api.tx.nft.setMintPermission(collectionId, false);39 const offMinting = api.tx.unique.setMintPermission(collectionId, false);40 await Promise.all([40 await Promise.all([41 mintItem.signAndSend(Ferdie),41 mintItem.signAndSend(Ferdie),42 offMinting.signAndSend(Alice),42 offMinting.signAndSend(Alice),43 ]);43 ]);44 let itemList = false;44 let itemList = false;45 itemList = (await (api.query.nft.nftItemList(collectionId, mintItem))).toJSON() as boolean;45 itemList = (await (api.query.unique.nftItemList(collectionId, mintItem))).toJSON() as boolean;46 // tslint:disable-next-line: no-unused-expression46 // tslint:disable-next-line: no-unused-expression47 expect(itemList).to.be.null;47 expect(itemList).to.be.null;48 await waitNewBlocks(2);48 await waitNewBlocks(2);49 });49 });50 });50 });51});51});52*/52*/tests/src/confirmSponsorship.test.tsdiffbeforeafterboth76 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);76 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);777778 // Transfer this tokens from unused address to Alice78 // Transfer this tokens from unused address to Alice79 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 0);79 const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 0);80 const events = await submitTransactionAsync(zeroBalance, zeroToAlice);80 const events = await submitTransactionAsync(zeroBalance, zeroToAlice);81 const result = getGenericResult(events);81 const result = getGenericResult(events);82 expect(result.success).to.be.true;82 expect(result.success).to.be.true;103 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);103 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);104104105 // Transfer this tokens from unused address to Alice105 // Transfer this tokens from unused address to Alice106 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);106 const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);107 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);107 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);108 const result1 = getGenericResult(events1);108 const result1 = getGenericResult(events1);109 expect(result1.success).to.be.true;109 expect(result1.success).to.be.true;129 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);129 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);130130131 // Transfer this tokens from unused address to Alice131 // Transfer this tokens from unused address to Alice132 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);132 const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);133 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);133 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);134 const result1 = getGenericResult(events1);134 const result1 = getGenericResult(events1);135135184184185 // Transfer this token from Alice to unused address and back185 // Transfer this token from Alice to unused address and back186 // Alice to Zero gets sponsored186 // Alice to Zero gets sponsored187 const aliceToZero = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 0);187 const aliceToZero = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 0);188 const events1 = await submitTransactionAsync(alice, aliceToZero);188 const events1 = await submitTransactionAsync(alice, aliceToZero);189 const result1 = getGenericResult(events1);189 const result1 = getGenericResult(events1);190190191 // Second transfer should fail191 // Second transfer should fail192 const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();192 const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();193 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);193 const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);194 const badTransaction = async function () {194 const badTransaction = async function () {195 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);195 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);196 };196 };222 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);222 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);223223224 // Transfer this tokens in parts from unused address to Alice224 // Transfer this tokens in parts from unused address to Alice225 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);225 const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);226 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);226 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);227 const result1 = getGenericResult(events1);227 const result1 = getGenericResult(events1);228 expect(result1.success).to.be.true;228 expect(result1.success).to.be.true;254 // Mint token for alice254 // Mint token for alice255 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);255 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);256256257 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(alice.address), collectionId, itemId, 1);257 const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 1);258258259 // Zero to alice gets sponsored259 // Zero to alice gets sponsored260 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);260 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);tests/src/contracts.test.tsdiffbeforeafterboth73 const collectionId = await createCollectionExpectSuccess();73 const collectionId = await createCollectionExpectSuccess();74 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');74 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');75 const [contract] = await deployTransferContract(api);75 const [contract] = await deployTransferContract(api);76 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);76 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, contract.address);77 await submitTransactionAsync(alice, changeAdminTx);77 await submitTransactionAsync(alice, changeAdminTx);787879 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));79 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));105 const result = getGenericResult(events);105 const result = getGenericResult(events);106 expect(result.success).to.be.true;106 expect(result.success).to.be.true;107107108 const tokensAfter = (await api.query.nft.nftItemList.entries(collectionId)).map((kv: any) => kv[1].toJSON());108 const tokensAfter = (await api.query.unique.nftItemList.entries(collectionId)).map((kv: any) => kv[1].toJSON());109 expect(tokensAfter).to.be.deep.equal([109 expect(tokensAfter).to.be.deep.equal([110 {110 {111 owner: bob.address,111 owner: bob.address,137 const result = getGenericResult(events);137 const result = getGenericResult(events);138 expect(result.success).to.be.true;138 expect(result.success).to.be.true;139139140 const tokensAfter: any = (await api.query.nft.nftItemList.entries(collectionId) as any)140 const tokensAfter: any = (await api.query.unique.nftItemList.entries(collectionId) as any)141 .map((kv: any) => kv[1].toJSON())141 .map((kv: any) => kv[1].toJSON())142 .sort((a: any, b: any) => a.constData.localeCompare(b.constData));142 .sort((a: any, b: any) => a.constData.localeCompare(b.constData));143 expect(tokensAfter).to.be.deep.equal([143 expect(tokensAfter).to.be.deep.equal([195 const result = getGenericResult(events);195 const result = getGenericResult(events);196 expect(result.success).to.be.true;196 expect(result.success).to.be.true;197197198 const token: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();198 const token: any = (await api.query.unique.nftItemList(collectionId, tokenId) as any).unwrap();199 expect(token.owner.toString()).to.be.equal(charlie.address);199 expect(token.owner.toString()).to.be.equal(charlie.address);200 });200 });201 });201 });213 const result = getGenericResult(events);213 const result = getGenericResult(events);214 expect(result.success).to.be.true;214 expect(result.success).to.be.true;215215216 const token: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();216 const token: any = (await api.query.unique.nftItemList(collectionId, tokenId) as any).unwrap();217 expect(token.variableData.toString()).to.be.equal('0x121314');217 expect(token.variableData.toString()).to.be.equal('0x121314');218 });218 });219 });219 });225225226 const collectionId = await createCollectionExpectSuccess();226 const collectionId = await createCollectionExpectSuccess();227 const [contract] = await deployTransferContract(api);227 const [contract] = await deployTransferContract(api);228 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);228 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, contract.address);229 await submitTransactionAsync(alice, changeAdminTx);229 await submitTransactionAsync(alice, changeAdminTx);230230231 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.false;231 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.false;tests/src/createMultipleItems.test.tsdiffbeforeafterboth34 expect(itemsListIndexBefore).to.be.equal(0);34 expect(itemsListIndexBefore).to.be.equal(0);35 const alice = privateKey('//Alice');35 const alice = privateKey('//Alice');36 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];36 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];37 const createMultipleItemsTx = api.tx.nft37 const createMultipleItemsTx = api.tx.unique38 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);38 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);39 await submitTransactionAsync(alice, createMultipleItemsTx);39 await submitTransactionAsync(alice, createMultipleItemsTx);40 const itemsListIndexAfter = await getLastTokenId(api, collectionId);40 const itemsListIndexAfter = await getLastTokenId(api, collectionId);65 {Fungible: {value: 2}},65 {Fungible: {value: 2}},66 {Fungible: {value: 3}},66 {Fungible: {value: 3}},67 ];67 ];68 const createMultipleItemsTx = api.tx.nft68 const createMultipleItemsTx = api.tx.unique69 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);69 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);70 await submitTransactionAsync(alice, createMultipleItemsTx);70 await submitTransactionAsync(alice, createMultipleItemsTx);71 const token1Data = await getBalance(api, collectionId, alice.address, 0);71 const token1Data = await getBalance(api, collectionId, alice.address, 0);85 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},85 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},86 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},86 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},87 ];87 ];88 const createMultipleItemsTx = api.tx.nft88 const createMultipleItemsTx = api.tx.unique89 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);89 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);90 await submitTransactionAsync(alice, createMultipleItemsTx);90 await submitTransactionAsync(alice, createMultipleItemsTx);91 const itemsListIndexAfter = await getLastTokenId(api, collectionId);91 const itemsListIndexAfter = await getLastTokenId(api, collectionId);117 {NFT: ['A', 'A']},117 {NFT: ['A', 'A']},118 {NFT: ['B', 'B']},118 {NFT: ['B', 'B']},119 ];119 ];120 const createMultipleItemsTx = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);120 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);121 const events = await submitTransactionAsync(alice, createMultipleItemsTx);121 const events = await submitTransactionAsync(alice, createMultipleItemsTx);122 const result = getGenericResult(events);122 const result = getGenericResult(events);123 expect(result.success).to.be.true;123 expect(result.success).to.be.true;144 expect(itemsListIndexBefore).to.be.equal(0);144 expect(itemsListIndexBefore).to.be.equal(0);145 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);145 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);146 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];146 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];147 const createMultipleItemsTx = api.tx.nft147 const createMultipleItemsTx = api.tx.unique148 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);148 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);149 await submitTransactionAsync(bob, createMultipleItemsTx);149 await submitTransactionAsync(bob, createMultipleItemsTx);150 const itemsListIndexAfter = await getLastTokenId(api, collectionId);150 const itemsListIndexAfter = await getLastTokenId(api, collectionId);175 {Fungible: {value: 2}},175 {Fungible: {value: 2}},176 {Fungible: {value: 3}},176 {Fungible: {value: 3}},177 ];177 ];178 const createMultipleItemsTx = api.tx.nft178 const createMultipleItemsTx = api.tx.unique179 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);179 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);180 await submitTransactionAsync(bob, createMultipleItemsTx);180 await submitTransactionAsync(bob, createMultipleItemsTx);181 const token1Data = await getBalance(api, collectionId, bob.address, 0);181 const token1Data = await getBalance(api, collectionId, bob.address, 0);195 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},195 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},196 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},196 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},197 ];197 ];198 const createMultipleItemsTx = api.tx.nft198 const createMultipleItemsTx = api.tx.unique199 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);199 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);200 await submitTransactionAsync(bob, createMultipleItemsTx);200 await submitTransactionAsync(bob, createMultipleItemsTx);201 const itemsListIndexAfter = await getLastTokenId(api, collectionId);201 const itemsListIndexAfter = await getLastTokenId(api, collectionId);234 const itemsListIndexBefore = await getLastTokenId(api, collectionId);234 const itemsListIndexBefore = await getLastTokenId(api, collectionId);235 expect(itemsListIndexBefore).to.be.equal(0);235 expect(itemsListIndexBefore).to.be.equal(0);236 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];236 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];237 const createMultipleItemsTx = api.tx.nft237 const createMultipleItemsTx = api.tx.unique238 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);238 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);239 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;239 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;240 });240 });250 {Fungible: {value: 2}},250 {Fungible: {value: 2}},251 {Fungible: {value: 3}},251 {Fungible: {value: 3}},252 ];252 ];253 const createMultipleItemsTx = api.tx.nft253 const createMultipleItemsTx = api.tx.unique254 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);254 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);255 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;255 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;256 });256 });266 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},266 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},267 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},267 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},268 ];268 ];269 const createMultipleItemsTx = api.tx.nft269 const createMultipleItemsTx = api.tx.unique270 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);270 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);271 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;271 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;272 });272 });275 it('Create token in not existing collection', async () => {275 it('Create token in not existing collection', async () => {276 await usingApi(async (api: ApiPromise) => {276 await usingApi(async (api: ApiPromise) => {277 const collectionId = await getCreatedCollectionCount(api) + 1;277 const collectionId = await getCreatedCollectionCount(api) + 1;278 const createMultipleItemsTx = api.tx.nft278 const createMultipleItemsTx = api.tx.unique279 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);279 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);280 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;280 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;281 });281 });291 {NFT: ['B'.repeat(2049), 'B'.repeat(2049)]},291 {NFT: ['B'.repeat(2049), 'B'.repeat(2049)]},292 {NFT: ['C'.repeat(2049), 'C'.repeat(2049)]},292 {NFT: ['C'.repeat(2049), 'C'.repeat(2049)]},293 ];293 ];294 const createMultipleItemsTx = api.tx.nft294 const createMultipleItemsTx = api.tx.unique295 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);295 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);296 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;296 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;297297303 {ReFungible: ['2'.repeat(2049), '2'.repeat(2049), 10]},303 {ReFungible: ['2'.repeat(2049), '2'.repeat(2049), 10]},304 {ReFungible: ['3'.repeat(2049), '3'.repeat(2049), 10]},304 {ReFungible: ['3'.repeat(2049), '3'.repeat(2049), 10]},305 ];305 ];306 const createMultipleItemsTxFungible = api.tx.nft306 const createMultipleItemsTxFungible = api.tx.unique307 .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);307 .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);308 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;308 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;309 });309 });312 it('Create tokens with different types', async () => {312 it('Create tokens with different types', async () => {313 await usingApi(async (api: ApiPromise) => {313 await usingApi(async (api: ApiPromise) => {314 const collectionId = await createCollectionExpectSuccess();314 const collectionId = await createCollectionExpectSuccess();315 const createMultipleItemsTx = api.tx.nft315 const createMultipleItemsTx = api.tx.unique316 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);316 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);317 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;317 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;318 // garbage collection :-D318 // garbage collection :-D328 {NFT: ['B', 'B'.repeat(2049)]},328 {NFT: ['B', 'B'.repeat(2049)]},329 {NFT: ['C'.repeat(2049), 'C']},329 {NFT: ['C'.repeat(2049), 'C']},330 ];330 ];331 const createMultipleItemsTx = await api.tx.nft331 const createMultipleItemsTx = await api.tx.unique332 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);332 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);333 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;333 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;334 });334 });345 {NFT: ['A', 'A']},345 {NFT: ['A', 'A']},346 {NFT: ['B', 'B']},346 {NFT: ['B', 'B']},347 ];347 ];348 const createMultipleItemsTx = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);348 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);349 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;349 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;350 });350 });351 });351 });tests/src/eth/nonFungible.test.tsdiffbeforeafterboth70 const alice = privateKey('//Alice');70 const alice = privateKey('//Alice');717172 const caller = await createEthAccountWithBalance(api, web3);72 const caller = await createEthAccountWithBalance(api, web3);73 const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: caller});73 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: caller});74 await submitTransactionAsync(alice, changeAdminTx);74 await submitTransactionAsync(alice, changeAdminTx);75 const receiver = createEthAccount(web3);75 const receiver = createEthAccount(web3);7676109 const alice = privateKey('//Alice');109 const alice = privateKey('//Alice');110110111 const caller = await createEthAccountWithBalance(api, web3);111 const caller = await createEthAccountWithBalance(api, web3);112 const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: caller});112 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: caller});113 await submitTransactionAsync(alice, changeAdminTx);113 await submitTransactionAsync(alice, changeAdminTx);114 const receiver = createEthAccount(web3);114 const receiver = createEthAccount(web3);115115tests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth88 const address = collectionIdToAddress(collection);88 const address = collectionIdToAddress(collection);89 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));89 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));909091 const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: contract.options.address});91 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});92 await submitTransactionAsync(alice, changeAdminTx);92 await submitTransactionAsync(alice, changeAdminTx);939394 {94 {127127128 const address = collectionIdToAddress(collection);128 const address = collectionIdToAddress(collection);129 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));129 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));130 const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: contract.options.address});130 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});131 await submitTransactionAsync(alice, changeAdminTx);131 await submitTransactionAsync(alice, changeAdminTx);132132133 {133 {190 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));190 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));191 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});191 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});192192193 const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: contract.options.address});193 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});194 await submitTransactionAsync(alice, changeAdminTx);194 await submitTransactionAsync(alice, changeAdminTx);195195196 {196 {tests/src/pallet-presence.test.tsdiffbeforeafterboth35 'cumulusxcm',35 'cumulusxcm',36 'dmpqueue',36 'dmpqueue',37 'inflation',37 'inflation',38 'nft',38 'unique',39 'nonfungible',39 'nonfungible',40 'refungible',40 'refungible',41 'scheduler',41 'scheduler',tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth22 const collection = await queryCollectionExpectSuccess(api, collectionId);22 const collection = await queryCollectionExpectSuccess(api, collectionId);23 expect(collection.owner.toString()).to.be.deep.eq(alice.address);23 expect(collection.owner.toString()).to.be.deep.eq(alice.address);24 // first - add collection admin Bob24 // first - add collection admin Bob25 const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));25 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));26 await submitTransactionAsync(alice, addAdminTx);26 await submitTransactionAsync(alice, addAdminTx);272728 const adminListAfterAddAdmin = await getAdminList(api, collectionId);28 const adminListAfterAddAdmin = await getAdminList(api, collectionId);29 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));29 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));303031 // then remove bob from admins of collection31 // then remove bob from admins of collection32 const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));32 const removeAdminTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));33 await submitTransactionAsync(alice, removeAdminTx);33 await submitTransactionAsync(alice, removeAdminTx);343435 const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);35 const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);46 const collection = await queryCollectionExpectSuccess(api, collectionId);46 const collection = await queryCollectionExpectSuccess(api, collectionId);47 expect(collection.owner.toString()).to.be.eq(alice.address);47 expect(collection.owner.toString()).to.be.eq(alice.address);48 // first - add collection admin Bob48 // first - add collection admin Bob49 const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));49 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));50 await submitTransactionAsync(alice, addAdminTx);50 await submitTransactionAsync(alice, addAdminTx);515152 const addAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(charlie.address));52 const addAdminTx2 = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(charlie.address));53 await submitTransactionAsync(alice, addAdminTx2);53 await submitTransactionAsync(alice, addAdminTx2);545455 const adminListAfterAddAdmin = await getAdminList(api, collectionId);55 const adminListAfterAddAdmin = await getAdminList(api, collectionId);56 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));56 expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));575758 // then remove bob from admins of collection58 // then remove bob from admins of collection59 const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));59 const removeAdminTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));60 await submitTransactionAsync(charlie, removeAdminTx);60 await submitTransactionAsync(charlie, removeAdminTx);616162 const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);62 const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);72 const adminListBeforeAddAdmin = await getAdminList(api, collectionId);72 const adminListBeforeAddAdmin = await getAdminList(api, collectionId);73 expect(adminListBeforeAddAdmin).to.have.lengthOf(0);73 expect(adminListBeforeAddAdmin).to.have.lengthOf(0);747475 const tx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(alice.address));75 const tx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(alice.address));76 await submitTransactionAsync(alice, tx);76 await submitTransactionAsync(alice, tx);77 });77 });78 });78 });86 const alice = privateKey('//Alice');86 const alice = privateKey('//Alice');87 const bob = privateKey('//Bob');87 const bob = privateKey('//Bob');888889 const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));89 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));90 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;90 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;919192 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)92 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)103103104 await destroyCollectionExpectSuccess(collectionId);104 await destroyCollectionExpectSuccess(collectionId);105105106 const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));106 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));107 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;107 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;108108109 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)109 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)118 const bob = privateKey('//Bob');118 const bob = privateKey('//Bob');119 const charlie = privateKey('//Charlie');119 const charlie = privateKey('//Charlie');120120121 const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));121 const addAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));122 await submitTransactionAsync(alice, addAdminTx);122 await submitTransactionAsync(alice, addAdminTx);123123124 const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));124 const changeOwnerTx = api.tx.unique.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));125 await expect(submitTransactionExpectFailAsync(charlie, changeOwnerTx)).to.be.rejected;125 await expect(submitTransactionExpectFailAsync(charlie, changeOwnerTx)).to.be.rejected;126126127 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)127 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)tests/src/removeCollectionSponsor.test.tsdiffbeforeafterboth545455 // Transfer this tokens from unused address to Alice - should fail55 // Transfer this tokens from unused address to Alice - should fail56 const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();56 const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();57 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);57 const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);58 const badTransaction = async function () {58 const badTransaction = async function () {59 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);59 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);60 };60 };tests/src/setCollectionLimits.test.tsdiffbeforeafterboth41 });41 });42 it('execute setCollectionLimits with predefined params ', async () => {42 it('execute setCollectionLimits with predefined params ', async () => {43 await usingApi(async (api: ApiPromise) => {43 await usingApi(async (api: ApiPromise) => {44 tx = api.tx.nft.setCollectionLimits(44 tx = api.tx.unique.setCollectionLimits(45 collectionIdForTesting,45 collectionIdForTesting,46 {46 {47 accountTokenOwnershipLimit: accountTokenOwnershipLimit,47 accountTokenOwnershipLimit: accountTokenOwnershipLimit,82 };82 };838384 // The first time84 // The first time85 const tx1 = api.tx.nft.setCollectionLimits(85 const tx1 = api.tx.unique.setCollectionLimits(86 collectionIdForTesting,86 collectionIdForTesting,87 collectionLimits,87 collectionLimits,88 );88 );93 expect(collectionInfo1.limits.tokenLimit.unwrap().toNumber()).to.be.equal(tokenLimit);93 expect(collectionInfo1.limits.tokenLimit.unwrap().toNumber()).to.be.equal(tokenLimit);949495 // The second time95 // The second time96 const tx2 = api.tx.nft.setCollectionLimits(96 const tx2 = api.tx.unique.setCollectionLimits(97 collectionIdForTesting,97 collectionIdForTesting,98 collectionLimits,98 collectionLimits,99 );99 );121 await usingApi(async (api: ApiPromise) => {121 await usingApi(async (api: ApiPromise) => {122 const collectionCount = await getCreatedCollectionCount(api);122 const collectionCount = await getCreatedCollectionCount(api);123 const nonExistedCollectionId = collectionCount + 1;123 const nonExistedCollectionId = collectionCount + 1;124 tx = api.tx.nft.setCollectionLimits(124 tx = api.tx.unique.setCollectionLimits(125 nonExistedCollectionId,125 nonExistedCollectionId,126 {126 {127 accountTokenOwnershipLimit,127 accountTokenOwnershipLimit,135 });135 });136 it('execute setCollectionLimits from user who is not owner of this collection', async () => {136 it('execute setCollectionLimits from user who is not owner of this collection', async () => {137 await usingApi(async (api: ApiPromise) => {137 await usingApi(async (api: ApiPromise) => {138 tx = api.tx.nft.setCollectionLimits(138 tx = api.tx.unique.setCollectionLimits(139 collectionIdForTesting,139 collectionIdForTesting,140 {140 {141 accountTokenOwnershipLimit,141 accountTokenOwnershipLimit,150 it('execute setCollectionLimits from admin collection', async () => {150 it('execute setCollectionLimits from admin collection', async () => {151 await addCollectionAdminExpectSuccess(alice, collectionIdForTesting, bob.address);151 await addCollectionAdminExpectSuccess(alice, collectionIdForTesting, bob.address);152 await usingApi(async (api: ApiPromise) => {152 await usingApi(async (api: ApiPromise) => {153 tx = api.tx.nft.setCollectionLimits(153 tx = api.tx.unique.setCollectionLimits(154 collectionIdForTesting,154 collectionIdForTesting,155 {155 {156 accountTokenOwnershipLimit,156 accountTokenOwnershipLimit,tests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth41 const collectionId = await createCollectionExpectSuccess();41 const collectionId = await createCollectionExpectSuccess();42 const collection = await queryCollectionExpectSuccess(api, collectionId);42 const collection = await queryCollectionExpectSuccess(api, collectionId);43 expect(collection.owner.toString()).to.be.eq(alice.address);43 expect(collection.owner.toString()).to.be.eq(alice.address);44 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);44 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);45 await submitTransactionAsync(alice, setShema);45 await submitTransactionAsync(alice, setShema);46 });46 });47 });47 });52 const collection = await queryCollectionExpectSuccess(api, collectionId);52 const collection = await queryCollectionExpectSuccess(api, collectionId);53 expect(collection.owner.toString()).to.be.eq(alice.address);53 expect(collection.owner.toString()).to.be.eq(alice.address);54 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);54 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);55 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);55 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);56 await submitTransactionAsync(bob, setShema);56 await submitTransactionAsync(bob, setShema);57 });57 });58 });58 });595960 it('Checking collection data using the ConstOnChainSchema parameter', async () => {60 it('Checking collection data using the ConstOnChainSchema parameter', async () => {61 await usingApi(async (api) => {61 await usingApi(async (api) => {62 const collectionId = await createCollectionExpectSuccess();62 const collectionId = await createCollectionExpectSuccess();63 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);63 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);64 await submitTransactionAsync(alice, setShema);64 await submitTransactionAsync(alice, setShema);65 const collection = await queryCollectionExpectSuccess(api, collectionId);65 const collection = await queryCollectionExpectSuccess(api, collectionId);66 expect(collection.constOnChainSchema.toString()).to.be.eq(shema);66 expect(collection.constOnChainSchema.toString()).to.be.eq(shema);74 await usingApi(async (api) => {74 await usingApi(async (api) => {75 // tslint:disable-next-line: radix75 // tslint:disable-next-line: radix76 const collectionId = await getCreatedCollectionCount(api) + 1;76 const collectionId = await getCreatedCollectionCount(api) + 1;77 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);77 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);78 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;78 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;79 });79 });80 });80 });83 await usingApi(async (api) => {83 await usingApi(async (api) => {84 const collectionId = await createCollectionExpectSuccess();84 const collectionId = await createCollectionExpectSuccess();85 await destroyCollectionExpectSuccess(collectionId);85 await destroyCollectionExpectSuccess(collectionId);86 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);86 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);87 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;87 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;88 });88 });89 });89 });909091 it('Set invalid data in schema (size too large:> 1024b)', async () => {91 it('Set invalid data in schema (size too large:> 1024b)', async () => {92 await usingApi(async (api) => {92 await usingApi(async (api) => {93 const collectionId = await createCollectionExpectSuccess();93 const collectionId = await createCollectionExpectSuccess();94 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, largeShema);94 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, largeShema);95 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;95 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;96 });96 });97 });97 });101 const collectionId = await createCollectionExpectSuccess();101 const collectionId = await createCollectionExpectSuccess();102 const collection = await queryCollectionExpectSuccess(api, collectionId);102 const collection = await queryCollectionExpectSuccess(api, collectionId);103 expect(collection.owner.toString()).to.be.eq(alice.address);103 expect(collection.owner.toString()).to.be.eq(alice.address);104 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);104 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);105 await expect(submitTransactionExpectFailAsync(bob, setShema)).to.be.rejected;105 await expect(submitTransactionExpectFailAsync(bob, setShema)).to.be.rejected;106 });106 });107 });107 });tests/src/setPublicAccessMode.test.tsdiffbeforeafterboth51 const collectionId = await createCollectionExpectSuccess();51 const collectionId = await createCollectionExpectSuccess();52 await enableAllowListExpectSuccess(alice, collectionId);52 await enableAllowListExpectSuccess(alice, collectionId);53 await enablePublicMintingExpectSuccess(alice, collectionId);53 await enablePublicMintingExpectSuccess(alice, collectionId);54 const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(bob.address), 'NFT');54 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(bob.address), 'NFT');55 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;55 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;56 });56 });57 });57 });62 await usingApi(async (api: ApiPromise) => {62 await usingApi(async (api: ApiPromise) => {63 // tslint:disable-next-line: radix63 // tslint:disable-next-line: radix64 const collectionId = await getCreatedCollectionCount(api) + 1;64 const collectionId = await getCreatedCollectionCount(api) + 1;65 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');65 const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');66 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;66 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;67 });67 });68 });68 });72 // tslint:disable-next-line: no-bitwise72 // tslint:disable-next-line: no-bitwise73 const collectionId = await createCollectionExpectSuccess();73 const collectionId = await createCollectionExpectSuccess();74 await destroyCollectionExpectSuccess(collectionId);74 await destroyCollectionExpectSuccess(collectionId);75 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');75 const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');76 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;76 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;77 });77 });78 });78 });89 await usingApi(async (api: ApiPromise) => {89 await usingApi(async (api: ApiPromise) => {90 // tslint:disable-next-line: no-bitwise90 // tslint:disable-next-line: no-bitwise91 const collectionId = await createCollectionExpectSuccess();91 const collectionId = await createCollectionExpectSuccess();92 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');92 const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');93 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;93 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;94 });94 });95 });95 });107 // tslint:disable-next-line: no-bitwise107 // tslint:disable-next-line: no-bitwise108 const collectionId = await createCollectionExpectSuccess();108 const collectionId = await createCollectionExpectSuccess();109 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);109 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);110 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');110 const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');111 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;111 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;112 });112 });113 });113 });tests/src/setSchemaVersion.test.tsdiffbeforeafterboth41 it('execute setSchemaVersion with image url and unique ', async () => {41 it('execute setSchemaVersion with image url and unique ', async () => {42 await usingApi(async (api: ApiPromise) => {42 await usingApi(async (api: ApiPromise) => {43 const collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});43 const collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});44 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Unique');44 tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'Unique');45 const events = await submitTransactionAsync(alice, tx);45 const events = await submitTransactionAsync(alice, tx);46 const result = getCreateItemResult(events);46 const result = getCreateItemResult(events);47 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);47 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);70 });70 });71 it('execute setSchemaVersion with image url and unique ', async () => {71 it('execute setSchemaVersion with image url and unique ', async () => {72 await usingApi(async (api: ApiPromise) => {72 await usingApi(async (api: ApiPromise) => {73 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Unique');73 tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'Unique');74 const events = await submitTransactionAsync(bob, tx);74 const events = await submitTransactionAsync(bob, tx);75 const result = getCreateItemResult(events);75 const result = getCreateItemResult(events);76 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);76 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);858586 it('validate schema version with just entered data', async () => {86 it('validate schema version with just entered data', async () => {87 await usingApi(async (api: ApiPromise) => {87 await usingApi(async (api: ApiPromise) => {88 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');88 tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'ImageURL');89 const events = await submitTransactionAsync(bob, tx);89 const events = await submitTransactionAsync(bob, tx);90 const result = getCreateItemResult(events);90 const result = getCreateItemResult(events);91 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);91 const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);114 await usingApi(async (api: ApiPromise) => {114 await usingApi(async (api: ApiPromise) => {115 const collectionCount = await getCreatedCollectionCount(api);115 const collectionCount = await getCreatedCollectionCount(api);116 const nonExistedCollectionId = collectionCount + 1;116 const nonExistedCollectionId = collectionCount + 1;117 tx = api.tx.nft.setSchemaVersion(nonExistedCollectionId, 'ImageURL');117 tx = api.tx.unique.setSchemaVersion(nonExistedCollectionId, 'ImageURL');118 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;118 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;119 });119 });120 });120 });121 it('execute setSchemaVersion for deleted collection', async () => {121 it('execute setSchemaVersion for deleted collection', async () => {122 await usingApi(async (api: ApiPromise) => {122 await usingApi(async (api: ApiPromise) => {123 await destroyCollectionExpectSuccess(collectionIdForTesting);123 await destroyCollectionExpectSuccess(collectionIdForTesting);124 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');124 tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'ImageURL');125 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;125 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;126 });126 });127 });127 });128 it('Regular user can`t execute setSchemaVersion with image url and unique ', async () => {128 it('Regular user can`t execute setSchemaVersion with image url and unique ', async () => {129 await usingApi(async (api: ApiPromise) => {129 await usingApi(async (api: ApiPromise) => {130 tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Unique');130 tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'Unique');131 await expect(submitTransactionAsync(charlie, tx)).to.be.rejected;131 await expect(submitTransactionAsync(charlie, tx)).to.be.rejected;132 });132 });133 });133 });tests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth41 const collectionId = await createCollectionExpectSuccess();41 const collectionId = await createCollectionExpectSuccess();42 const collection = await queryCollectionExpectSuccess(api, collectionId);42 const collection = await queryCollectionExpectSuccess(api, collectionId);43 expect(collection.owner.toString()).to.be.eq(alice.address);43 expect(collection.owner.toString()).to.be.eq(alice.address);44 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);44 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);45 await submitTransactionAsync(alice, setSchema);45 await submitTransactionAsync(alice, setSchema);46 });46 });47 });47 });484849 it('Checking collection data using the setVariableOnChainSchema parameter', async () => {49 it('Checking collection data using the setVariableOnChainSchema parameter', async () => {50 await usingApi(async (api) => {50 await usingApi(async (api) => {51 const collectionId = await createCollectionExpectSuccess();51 const collectionId = await createCollectionExpectSuccess();52 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);52 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);53 await submitTransactionAsync(alice, setSchema);53 await submitTransactionAsync(alice, setSchema);54 const collection = await queryCollectionExpectSuccess(api, collectionId);54 const collection = await queryCollectionExpectSuccess(api, collectionId);55 expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);55 expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);66 const collection = await queryCollectionExpectSuccess(api, collectionId);66 const collection = await queryCollectionExpectSuccess(api, collectionId);67 expect(collection.owner.toString()).to.be.eq(alice.address);67 expect(collection.owner.toString()).to.be.eq(alice.address);68 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);68 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);69 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);69 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);70 await submitTransactionAsync(bob, setSchema);70 await submitTransactionAsync(bob, setSchema);71 });71 });72 });72 });75 await usingApi(async (api) => {75 await usingApi(async (api) => {76 const collectionId = await createCollectionExpectSuccess();76 const collectionId = await createCollectionExpectSuccess();77 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);77 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);78 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);78 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);79 await submitTransactionAsync(bob, setSchema);79 await submitTransactionAsync(bob, setSchema);80 const collection = await queryCollectionExpectSuccess(api, collectionId);80 const collection = await queryCollectionExpectSuccess(api, collectionId);81 expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);81 expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);90 await usingApi(async (api) => {90 await usingApi(async (api) => {91 // tslint:disable-next-line: radix91 // tslint:disable-next-line: radix92 const collectionId = await getCreatedCollectionCount(api) + 1;92 const collectionId = await getCreatedCollectionCount(api) + 1;93 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);93 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);94 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;94 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;95 });95 });96 });96 });99 await usingApi(async (api) => {99 await usingApi(async (api) => {100 const collectionId = await createCollectionExpectSuccess();100 const collectionId = await createCollectionExpectSuccess();101 await destroyCollectionExpectSuccess(collectionId);101 await destroyCollectionExpectSuccess(collectionId);102 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);102 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);103 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;103 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;104 });104 });105 });105 });106106107 it('Set invalid data in schema (size too large:> 1024b)', async () => {107 it('Set invalid data in schema (size too large:> 1024b)', async () => {108 await usingApi(async (api) => {108 await usingApi(async (api) => {109 const collectionId = await createCollectionExpectSuccess();109 const collectionId = await createCollectionExpectSuccess();110 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, largeSchema);110 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, largeSchema);111 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;111 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;112 });112 });113 });113 });117 const collectionId = await createCollectionExpectSuccess();117 const collectionId = await createCollectionExpectSuccess();118 const collection = await queryCollectionExpectSuccess(api, collectionId);118 const collection = await queryCollectionExpectSuccess(api, collectionId);119 expect(collection.owner.toString()).to.be.eq(alice.address);119 expect(collection.owner.toString()).to.be.eq(alice.address);120 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);120 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);121 await expect(submitTransactionExpectFailAsync(bob, setSchema)).to.be.rejected;121 await expect(submitTransactionExpectFailAsync(bob, setSchema)).to.be.rejected;122 });122 });123 });123 });tests/src/substrate/substrate-api.tsdiffbeforeafterboth24 },24 },25 },25 },26 rpc: {26 rpc: {27 nft: defs.nft.rpc,27 unique: defs.unique.rpc,28 },28 },29 };29 };30}30}tests/src/toggleContractAllowList.test.tsdiffbeforeafterboth27 await usingApi(async api => {27 await usingApi(async api => {28 const [contract, deployer] = await deployFlipper(api);28 const [contract, deployer] = await deployFlipper(api);292930 const enabledBefore = (await api.query.nft.contractAllowListEnabled(contract.address)).toJSON();30 const enabledBefore = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();31 const enableAllowListTx = api.tx.nft.toggleContractAllowList(contract.address, true);31 const enableAllowListTx = api.tx.unique.toggleContractAllowList(contract.address, true);32 const enableEvents = await submitTransactionAsync(deployer, enableAllowListTx);32 const enableEvents = await submitTransactionAsync(deployer, enableAllowListTx);33 const enabled = (await api.query.nft.contractAllowListEnabled(contract.address)).toJSON();33 const enabled = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();343435 expect(getGenericResult(enableEvents).success).to.be.true;35 expect(getGenericResult(enableEvents).success).to.be.true;36 expect(enabledBefore).to.be.false;36 expect(enabledBefore).to.be.false;60 await deployerCanFlip();60 await deployerCanFlip();616162 flipValueBefore = await getFlipValue(contract, deployer);62 flipValueBefore = await getFlipValue(contract, deployer);63 const enableAllowListTx = api.tx.nft.toggleContractAllowList(contract.address, true);63 const enableAllowListTx = api.tx.unique.toggleContractAllowList(contract.address, true);64 await submitTransactionAsync(deployer, enableAllowListTx);64 await submitTransactionAsync(deployer, enableAllowListTx);65 const flipWithEnabledAllowList = contract.tx.flip(value, gasLimit);65 const flipWithEnabledAllowList = contract.tx.flip(value, gasLimit);66 await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledAllowList)).to.be.rejected;66 await expect(submitTransactionExpectFailAsync(bob, flipWithEnabledAllowList)).to.be.rejected;70 await deployerCanFlip();70 await deployerCanFlip();717172 flipValueBefore = await getFlipValue(contract, deployer);72 flipValueBefore = await getFlipValue(contract, deployer);73 const addBobToAllowListTx = api.tx.nft.addToContractAllowList(contract.address, bob.address);73 const addBobToAllowListTx = api.tx.unique.addToContractAllowList(contract.address, bob.address);74 await submitTransactionAsync(deployer, addBobToAllowListTx);74 await submitTransactionAsync(deployer, addBobToAllowListTx);75 const flipWithAllowlistedBob = contract.tx.flip(value, gasLimit);75 const flipWithAllowlistedBob = contract.tx.flip(value, gasLimit);76 await submitTransactionAsync(bob, flipWithAllowlistedBob);76 await submitTransactionAsync(bob, flipWithAllowlistedBob);80 await deployerCanFlip();80 await deployerCanFlip();818182 flipValueBefore = await getFlipValue(contract, deployer);82 flipValueBefore = await getFlipValue(contract, deployer);83 const removeBobFromAllowListTx = api.tx.nft.removeFromContractAllowList(contract.address, bob.address);83 const removeBobFromAllowListTx = api.tx.unique.removeFromContractAllowList(contract.address, bob.address);84 await submitTransactionAsync(deployer, removeBobFromAllowListTx);84 await submitTransactionAsync(deployer, removeBobFromAllowListTx);85 const bobRemoved = contract.tx.flip(value, gasLimit);85 const bobRemoved = contract.tx.flip(value, gasLimit);86 await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;86 await expect(submitTransactionExpectFailAsync(bob, bobRemoved)).to.be.rejected;90 await deployerCanFlip();90 await deployerCanFlip();919192 flipValueBefore = await getFlipValue(contract, deployer);92 flipValueBefore = await getFlipValue(contract, deployer);93 const disableAllowListTx = api.tx.nft.toggleContractAllowList(contract.address, false);93 const disableAllowListTx = api.tx.unique.toggleContractAllowList(contract.address, false);94 await submitTransactionAsync(deployer, disableAllowListTx);94 await submitTransactionAsync(deployer, disableAllowListTx);95 const allowListDisabledFlip = contract.tx.flip(value, gasLimit);95 const allowListDisabledFlip = contract.tx.flip(value, gasLimit);96 await submitTransactionAsync(bob, allowListDisabledFlip);96 await submitTransactionAsync(bob, allowListDisabledFlip);104 await usingApi(async api => {104 await usingApi(async api => {105 const [contract, deployer] = await deployFlipper(api);105 const [contract, deployer] = await deployFlipper(api);106106107 const enabledBefore = (await api.query.nft.contractAllowListEnabled(contract.address)).toJSON();107 const enabledBefore = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();108 const enableAllowListTx = api.tx.nft.toggleContractAllowList(contract.address, true);108 const enableAllowListTx = api.tx.unique.toggleContractAllowList(contract.address, true);109 const enableEvents = await submitTransactionAsync(deployer, enableAllowListTx);109 const enableEvents = await submitTransactionAsync(deployer, enableAllowListTx);110 const enabled = (await api.query.nft.contractAllowListEnabled(contract.address)).toJSON();110 const enabled = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();111 const enableAgainEvents = await submitTransactionAsync(deployer, enableAllowListTx);111 const enableAgainEvents = await submitTransactionAsync(deployer, enableAllowListTx);112 const enabledAgain = (await api.query.nft.contractAllowListEnabled(contract.address)).toJSON();112 const enabledAgain = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();113113114 expect(getGenericResult(enableEvents).success).to.be.true;114 expect(getGenericResult(enableEvents).success).to.be.true;115 expect(enabledBefore).to.be.false;115 expect(enabledBefore).to.be.false;128 const alice = privateKey('//Alice');128 const alice = privateKey('//Alice');129 const bobGuineaPig = privateKey('//Bob');129 const bobGuineaPig = privateKey('//Bob');130130131 const enabledBefore = (await api.query.nft.contractAllowListEnabled(bobGuineaPig.address)).toJSON();131 const enabledBefore = (await api.query.unique.contractAllowListEnabled(bobGuineaPig.address)).toJSON();132 const enableAllowListTx = api.tx.nft.toggleContractAllowList(bobGuineaPig.address, true);132 const enableAllowListTx = api.tx.unique.toggleContractAllowList(bobGuineaPig.address, true);133 await expect(submitTransactionExpectFailAsync(alice, enableAllowListTx)).to.be.rejected;133 await expect(submitTransactionExpectFailAsync(alice, enableAllowListTx)).to.be.rejected;134 const enabled = (await api.query.nft.contractAllowListEnabled(bobGuineaPig.address)).toJSON();134 const enabled = (await api.query.unique.contractAllowListEnabled(bobGuineaPig.address)).toJSON();135135136 expect(enabledBefore).to.be.false;136 expect(enabledBefore).to.be.false;137 expect(enabled).to.be.false;137 expect(enabled).to.be.false;143 const bob = privateKey('//Bob');143 const bob = privateKey('//Bob');144 const [contract] = await deployFlipper(api);144 const [contract] = await deployFlipper(api);145145146 const enabledBefore = (await api.query.nft.contractAllowListEnabled(contract.address)).toJSON();146 const enabledBefore = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();147 const enableAllowListTx = api.tx.nft.toggleContractAllowList(contract.address, true);147 const enableAllowListTx = api.tx.unique.toggleContractAllowList(contract.address, true);148 await expect(submitTransactionExpectFailAsync(bob, enableAllowListTx)).to.be.rejected;148 await expect(submitTransactionExpectFailAsync(bob, enableAllowListTx)).to.be.rejected;149 const enabled = (await api.query.nft.contractAllowListEnabled(contract.address)).toJSON();149 const enabled = (await api.query.unique.contractAllowListEnabled(contract.address)).toJSON();150150151 expect(enabledBefore).to.be.false;151 expect(enabledBefore).to.be.false;152 expect(enabled).to.be.false;152 expect(enabled).to.be.false;tests/src/transfer.test.tsdiffbeforeafterboth249 const nftCollectionId = await createCollectionExpectSuccess();249 const nftCollectionId = await createCollectionExpectSuccess();250 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');250 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');251251252 const transferTx = api.tx.nft.transfer(normalizeAccountId(bob), nftCollectionId, newNftTokenId, 0);252 const transferTx = api.tx.unique.transfer(normalizeAccountId(bob), nftCollectionId, newNftTokenId, 0);253 await submitTransactionAsync(alice, transferTx);253 await submitTransactionAsync(alice, transferTx);254 const address = normalizeAccountId(await getTokenOwner(api, nftCollectionId, newNftTokenId));254 const address = normalizeAccountId(await getTokenOwner(api, nftCollectionId, newNftTokenId));255255264 const balanceBeforeAlice = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(alice), newReFungibleTokenId);264 const balanceBeforeAlice = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(alice), newReFungibleTokenId);265 const balanceBeforeBob = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(bob), newReFungibleTokenId);265 const balanceBeforeBob = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(bob), newReFungibleTokenId);266266267 const transferTx = api.tx.nft.transfer(normalizeAccountId(bob), reFungibleCollectionId, newReFungibleTokenId, 0);267 const transferTx = api.tx.unique.transfer(normalizeAccountId(bob), reFungibleCollectionId, newReFungibleTokenId, 0);268 await submitTransactionAsync(alice, transferTx);268 await submitTransactionAsync(alice, transferTx);269269270 const balanceAfterAlice = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(alice), newReFungibleTokenId);270 const balanceAfterAlice = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(alice), newReFungibleTokenId);282 const balanceBeforeAlice = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(alice), newFungibleTokenId);282 const balanceBeforeAlice = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(alice), newFungibleTokenId);283 const balanceBeforeBob = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(bob), newFungibleTokenId);283 const balanceBeforeBob = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(bob), newFungibleTokenId);284284285 const transferTx = api.tx.nft.transfer(normalizeAccountId(bob), fungibleCollectionId, newFungibleTokenId, 0);285 const transferTx = api.tx.unique.transfer(normalizeAccountId(bob), fungibleCollectionId, newFungibleTokenId, 0);286 await submitTransactionAsync(alice, transferTx);286 await submitTransactionAsync(alice, transferTx);287287288 const balanceAfterAlice = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(alice), newFungibleTokenId);288 const balanceAfterAlice = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(alice), newFungibleTokenId);tests/src/util/helpers.tsdiffbeforeafterboth283 modeprm = {refungible: null};283 modeprm = {refungible: null};284 }284 }285285286 const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm as any);286 const tx = api.tx.unique.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm as any);287 const events = await submitTransactionAsync(alicePrivateKey, tx);287 const events = await submitTransactionAsync(alicePrivateKey, tx);288 const result = getCreateCollectionResult(events);288 const result = getCreateCollectionResult(events);289289329329330 // Run the CreateCollection transaction330 // Run the CreateCollection transaction331 const alicePrivateKey = privateKey('//Alice');331 const alicePrivateKey = privateKey('//Alice');332 const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm as any);332 const tx = api.tx.unique.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm as any);333 const events = await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;333 const events = await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;334 const result = getCreateCollectionResult(events);334 const result = getCreateCollectionResult(events);335335356}356}357357358export async function getAllowance(api: ApiPromise, collectionId: number, owner: CrossAccountId | string, approved: CrossAccountId | string, tokenId: number) {358export async function getAllowance(api: ApiPromise, collectionId: number, owner: CrossAccountId | string, approved: CrossAccountId | string, tokenId: number) {359 return (await api.rpc.nft.allowance(collectionId, normalizeAccountId(owner), normalizeAccountId(approved), tokenId)).toBigInt();359 return (await api.rpc.unique.allowance(collectionId, normalizeAccountId(owner), normalizeAccountId(approved), tokenId)).toBigInt();360}360}361361362export function findUnusedAddresses(api: ApiPromise, amount: number): Promise<IKeyringPair[]> {362export function findUnusedAddresses(api: ApiPromise, amount: number): Promise<IKeyringPair[]> {383 await usingApi(async (api) => {383 await usingApi(async (api) => {384 // Run the DestroyCollection transaction384 // Run the DestroyCollection transaction385 const alicePrivateKey = privateKey(senderSeed);385 const alicePrivateKey = privateKey(senderSeed);386 const tx = api.tx.nft.destroyCollection(collectionId);386 const tx = api.tx.unique.destroyCollection(collectionId);387 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;387 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;388 });388 });389}389}392 await usingApi(async (api) => {392 await usingApi(async (api) => {393 // Run the DestroyCollection transaction393 // Run the DestroyCollection transaction394 const alicePrivateKey = privateKey(senderSeed);394 const alicePrivateKey = privateKey(senderSeed);395 const tx = api.tx.nft.destroyCollection(collectionId);395 const tx = api.tx.unique.destroyCollection(collectionId);396 const events = await submitTransactionAsync(alicePrivateKey, tx);396 const events = await submitTransactionAsync(alicePrivateKey, tx);397 const result = getDestroyResult(events);397 const result = getDestroyResult(events);398 expect(result).to.be.true;398 expect(result).to.be.true;404404405export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) {405export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) {406 await usingApi(async (api) => {406 await usingApi(async (api) => {407 const tx = api.tx.nft.setCollectionLimits(collectionId, limits);407 const tx = api.tx.unique.setCollectionLimits(collectionId, limits);408 const events = await submitTransactionAsync(sender, tx);408 const events = await submitTransactionAsync(sender, tx);409 const result = getGenericResult(events);409 const result = getGenericResult(events);410410414414415export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {415export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {416 await usingApi(async (api) => {416 await usingApi(async (api) => {417 const tx = api.tx.nft.setCollectionLimits(collectionId, limits);417 const tx = api.tx.unique.setCollectionLimits(collectionId, limits);418 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;418 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;419 const result = getGenericResult(events);419 const result = getGenericResult(events);420420427427428 // Run the transaction428 // Run the transaction429 const senderPrivateKey = privateKey(sender);429 const senderPrivateKey = privateKey(sender);430 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);430 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);431 const events = await submitTransactionAsync(senderPrivateKey, tx);431 const events = await submitTransactionAsync(senderPrivateKey, tx);432 const result = getGenericResult(events);432 const result = getGenericResult(events);433433447447448 // Run the transaction448 // Run the transaction449 const alicePrivateKey = privateKey(sender);449 const alicePrivateKey = privateKey(sender);450 const tx = api.tx.nft.removeCollectionSponsor(collectionId);450 const tx = api.tx.unique.removeCollectionSponsor(collectionId);451 const events = await submitTransactionAsync(alicePrivateKey, tx);451 const events = await submitTransactionAsync(alicePrivateKey, tx);452 const result = getGenericResult(events);452 const result = getGenericResult(events);453453465465466 // Run the transaction466 // Run the transaction467 const alicePrivateKey = privateKey(senderSeed);467 const alicePrivateKey = privateKey(senderSeed);468 const tx = api.tx.nft.removeCollectionSponsor(collectionId);468 const tx = api.tx.unique.removeCollectionSponsor(collectionId);469 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;469 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;470 });470 });471}471}475475476 // Run the transaction476 // Run the transaction477 const alicePrivateKey = privateKey(senderSeed);477 const alicePrivateKey = privateKey(senderSeed);478 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);478 const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);479 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;479 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;480 });480 });481}481}485485486 // Run the transaction486 // Run the transaction487 const sender = privateKey(senderSeed);487 const sender = privateKey(senderSeed);488 const tx = api.tx.nft.confirmSponsorship(collectionId);488 const tx = api.tx.unique.confirmSponsorship(collectionId);489 const events = await submitTransactionAsync(sender, tx);489 const events = await submitTransactionAsync(sender, tx);490 const result = getGenericResult(events);490 const result = getGenericResult(events);491491506506507 // Run the transaction507 // Run the transaction508 const sender = privateKey(senderSeed);508 const sender = privateKey(senderSeed);509 const tx = api.tx.nft.confirmSponsorship(collectionId);509 const tx = api.tx.unique.confirmSponsorship(collectionId);510 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;510 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;511 });511 });512}512}513513514export async function setMetadataUpdatePermissionFlagExpectSuccess(sender: IKeyringPair, collectionId: number, flag: string) {514export async function setMetadataUpdatePermissionFlagExpectSuccess(sender: IKeyringPair, collectionId: number, flag: string) {515515516 await usingApi(async (api) => {516 await usingApi(async (api) => {517 const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag as any);517 const tx = api.tx.unique.setMetaUpdatePermissionFlag(collectionId, flag as any);518 const events = await submitTransactionAsync(sender, tx);518 const events = await submitTransactionAsync(sender, tx);519 const result = getGenericResult(events);519 const result = getGenericResult(events);520520525export async function setMetadataUpdatePermissionFlagExpectFailure(sender: IKeyringPair, collectionId: number, flag: string) {525export async function setMetadataUpdatePermissionFlagExpectFailure(sender: IKeyringPair, collectionId: number, flag: string) {526526527 await usingApi(async (api) => {527 await usingApi(async (api) => {528 const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag as any);528 const tx = api.tx.unique.setMetaUpdatePermissionFlag(collectionId, flag as any);529 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;529 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;530 const result = getGenericResult(events);530 const result = getGenericResult(events);531531535535536export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {536export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {537 await usingApi(async (api) => {537 await usingApi(async (api) => {538 const tx = api.tx.nft.enableContractSponsoring(contractAddress, enable);538 const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);539 const events = await submitTransactionAsync(sender, tx);539 const events = await submitTransactionAsync(sender, tx);540 const result = getGenericResult(events);540 const result = getGenericResult(events);541541545545546export async function enableContractSponsoringExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {546export async function enableContractSponsoringExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {547 await usingApi(async (api) => {547 await usingApi(async (api) => {548 const tx = api.tx.nft.enableContractSponsoring(contractAddress, enable);548 const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);549 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;549 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;550 const result = getGenericResult(events);550 const result = getGenericResult(events);551551557557558 await usingApi(async (api) => {558 await usingApi(async (api) => {559559560 const tx = api.tx.nft.setTransfersEnabledFlag (collectionId, enabled);560 const tx = api.tx.unique.setTransfersEnabledFlag (collectionId, enabled);561 const events = await submitTransactionAsync(sender, tx);561 const events = await submitTransactionAsync(sender, tx);562 const result = getGenericResult(events);562 const result = getGenericResult(events);563563569569570 await usingApi(async (api) => {570 await usingApi(async (api) => {571571572 const tx = api.tx.nft.setTransfersEnabledFlag (collectionId, enabled);572 const tx = api.tx.unique.setTransfersEnabledFlag (collectionId, enabled);573 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;573 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;574 const result = getGenericResult(events);574 const result = getGenericResult(events);575575579579580export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {580export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {581 await usingApi(async (api) => {581 await usingApi(async (api) => {582 const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);582 const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);583 const events = await submitTransactionAsync(sender, tx);583 const events = await submitTransactionAsync(sender, tx);584 const result = getGenericResult(events);584 const result = getGenericResult(events);585585589589590export async function setContractSponsoringRateLimitExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {590export async function setContractSponsoringRateLimitExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {591 await usingApi(async (api) => {591 await usingApi(async (api) => {592 const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);592 const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);593 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;593 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;594 const result = getGenericResult(events);594 const result = getGenericResult(events);595595599599600export async function toggleContractAllowlistExpectSuccess(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.toggleContractAllowList(contractAddress, value);602 const tx = api.tx.unique.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);605605610export async function isAllowlistedInContract(contractAddress: AccountId | string, user: string) {610export async function isAllowlistedInContract(contractAddress: AccountId | string, user: string) {611 let allowlisted = false;611 let allowlisted = false;612 await usingApi(async (api) => {612 await usingApi(async (api) => {613 allowlisted = (await api.query.nft.contractAllowList(contractAddress, user)).toJSON() as boolean;613 allowlisted = (await api.query.unique.contractAllowList(contractAddress, user)).toJSON() as boolean;614 });614 });615 return allowlisted;615 return allowlisted;616}616}617617618export async function addToContractAllowListExpectSuccess(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.addToContractAllowList(contractAddress.toString(), user.toString());620 const tx = api.tx.unique.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);623623627627628export async function removeFromContractAllowListExpectSuccess(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.removeFromContractAllowList(contractAddress.toString(), user.toString());630 const tx = api.tx.unique.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);633633637637638export async function removeFromContractAllowListExpectFailure(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.removeFromContractAllowList(contractAddress.toString(), user.toString());640 const tx = api.tx.unique.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);643643647647648export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {648export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {649 await usingApi(async (api) => {649 await usingApi(async (api) => {650 const tx = api.tx.nft.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex'));650 const tx = api.tx.unique.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex'));651 const events = await submitTransactionAsync(sender, tx);651 const events = await submitTransactionAsync(sender, tx);652 const result = getGenericResult(events);652 const result = getGenericResult(events);653653657657658export async function setVariableMetaDataExpectFailure(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {658export async function setVariableMetaDataExpectFailure(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {659 await usingApi(async (api) => {659 await usingApi(async (api) => {660 const tx = api.tx.nft.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex'));660 const tx = api.tx.unique.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex'));661 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;661 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;662 });662 });663}663}664664665export async function setOffchainSchemaExpectSuccess(sender: IKeyringPair, collectionId: number, data: number[]) {665export async function setOffchainSchemaExpectSuccess(sender: IKeyringPair, collectionId: number, data: number[]) {666 await usingApi(async (api) => {666 await usingApi(async (api) => {667 const tx = api.tx.nft.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));667 const tx = api.tx.unique.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));668 const events = await submitTransactionAsync(sender, tx);668 const events = await submitTransactionAsync(sender, tx);669 const result = getGenericResult(events);669 const result = getGenericResult(events);670670674674675export async function setOffchainSchemaExpectFailure(sender: IKeyringPair, collectionId: number, data: number[]) {675export async function setOffchainSchemaExpectFailure(sender: IKeyringPair, collectionId: number, data: number[]) {676 await usingApi(async (api) => {676 await usingApi(async (api) => {677 const tx = api.tx.nft.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));677 const tx = api.tx.unique.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));678 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;678 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;679 });679 });680}680}700 // if burning token by admin - use adminButnItemExpectSuccess700 // if burning token by admin - use adminButnItemExpectSuccess701 expect(balanceBefore >= BigInt(value)).to.be.true;701 expect(balanceBefore >= BigInt(value)).to.be.true;702702703 const tx = api.tx.nft.burnItem(collectionId, tokenId, value);703 const tx = api.tx.unique.burnItem(collectionId, tokenId, value);704 const events = await submitTransactionAsync(sender, tx);704 const events = await submitTransactionAsync(sender, tx);705 const result = getGenericResult(events);705 const result = getGenericResult(events);706 expect(result.success).to.be.true;706 expect(result.success).to.be.true;716 tokenId: number, owner: IKeyringPair, approved: CrossAccountId | string, amount: number | bigint = 1,716 tokenId: number, owner: IKeyringPair, approved: CrossAccountId | string, amount: number | bigint = 1,717) {717) {718 await usingApi(async (api: ApiPromise) => {718 await usingApi(async (api: ApiPromise) => {719 const approveNftTx = api.tx.nft.approve(normalizeAccountId(approved), collectionId, tokenId, amount);719 const approveNftTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);720 const events = await submitTransactionAsync(owner, approveNftTx);720 const events = await submitTransactionAsync(owner, approveNftTx);721 const result = getGenericResult(events);721 const result = getGenericResult(events);722 expect(result.success).to.be.true;722 expect(result.success).to.be.true;730 tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,730 tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,731) {731) {732 await usingApi(async (api: ApiPromise) => {732 await usingApi(async (api: ApiPromise) => {733 const approveNftTx = api.tx.nft.approve(normalizeAccountId(approved), collectionId, tokenId, amount);733 const approveNftTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);734 const events = await submitTransactionAsync(admin, approveNftTx);734 const events = await submitTransactionAsync(admin, approveNftTx);735 const result = getGenericResult(events);735 const result = getGenericResult(events);736 expect(result.success).to.be.true;736 expect(result.success).to.be.true;755 if (type === 'Fungible') {755 if (type === 'Fungible') {756 balanceBefore = await getBalance(api, collectionId, to, tokenId);756 balanceBefore = await getBalance(api, collectionId, to, tokenId);757 }757 }758 const transferFromTx = api.tx.nft.transferFrom(normalizeAccountId(accountFrom), to, collectionId, tokenId, value);758 const transferFromTx = api.tx.unique.transferFrom(normalizeAccountId(accountFrom), to, collectionId, tokenId, value);759 const events = await submitTransactionAsync(accountApproved, transferFromTx);759 const events = await submitTransactionAsync(accountApproved, transferFromTx);760 const result = getCreateItemResult(events);760 const result = getCreateItemResult(events);761 // tslint:disable-next-line:no-unused-expression761 // tslint:disable-next-line:no-unused-expression783 value: number | bigint = 1,783 value: number | bigint = 1,784) {784) {785 await usingApi(async (api: ApiPromise) => {785 await usingApi(async (api: ApiPromise) => {786 const transferFromTx = api.tx.nft.transferFrom(normalizeAccountId(accountFrom.address), normalizeAccountId(accountTo.address), collectionId, tokenId, value);786 const transferFromTx = api.tx.unique.transferFrom(normalizeAccountId(accountFrom.address), normalizeAccountId(accountTo.address), collectionId, tokenId, value);787 const events = await expect(submitTransactionExpectFailAsync(accountApproved, transferFromTx)).to.be.rejected;787 const events = await expect(submitTransactionExpectFailAsync(accountApproved, transferFromTx)).to.be.rejected;788 const result = getCreateCollectionResult(events);788 const result = getCreateCollectionResult(events);789 // tslint:disable-next-line:no-unused-expression789 // tslint:disable-next-line:no-unused-expression803803804export async function addCollectionAdminExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | CrossAccountId) {804export async function addCollectionAdminExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | CrossAccountId) {805 await usingApi(async (api) => {805 await usingApi(async (api) => {806 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(address));806 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(address));807 const events = await submitTransactionAsync(sender, changeAdminTx);807 const events = await submitTransactionAsync(sender, changeAdminTx);808 const result = getCreateCollectionResult(events);808 const result = getCreateCollectionResult(events);809 expect(result.success).to.be.true;809 expect(result.success).to.be.true;835 const expectedBlockNumber = blockNumber + blockSchedule;835 const expectedBlockNumber = blockNumber + blockSchedule;836836837 expect(blockNumber).to.be.greaterThan(0);837 expect(blockNumber).to.be.greaterThan(0);838 const transferTx = api.tx.nft.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);838 const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);839 const scheduleTx = api.tx.scheduler.schedule(expectedBlockNumber, null, 0, transferTx as any);839 const scheduleTx = api.tx.scheduler.schedule(expectedBlockNumber, null, 0, transferTx as any);840840841 await submitTransactionAsync(sender, scheduleTx);841 await submitTransactionAsync(sender, scheduleTx);871 if (type === 'Fungible') {871 if (type === 'Fungible') {872 balanceBefore = await getBalance(api, collectionId, to, tokenId);872 balanceBefore = await getBalance(api, collectionId, to, tokenId);873 }873 }874 const transferTx = api.tx.nft.transfer(to, collectionId, tokenId, value);874 const transferTx = api.tx.unique.transfer(to, collectionId, tokenId, value);875 const events = await submitTransactionAsync(sender, transferTx);875 const events = await submitTransactionAsync(sender, transferTx);876 const result = getTransferResult(events);876 const result = getTransferResult(events);877 // tslint:disable-next-line:no-unused-expression877 // tslint:disable-next-line:no-unused-expression903 value: number | bigint = 1,903 value: number | bigint = 1,904) {904) {905 await usingApi(async (api: ApiPromise) => {905 await usingApi(async (api: ApiPromise) => {906 const transferTx = api.tx.nft.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);906 const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);907 const events = await expect(submitTransactionExpectFailAsync(sender, transferTx)).to.be.rejected;907 const events = await expect(submitTransactionExpectFailAsync(sender, transferTx)).to.be.rejected;908 const result = getGenericResult(events);908 const result = getGenericResult(events);909 // if (events && Array.isArray(events)) {909 // if (events && Array.isArray(events)) {920 tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1,920 tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1,921) {921) {922 await usingApi(async (api: ApiPromise) => {922 await usingApi(async (api: ApiPromise) => {923 const approveNftTx = api.tx.nft.approve(normalizeAccountId(approved.address), collectionId, tokenId, amount);923 const approveNftTx = api.tx.unique.approve(normalizeAccountId(approved.address), collectionId, tokenId, amount);924 const events = await expect(submitTransactionExpectFailAsync(owner, approveNftTx)).to.be.rejected;924 const events = await expect(submitTransactionExpectFailAsync(owner, approveNftTx)).to.be.rejected;925 const result = getCreateCollectionResult(events);925 const result = getCreateCollectionResult(events);926 // tslint:disable-next-line:no-unused-expression926 // tslint:disable-next-line:no-unused-expression934 owner: string | CrossAccountId,934 owner: string | CrossAccountId,935 token: number,935 token: number,936): Promise<bigint> {936): Promise<bigint> {937 return (await api.rpc.nft.balance(collectionId, normalizeAccountId(owner), token)).toBigInt();937 return (await api.rpc.unique.balance(collectionId, normalizeAccountId(owner), token)).toBigInt();938}938}939export async function getTokenOwner(939export async function getTokenOwner(940 api: ApiPromise,940 api: ApiPromise,941 collectionId: number,941 collectionId: number,942 token: number,942 token: number,943): Promise<CrossAccountId> {943): Promise<CrossAccountId> {944 return normalizeAccountId((await api.rpc.nft.tokenOwner(collectionId, token)).toJSON() as any);944 return normalizeAccountId((await api.rpc.unique.tokenOwner(collectionId, token)).toJSON() as any);945}945}946export async function isTokenExists(946export async function isTokenExists(947 api: ApiPromise,947 api: ApiPromise,948 collectionId: number,948 collectionId: number,949 token: number,949 token: number,950): Promise<boolean> {950): Promise<boolean> {951 return (await api.rpc.nft.tokenExists(collectionId, token)).toJSON();951 return (await api.rpc.unique.tokenExists(collectionId, token)).toJSON();952}952}953export async function getLastTokenId(953export async function getLastTokenId(954 api: ApiPromise,954 api: ApiPromise,955 collectionId: number,955 collectionId: number,956): Promise<number> {956): Promise<number> {957 return (await api.rpc.nft.lastTokenId(collectionId)).toJSON();957 return (await api.rpc.unique.lastTokenId(collectionId)).toJSON();958}958}959export async function getAdminList(959export async function getAdminList(960 api: ApiPromise,960 api: ApiPromise,961 collectionId: number,961 collectionId: number,962): Promise<string[]> {962): Promise<string[]> {963 return (await api.rpc.nft.adminlist(collectionId)).toHuman() as any;963 return (await api.rpc.unique.adminlist(collectionId)).toHuman() as any;964}964}965export async function getVariableMetadata(965export async function getVariableMetadata(966 api: ApiPromise,966 api: ApiPromise,967 collectionId: number,967 collectionId: number,968 tokenId: number,968 tokenId: number,969): Promise<number[]> {969): Promise<number[]> {970 return [...(await api.rpc.nft.variableMetadata(collectionId, tokenId))];970 return [...(await api.rpc.unique.variableMetadata(collectionId, tokenId))];971}971}972export async function getConstMetadata(972export async function getConstMetadata(973 api: ApiPromise,973 api: ApiPromise,974 collectionId: number,974 collectionId: number,975 tokenId: number,975 tokenId: number,976): Promise<number[]> {976): Promise<number[]> {977 return [...(await api.rpc.nft.constMetadata(collectionId, tokenId))];977 return [...(await api.rpc.unique.constMetadata(collectionId, tokenId))];978}978}979979980export async function createFungibleItemExpectSuccess(980export async function createFungibleItemExpectSuccess(984 owner: CrossAccountId | string = sender.address,984 owner: CrossAccountId | string = sender.address,985) {985) {986 return await usingApi(async (api) => {986 return await usingApi(async (api) => {987 const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(owner), {Fungible: data});987 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), {Fungible: data});988988989 const events = await submitTransactionAsync(sender, tx);989 const events = await submitTransactionAsync(sender, tx);990 const result = getCreateItemResult(events);990 const result = getCreateItemResult(events);1004 let tx;1004 let tx;1005 if (createMode === 'Fungible') {1005 if (createMode === 'Fungible') {1006 const createData = {fungible: {value: 10}};1006 const createData = {fungible: {value: 10}};1007 tx = api.tx.nft.createItem(collectionId, to, createData as any);1007 tx = api.tx.unique.createItem(collectionId, to, createData as any);1008 } else if (createMode === 'ReFungible') {1008 } else if (createMode === 'ReFungible') {1009 const createData = {refungible: {const_data: [], variable_data: [], pieces: 100}};1009 const createData = {refungible: {const_data: [], variable_data: [], pieces: 100}};1010 tx = api.tx.nft.createItem(collectionId, to, createData as any);1010 tx = api.tx.unique.createItem(collectionId, to, createData as any);1011 } else {1011 } else {1012 const createData = {nft: {const_data: [], variable_data: []}};1012 const createData = {nft: {const_data: [], variable_data: []}};1013 tx = api.tx.nft.createItem(collectionId, to, createData as any);1013 tx = api.tx.unique.createItem(collectionId, to, createData as any);1014 }1014 }101510151016 const events = await submitTransactionAsync(sender, tx);1016 const events = await submitTransactionAsync(sender, tx);103710371038export async function createItemExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, owner: string = sender.address) {1038export async function createItemExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, owner: string = sender.address) {1039 await usingApi(async (api) => {1039 await usingApi(async (api) => {1040 const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(owner), createMode);1040 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);104110411042 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1042 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1043 const result = getCreateItemResult(events);1043 const result = getCreateItemResult(events);1053 await usingApi(async (api) => {1053 await usingApi(async (api) => {105410541055 // Run the transaction1055 // Run the transaction1056 const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);1056 const tx = api.tx.unique.setPublicAccessMode(collectionId, accessMode);1057 const events = await submitTransactionAsync(sender, tx);1057 const events = await submitTransactionAsync(sender, tx);1058 const result = getGenericResult(events);1058 const result = getGenericResult(events);105910591074 await usingApi(async (api) => {1074 await usingApi(async (api) => {107510751076 // Run the transaction1076 // Run the transaction1077 const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);1077 const tx = api.tx.unique.setPublicAccessMode(collectionId, accessMode);1078 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1078 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1079 const result = getGenericResult(events);1079 const result = getGenericResult(events);108010801100 await usingApi(async (api) => {1100 await usingApi(async (api) => {110111011102 // Run the transaction1102 // Run the transaction1103 const tx = api.tx.nft.setMintPermission(collectionId, enabled);1103 const tx = api.tx.unique.setMintPermission(collectionId, enabled);1104 const events = await submitTransactionAsync(sender, tx);1104 const events = await submitTransactionAsync(sender, tx);1105 const result = getGenericResult(events);1105 const result = getGenericResult(events);1106 expect(result.success).to.be.true;1106 expect(result.success).to.be.true;1119export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {1119export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {1120 await usingApi(async (api) => {1120 await usingApi(async (api) => {1121 // Run the transaction1121 // Run the transaction1122 const tx = api.tx.nft.setMintPermission(collectionId, enabled);1122 const tx = api.tx.unique.setMintPermission(collectionId, enabled);1123 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1123 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1124 const result = getCreateCollectionResult(events);1124 const result = getCreateCollectionResult(events);1125 // tslint:disable-next-line:no-unused-expression1125 // tslint:disable-next-line:no-unused-expression1130export async function setChainLimitsExpectFailure(sender: IKeyringPair, limits: IChainLimits) {1130export async function setChainLimitsExpectFailure(sender: IKeyringPair, limits: IChainLimits) {1131 await usingApi(async (api) => {1131 await usingApi(async (api) => {1132 // Run the transaction1132 // Run the transaction1133 const tx = api.tx.nft.setChainLimits(limits);1133 const tx = api.tx.unique.setChainLimits(limits);1134 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1134 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1135 const result = getCreateCollectionResult(events);1135 const result = getCreateCollectionResult(events);1136 // tslint:disable-next-line:no-unused-expression1136 // tslint:disable-next-line:no-unused-expression1139}1139}114011401141export async function isAllowlisted(api: ApiPromise, collectionId: number, address: string | CrossAccountId) {1141export async function isAllowlisted(api: ApiPromise, collectionId: number, address: string | CrossAccountId) {1142 return (await api.rpc.nft.allowed(collectionId, normalizeAccountId(address))).toJSON();1142 return (await api.rpc.unique.allowed(collectionId, normalizeAccountId(address))).toJSON();1143}1143}114411441145export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1145export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1146 await usingApi(async (api) => {1146 await usingApi(async (api) => {1147 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.false;1147 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.false;114811481149 // Run the transaction1149 // Run the transaction1150 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1150 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1151 const events = await submitTransactionAsync(sender, tx);1151 const events = await submitTransactionAsync(sender, tx);1152 const result = getGenericResult(events);1152 const result = getGenericResult(events);1153 expect(result.success).to.be.true;1153 expect(result.success).to.be.true;1162 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;1162 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;116311631164 // Run the transaction1164 // Run the transaction1165 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1165 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1166 const events = await submitTransactionAsync(sender, tx);1166 const events = await submitTransactionAsync(sender, tx);1167 const result = getGenericResult(events);1167 const result = getGenericResult(events);1168 expect(result.success).to.be.true;1168 expect(result.success).to.be.true;1175 await usingApi(async (api) => {1175 await usingApi(async (api) => {117611761177 // Run the transaction1177 // Run the transaction1178 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1178 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1179 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1179 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1180 const result = getGenericResult(events);1180 const result = getGenericResult(events);118111811188export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1188export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1189 await usingApi(async (api) => {1189 await usingApi(async (api) => {1190 // Run the transaction1190 // Run the transaction1191 const tx = api.tx.nft.removeFromAllowList(collectionId, normalizeAccountId(address));1191 const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1192 const events = await submitTransactionAsync(sender, tx);1192 const events = await submitTransactionAsync(sender, tx);1193 const result = getGenericResult(events);1193 const result = getGenericResult(events);119411941201export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1201export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1202 await usingApi(async (api) => {1202 await usingApi(async (api) => {1203 // Run the transaction1203 // Run the transaction1204 const tx = api.tx.nft.removeFromAllowList(collectionId, normalizeAccountId(address));1204 const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1205 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1205 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1206 const result = getGenericResult(events);1206 const result = getGenericResult(events);12071207121312131214export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)1214export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)1215 : Promise<NftDataStructsCollection | null> => {1215 : Promise<NftDataStructsCollection | null> => {1216 return (await api.rpc.nft.collectionById(collectionId)).unwrapOr(null);1216 return (await api.rpc.unique.collectionById(collectionId)).unwrapOr(null);1217};1217};121812181219export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {1219export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {1220 // set global object - collectionsCount1220 // set global object - collectionsCount1221 return (await api.rpc.nft.collectionStats()).created.toNumber();1221 return (await api.rpc.unique.collectionStats()).created.toNumber();1222};1222};122312231224export async function queryCollectionExpectSuccess(api: ApiPromise, collectionId: number): Promise<NftDataStructsCollection> {1224export async function queryCollectionExpectSuccess(api: ApiPromise, collectionId: number): Promise<NftDataStructsCollection> {1225 return (await api.rpc.nft.collectionById(collectionId)).unwrap();1225 return (await api.rpc.unique.collectionById(collectionId)).unwrap();1226}1226}122712271228export async function waitNewBlocks(blocksCount = 1): Promise<void> {1228export async function waitNewBlocks(blocksCount = 1): Promise<void> {