git.delta.rocks / unique-network / refs/commits / 859444d47d73

difftreelog

Merge develop into unit-test fixes

Greg Zaitsev2021-11-24parents: #455ab69 #ee40b79.patch.diff
in: master

160 files changed

modified.devcontainer/devcontainer.jsondiffbeforeafterboth
1{1{
2 "name": "Rust",2 "name": "Rust",
3 "dockerComposeFile": "./docker-compose.yml",3 "dockerComposeFile": "./docker-compose.yml",
4 "service": "nft_private",4 "service": "unique-chain",
5 "workspaceFolder": "/workspaces/nft_private",5 "workspaceFolder": "/workspaces/unique-chain",
6 "settings": { 6 "settings": {
7 "terminal.integrated.shell.linux": "/bin/bash",7 "terminal.integrated.shell.linux": "/bin/bash",
8 "lldb.executable": "/usr/bin/lldb",8 "lldb.executable": "/usr/bin/lldb",
modified.devcontainer/docker-compose.ymldiffbeforeafterboth
1version: '3'1version: '3'
2services:2services:
3 nft_private:3 unique-chain:
4 build: 4 build:
5 context: .5 context: .
6 environment:6 environment:
7 - JAEGER_AGENT_HOST=jaeger7 - JAEGER_AGENT_HOST=jaeger
8 - JAEGER_AGENT_PORT=68318 - JAEGER_AGENT_PORT=6831
9 volumes:9 volumes:
10 - ..:/workspaces/nft_private:cached10 - ..:/workspaces/unique-chain:cached
11 - ../../polkadot:/workspaces/polkadot:cached11 - ../../polkadot:/workspaces/polkadot:cached
12 - ../../polkadot-launch:/workspaces/polkadot-launch:cached12 - ../../polkadot-launch:/workspaces/polkadot-launch:cached
13 #- ../../frontier:/workspaces/frontier13 #- ../../frontier:/workspaces/frontier
modified.envdiffbeforeafterboth
1RUST_TOOLCHAIN=nightly-2021-06-281RUST_TOOLCHAIN=nightly-2021-06-28
2RUST_C=1.55.0-nightly2RUST_C=1.55.0-nightly
3POLKA_VERSION=v0.9.123POLKA_VERSION=v0.9.12
4NFT_BRANCH=develop4UNIQUE_BRANCH=develop
5USER=***5USER=***
6PASS=***6PASS=***
77
modified.github/workflows/node_build_test.ymldiffbeforeafterboth
32 key: ${{ secrets.KEY }}32 key: ${{ secrets.KEY }}
33 port: ${{ secrets.SERVER_PORT }}33 port: ${{ secrets.SERVER_PORT }}
34 command_timeout: 300m34 command_timeout: 300m
35 script: |35 script: |
36 eval $(ssh-agent -s)36 eval $(ssh-agent -s)
37 ssh-add /home/devops/.ssh/git_hub37 ssh-add /home/devops/.ssh/git_hub
38 git clone git@github.com:UniqueNetwork/nft_private.git38 git clone git@github.com:UniqueNetwork/unique-chain.git
39 cd nft_private39 cd unique-chain
40 git checkout develop40 git checkout develop
41 # git pull --all41 # git pull --all
42 chmod +x ci_node.sh42 chmod +x ci_node.sh
43 ./ci_node.sh43 ./ci_node.sh
44 rm -rf /home/polkadot/nft_private44 rm -rf /home/polkadot/unique-chain
4545
modifiedCargo.lockdiffbeforeafterboth
4938 "winapi 0.3.9",4938 "winapi 0.3.9",
4939]4939]
4940
4941[[package]]
4942name = "nft"
4943version = "0.9.12"
4944dependencies = [
4945 "cumulus-client-cli",
4946 "cumulus-client-collator",
4947 "cumulus-client-consensus-aura",
4948 "cumulus-client-consensus-common",
4949 "cumulus-client-network",
4950 "cumulus-client-service",
4951 "cumulus-primitives-core",
4952 "cumulus-primitives-parachain-inherent",
4953 "fc-consensus",
4954 "fc-db",
4955 "fc-mapping-sync",
4956 "fc-rpc",
4957 "fc-rpc-core",
4958 "flexi_logger",
4959 "fp-rpc",
4960 "frame-benchmarking",
4961 "frame-benchmarking-cli",
4962 "futures 0.3.17",
4963 "jsonrpc-core",
4964 "jsonrpc-pubsub",
4965 "log",
4966 "nft-data-structs",
4967 "nft-rpc",
4968 "nft-runtime",
4969 "pallet-ethereum",
4970 "pallet-transaction-payment-rpc",
4971 "parity-scale-codec",
4972 "parking_lot 0.11.2",
4973 "polkadot-cli",
4974 "polkadot-parachain",
4975 "polkadot-primitives",
4976 "polkadot-service",
4977 "polkadot-test-service",
4978 "sc-basic-authorship",
4979 "sc-chain-spec",
4980 "sc-cli",
4981 "sc-client-api",
4982 "sc-consensus",
4983 "sc-consensus-aura",
4984 "sc-executor",
4985 "sc-finality-grandpa",
4986 "sc-keystore",
4987 "sc-network",
4988 "sc-rpc",
4989 "sc-rpc-api",
4990 "sc-service",
4991 "sc-telemetry",
4992 "sc-tracing",
4993 "sc-transaction-pool",
4994 "serde",
4995 "serde_json",
4996 "sp-api",
4997 "sp-block-builder",
4998 "sp-blockchain",
4999 "sp-consensus",
5000 "sp-consensus-aura",
5001 "sp-core",
5002 "sp-finality-grandpa",
5003 "sp-inherents",
5004 "sp-keystore",
5005 "sp-offchain",
5006 "sp-runtime",
5007 "sp-session",
5008 "sp-timestamp",
5009 "sp-transaction-pool",
5010 "sp-trie",
5011 "structopt",
5012 "substrate-build-script-utils",
5013 "substrate-frame-rpc-system",
5014 "substrate-prometheus-endpoint",
5015]
5016
5017[[package]]
5018name = "nft-data-structs"
5019version = "0.9.0"
5020dependencies = [
5021 "derivative",
5022 "frame-support",
5023 "frame-system",
5024 "parity-scale-codec",
5025 "scale-info",
5026 "serde",
5027 "sp-core",
5028 "sp-runtime",
5029 "sp-std",
5030]
5031
5032[[package]]
5033name = "nft-rpc"
5034version = "3.3.1"
5035dependencies = [
5036 "fc-db",
5037 "fc-mapping-sync",
5038 "fc-rpc",
5039 "fc-rpc-core",
5040 "fp-rpc",
5041 "futures 0.3.17",
5042 "jsonrpc-core",
5043 "jsonrpc-pubsub",
5044 "nft-runtime",
5045 "pallet-ethereum",
5046 "pallet-nft",
5047 "pallet-transaction-payment-rpc",
5048 "pallet-transaction-payment-rpc-runtime-api",
5049 "sc-client-api",
5050 "sc-consensus-aura",
5051 "sc-consensus-epochs",
5052 "sc-finality-grandpa",
5053 "sc-finality-grandpa-rpc",
5054 "sc-keystore",
5055 "sc-network",
5056 "sc-rpc",
5057 "sc-rpc-api",
5058 "sc-service",
5059 "sc-transaction-pool",
5060 "sp-api",
5061 "sp-block-builder",
5062 "sp-blockchain",
5063 "sp-consensus",
5064 "sp-consensus-aura",
5065 "sp-core",
5066 "sp-offchain",
5067 "sp-runtime",
5068 "sp-session",
5069 "sp-storage",
5070 "sp-transaction-pool",
5071 "substrate-frame-rpc-system",
5072 "tokio 0.2.25",
5073 "uc-rpc",
5074 "up-rpc",
5075]
5076
5077[[package]]
5078name = "nft-runtime"
5079version = "0.9.12"
5080dependencies = [
5081 "cumulus-pallet-aura-ext",
5082 "cumulus-pallet-dmp-queue",
5083 "cumulus-pallet-parachain-system",
5084 "cumulus-pallet-xcm",
5085 "cumulus-pallet-xcmp-queue",
5086 "cumulus-primitives-core",
5087 "cumulus-primitives-timestamp",
5088 "cumulus-primitives-utility",
5089 "derivative",
5090 "fp-rpc",
5091 "fp-self-contained",
5092 "frame-benchmarking",
5093 "frame-executive",
5094 "frame-support",
5095 "frame-system",
5096 "frame-system-benchmarking",
5097 "frame-system-rpc-runtime-api",
5098 "hex-literal",
5099 "nft-data-structs",
5100 "orml-vesting",
5101 "pallet-aura",
5102 "pallet-balances",
5103 "pallet-common",
5104 "pallet-ethereum",
5105 "pallet-evm",
5106 "pallet-evm-coder-substrate",
5107 "pallet-evm-contract-helpers",
5108 "pallet-evm-migration",
5109 "pallet-evm-transaction-payment",
5110 "pallet-fungible",
5111 "pallet-inflation",
5112 "pallet-nft",
5113 "pallet-nft-transaction-payment",
5114 "pallet-nonfungible",
5115 "pallet-randomness-collective-flip",
5116 "pallet-refungible",
5117 "pallet-sudo",
5118 "pallet-template-transaction-payment",
5119 "pallet-timestamp",
5120 "pallet-transaction-payment",
5121 "pallet-transaction-payment-rpc-runtime-api",
5122 "pallet-treasury",
5123 "pallet-unq-scheduler",
5124 "pallet-xcm",
5125 "parachain-info",
5126 "parity-scale-codec",
5127 "polkadot-parachain",
5128 "scale-info",
5129 "serde",
5130 "smallvec",
5131 "sp-api",
5132 "sp-arithmetic",
5133 "sp-block-builder",
5134 "sp-consensus-aura",
5135 "sp-core",
5136 "sp-inherents",
5137 "sp-io",
5138 "sp-offchain",
5139 "sp-runtime",
5140 "sp-session",
5141 "sp-std",
5142 "sp-transaction-pool",
5143 "sp-version",
5144 "substrate-wasm-builder",
5145 "up-rpc",
5146 "xcm",
5147 "xcm-builder",
5148 "xcm-executor",
5149]
51504940
5151[[package]]4941[[package]]
5152name = "nodrop"4942name = "nodrop"
5581 "evm-coder",5371 "evm-coder",
5582 "frame-support",5372 "frame-support",
5583 "frame-system",5373 "frame-system",
5584 "nft-data-structs",
5585 "pallet-evm",5374 "pallet-evm",
5586 "pallet-evm-coder-substrate",5375 "pallet-evm-coder-substrate",
5587 "parity-scale-codec",5376 "parity-scale-codec",
5590 "sp-core",5379 "sp-core",
5591 "sp-runtime",5380 "sp-runtime",
5592 "sp-std",5381 "sp-std",
5382 "up-data-structs",
5383 "up-evm-mapping",
5593]5384]
55945385
5595[[package]]5386[[package]]
5839 "sp-io",5630 "sp-io",
5840 "sp-runtime",5631 "sp-runtime",
5841 "sp-std",5632 "sp-std",
5633 "up-evm-mapping",
5842 "up-sponsorship",5634 "up-sponsorship",
5843]5635]
58445636
5851 "frame-benchmarking",5643 "frame-benchmarking",
5852 "frame-support",5644 "frame-support",
5853 "frame-system",5645 "frame-system",
5854 "nft-data-structs",
5855 "pallet-common",5646 "pallet-common",
5856 "pallet-evm-coder-substrate",5647 "pallet-evm-coder-substrate",
5857 "parity-scale-codec",5648 "parity-scale-codec",
5858 "scale-info",5649 "scale-info",
5859 "sp-core",5650 "sp-core",
5860 "sp-runtime",5651 "sp-runtime",
5861 "sp-std",5652 "sp-std",
5653 "up-data-structs",
5862]5654]
58635655
5864[[package]]5656[[package]]
59545746
5955[[package]]5747[[package]]
5956name = "pallet-inflation"5748name = "pallet-inflation"
5957version = "3.0.0"5749version = "0.1.0"
5958dependencies = [5750dependencies = [
5959 "frame-benchmarking",5751 "frame-benchmarking",
5960 "frame-support",5752 "frame-support",
6054 "sp-std",5846 "sp-std",
6055]5847]
6056
6057[[package]]
6058name = "pallet-nft"
6059version = "3.0.0"
6060dependencies = [
6061 "ethereum 0.9.0 (git+https://github.com/purestake/ethereum?branch=joshy-scale-info)",
6062 "evm-coder",
6063 "fp-evm",
6064 "frame-benchmarking",
6065 "frame-support",
6066 "frame-system",
6067 "hex-literal",
6068 "nft-data-structs",
6069 "pallet-balances",
6070 "pallet-common",
6071 "pallet-ethereum",
6072 "pallet-evm",
6073 "pallet-evm-coder-substrate",
6074 "pallet-fungible",
6075 "pallet-nonfungible",
6076 "pallet-randomness-collective-flip",
6077 "pallet-refungible",
6078 "pallet-timestamp",
6079 "pallet-transaction-payment",
6080 "parity-scale-codec",
6081 "primitive-types 0.10.1",
6082 "rlp",
6083 "scale-info",
6084 "serde",
6085 "sp-api",
6086 "sp-core",
6087 "sp-io",
6088 "sp-runtime",
6089 "sp-std",
6090 "up-sponsorship",
6091]
6092
6093[[package]]
6094name = "pallet-nft-transaction-payment"
6095version = "3.0.0"
6096dependencies = [
6097 "frame-benchmarking",
6098 "frame-support",
6099 "frame-system",
6100 "pallet-transaction-payment",
6101 "parity-scale-codec",
6102 "scale-info",
6103 "serde",
6104 "sp-core",
6105 "sp-io",
6106 "sp-runtime",
6107 "sp-std",
6108 "up-sponsorship",
6109]
61105848
6111[[package]]5849[[package]]
6112name = "pallet-nicks"5850name = "pallet-nicks"
6131 "frame-benchmarking",5869 "frame-benchmarking",
6132 "frame-support",5870 "frame-support",
6133 "frame-system",5871 "frame-system",
6134 "nft-data-structs",
6135 "pallet-common",5872 "pallet-common",
6136 "pallet-evm-coder-substrate",5873 "pallet-evm-coder-substrate",
6137 "parity-scale-codec",5874 "parity-scale-codec",
6138 "scale-info",5875 "scale-info",
6139 "sp-core",5876 "sp-core",
6140 "sp-runtime",5877 "sp-runtime",
6141 "sp-std",5878 "sp-std",
5879 "up-data-structs",
6142]5880]
61435881
6144[[package]]5882[[package]]
6231 "frame-benchmarking",5969 "frame-benchmarking",
6232 "frame-support",5970 "frame-support",
6233 "frame-system",5971 "frame-system",
6234 "nft-data-structs",
6235 "pallet-common",5972 "pallet-common",
6236 "parity-scale-codec",5973 "parity-scale-codec",
6237 "scale-info",5974 "scale-info",
6238 "sp-core",5975 "sp-core",
6239 "sp-runtime",5976 "sp-runtime",
6240 "sp-std",5977 "sp-std",
5978 "up-data-structs",
6241]5979]
62425980
6243[[package]]5981[[package]]
6483 "sp-std",6221 "sp-std",
6484]6222]
6223
6224[[package]]
6225name = "pallet-unique"
6226version = "0.1.0"
6227dependencies = [
6228 "ethereum 0.9.0 (git+https://github.com/purestake/ethereum?branch=joshy-scale-info)",
6229 "evm-coder",
6230 "fp-evm",
6231 "frame-benchmarking",
6232 "frame-support",
6233 "frame-system",
6234 "hex-literal",
6235 "pallet-balances",
6236 "pallet-common",
6237 "pallet-ethereum",
6238 "pallet-evm",
6239 "pallet-evm-coder-substrate",
6240 "pallet-fungible",
6241 "pallet-nonfungible",
6242 "pallet-randomness-collective-flip",
6243 "pallet-refungible",
6244 "pallet-timestamp",
6245 "pallet-transaction-payment",
6246 "parity-scale-codec",
6247 "primitive-types 0.10.1",
6248 "rlp",
6249 "scale-info",
6250 "serde",
6251 "sp-api",
6252 "sp-core",
6253 "sp-io",
6254 "sp-runtime",
6255 "sp-std",
6256 "up-data-structs",
6257 "up-evm-mapping",
6258 "up-sponsorship",
6259]
64856260
6486[[package]]6261[[package]]
6487name = "pallet-unq-scheduler"6262name = "pallet-unq-scheduler"
6488version = "3.0.0"6263version = "0.1.0"
6489dependencies = [6264dependencies = [
6490 "frame-benchmarking",6265 "frame-benchmarking",
6491 "frame-support",6266 "frame-support",
11729 "jsonrpc-core",11504 "jsonrpc-core",
11730 "jsonrpc-core-client",11505 "jsonrpc-core-client",
11731 "jsonrpc-derive",11506 "jsonrpc-derive",
11732 "nft-data-structs",
11733 "pallet-common",11507 "pallet-common",
11734 "parity-scale-codec",11508 "parity-scale-codec",
11735 "sp-api",11509 "sp-api",
11736 "sp-blockchain",11510 "sp-blockchain",
11737 "sp-core",11511 "sp-core",
11738 "sp-rpc",11512 "sp-rpc",
11739 "sp-runtime",11513 "sp-runtime",
11514 "up-data-structs",
11740 "up-rpc",11515 "up-rpc",
11741]11516]
1174211517
11800source = "registry+https://github.com/rust-lang/crates.io-index"11575source = "registry+https://github.com/rust-lang/crates.io-index"
11801checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"11576checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
11577
11578[[package]]
11579name = "unique-node"
11580version = "0.9.12"
11581dependencies = [
11582 "cumulus-client-cli",
11583 "cumulus-client-collator",
11584 "cumulus-client-consensus-aura",
11585 "cumulus-client-consensus-common",
11586 "cumulus-client-network",
11587 "cumulus-client-service",
11588 "cumulus-primitives-core",
11589 "cumulus-primitives-parachain-inherent",
11590 "fc-consensus",
11591 "fc-db",
11592 "fc-mapping-sync",
11593 "fc-rpc",
11594 "fc-rpc-core",
11595 "flexi_logger",
11596 "fp-rpc",
11597 "frame-benchmarking",
11598 "frame-benchmarking-cli",
11599 "futures 0.3.17",
11600 "jsonrpc-core",
11601 "jsonrpc-pubsub",
11602 "log",
11603 "pallet-ethereum",
11604 "pallet-transaction-payment-rpc",
11605 "parity-scale-codec",
11606 "parking_lot 0.11.2",
11607 "polkadot-cli",
11608 "polkadot-parachain",
11609 "polkadot-primitives",
11610 "polkadot-service",
11611 "polkadot-test-service",
11612 "sc-basic-authorship",
11613 "sc-chain-spec",
11614 "sc-cli",
11615 "sc-client-api",
11616 "sc-consensus",
11617 "sc-consensus-aura",
11618 "sc-executor",
11619 "sc-finality-grandpa",
11620 "sc-keystore",
11621 "sc-network",
11622 "sc-rpc",
11623 "sc-rpc-api",
11624 "sc-service",
11625 "sc-telemetry",
11626 "sc-tracing",
11627 "sc-transaction-pool",
11628 "serde",
11629 "serde_json",
11630 "sp-api",
11631 "sp-block-builder",
11632 "sp-blockchain",
11633 "sp-consensus",
11634 "sp-consensus-aura",
11635 "sp-core",
11636 "sp-finality-grandpa",
11637 "sp-inherents",
11638 "sp-keystore",
11639 "sp-offchain",
11640 "sp-runtime",
11641 "sp-session",
11642 "sp-timestamp",
11643 "sp-transaction-pool",
11644 "sp-trie",
11645 "structopt",
11646 "substrate-build-script-utils",
11647 "substrate-frame-rpc-system",
11648 "substrate-prometheus-endpoint",
11649 "unique-rpc",
11650 "unique-runtime",
11651 "up-data-structs",
11652]
11653
11654[[package]]
11655name = "unique-rpc"
11656version = "0.1.0"
11657dependencies = [
11658 "fc-db",
11659 "fc-mapping-sync",
11660 "fc-rpc",
11661 "fc-rpc-core",
11662 "fp-rpc",
11663 "futures 0.3.17",
11664 "jsonrpc-core",
11665 "jsonrpc-pubsub",
11666 "pallet-ethereum",
11667 "pallet-transaction-payment-rpc",
11668 "pallet-transaction-payment-rpc-runtime-api",
11669 "pallet-unique",
11670 "sc-client-api",
11671 "sc-consensus-aura",
11672 "sc-consensus-epochs",
11673 "sc-finality-grandpa",
11674 "sc-finality-grandpa-rpc",
11675 "sc-keystore",
11676 "sc-network",
11677 "sc-rpc",
11678 "sc-rpc-api",
11679 "sc-service",
11680 "sc-transaction-pool",
11681 "sp-api",
11682 "sp-block-builder",
11683 "sp-blockchain",
11684 "sp-consensus",
11685 "sp-consensus-aura",
11686 "sp-core",
11687 "sp-offchain",
11688 "sp-runtime",
11689 "sp-session",
11690 "sp-storage",
11691 "sp-transaction-pool",
11692 "substrate-frame-rpc-system",
11693 "tokio 0.2.25",
11694 "uc-rpc",
11695 "unique-runtime",
11696 "up-rpc",
11697]
11698
11699[[package]]
11700name = "unique-runtime"
11701version = "0.9.12"
11702dependencies = [
11703 "cumulus-pallet-aura-ext",
11704 "cumulus-pallet-dmp-queue",
11705 "cumulus-pallet-parachain-system",
11706 "cumulus-pallet-xcm",
11707 "cumulus-pallet-xcmp-queue",
11708 "cumulus-primitives-core",
11709 "cumulus-primitives-timestamp",
11710 "cumulus-primitives-utility",
11711 "derivative",
11712 "fp-rpc",
11713 "fp-self-contained",
11714 "frame-benchmarking",
11715 "frame-executive",
11716 "frame-support",
11717 "frame-system",
11718 "frame-system-benchmarking",
11719 "frame-system-rpc-runtime-api",
11720 "hex-literal",
11721 "orml-vesting",
11722 "pallet-aura",
11723 "pallet-balances",
11724 "pallet-common",
11725 "pallet-ethereum",
11726 "pallet-evm",
11727 "pallet-evm-coder-substrate",
11728 "pallet-evm-contract-helpers",
11729 "pallet-evm-migration",
11730 "pallet-evm-transaction-payment",
11731 "pallet-fungible",
11732 "pallet-inflation",
11733 "pallet-nonfungible",
11734 "pallet-randomness-collective-flip",
11735 "pallet-refungible",
11736 "pallet-sudo",
11737 "pallet-template-transaction-payment",
11738 "pallet-timestamp",
11739 "pallet-transaction-payment",
11740 "pallet-transaction-payment-rpc-runtime-api",
11741 "pallet-treasury",
11742 "pallet-unique",
11743 "pallet-unq-scheduler",
11744 "pallet-xcm",
11745 "parachain-info",
11746 "parity-scale-codec",
11747 "polkadot-parachain",
11748 "scale-info",
11749 "serde",
11750 "smallvec",
11751 "sp-api",
11752 "sp-arithmetic",
11753 "sp-block-builder",
11754 "sp-consensus-aura",
11755 "sp-core",
11756 "sp-inherents",
11757 "sp-io",
11758 "sp-offchain",
11759 "sp-runtime",
11760 "sp-session",
11761 "sp-std",
11762 "sp-transaction-pool",
11763 "sp-version",
11764 "substrate-wasm-builder",
11765 "up-data-structs",
11766 "up-evm-mapping",
11767 "up-rpc",
11768 "xcm",
11769 "xcm-builder",
11770 "xcm-executor",
11771]
1180211772
11803[[package]]11773[[package]]
11804name = "universal-hash"11774name = "universal-hash"
11846source = "registry+https://github.com/rust-lang/crates.io-index"11816source = "registry+https://github.com/rust-lang/crates.io-index"
11847checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"11817checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
11818
11819[[package]]
11820name = "up-data-structs"
11821version = "0.1.0"
11822dependencies = [
11823 "derivative",
11824 "frame-support",
11825 "frame-system",
11826 "parity-scale-codec",
11827 "scale-info",
11828 "serde",
11829 "sp-core",
11830 "sp-runtime",
11831 "sp-std",
11832]
11833
11834[[package]]
11835name = "up-evm-mapping"
11836version = "0.1.0"
11837dependencies = [
11838 "frame-support",
11839 "sp-core",
11840]
1184811841
11849[[package]]11842[[package]]
11850name = "up-rpc"11843name = "up-rpc"
11851version = "0.1.0"11844version = "0.1.0"
11852dependencies = [11845dependencies = [
11853 "nft-data-structs",
11854 "pallet-common",11846 "pallet-common",
11855 "parity-scale-codec",11847 "parity-scale-codec",
11856 "sp-api",11848 "sp-api",
11857 "sp-core",11849 "sp-core",
11858 "sp-runtime",11850 "sp-runtime",
11859 "sp-std",11851 "sp-std",
11852 "up-data-structs",
11860]11853]
1186111854
11862[[package]]11855[[package]]
deletedDockerfilediffbeforeafterboth

no changes

modifiedDockerfile-parachaindiffbeforeafterboth
5ARG RUST_TOOLCHAIN=nightly-2021-06-285ARG RUST_TOOLCHAIN=nightly-2021-06-28
6#ARG RUST_C=1.55.0-nightly6#ARG RUST_C=1.55.0-nightly
7ARG POLKA_VERSION=v0.9.127ARG POLKA_VERSION=v0.9.12
8ARG NFT_BRANCH=develop8ARG UNIQUE_BRANCH=develop
99
10#ARG USER=***10#ARG USER=***
11#ARG PASS=***11#ARG PASS=***
14ENV RUST_TOOLCHAIN $RUST_TOOLCHAIN14ENV RUST_TOOLCHAIN $RUST_TOOLCHAIN
15#ENV RUST_C $RUST_C15#ENV RUST_C $RUST_C
16ENV POLKA_VERSION $POLKA_VERSION16ENV POLKA_VERSION $POLKA_VERSION
17ENV NFT_BRANCH $NFT_BRANCH17ENV UNIQUE_BRANCH $UNIQUE_BRANCH
1818
1919
20#RUN echo $RUST_TOOLCHAIN20#RUN echo $RUST_TOOLCHAIN
21#RUN echo $RUST_C21#RUN echo $RUST_C
22#RUN echo $POLKA_VERSION22#RUN echo $POLKA_VERSION
23#RUN echo $NFT_BRANCH23#RUN echo $UNIQUE_BRANCH
2424
25ENV CARGO_HOME="/cargo-home"25ENV CARGO_HOME="/cargo-home"
26ENV PATH="/cargo-home/bin:$PATH"26ENV PATH="/cargo-home/bin:$PATH"
4040
41RUN cargo install cargo-chef41RUN cargo install cargo-chef
4242
43RUN mkdir nft_parachain43RUN mkdir unique_parachain
44WORKDIR /nft_parachain44WORKDIR /unique_parachain
4545
46# ===== Chef =====46# ===== Chef =====
47FROM rust-builder as chef47FROM rust-builder as chef
52# ===== BUILD ======52# ===== BUILD ======
53FROM rust-builder as builder53FROM rust-builder as builder
5454
55RUN mkdir nft_parachain55RUN mkdir unique_parachain
56WORKDIR /nft_parachain56WORKDIR /unique_parachain
5757
58COPY --from=chef /nft_parachain/recipe.json recipe.json58COPY --from=chef /unique_parachain/recipe.json recipe.json
59ARG PROFILE=release59ARG PROFILE=release
60RUN cargo chef cook "--$PROFILE" --recipe-path recipe.json60RUN cargo chef cook "--$PROFILE" --recipe-path recipe.json
6161
67# ===== BUILD POLKADOT =====67# ===== BUILD POLKADOT =====
68FROM rust-builder as builder-polkadot68FROM rust-builder as builder-polkadot
6969
70RUN mkdir nft_parachain70RUN mkdir unique_parachain
71WORKDIR /nft_parachain71WORKDIR /unique_parachain
7272
73RUN 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 yarn
100100
101COPY --from=builder /nft_parachain/target/$PROFILE/nft /nft_private/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/
103103
104CMD 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" && \
deletedDockerfile-unitdiffbeforeafterboth

no changes

modifiedMakefilediffbeforeafterboth
4 @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"
88
9.PHONY: regenerate_solidity9.PHONY: regenerate_solidity
10regenerate_solidity:10regenerate_solidity:
41bench-evm-migration:41bench-evm-migration:
42 make _bench PALLET=evm-migration42 make _bench PALLET=evm-migration
4343
44.PHONY: bench-nft44.PHONY: bench-unique
45bench-nft:45bench-unique:
46 make _bench PALLET=nft46 make _bench PALLET=unique
4747
48.PHONY: bench-fungible48.PHONY: bench-fungible
49bench-fungible:49bench-fungible:
58 make _bench PALLET=nonfungible58 make _bench PALLET=nonfungible
5959
60.PHONY: bench60.PHONY: bench
61bench: bench-evm-migration bench-nft bench-fungible bench-refungible bench-nonfungible61bench: bench-evm-migration bench-unique bench-fungible bench-refungible bench-nonfungible
6262
modifiedREADME.mddiffbeforeafterboth
1![Docker build](https://github.com/usetech-llc/nft_parachain/workflows/Docker%20build/badge.svg)1![Docker build](https://github.com/usetech-llc/nft_parachain/workflows/Docker%20build/badge.svg)
22
3# NFT Parachain3# Unique Parachain
44
5## Project Description5## Project Description
66
7The 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 the
8basement 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 of
9a given Collection, and managing their ownership.9a given Collection, and managing their ownership.
1010
11The 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 a
12concrete 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 knowledge
13about 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.
1414
15The NFT Chain also provides:15The Unique Chain also provides:
1616
17- Smart Contracts Pallet and example smart contract that interacts with NFT Runtime17- Smart Contracts Pallet and example smart contract that interacts with Unique Runtime
18- 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 split
19 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 attract
21 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 collection
22 Transfer transactions.22 Transfer transactions.
2323
24Wider NFT Ecosystem (most of it was developed during Hackusama):24Wider Unique Ecosystem (most of it was developed during Hackusama):
2525
26- [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)
2929
30Please 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:
3535
36- Enabled Smart Contracts Pallet36- Enabled Smart Contracts Pallet
37- 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 Pallet
39- 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 Mode
42 - Off-Chain Schema to store token image URLs42 - Off-Chain Schema to store token image URLs
43 - Alternative economic model43 - Alternative economic model
44 - Allow Lists and Public Mint Permission44 - Allow Lists and Public Mint Permission
45- 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 Testnet
46 Blockchain.46 Blockchain.
4747
48## Application Development48## Application Development
5151
52## Building52## Building
5353
54Building 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 everything
55so that we can keep the builds stable.55so that we can keep the builds stable.
5656
571. Install Rust:571. Install Rust:
168168
169```169```
170170
1713. Export genesis state and runtime wasm from NFT parachain:1713. Export genesis state and runtime wasm from Unique parachain:
172172
173Run 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-genesis
176./target/release/nft export-genesis-wasm > ./resources/para-2000-wasm176./target/release/unique-collator export-genesis-wasm > ./resources/para-2000-wasm
177```177```
178178
1794. Run two parachain nodes:1794. Run two parachain nodes:
182182
183Run 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 9977
186./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/12D3KooWN1ah2bFQSysEFnwZqcmcVpDDR8UedXyo6xfzV1zDNMNg
187```187```
188188
1894. 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-reserve
218218
219Run benchmark219Run benchmark
220```bash220```bash
221target/release/nft benchmark --chain dev --pallet "pallet_nft" --extrinsic "*" --repeat 1221target/release/unique-collator benchmark --chain dev --pallet "pallet_unique" --extrinsic "*" --repeat 1
222```222```
223223
224## UI custom types224## UI custom types
modifiedclient/rpc/Cargo.tomldiffbeforeafterboth
55
6[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"
modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
3use 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::{CollectionId, 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;
1010
11#[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>;
2727
28 #[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>>;
4949
50 #[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>;
7676
77 #[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 = "unique_allowed")]
90 fn allowed(
91 &self,
92 collection: CollectionId,
93 user: CrossAccountId,
94 at: Option<BlockHash>,
95 ) -> Result<bool>;
89 #[rpc(name = "nft_lastTokenId")]96 #[rpc(name = "unique_lastTokenId")]
90 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 = "unique_collectionById")]
99 fn collection_by_id(
100 &self,
101 collection: CollectionId,
102 at: Option<BlockHash>,
103 ) -> Result<Option<Collection<AccountId>>>;
104 #[rpc(name = "unique_collectionStats")]
105 fn collection_stats(&self, at: Option<BlockHash>) -> Result<CollectionStats>;
91}106}
92107
93pub struct Nft<C, P> {108pub struct Unique<C, P> {
94 client: Arc<C>,109 client: Arc<C>,
95 _marker: std::marker::PhantomData<P>,110 _marker: std::marker::PhantomData<P>,
96}111}
97112
98impl<C, P> Nft<C, P> {113impl<C, P> Unique<C, P> {
99 pub fn new(client: Arc<C>) -> Self {114 pub fn new(client: Arc<C>) -> Self {
100 Self {115 Self {
101 client,116 client,
139 };154 };
140}155}
141156
142impl<C, Block, CrossAccountId, AccountId> NftApi<<Block as BlockT>::Hash, CrossAccountId, AccountId>157impl<C, Block, CrossAccountId, AccountId>
143 for Nft<C, Block>158 UniqueApi<<Block as BlockT>::Hash, CrossAccountId, AccountId> for Unique<C, Block>
144where159where
145 Block: BlockT,160 Block: BlockT,
146 AccountId: Decode,161 AccountId: Decode,
147 C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,162 C: 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
148 C::Api: NftRuntimeApi<Block, CrossAccountId, AccountId>,163 C::Api: UniqueRuntimeApi<Block, CrossAccountId, AccountId>,
149 CrossAccountId: pallet_common::account::CrossAccountId<AccountId>,164 CrossAccountId: pallet_common::account::CrossAccountId<AccountId>,
150{165{
151 pass_method!(account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>);166 pass_method!(account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>);
160175
161 pass_method!(adminlist(collection: CollectionId) -> Vec<CrossAccountId>);176 pass_method!(adminlist(collection: CollectionId) -> Vec<CrossAccountId>);
162 pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>);177 pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>);
178 pass_method!(allowed(collection: CollectionId, user: CrossAccountId) -> bool);
163 pass_method!(last_token_id(collection: CollectionId) -> TokenId);179 pass_method!(last_token_id(collection: CollectionId) -> TokenId);
180 pass_method!(collection_by_id(collection: CollectionId) -> Option<Collection<AccountId>>);
181 pass_method!(collection_stats() -> CollectionStats);
164}182}
165183
modifieddocker-compose-tests-parachain.ymldiffbeforeafterboth
9 - 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.json
15 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.ts
26 - /home/ubuntu/mochawesome-report:/nft_parachain/mochawesome-report26 - /home/ubuntu/mochawesome-report:/unique_parachain/mochawesome-report
27 depends_on:27 depends_on:
28 - blockchain_nodes28 - blockchain_nodes
2929
deleteddocker-compose.ymldiffbeforeafterboth

no changes

modifiedlaunch-config.jsondiffbeforeafterboth
55 },55 },
56 "parachains": [56 "parachains": [
57 {57 {
58 "bin": "../nft_private/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": [
deletednftTestnetSpec.jsondiffbeforeafterboth

no changes

deletednftTestnetSpecRaw.jsondiffbeforeafterboth

no changes

modifiednode/cli/Cargo.tomldiffbeforeafterboth
231################################################################################231################################################################################
232# Local dependencies232# Local dependencies
233233
234[dependencies.nft-runtime]234[dependencies.unique-runtime]
235path = '../../runtime'235path = '../../runtime'
236version = '0.9.12'
237236
238[dependencies.nft-data-structs]237[dependencies.up-data-structs]
239path = "../../primitives/nft"238path = "../../primitives/data-structs"
240default-features = false239default-features = false
241240
242################################################################################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'
255254
256[[bin]]255[[bin]]
257name = 'nft'256name = 'unique-collator'
257path = "src/main.rs"
258258
259[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" }
278278
279nft-rpc = { path = "../rpc" }279unique-rpc = { path = "../rpc" }
280280
281[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]
287287
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
4//4//
55
6use 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;
1616
17/// 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>;
1919
20/// Helper function to generate a crypto pair from seed20/// Helper function to generate a crypto pair from seed
21pub 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_BINARY
156 .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(),
modifiednode/cli/src/command.rsdiffbeforeafterboth
24use 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 }
8989
90 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::VERSION
92 }92 }
93}93}
9494
modifiednode/cli/src/service.rsdiffbeforeafterboth
13use futures::StreamExt;13use futures::StreamExt;
1414
15// Local Runtime Types15// Local Runtime Types
16use nft_runtime::RuntimeApi;16use unique_runtime::RuntimeApi;
1717
18// Cumulus Imports18// Cumulus Imports
19use 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;
5555
56 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 }
5959
60 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}
6464
68 .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");
7474
291291
292 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 };
309309
310 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 ))
modifiednode/rpc/Cargo.tomldiffbeforeafterboth
1[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" }
5050
51pallet-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" }
5555
56[features]56[features]
57std = []57std = []
modifiednode/rpc/src/lib.rsdiffbeforeafterboth
1use 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};
100where100where
101 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.client
108 .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())));
208208
209 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(
modifiedpallets/common/Cargo.tomldiffbeforeafterboth
15sp-runtime = { default-features = false, git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.12' }15sp-runtime = { 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' }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' }
18nft-data-structs = { default-features = false, path = '../../primitives/nft' }19up-data-structs = { default-features = false, path = '../../primitives/data-structs' }
19pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }20pallet-evm-coder-substrate = { default-features = false, path = '../../pallets/evm-coder-substrate' }
20evm-coder = { default-features = false, path = '../../crates/evm-coder' }21evm-coder = { default-features = false, path = '../../crates/evm-coder' }
21
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 "up-evm-mapping/std",
35 "nft-data-structs/std",36 "up-data-structs/std",
36 "pallet-evm/std",37 "pallet-evm/std",
37]38]
38runtime-benchmarks = []39runtime-benchmarks = []
modifiedpallets/common/src/account.rsdiffbeforeafterboth
2use codec::{Encode, EncodeLike, Decode};2use codec::{Encode, EncodeLike, Decode};
3use sp_core::H160;3use sp_core::H160;
4use scale_info::{Type, TypeInfo};4use scale_info::{Type, TypeInfo};
5use sp_core::crypto::AccountId32;
6use core::cmp::Ordering;5use core::cmp::Ordering;
7use serde::{Serialize, Deserialize};6use serde::{Serialize, Deserialize};
8use pallet_evm::AddressMapping;7use pallet_evm::AddressMapping;
9use sp_std::vec::Vec;8use sp_std::vec::Vec;
10use sp_std::clone::Clone;9use sp_std::clone::Clone;
10pub use up_evm_mapping::EvmBackwardsAddressMapping;
1111
12pub trait CrossAccountId<AccountId>:12pub trait CrossAccountId<AccountId>:
13 Encode + EncodeLike + Decode + TypeInfo + Clone + PartialEq + Ord + core::fmt::Debug + Default13 Encode + EncodeLike + Decode + TypeInfo + Clone + PartialEq + Ord + core::fmt::Debug + Default
177 }177 }
178}178}
179
180pub trait EvmBackwardsAddressMapping<AccountId> {
181 fn from_account_id(account_id: AccountId) -> H160;
182}
183
184/// Should have same mapping as EnsureAddressTruncated
185pub struct MapBackwardsAddressTruncated;
186impl EvmBackwardsAddressMapping<AccountId32> for MapBackwardsAddressTruncated {
187 fn from_account_id(account_id: AccountId32) -> H160 {
188 let mut out = [0; 20];
189 out.copy_from_slice(&(account_id.as_ref() as &[u8])[0..20]);
190 H160(out)
191 }
192}
193179
modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
1use 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,
19pub fn create_collection_raw<T: Config, R>(19pub fn create_collection_raw<T: Config, R>(
20 owner: T::AccountId,20 owner: T::AccountId,
21 mode: CollectionMode,21 mode: CollectionMode,
22 handler: impl FnOnce(Collection<T>) -> Result<CollectionId, DispatchError>,22 handler: impl FnOnce(Collection<T::AccountId>) -> Result<CollectionId, DispatchError>,
23 cast: impl FnOnce(CollectionHandle<T>) -> R,23 cast: impl FnOnce(CollectionHandle<T>) -> R,
24) -> Result<R, DispatchError> {24) -> Result<R, DispatchError> {
25 T::Currency::deposit_creating(&owner, T::CollectionCreationPrice::get());25 T::Currency::deposit_creating(&owner, T::CollectionCreationPrice::get());
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
1use nft_data_structs::{CollectionId, TokenId};1use up_data_structs::{CollectionId, TokenId};
2use sp_core::H160;2use sp_core::H160;
33
4// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 14// 0x17c4e6453Cc49AAAaEACA894e6D9683e00000001 - collection 1
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
8 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,
15 WithdrawReasons,15 WithdrawReasons, CollectionStats,
16};16};
17pub use pallet::*;17pub use pallet::*;
18use sp_core::H160;18use sp_core::H160;
26#[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]26#[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]
27pub struct CollectionHandle<T: Config> {27pub struct CollectionHandle<T: Config> {
28 pub id: CollectionId,28 pub id: CollectionId,
29 collection: Collection<T>,29 collection: Collection<T::AccountId>,
30 pub recorder: pallet_evm_coder_substrate::SubstrateRecorder<T>,30 pub recorder: pallet_evm_coder_substrate::SubstrateRecorder<T>,
31}31}
32impl<T: Config> CollectionHandle<T> {32impl<T: Config> CollectionHandle<T> {
78 }78 }
79}79}
80impl<T: Config> Deref for CollectionHandle<T> {80impl<T: Config> Deref for CollectionHandle<T> {
81 type Target = Collection<T>;81 type Target = Collection<T::AccountId>;
8282
83 fn deref(&self) -> &Self::Target {83 fn deref(&self) -> &Self::Target {
84 &self.collection84 &self.collection
141pub mod pallet {141pub mod pallet {
142 use super::*;142 use super::*;
143 use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};143 use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};
144 use account::{EvmBackwardsAddressMapping, 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;
148148
149 #[pallet::config]149 #[pallet::config]
153 type CrossAccountId: CrossAccountId<Self::AccountId>;153 type CrossAccountId: CrossAccountId<Self::AccountId>;
154154
155 type EvmAddressMapping: pallet_evm::AddressMapping<Self::AccountId>;155 type EvmAddressMapping: pallet_evm::AddressMapping<Self::AccountId>;
156 type EvmBackwardsAddressMapping: EvmBackwardsAddressMapping<Self::AccountId>;156 type EvmBackwardsAddressMapping: up_evm_mapping::EvmBackwardsAddressMapping<Self::AccountId>;
157157
158 type Currency: Currency<Self::AccountId>;158 type Currency: Currency<Self::AccountId>;
159 type CollectionCreationPrice: Get<159 type CollectionCreationPrice: Get<
311 pub type CollectionById<T> = StorageMap<311 pub type CollectionById<T> = StorageMap<
312 Hasher = Blake2_128Concat,312 Hasher = Blake2_128Concat,
313 Key = CollectionId,313 Key = CollectionId,
314 Value = Collection<T>,314 Value = Collection<<T as frame_system::Config>::AccountId>,
315 QueryKind = OptionQuery,315 QueryKind = OptionQuery,
316 >;316 >;
317317
345 QueryKind = ValueQuery,345 QueryKind = ValueQuery,
346 >;346 >;
347
348 /// Not used by code, exists only to provide some types to metadata
349 #[pallet::storage]
350 pub type DummyStorageValue<T> =
351 StorageValue<Value = (CollectionStats, CollectionId, TokenId), QueryKind = OptionQuery>;
347}352}
348353
349impl<T: Config> Pallet<T> {354impl<T: Config> Pallet<T> {
355 );360 );
356 Ok(())361 Ok(())
357 }362 }
363 pub fn adminlist(collection: CollectionId) -> Vec<T::CrossAccountId> {
364 <IsAdmin<T>>::iter_prefix((collection,))
365 .map(|(a, _)| a)
366 .collect()
367 }
368 pub fn allowlist(collection: CollectionId) -> Vec<T::CrossAccountId> {
369 <Allowlist<T>>::iter_prefix((collection,))
370 .map(|(a, _)| a)
371 .collect()
372 }
373 pub fn allowed(collection: CollectionId, user: T::CrossAccountId) -> bool {
374 <Allowlist<T>>::get((collection, user))
375 }
376 pub fn collection_stats() -> CollectionStats {
377 let created = <CreatedCollectionCount<T>>::get();
378 let destroyed = <DestroyedCollectionCount<T>>::get();
379 CollectionStats {
380 created: created.0,
381 destroyed: destroyed.0,
382 alive: created.0 - destroyed.0,
383 }
384 }
358}385}
359386
360impl<T: Config> Pallet<T> {387impl<T: Config> Pallet<T> {
361 pub fn init_collection(data: Collection<T>) -> Result<CollectionId, DispatchError> {388 pub fn init_collection(data: Collection<T::AccountId>) -> Result<CollectionId, DispatchError> {
362 {389 {
363 ensure!(390 ensure!(
364 data.name.len() <= MAX_COLLECTION_NAME_LENGTH,391 data.name.len() <= MAX_COLLECTION_NAME_LENGTH,
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
5959
60 fn allowed(&self, contract_address: address, user: address) -> Result<bool> {60 fn allowed(&self, contract_address: address, user: address) -> Result<bool> {
61 self.0.consume_sload()?;61 self.0.consume_sload()?;
62 Ok(<Pallet<T>>::allowed(contract_address, user, true))62 Ok(<Pallet<T>>::allowed(contract_address, user)
63 || !<AllowlistEnabled<T>>::get(contract_address))
63 }64 }
6465
65 fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {66 fn allowlist_enabled(&self, contract_address: address) -> Result<bool> {
113 value: sp_core::U256,114 value: sp_core::U256,
114 ) -> Option<PrecompileOutput> {115 ) -> Option<PrecompileOutput> {
115 // TODO: Extract to another OnMethodCall handler116 // TODO: Extract to another OnMethodCall handler
116 if !<Pallet<T>>::allowed(*target, *source, true) {117 if <AllowlistEnabled<T>>::get(target) && !<Pallet<T>>::allowed(*target, *source) {
117 return Some(PrecompileOutput {118 return Some(PrecompileOutput {
118 exit_status: ExitReason::Revert(ExitRevert::Reverted),119 exit_status: ExitReason::Revert(ExitRevert::Reverted),
119 cost: 0,120 cost: 0,
151pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);152pub struct HelpersContractSponsoring<T: Config>(PhantomData<*const T>);
152impl<T: Config> SponsorshipHandler<H160, (H160, Vec<u8>)> for HelpersContractSponsoring<T> {153impl<T: Config> SponsorshipHandler<H160, (H160, Vec<u8>)> for HelpersContractSponsoring<T> {
153 fn get_sponsor(who: &H160, call: &(H160, Vec<u8>)) -> Option<H160> {154 fn get_sponsor(who: &H160, call: &(H160, Vec<u8>)) -> Option<H160> {
154 if <SelfSponsoring<T>>::get(&call.0) && <Pallet<T>>::allowed(call.0, *who, false) {155 if !<SelfSponsoring<T>>::get(&call.0) {
156 return None;
157 }
158 if !<Pallet<T>>::allowed(call.0, *who) {
159 return None;
160 }
155 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;161 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
162
156 if let Some(last_tx_block) = <SponsorBasket<T>>::get(&call.0, who) {163 if let Some(last_tx_block) = <SponsorBasket<T>>::get(&call.0, who) {
157 let rate_limit = <SponsoringRateLimit<T>>::get(&call.0);164 let limit = <SponsoringRateLimit<T>>::get(&call.0);
165
158 let limit_time = last_tx_block + rate_limit;166 let timeout = last_tx_block + limit.into();
159167 if block_number < timeout {
160 if block_number > limit_time {168 return None;
161 <SponsorBasket<T>>::insert(&call.0, who, block_number);169 }
162 return Some(call.0);
163 }
164 } else {170 }
171
165 <SponsorBasket<T>>::insert(&call.0, who, block_number);172 <SponsorBasket<T>>::insert(&call.0, who, block_number);
173
166 return Some(call.0);174 Some(call.0)
167 }
168 }
169 None
170 }175 }
171}176}
172177
modifiedpallets/evm-contract-helpers/src/lib.rsdiffbeforeafterboth
76 <SponsoringRateLimit<T>>::insert(contract, rate_limit);76 <SponsoringRateLimit<T>>::insert(contract, rate_limit);
77 }77 }
7878
79 /// Default is returned if allowlist is disabled
80 pub fn allowed(contract: H160, user: H160, default: bool) -> bool {79 pub fn allowed(contract: H160, user: H160) -> bool {
81 if !<AllowlistEnabled<T>>::get(contract) {
82 return default;
83 }
84 <Allowlist<T>>::get(&contract, &user) || <Owner<T>>::get(&contract) == user80 <Allowlist<T>>::get(&contract, &user) || <Owner<T>>::get(&contract) == user
85 }81 }
8682
modifiedpallets/evm-migration/src/weights.rsdiffbeforeafterboth
7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1287//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128
88
9// Executed Command:9// Executed Command:
10// target/release/nft10// target/release/unique-collator
11// benchmark11// benchmark
12// --pallet12// --pallet
13// pallet-evm-migration13// pallet-evm-migration
modifiedpallets/evm-transaction-payment/Cargo.tomldiffbeforeafterboth
15fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }15fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
16pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }16pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/frontier.git", branch = "unique-polkadot-v0.9.12" }
17up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" } 17up-sponsorship = { version = "0.1.0", default-features = false, git = "https://github.com/UniqueNetwork/pallet-sponsoring" }
18up-evm-mapping = { default-features = false, path = "../../primitives/evm-mapping" }
1819
19[dependencies.codec]20[dependencies.codec]
20default-features = false21default-features = false
35 "pallet-ethereum/std",36 "pallet-ethereum/std",
36 "fp-evm/std",37 "fp-evm/std",
37 "up-sponsorship/std",38 "up-sponsorship/std",
39 "up-evm-mapping/std",
38]40]
3941
modifiedpallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth
1#![cfg_attr(not(feature = "std"), no_std)]1#![cfg_attr(not(feature = "std"), no_std)]
22
3pub use pallet::*;
4
5#[frame_support::pallet]
6pub mod pallet {
7 use core::marker::PhantomData;3use core::marker::PhantomData;
4use fp_evm::WithdrawReason;
8 use frame_support::traits::Currency;5use frame_support::traits::{Currency, IsSubType};
9 use pallet_evm::EVMCurrencyAdapter;6pub use pallet::*;
10 use fp_evm::WithdrawReason;7use pallet_evm::{EVMCurrencyAdapter, EnsureAddressOrigin};
11 use sp_core::{H160, U256};8use sp_core::{H160, U256};
12 use sp_runtime::TransactionOutcome;9use sp_runtime::TransactionOutcome;
13 use up_sponsorship::SponsorshipHandler;10use up_sponsorship::SponsorshipHandler;
11use up_evm_mapping::EvmBackwardsAddressMapping;
12use pallet_evm::AddressMapping;
13
14#[frame_support::pallet]
15pub mod pallet {
16 use super::*;
17
14 use sp_std::vec::Vec;18 use frame_support::traits::Currency;
15
16 type NegativeImbalanceOf<C, T> =
17 <C as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;19 use sp_std::vec::Vec;
1820
19 #[pallet::config]21 #[pallet::config]
20 pub trait Config: frame_system::Config {22 pub trait Config: frame_system::Config {
21 type SponsorshipHandler: SponsorshipHandler<H160, (H160, Vec<u8>)>;23 type EvmSponsorshipHandler: SponsorshipHandler<H160, (H160, Vec<u8>)>;
22 type Currency: Currency<Self::AccountId>;24 type Currency: Currency<Self::AccountId>;
25 type EvmBackwardsAddressMapping: EvmBackwardsAddressMapping<Self::AccountId>;
26 type EvmAddressMapping: AddressMapping<Self::AccountId>;
23 }27 }
2428
25 #[pallet::pallet]29 #[pallet::pallet]
26 #[pallet::generate_store(pub(super) trait Store)]30 #[pallet::generate_store(pub(super) trait Store)]
27 pub struct Pallet<T>(_);31 pub struct Pallet<T>(_);
32}
33
34type NegativeImbalanceOf<C, T> =
35 <C as Currency<<T as frame_system::Config>::AccountId>>::NegativeImbalance;
2836
29 pub struct ChargeEvmLiquidityInfo<T>37pub struct ChargeEvmLiquidityInfo<T>
30 where38where
42 WithdrawReason::Call { target, input } => {50 WithdrawReason::Call { target, input } => {
43 // This method is only used for checking, we shouldn't touch storage in it51 // This method is only used for checking, we shouldn't touch storage in it
44 frame_support::storage::with_transaction(|| {52 frame_support::storage::with_transaction(|| {
45 TransactionOutcome::Rollback(T::SponsorshipHandler::get_sponsor(53 TransactionOutcome::Rollback(T::EvmSponsorshipHandler::get_sponsor(
46 &origin,54 &origin,
47 &(*target, input.clone()),55 &(*target, input.clone()),
48 ))56 ))
68 ) -> core::result::Result<Self::LiquidityInfo, pallet_evm::Error<T>> {75 ) -> core::result::Result<Self::LiquidityInfo, pallet_evm::Error<T>> {
69 let mut who_pays_fee = *who;76 let mut who_pays_fee = *who;
70 if let WithdrawReason::Call { target, input } = &reason {77 if let WithdrawReason::Call { target, input } = &reason {
71 who_pays_fee = T::SponsorshipHandler::get_sponsor(who, &(*target, input.clone()))78 who_pays_fee = T::EvmSponsorshipHandler::get_sponsor(who, &(*target, input.clone()))
72 .unwrap_or(who_pays_fee);79 .unwrap_or(who_pays_fee);
73 }80 }
74 let negative_imbalance =81 let negative_imbalance = EVMCurrencyAdapter::<<T as Config>::Currency, ()>::withdraw_fee(
95 )101 )
96 }102 }
97 }103}
98}104
105/// Implements sponsoring for evm calls performed from pallet-evm (via api.tx.ethereum.transact/api.tx.evm.call)
106pub struct BridgeSponsorshipHandler<T>(PhantomData<T>);
107impl<T, C> SponsorshipHandler<T::AccountId, C> for BridgeSponsorshipHandler<T>
108where
109 T: Config + pallet_evm::Config,
110 C: IsSubType<pallet_evm::Call<T>>,
111{
112 fn get_sponsor(who: &T::AccountId, call: &C) -> Option<T::AccountId> {
113 match call.is_sub_type()? {
114 pallet_evm::Call::call {
115 source,
116 target,
117 input,
118 ..
119 } => {
120 let _ = T::CallOrigin::ensure_address_origin(
121 source,
122 <frame_system::RawOrigin<T::AccountId>>::Signed(who.clone()).into(),
123 )
124 .ok()?;
125 let who = T::EvmBackwardsAddressMapping::from_account_id(who.clone());
126 // Effects from EvmSponsorshipHandler are applied in OnChargeEvmTransaction by pallet_evm::runner
127 // TODO: Should we implement simulation mode (test, but do not apply effects) in `up-sponsorship`?
128 let sponsor = frame_support::storage::with_transaction(|| {
129 TransactionOutcome::Rollback(T::EvmSponsorshipHandler::get_sponsor(
130 &who,
131 &(target.clone(), input.clone()),
132 ))
133 })?;
134 let sponsor = T::EvmAddressMapping::into_account_id(sponsor);
135 Some(sponsor)
136 }
137 _ => None,
138 }
139 }
140}
99141
modifiedpallets/fungible/Cargo.tomldiffbeforeafterboth
16sp-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",
modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
4use 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;
99
10const SEED: u32 = 1;10const SEED: u32 = 1;
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
1use core::marker::PhantomData;1use core::marker::PhantomData;
22
3use 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 = sum
76 .checked_add(data.value)76 .checked_add(data.value)
77 .ok_or(ArithmeticError::Overflow)?;77 .ok_or(ArithmeticError::Overflow)?;
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
1use 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;
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
22
3use 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;
3030
31 #[pallet::error]31 #[pallet::error]
91}91}
9292
93impl<T: Config> Pallet<T> {93impl<T: Config> Pallet<T> {
94 pub fn init_collection(data: Collection<T>) -> Result<CollectionId, DispatchError> {94 pub fn init_collection(data: Collection<T::AccountId>) -> Result<CollectionId, DispatchError> {
95 PalletCommon::init_collection(data)95 <PalletCommon<T>>::init_collection(data)
96 }96 }
97 pub fn destroy_collection(97 pub fn destroy_collection(
98 collection: FungibleHandle<T>,98 collection: FungibleHandle<T>,
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1287//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128
88
9// Executed Command:9// Executed Command:
10// target/release/nft10// target/release/unique-collator
11// benchmark11// benchmark
12// --pallet12// --pallet
13// pallet-fungible13// pallet-fungible
modifiedpallets/inflation/Cargo.tomldiffbeforeafterboth
33
4[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'
1313
14[package.metadata.docs.rs]14[package.metadata.docs.rs]
15targets = ['x86_64-unknown-linux-gnu']15targets = ['x86_64-unknown-linux-gnu']
modifiedpallets/inflation/src/lib.rsdiffbeforeafterboth
8585
86 let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);86 let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);
87
88 // TODO: Rewrite inflation to use block timestamp instead of block number
89 // let _now = <timestamp::Module<T>>::get();
8790
88 // Recalculate inflation on the first block of the year (or if it is not initialized yet)91 // Recalculate inflation on the first block of the year (or if it is not initialized yet)
89 if (now % T::BlockNumber::from(YEAR)).is_zero() || <BlockInflation<T>>::get().is_zero() {92 if (now % T::BlockNumber::from(YEAR)).is_zero() || <BlockInflation<T>>::get().is_zero() {
deletedpallets/nft-transaction-payment/Cargo.tomldiffbeforeafterboth

no changes

deletedpallets/nft-transaction-payment/README.mddiffbeforeafterboth

no changes

deletedpallets/nft-transaction-payment/src/lib.rsdiffbeforeafterboth

no changes

deletedpallets/nft/Cargo.tomldiffbeforeafterboth

no changes

deletedpallets/nft/src/benchmarking.rsdiffbeforeafterboth

no changes

deletedpallets/nft/src/common.rsdiffbeforeafterboth

no changes

deletedpallets/nft/src/dispatch.rsdiffbeforeafterboth

no changes

deletedpallets/nft/src/eth/mod.rsdiffbeforeafterboth

no changes

deletedpallets/nft/src/eth/sponsoring.rsdiffbeforeafterboth

no changes

deletedpallets/nft/src/lib.rsdiffbeforeafterboth

no changes

deletedpallets/nft/src/mock.rsdiffbeforeafterboth

no changes

deletedpallets/nft/src/sponsorship.rsdiffbeforeafterboth

no changes

deletedpallets/nft/src/tests.rsdiffbeforeafterboth

no changes

deletedpallets/nft/src/weights.rsdiffbeforeafterboth

no changes

modifiedpallets/nonfungible/Cargo.tomldiffbeforeafterboth
16sp-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",
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
4use 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;
1010
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
1use core::marker::PhantomData;1use core::marker::PhantomData;
22
3use 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}
4848
49fn 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 = data
83 .into_iter()83 .into_iter()
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
4};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};
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
22
3use 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;
4646
47 #[pallet::error]47 #[pallet::error]
133133
134// unchecked calls skips any permission checks134// unchecked calls skips any permission checks
135impl<T: Config> Pallet<T> {135impl<T: Config> Pallet<T> {
136 pub fn init_collection(data: Collection<T>) -> Result<CollectionId, DispatchError> {136 pub fn init_collection(data: Collection<T::AccountId>) -> Result<CollectionId, DispatchError> {
137 PalletCommon::init_collection(data)137 <PalletCommon<T>>::init_collection(data)
138 }138 }
139 pub fn destroy_collection(139 pub fn destroy_collection(
140 collection: NonfungibleHandle<T>,140 collection: NonfungibleHandle<T>,
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1287//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128
88
9// Executed Command:9// Executed Command:
10// target/release/nft10// target/release/unique-collator
11// benchmark11// benchmark
12// --pallet12// --pallet
13// pallet-nonfungible13// pallet-nonfungible
modifiedpallets/refungible/Cargo.tomldiffbeforeafterboth
16sp-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]
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
4use 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;
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
22
3use 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}
6868
69fn 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 = data
107 .into_iter()107 .into_iter()
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
1use nft_data_structs::TokenId;1use up_data_structs::TokenId;
2use pallet_common::erc::CommonEvmHandler;2use pallet_common::erc::CommonEvmHandler;
33
4use crate::{Config, RefungibleHandle};4use crate::{Config, RefungibleHandle};
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
1#![cfg_attr(not(feature = "std"), no_std)]1#![cfg_attr(not(feature = "std"), no_std)]
22
3use 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;
4242
43 #[pallet::error]43 #[pallet::error]
156156
157// unchecked calls skips any permission checks157// unchecked calls skips any permission checks
158impl<T: Config> Pallet<T> {158impl<T: Config> Pallet<T> {
159 pub fn init_collection(data: Collection<T>) -> Result<CollectionId, DispatchError> {159 pub fn init_collection(data: Collection<T::AccountId>) -> Result<CollectionId, DispatchError> {
160 PalletCommon::init_collection(data)160 <PalletCommon<T>>::init_collection(data)
161 }161 }
162 pub fn destroy_collection(162 pub fn destroy_collection(
163 collection: RefungibleHandle<T>,163 collection: RefungibleHandle<T>,
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1287//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 128
88
9// Executed Command:9// Executed Command:
10// target/release/nft10// target/release/unique-collator
11// benchmark11// benchmark
12// --pallet12// --pallet
13// pallet-refungible13// pallet-refungible
modifiedpallets/scheduler/Cargo.tomldiffbeforeafterboth
1[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"
1111
12[dependencies]12[dependencies]
modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
62 traits::{Zero, One, BadOrigin, Saturating},62 traits::{Zero, One, BadOrigin, Saturating},
63};63};
64use frame_support::{64use frame_support::{
65 decl_module, decl_storage, decl_event, decl_error, IterableStorageMap,65 decl_module, decl_storage, decl_event, decl_error,
66 dispatch::{Dispatchable, DispatchError, DispatchResult, Parameter},66 dispatch::{Dispatchable, DispatchError, DispatchResult, Parameter},
67 traits::{67 traits::{
68 Get,68 Get,
456}456}
457457
458impl<T: Config> Module<T> {458impl<T: Config> Module<T> {
459 /// Migrate storage format from V1 to V2.
460 /// Return true if migration is performed.
461 pub fn migrate_v1_to_t2() -> bool {
462 if StorageVersion::get() == Releases::V1 {
463 StorageVersion::put(Releases::V2);
464
465 Agenda::<T>::translate::<
466 Vec<Option<ScheduledV1<<T as Config>::Call, T::BlockNumber>>>,
467 _,
468 >(|_, agenda| {
469 Some(
470 agenda
471 .into_iter()
472 .map(|schedule| {
473 schedule.map(|schedule| ScheduledV2 {
474 maybe_id: schedule.maybe_id,
475 priority: schedule.priority,
476 call: schedule.call,
477 maybe_periodic: schedule.maybe_periodic,
478 origin: system::RawOrigin::Root.into(),
479 _phantom: Default::default(),
480 })
481 })
482 .collect::<Vec<_>>(),
483 )
484 });
485
486 true
487 } else {
488 false
489 }
490 }
491
492 /// Helper to migrate scheduler when the pallet origin type has changed.
493 pub fn migrate_origin<OldOrigin: Into<T::PalletsOrigin> + codec::Decode>() {
494 Agenda::<T>::translate::<
495 Vec<Option<Scheduled<<T as Config>::Call, T::BlockNumber, OldOrigin, T::AccountId>>>,
496 _,
497 >(|_, agenda| {
498 Some(
499 agenda
500 .into_iter()
501 .map(|schedule| {
502 schedule.map(|schedule| Scheduled {
503 maybe_id: schedule.maybe_id,
504 priority: schedule.priority,
505 call: schedule.call,
506 maybe_periodic: schedule.maybe_periodic,
507 origin: schedule.origin.into(),
508 _phantom: Default::default(),
509 })
510 })
511 .collect::<Vec<_>>(),
512 )
513 });
514 }
515
516 fn resolve_time(when: DispatchTime<T::BlockNumber>) -> Result<T::BlockNumber, DispatchError> {459 fn resolve_time(when: DispatchTime<T::BlockNumber>) -> Result<T::BlockNumber, DispatchError> {
517 let now = frame_system::Pallet::<T>::block_number();460 let now = frame_system::Pallet::<T>::block_number();
addedpallets/unique/Cargo.tomldiffbeforeafterboth

no changes

addedpallets/unique/src/benchmarking.rsdiffbeforeafterboth

no changes

addedpallets/unique/src/common.rsdiffbeforeafterboth

no changes

addedpallets/unique/src/dispatch.rsdiffbeforeafterboth

no changes

addedpallets/unique/src/eth/mod.rsdiffbeforeafterboth

no changes

addedpallets/unique/src/eth/sponsoring.rsdiffbeforeafterboth

no changes

addedpallets/unique/src/lib.rsdiffbeforeafterboth

no changes

addedpallets/unique/src/mock.rsdiffbeforeafterboth

no changes

addedpallets/unique/src/sponsorship.rsdiffbeforeafterboth

no changes

addedpallets/unique/src/tests.rsdiffbeforeafterboth

no changes

addedpallets/unique/src/weights.rsdiffbeforeafterboth

no changes

addedprimitives/data-structs/Cargo.tomldiffbeforeafterboth

no changes

addedprimitives/data-structs/src/lib.rsdiffbeforeafterboth

no changes

addedprimitives/evm-mapping/Cargo.tomldiffbeforeafterboth

no changes

addedprimitives/evm-mapping/src/lib.rsdiffbeforeafterboth

no changes

deletedprimitives/nft/Cargo.tomldiffbeforeafterboth

no changes

deletedprimitives/nft/src/lib.rsdiffbeforeafterboth

no changes

modifiedprimitives/rpc/Cargo.tomldiffbeforeafterboth
55
6[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]
2828
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
1#![cfg_attr(not(feature = "std"), no_std)]1#![cfg_attr(not(feature = "std"), no_std)]
22
3use nft_data_structs::{CollectionId, TokenId};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;
77
8sp_api::decl_runtime_apis! {8sp_api::decl_runtime_apis! {
9 pub trait NftApi<CrossAccountId, AccountId> where9 pub trait UniqueApi<CrossAccountId, AccountId> where
10 AccountId: Decode,10 AccountId: Decode,
11 CrossAccountId: pallet_common::account::CrossAccountId<AccountId>,11 CrossAccountId: pallet_common::account::CrossAccountId<AccountId>,
12 {12 {
3232
33 fn adminlist(collection: CollectionId) -> Vec<CrossAccountId>;33 fn adminlist(collection: CollectionId) -> Vec<CrossAccountId>;
34 fn allowlist(collection: CollectionId) -> Vec<CrossAccountId>;34 fn allowlist(collection: CollectionId) -> Vec<CrossAccountId>;
35 fn allowed(collection: CollectionId, user: CrossAccountId) -> bool;
35 fn last_token_id(collection: CollectionId) -> TokenId;36 fn last_token_id(collection: CollectionId) -> TokenId;
37 fn collection_by_id(collection: CollectionId) -> Option<Collection<AccountId>>;
38 fn collection_stats() -> CollectionStats;
36 }39 }
37}40}
3841
deletedrun.shdiffbeforeafterboth

no changes

modifiedruntime/Cargo.tomldiffbeforeafterboth
4[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'
1414
15[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',
69 'pallet-ethereum/std',69 'pallet-ethereum/std',
70 'fp-rpc/std',70 'fp-rpc/std',
71 'up-rpc/std',71 'up-rpc/std',
72 'up-evm-mapping/std',
72 'fp-self-contained/std',73 'fp-self-contained/std',
73 'parachain-info/std',74 'parachain-info/std',
74 'serde',75 'serde',
77 'pallet-fungible/std',78 'pallet-fungible/std',
78 'pallet-refungible/std',79 'pallet-refungible/std',
79 'pallet-nonfungible/std',80 'pallet-nonfungible/std',
80 'pallet-nft/std',81 'pallet-unique/std',
81 'pallet-unq-scheduler/std',82 'pallet-unq-scheduler/std',
82 'pallet-nft-charge-transaction/std',83 'pallet-charge-transaction/std',
83 'pallet-nft-transaction-payment/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",
100100
101 "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']
104104
105################################################################################105################################################################################
106# Substrate Dependencies106# Substrate Dependencies
374 "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 }
379pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }380pallet-inflation = { path = '../pallets/inflation', default-features = false }
380nft-data-structs = { path = '../primitives/nft', default-features = false, version = '0.9.0' }381up-data-structs = { path = '../primitives/data-structs', default-features = false }
381pallet-common = { default-features = false, path = "../pallets/common" }382pallet-common = { default-features = false, path = "../pallets/common" }
382pallet-fungible = { default-features = false, path = "../pallets/fungible" }383pallet-fungible = { default-features = false, path = "../pallets/fungible" }
383pallet-refungible = { default-features = false, path = "../pallets/refungible" }384pallet-refungible = { default-features = false, path = "../pallets/refungible" }
384pallet-nonfungible = { default-features = false, path = "../pallets/nonfungible" }385pallet-nonfungible = { default-features = false, path = "../pallets/nonfungible" }
385pallet-unq-scheduler = { path = '../pallets/scheduler', default-features = false, version = '3.0.0' }386pallet-unq-scheduler = { path = '../pallets/scheduler', default-features = false }
386# 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' }
387pallet-nft-transaction-payment = { path = '../pallets/nft-transaction-payment', default-features = false, version = '3.0.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 }
deletedruntime/src/chain_extension.rsdiffbeforeafterboth

no changes

modifiedruntime/src/lib.rsdiffbeforeafterboth
53 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>;
736736
737impl pallet_common::Config for Runtime {737impl pallet_common::Config for Runtime {
738 type Event = Event;738 type Event = Event;
739 type EvmBackwardsAddressMapping = pallet_common::account::MapBackwardsAddressTruncated;739 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
740 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;740 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
741 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;741 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;
742742
755 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;755 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;
756}756}
757757
758/// 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}
762761
763parameter_types! {762parameter_types! {
771 type InflationBlockInterval = InflationBlockInterval;770 type InflationBlockInterval = InflationBlockInterval;
772}771}
773772
774parameter_types! {773// parameter_types! {
775 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *774// pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *
776 RuntimeBlockWeights::get().max_block;775// RuntimeBlockWeights::get().max_block;
777 pub const MaxScheduledPerBlock: u32 = 50;776// pub const MaxScheduledPerBlock: u32 = 50;
778}777// }
779778
780pub struct Sponsoring;
781impl SponsoringResolve<AccountId, Call> for Sponsoring {
782 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>
783 where
784 Call: Dispatchable<Info = DispatchInfo>,779type EvmSponsorshipHandler = (
785 AccountId: AsRef<[u8]>,780 pallet_unique::UniqueEthSponsorshipHandler<Runtime>,
786 {
787 pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)781 pallet_evm_contract_helpers::HelpersContractSponsoring<Runtime>,
788 }782);
789}
790
791type SponsorshipHandler = (783type SponsorshipHandler = (
792 pallet_nft::NftSponsorshipHandler<Runtime>,784 pallet_unique::UniqueSponsorshipHandler<Runtime>,
793 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,785 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,
786 pallet_evm_transaction_payment::BridgeSponsorshipHandler<Runtime>,
794);787);
788
789// impl pallet_unq_scheduler::Config for Runtime {
790// type Event = Event;
791// type Origin = Origin;
792// type PalletsOrigin = OriginCaller;
793// type Call = Call;
794// type MaximumWeight = MaximumSchedulerWeight;
795// type ScheduleOrigin = EnsureSigned<AccountId>;
796// type MaxScheduledPerBlock = MaxScheduledPerBlock;
797// type SponsorshipHandler = SponsorshipHandler;
798// type WeightInfo = ();
799// }
795800
796impl pallet_unq_scheduler::Config for Runtime {801impl pallet_evm_transaction_payment::Config for Runtime {
797 type Event = Event;802 type EvmSponsorshipHandler = EvmSponsorshipHandler;
798 type Origin = Origin;803 type Currency = Balances;
799 type PalletsOrigin = OriginCaller;
800 type Call = Call;
801 type MaximumWeight = MaximumSchedulerWeight;
802 type ScheduleOrigin = EnsureSigned<AccountId>;804 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;
803 type MaxScheduledPerBlock = MaxScheduledPerBlock;805 type EvmBackwardsAddressMapping = up_evm_mapping::MapBackwardsAddressTruncated;
804 type SponsorshipHandler = SponsorshipHandler;
805 type WeightInfo = ();
806}806}
807807
808impl pallet_nft_transaction_payment::Config for Runtime {808impl pallet_charge_transaction::Config for Runtime {
809 type SponsorshipHandler = SponsorshipHandler;809 type SponsorshipHandler = SponsorshipHandler;
810}810}
811
812impl pallet_evm_transaction_payment::Config for Runtime {
813 type SponsorshipHandler = (
814 pallet_nft::NftEthSponsorshipHandler<Self>,
815 pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,
816 );
817 type Currency = Balances;
818}
819
820impl pallet_nft_charge_transaction::Config for Runtime {
821 type SponsorshipHandler = pallet_nft::NftSponsorshipHandler<Runtime>;
822}
823811
824// impl pallet_contract_helpers::Config for Runtime {812// impl pallet_contract_helpers::Config for Runtime {
825// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;813// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;
868856
869 // Unique Pallets857 // Unique Pallets
870 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,858 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,
871 Nft: pallet_nft::{Pallet, Call, Storage} = 61,859 Unique: pallet_unique::{Pallet, Call, Storage} = 61,
872 Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,860 // Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,
873 NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,861 // free = 63
874 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,862 Charging: pallet_charge_transaction::{Pallet, Call, Storage } = 64,
875 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,863 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,
876 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,864 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,
877 Fungible: pallet_fungible::{Pallet, Storage} = 67,865 Fungible: pallet_fungible::{Pallet, Storage} = 67,
931 system::CheckEra<Runtime>,919 system::CheckEra<Runtime>,
932 system::CheckNonce<Runtime>,920 system::CheckNonce<Runtime>,
933 system::CheckWeight<Runtime>,921 system::CheckWeight<Runtime>,
934 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,922 pallet_charge_transaction::ChargeTransactionPayment<Runtime>,
935 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,923 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,
936);924);
937/// Unchecked extrinsic type as expected by this runtime.925/// Unchecked extrinsic type as expected by this runtime.
1001 }989 }
1002}990}
1003991
1004macro_rules! dispatch_nft_runtime {992macro_rules! dispatch_unique_runtime {
1005 ($collection:ident.$method:ident($($name:ident),*)) => {{993 ($collection:ident.$method:ident($($name:ident),*)) => {{
1006 use pallet_nft::dispatch::Dispatched;994 use pallet_unique::dispatch::Dispatched;
1007995
1008 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::new($collection).unwrap());996 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::new($collection).unwrap());
1009 let dispatch = collection.as_dyn();997 let dispatch = collection.as_dyn();
1012 }};1000 }};
1013}1001}
1014impl_runtime_apis! {1002impl_runtime_apis! {
1015 impl up_rpc::NftApi<Block, CrossAccountId, AccountId>1003 impl up_rpc::UniqueApi<Block, CrossAccountId, AccountId>
1016 for Runtime1004 for Runtime
1017 {1005 {
1018 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId> {1006 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId> {
1019 dispatch_nft_runtime!(collection.account_tokens(account))1007 dispatch_unique_runtime!(collection.account_tokens(account))
1020 }1008 }
1021 fn token_exists(collection: CollectionId, token: TokenId) -> bool {1009 fn token_exists(collection: CollectionId, token: TokenId) -> bool {
1022 dispatch_nft_runtime!(collection.token_exists(token))1010 dispatch_unique_runtime!(collection.token_exists(token))
1023 }1011 }
10241012
1025 fn token_owner(collection: CollectionId, token: TokenId) -> CrossAccountId {1013 fn token_owner(collection: CollectionId, token: TokenId) -> CrossAccountId {
1026 dispatch_nft_runtime!(collection.token_owner(token))1014 dispatch_unique_runtime!(collection.token_owner(token))
1027 }1015 }
1028 fn const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {1016 fn const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {
1029 dispatch_nft_runtime!(collection.const_metadata(token))1017 dispatch_unique_runtime!(collection.const_metadata(token))
1030 }1018 }
1031 fn variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {1019 fn variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {
1032 dispatch_nft_runtime!(collection.variable_metadata(token))1020 dispatch_unique_runtime!(collection.variable_metadata(token))
1033 }1021 }
10341022
1035 fn collection_tokens(collection: CollectionId) -> u32 {1023 fn collection_tokens(collection: CollectionId) -> u32 {
1036 dispatch_nft_runtime!(collection.collection_tokens())1024 dispatch_unique_runtime!(collection.collection_tokens())
1037 }1025 }
1038 fn account_balance(collection: CollectionId, account: CrossAccountId) -> u32 {1026 fn account_balance(collection: CollectionId, account: CrossAccountId) -> u32 {
1039 dispatch_nft_runtime!(collection.account_balance(account))1027 dispatch_unique_runtime!(collection.account_balance(account))
1040 }1028 }
1041 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> u128 {1029 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> u128 {
1042 dispatch_nft_runtime!(collection.balance(account, token))1030 dispatch_unique_runtime!(collection.balance(account, token))
1043 }1031 }
1044 fn allowance(1032 fn allowance(
1045 collection: CollectionId,1033 collection: CollectionId,
1046 sender: CrossAccountId,1034 sender: CrossAccountId,
1047 spender: CrossAccountId,1035 spender: CrossAccountId,
1048 token: TokenId,1036 token: TokenId,
1049 ) -> u128 {1037 ) -> u128 {
1050 dispatch_nft_runtime!(collection.allowance(sender, spender, token))1038 dispatch_unique_runtime!(collection.allowance(sender, spender, token))
1051 }1039 }
10521040
1053 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {1041 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {
1054 <pallet_nft::NftErcSupport<Runtime>>::get_code(&account)1042 <pallet_unique::UniqueErcSupport<Runtime>>::get_code(&account)
1055 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))1043 .or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account))
1056 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))1044 .or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))
1057 }1045 }
1058 fn adminlist(collection: CollectionId) -> Vec<CrossAccountId> {1046 fn adminlist(collection: CollectionId) -> Vec<CrossAccountId> {
1059 <pallet_nft::Pallet<Runtime>>::adminlist(collection)1047 <pallet_common::Pallet<Runtime>>::adminlist(collection)
1060 }1048 }
1061 fn allowlist(collection: CollectionId) -> Vec<CrossAccountId> {1049 fn allowlist(collection: CollectionId) -> Vec<CrossAccountId> {
1062 <pallet_nft::Pallet<Runtime>>::allowlist(collection)1050 <pallet_common::Pallet<Runtime>>::allowlist(collection)
1063 }1051 }
1052 fn allowed(collection: CollectionId, user: CrossAccountId) -> bool {
1053 <pallet_common::Pallet<Runtime>>::allowed(collection, user)
1054 }
1064 fn last_token_id(collection: CollectionId) -> TokenId {1055 fn last_token_id(collection: CollectionId) -> TokenId {
1065 dispatch_nft_runtime!(collection.last_token_id())1056 dispatch_unique_runtime!(collection.last_token_id())
1066 }1057 }
1058 fn collection_by_id(collection: CollectionId) -> Option<Collection<AccountId>> {
1059 <pallet_common::CollectionById<Runtime>>::get(collection)
1060 }
1061 fn collection_stats() -> CollectionStats {
1062 <pallet_common::Pallet<Runtime>>::collection_stats()
1063 }
1067 }1064 }
10681065
1069 impl sp_api::Core<Block> for Runtime {1066 impl sp_api::Core<Block> for Runtime {
1340 let mut list = Vec::<BenchmarkList>::new();1337 let mut list = Vec::<BenchmarkList>::new();
13411338
1342 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);1339 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);
1343 list_benchmark!(list, extra, pallet_nft, Nft);1340 list_benchmark!(list, extra, pallet_unique, Unique);
1344 list_benchmark!(list, extra, pallet_inflation, Inflation);1341 list_benchmark!(list, extra, pallet_inflation, Inflation);
1345 list_benchmark!(list, extra, pallet_fungible, Fungible);1342 list_benchmark!(list, extra, pallet_fungible, Fungible);
1346 list_benchmark!(list, extra, pallet_refungible, Refungible);1343 list_benchmark!(list, extra, pallet_refungible, Refungible);
1373 let params = (&config, &allowlist);1370 let params = (&config, &allowlist);
13741371
1375 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1372 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);
1376 add_benchmark!(params, batches, pallet_nft, Nft);1373 add_benchmark!(params, batches, pallet_unique, Unique);
1377 add_benchmark!(params, batches, pallet_inflation, Inflation);1374 add_benchmark!(params, batches, pallet_inflation, Inflation);
1378 add_benchmark!(params, batches, pallet_fungible, Fungible);1375 add_benchmark!(params, batches, pallet_fungible, Fungible);
1379 add_benchmark!(params, batches, pallet_refungible, Refungible);1376 add_benchmark!(params, batches, pallet_refungible, Refungible);
deletedsubkeydiffbeforeafterboth

no changes

modifiedtests/Dockerfile-testsdiffbeforeafterboth
7RUN apt -y update; apt -y upgrade; apt -y install curl7RUN apt -y update; apt -y upgrade; apt -y install curl
88
99
10RUN mkdir nft_parachain10RUN mkdir unique_parachain
11WORKDIR /nft_parachain11WORKDIR /unique_parachain
1212
13RUN apt-get -y update && \13RUN apt-get -y update && \
14 apt-get -y upgrade && \14 apt-get -y upgrade && \
modifiedtests/README.mddiffbeforeafterboth
51. Checkout polkadot in sibling folder with this project51. Checkout polkadot in sibling folder with this project
6```bash6```bash
7git clone https://github.com/paritytech/polkadot.git && cd polkadot7git clone https://github.com/paritytech/polkadot.git && cd polkadot
8git checkout release-v0.9.98git checkout release-v0.9.12
9```9```
1010
112. Build with nightly-2021-06-28112. Build with nightly-2021-06-28
modifiedtests/package.jsondiffbeforeafterboth
1{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",
modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
8import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';
9import privateKey from './substrate/privateKey';9import privateKey from './substrate/privateKey';
10import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';10import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
11import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId} from './util/helpers';11import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';
1212
13chai.use(chaiAsPromised);13chai.use(chaiAsPromised);
14const expect = chai.expect;14const expect = chai.expect;
20 const alice = privateKey('//Alice');20 const alice = privateKey('//Alice');
21 const bob = privateKey('//Bob');21 const bob = privateKey('//Bob');
2222
23 const collection = (await api.query.common.collectionById(collectionId)).unwrap();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);
2525
26 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);
2828
29 const adminListAfterAddAdmin = await getAdminList(api, collectionId);29 const adminListAfterAddAdmin = await getAdminList(api, collectionId);
38 const bob = privateKey('//Bob');38 const bob = privateKey('//Bob');
39 const charlie = privateKey('//CHARLIE');39 const charlie = privateKey('//CHARLIE');
4040
41 const collection = (await api.query.common.collectionById(collectionId)).unwrap();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);
4343
44 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);
4646
47 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));
4949
50 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');
6565
66 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;
6868
69 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');
8282
83 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;
8585
86 // 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;
9999
100 // 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 }
127127
128 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 });
modifiedtests/src/addToAllowList.test.tsdiffbeforeafterboth
18 normalizeAccountId,18 normalizeAccountId,
19 addCollectionAdminExpectSuccess,19 addCollectionAdminExpectSuccess,
20 addToAllowListExpectFail,20 addToAllowListExpectFail,
21 getCreatedCollectionCount,
21} from './util/helpers';22} from './util/helpers';
2223
23chai.use(chaiAsPromised);24chai.use(chaiAsPromised);
55 it('Allow list an address in the collection that does not exist', async () => {56 it('Allow list an address in the collection that does not exist', async () => {
56 await usingApi(async (api) => {57 await usingApi(async (api) => {
57 // tslint:disable-next-line: no-bitwise58 // tslint:disable-next-line: no-bitwise
58 const collectionId = ((await api.query.common.createdCollectionCount()).toNumber()) + 1;59 const collectionId = await getCreatedCollectionCount(api) + 1;
59 const bob = privateKey('//Bob');60 const bob = privateKey('//Bob');
6061
61 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(bob.address));62 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(bob.address));
62 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;63 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
63 });64 });
64 });65 });
70 // tslint:disable-next-line: no-bitwise71 // tslint:disable-next-line: no-bitwise
71 const collectionId = await createCollectionExpectSuccess();72 const collectionId = await createCollectionExpectSuccess();
72 await destroyCollectionExpectSuccess(collectionId);73 await destroyCollectionExpectSuccess(collectionId);
73 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(bob.address));74 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(bob.address));
74 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;75 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
75 });76 });
76 });77 });
82 const collectionId = await createCollectionExpectSuccess();83 const collectionId = await createCollectionExpectSuccess();
83 await enableAllowListExpectSuccess(alice, collectionId);84 await enableAllowListExpectSuccess(alice, collectionId);
84 await enablePublicMintingExpectSuccess(alice, collectionId);85 await enablePublicMintingExpectSuccess(alice, collectionId);
85 const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(ferdie.address), 'NFT');86 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(ferdie.address), 'NFT');
86 await expect(submitTransactionExpectFailAsync(ferdie, tx)).to.be.rejected;87 await expect(submitTransactionExpectFailAsync(ferdie, tx)).to.be.rejected;
87 });88 });
88 });89 });
modifiedtests/src/addToContractAllowList.test.tsdiffbeforeafterboth
24 const bob = privateKey('//Bob');24 const bob = privateKey('//Bob');
25 const [contract, deployer] = await deployFlipper(api);25 const [contract, deployer] = await deployFlipper(api);
2626
27 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();
3131
32 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);
4242
43 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();
4949
50 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');
6666
67 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();
7171
72 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);
8181
82 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();
8686
87 expect(allowListedBefore).to.be.false;87 expect(allowListedBefore).to.be.false;
88 expect(allowListedAfter).to.be.false;88 expect(allowListedAfter).to.be.false;
modifiedtests/src/allowLists.test.tsdiffbeforeafterboth
189 await enableAllowListExpectSuccess(alice, collectionId);189 await enableAllowListExpectSuccess(alice, collectionId);
190190
191 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 };
modifiedtests/src/approve.test.tsdiffbeforeafterboth
18 transferExpectSuccess,18 transferExpectSuccess,
19 addCollectionAdminExpectSuccess,19 addCollectionAdminExpectSuccess,
20 adminApproveFromExpectSuccess,20 adminApproveFromExpectSuccess,
21 getCreatedCollectionCount,
22 transferFromExpectSuccess,
23 transferFromExpectFail,
21} from './util/helpers';24} from './util/helpers';
2225
23chai.use(chaiAsPromised);26chai.use(chaiAsPromised);
27const expect = chai.expect;
2428
25describe('Integration Test approve(spender, collection_id, item_id, amount):', () => {29describe('Integration Test approve(spender, collection_id, item_id, amount):', () => {
26 let alice: IKeyringPair;30 let alice: IKeyringPair;
78 });82 });
79});83});
8084
85describe('Normal user can approve other users to transfer:', () => {
86 let alice: IKeyringPair;
87 let bob: IKeyringPair;
88 let charlie: IKeyringPair;
89
90 before(async () => {
91 await usingApi(async () => {
92 alice = privateKey('//Alice');
93 bob = privateKey('//Bob');
94 charlie = privateKey('//Charlie');
95 });
96 });
97
98 it('NFT', async () => {
99 const collectionId = await createCollectionExpectSuccess();
100 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
101 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
102 });
103
104 it('Fungible up to an approved amount', async () => {
105 const collectionId = await createCollectionExpectSuccess({mode:{type: 'Fungible', decimalPoints: 0}});
106 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', bob.address);
107 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
108 });
109
110 it('ReFungible up to an approved amount', async () => {
111 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
112 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', bob.address);
113 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
114 });
115});
116
117describe('Approved users can transferFrom up to approved amount:', () => {
118 let alice: IKeyringPair;
119 let bob: IKeyringPair;
120 let charlie: IKeyringPair;
121
122 before(async () => {
123 await usingApi(async () => {
124 alice = privateKey('//Alice');
125 bob = privateKey('//Bob');
126 charlie = privateKey('//Charlie');
127 });
128 });
129
130 it('NFT', async () => {
131 const collectionId = await createCollectionExpectSuccess();
132 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
133 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
134 await transferFromExpectSuccess(collectionId, itemId, charlie, bob, alice, 1, 'NFT');
135 });
136
137 it('Fungible up to an approved amount', async () => {
138 const collectionId = await createCollectionExpectSuccess({mode:{type: 'Fungible', decimalPoints: 0}});
139 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', bob.address);
140 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
141 await transferFromExpectSuccess(collectionId, itemId, charlie, bob, alice, 1, 'Fungible');
142 });
143
144 it('ReFungible up to an approved amount', async () => {
145 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
146 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', bob.address);
147 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
148 await transferFromExpectSuccess(collectionId, itemId, charlie, bob, alice, 1, 'ReFungible');
149 });
150});
151
152describe('Approved users cannot use transferFrom to repeat transfers if approved amount was already transferred:', () => {
153 let alice: IKeyringPair;
154 let bob: IKeyringPair;
155 let charlie: IKeyringPair;
156
157 before(async () => {
158 await usingApi(async () => {
159 alice = privateKey('//Alice');
160 bob = privateKey('//Bob');
161 charlie = privateKey('//Charlie');
162 });
163 });
164
165 it('NFT', async () => {
166 const collectionId = await createCollectionExpectSuccess();
167 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
168 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
169 await transferFromExpectSuccess(collectionId, itemId, charlie, bob, alice, 1, 'NFT');
170 await transferFromExpectFail(collectionId, itemId, charlie, bob, alice, 1);
171 });
172
173 it('Fungible up to an approved amount', async () => {
174 const collectionId = await createCollectionExpectSuccess({mode:{type: 'Fungible', decimalPoints: 0}});
175 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', bob.address);
176 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
177 await transferFromExpectSuccess(collectionId, itemId, charlie, bob, alice, 1, 'Fungible');
178 await transferFromExpectFail(collectionId, itemId, charlie, bob, alice, 1);
179 });
180
181 it('ReFungible up to an approved amount', async () => {
182 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
183 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', bob.address);
184 await approveExpectSuccess(collectionId, itemId, bob, charlie.address);
185 await transferFromExpectSuccess(collectionId, itemId, charlie, bob, alice, 1, 'ReFungible');
186 await transferFromExpectFail(collectionId, itemId, charlie, bob, alice, 1);
187 });
188});
189
190describe('Approved amount decreases by the transferred amount.:', () => {
191 let alice: IKeyringPair;
192 let bob: IKeyringPair;
193 let charlie: IKeyringPair;
194 let dave: IKeyringPair;
195
196 before(async () => {
197 await usingApi(async () => {
198 alice = privateKey('//Alice');
199 bob = privateKey('//Bob');
200 charlie = privateKey('//Charlie');
201 dave = privateKey('//Dave');
202 });
203 });
204
205 it('If a user B is approved to transfer 10 Fungible tokens from user A, they can transfer 2 tokens to user C, which will result in decreasing approval from 10 to 8. Then user B can transfer 8 tokens to user D.', async () => {
206 const collectionId = await createCollectionExpectSuccess({mode:{type: 'Fungible', decimalPoints: 0}});
207 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', alice.address);
208 await approveExpectSuccess(collectionId, itemId, alice, bob.address, 10);
209 await transferFromExpectSuccess(collectionId, itemId, bob, alice, charlie, 2, 'Fungible');
210 await transferFromExpectSuccess(collectionId, itemId, bob, alice, dave, 8, 'Fungible');
211 });
212});
213
214describe('User may clear the approvals to approving for 0 amount:', () => {
215 let alice: IKeyringPair;
216 let bob: IKeyringPair;
217 let charlie: IKeyringPair;
218
219 before(async () => {
220 await usingApi(async () => {
221 alice = privateKey('//Alice');
222 bob = privateKey('//Bob');
223 charlie = privateKey('//Charlie');
224 });
225 });
226
227 it('NFT', async () => {
228 const collectionId = await createCollectionExpectSuccess();
229 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT');
230 await approveExpectSuccess(collectionId, itemId, alice, bob.address, 1);
231 await approveExpectSuccess(collectionId, itemId, alice, bob.address, 0);
232 await transferFromExpectFail(collectionId, itemId, bob, bob, charlie, 1);
233 });
234
235 it('Fungible', async () => {
236 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
237 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
238 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address, 1);
239 await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address, 0);
240 await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, bob, charlie, 1);
241 });
242
243 it('ReFungible', async () => {
244 const reFungibleCollectionId =
245 await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
246 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
247 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address, 1);
248 await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address, 0);
249 await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, bob, bob, charlie, 1);
250 });
251});
252
253describe('User cannot approve for the amount greater than they own:', () => {
254 let alice: IKeyringPair;
255 let bob: IKeyringPair;
256 let charlie: IKeyringPair;
257
258 before(async () => {
259 await usingApi(async () => {
260 alice = privateKey('//Alice');
261 bob = privateKey('//Bob');
262 charlie = privateKey('//Charlie');
263 });
264 });
265
266 it('1 for NFT', async () => {
267 const collectionId = await createCollectionExpectSuccess();
268 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
269 await approveExpectFail(collectionId, itemId, bob, charlie, 2);
270 });
271
272 it('Fungible', async () => {
273 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
274 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
275 await approveExpectFail(fungibleCollectionId, newFungibleTokenId, bob, charlie, 11);
276 });
277
278 it('ReFungible', async () => {
279 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
280 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
281 await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, bob, charlie, 101);
282 });
283});
284
285describe('Administrator and collection owner do not need approval in order to execute TransferFrom:', () => {
286 let alice: IKeyringPair;
287 let bob: IKeyringPair;
288 let charlie: IKeyringPair;
289 let dave: IKeyringPair;
290
291 before(async () => {
292 await usingApi(async () => {
293 alice = privateKey('//Alice');
294 bob = privateKey('//Bob');
295 charlie = privateKey('//Charlie');
296 dave = privateKey('//Dave');
297 });
298 });
299
300 it('NFT', async () => {
301 const collectionId = await createCollectionExpectSuccess();
302 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', charlie.address);
303 await transferFromExpectSuccess(collectionId, itemId, alice, charlie, dave, 1, 'NFT');
304 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
305 await transferFromExpectSuccess(collectionId, itemId, bob, dave, alice, 1, 'NFT');
306 });
307
308 it('Fungible up to an approved amount', async () => {
309 const collectionId = await createCollectionExpectSuccess({mode:{type: 'Fungible', decimalPoints: 0}});
310 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', charlie.address);
311 await transferFromExpectSuccess(collectionId, itemId, alice, charlie, dave, 1, 'Fungible');
312 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
313 await transferFromExpectSuccess(collectionId, itemId, bob, dave, alice, 1, 'Fungible');
314 });
315
316 it('ReFungible up to an approved amount', async () => {
317 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
318 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', charlie.address);
319 await transferFromExpectSuccess(collectionId, itemId, alice, charlie, dave, 1, 'ReFungible');
320 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
321 await transferFromExpectSuccess(collectionId, itemId, bob, dave, alice, 1, 'ReFungible');
322 });
323});
324
325describe('Repeated approvals add up', () => {
326 let alice: IKeyringPair;
327 let bob: IKeyringPair;
328 let charlie: IKeyringPair;
329 let dave: IKeyringPair;
330
331 before(async () => {
332 await usingApi(async () => {
333 alice = privateKey('//Alice');
334 bob = privateKey('//Bob');
335 charlie = privateKey('//Charlie');
336 dave = privateKey('//Dave');
337 });
338 });
339
340 it.skip('Owned 10, approval 1: 1, approval 2: 1, resulting approved value: 2. Fungible', async () => {
341 const collectionId = await createCollectionExpectSuccess({mode:{type: 'Fungible', decimalPoints: 0}});
342 await createItemExpectSuccess(alice, collectionId, 'Fungible', alice.address);
343 await approveExpectSuccess(collectionId, 0, alice, bob.address, 1);
344 await approveExpectSuccess(collectionId, 0, alice, charlie.address, 1);
345 // const allowances1 = await getAllowance(collectionId, 0, Alice.address, Bob.address);
346 // const allowances2 = await getAllowance(collectionId, 0, Alice.address, Charlie.address);
347 // expect(allowances1 + allowances2).to.be.eq(BigInt(2));
348 });
349
350 it.skip('Owned 10, approval 1: 1, approval 2: 1, resulting approved value: 2. ReFungible', async () => {
351 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
352 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', alice.address);
353 await approveExpectSuccess(collectionId, itemId, alice, bob.address, 1);
354 await approveExpectSuccess(collectionId, itemId, alice, charlie.address, 1);
355 // const allowances1 = await getAllowance(collectionId, itemId, Alice.address, Bob.address);
356 // const allowances2 = await getAllowance(collectionId, itemId, Alice.address, Charlie.address);
357 // expect(allowances1 + allowances2).to.be.eq(BigInt(2));
358 });
359
360 // Canceled by changing approve logic
361 it.skip('Cannot approve for more than total user`s amount (owned: 10, approval 1: 5 - should succeed, approval 2: 6 - should fail). Fungible', async () => {
362 const collectionId = await createCollectionExpectSuccess({mode:{type: 'Fungible', decimalPoints: 0}});
363 await createItemExpectSuccess(alice, collectionId, 'Fungible', dave.address);
364 await approveExpectSuccess(collectionId, 0, dave, bob.address, 5);
365 await approveExpectFail(collectionId, 0, dave, charlie, 6);
366 });
367
368 // Canceled by changing approve logic
369 it.skip('Cannot approve for more than total users amount (owned: 100, approval 1: 50 - should succeed, approval 2: 51 - should fail). ReFungible', async () => {
370 const collectionId = await createCollectionExpectSuccess({mode:{type: 'ReFungible'}});
371 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', dave.address);
372 await approveExpectSuccess(collectionId, itemId, dave, bob.address, 50);
373 await approveExpectFail(collectionId, itemId, dave, charlie, 51);
374 });
375});
376
377describe('Integration Test approve(spender, collection_id, item_id, amount) with collection admin permissions:', () => {
378 let alice: IKeyringPair;
379 let bob: IKeyringPair;
380 let charlie: IKeyringPair;
381
382 before(async () => {
383 await usingApi(async () => {
384 alice = privateKey('//Alice');
385 bob = privateKey('//Bob');
386 charlie = privateKey('//Charlie');
387 });
388 });
389
390 it('can be called by collection admin on non-owned item', async () => {
391 const collectionId = await createCollectionExpectSuccess();
392 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
393
394 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
395 await adminApproveFromExpectSuccess(collectionId, itemId, bob, alice.address, charlie.address);
396 });
397});
398
81describe('Negative Integration Test approve(spender, collection_id, item_id, amount):', () => {399describe('Negative Integration Test approve(spender, collection_id, item_id, amount):', () => {
82 let alice: IKeyringPair;400 let alice: IKeyringPair;
94 it('Approve for a collection that does not exist', async () => {412 it('Approve for a collection that does not exist', async () => {
95 await usingApi(async (api: ApiPromise) => {413 await usingApi(async (api: ApiPromise) => {
96 // nft414 // nft
97 const nftCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();415 const nftCollectionCount = await getCreatedCollectionCount(api);
98 await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);416 await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);
99 // fungible417 // fungible
100 const fungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();418 const fungibleCollectionCount = await getCreatedCollectionCount(api);
101 await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);419 await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);
102 // reFungible420 // reFungible
103 const reFungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();421 const reFungibleCollectionCount = await getCreatedCollectionCount(api);
104 await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);422 await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);
105 });423 });
106 });424 });
169 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: false});487 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: false});
170488
171 await approveExpectFail(collectionId, itemId, alice, charlie);489 await approveExpectFail(collectionId, itemId, alice, charlie);
172 });
173});
174
175describe('Integration Test approve(spender, collection_id, item_id, amount) with collection admin permissions:', () => {
176 let alice: IKeyringPair;
177 let bob: IKeyringPair;
178 let charlie: IKeyringPair;
179
180 before(async () => {
181 await usingApi(async () => {
182 alice = privateKey('//Alice');
183 bob = privateKey('//Bob');
184 charlie = privateKey('//Charlie');
185 });
186 });
187
188 it('can be called by collection admin on non-owned item', async () => {
189 const collectionId = await createCollectionExpectSuccess();
190 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
191
192 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
193 await adminApproveFromExpectSuccess(collectionId, itemId, bob, alice.address, charlie.address);
194 });490 });
195});491});
196492
modifiedtests/src/burnItem.test.tsdiffbeforeafterboth
40 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);40 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
4141
42 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);
4646
5858
59 await usingApi(async (api) => {59 await usingApi(async (api) => {
60 // Destroy 1 of 1060 // Destroy 1 of 10
61 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);
6464
77 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);77 const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
7878
79 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);
8383
9797
98 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 Bob
100 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);
103103
106 const aliceBalanceBefore = await getBalance(api, collectionId, alice.address, tokenId);106 const aliceBalanceBefore = await getBalance(api, collectionId, alice.address, tokenId);
107107
108 // Bob burns his portion108 // Bob burns his portion
109 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);
112112
146 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);146 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
147147
148 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);
152152
165165
166 await usingApi(async (api) => {166 await usingApi(async (api) => {
167 // Destroy 1 of 10167 // Destroy 1 of 10
168 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);
171171
186 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);186 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
187187
188 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 balance
213 await destroyCollectionExpectSuccess(collectionId);213 await destroyCollectionExpectSuccess(collectionId);
214214
215 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;
229229
230 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);
244244
245 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 };
259259
260 await usingApi(async (api) => {260 await usingApi(async (api) => {
261261
262 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;
266266
267 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 };
282282
283 await usingApi(async (api) => {283 await usingApi(async (api) => {
284 // Destroy 11 of 10284 // Destroy 11 of 10
285 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 };
modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
22 setMintPermissionExpectFailure,22 setMintPermissionExpectFailure,
23 destroyCollectionExpectFailure,23 destroyCollectionExpectFailure,
24 setPublicAccessModeExpectSuccess,24 setPublicAccessModeExpectSuccess,
25 queryCollectionExpectSuccess,
25} from './util/helpers';26} from './util/helpers';
2627
27chai.use(chaiAsPromised);28chai.use(chaiAsPromised);
34 const alice = privateKey('//Alice');35 const alice = privateKey('//Alice');
35 const bob = privateKey('//Bob');36 const bob = privateKey('//Bob');
3637
37 const collection = (await api.query.common.collectionById(collectionId)).unwrap();38 const collection =await queryCollectionExpectSuccess(api, collectionId);
38 expect(collection.owner.toString()).to.be.deep.eq(alice.address);39 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
3940
40 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);41 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
41 await submitTransactionAsync(alice, changeOwnerTx);42 await submitTransactionAsync(alice, changeOwnerTx);
4243
43 const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();44 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);
44 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);45 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
45 });46 });
46 });47 });
53 const alice = privateKey('//Alice');54 const alice = privateKey('//Alice');
54 const bob = privateKey('//Bob');55 const bob = privateKey('//Bob');
5556
56 const collection = (await api.query.common.collectionById(collectionId)).unwrap();57 const collection = await queryCollectionExpectSuccess(api, collectionId);
57 expect(collection.owner.toString()).to.be.deep.eq(alice.address);58 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
5859
59 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);60 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
60 await submitTransactionAsync(alice, changeOwnerTx);61 await submitTransactionAsync(alice, changeOwnerTx);
6162
62 const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);63 const badChangeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, alice.address);
63 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;64 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;
6465
65 const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();66 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);
66 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);67 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
67 });68 });
68 });69 });
74 const bob = privateKey('//Bob');75 const bob = privateKey('//Bob');
75 const charlie = privateKey('//Charlie');76 const charlie = privateKey('//Charlie');
7677
77 const collection = (await api.query.common.collectionById(collectionId)).unwrap();78 const collection = await queryCollectionExpectSuccess(api, collectionId);
78 expect(collection.owner.toString()).to.be.deep.eq(alice.address);79 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
7980
80 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);81 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
81 await submitTransactionAsync(alice, changeOwnerTx);82 await submitTransactionAsync(alice, changeOwnerTx);
8283
83 const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();84 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);
84 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);85 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
8586
86 // After changing the owner of the collection, all privileged methods are available to the new owner87 // After changing the owner of the collection, all privileged methods are available to the new owner
98 ownerCanTransfer: true,99 ownerCanTransfer: true,
99 ownerCanDestroy: true,100 ownerCanDestroy: true,
100 };101 };
101 const tx1 = api.tx.nft.setCollectionLimits(102 const tx1 = api.tx.unique.setCollectionLimits(
102 collectionId,103 collectionId,
103 collectionLimits,104 collectionLimits,
104 );105 );
118 const bob = privateKey('//Bob');119 const bob = privateKey('//Bob');
119 const charlie = privateKey('//Charlie');120 const charlie = privateKey('//Charlie');
120121
121 const collection = (await api.query.common.collectionById(collectionId)).unwrap();122 const collection = await queryCollectionExpectSuccess(api, collectionId);
122 expect(collection.owner.toString()).to.be.deep.eq(alice.address);123 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
123124
124 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);125 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
125 await submitTransactionAsync(alice, changeOwnerTx);126 await submitTransactionAsync(alice, changeOwnerTx);
126127
127 const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();128 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);
128 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);129 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
129130
130 const changeOwnerTx2 = api.tx.nft.changeCollectionOwner(collectionId, charlie.address);131 const changeOwnerTx2 = api.tx.unique.changeCollectionOwner(collectionId, charlie.address);
131 await submitTransactionAsync(bob, changeOwnerTx2);132 await submitTransactionAsync(bob, changeOwnerTx2);
132133
133 // ownership lost134 // ownership lost
134 const collectionAfterOwnerChange2 = (await api.query.common.collectionById(collectionId)).unwrap();135 const collectionAfterOwnerChange2 = await queryCollectionExpectSuccess(api, collectionId);
135 expect(collectionAfterOwnerChange2.owner.toString()).to.be.deep.eq(charlie.address);136 expect(collectionAfterOwnerChange2.owner.toString()).to.be.deep.eq(charlie.address);
136 });137 });
137 });138 });
144 const alice = privateKey('//Alice');145 const alice = privateKey('//Alice');
145 const bob = privateKey('//Bob');146 const bob = privateKey('//Bob');
146147
147 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);148 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
148 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;149 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;
149150
150 const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();151 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);
151 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(alice.address);152 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(alice.address);
152153
153 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)154 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
163164
164 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);165 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
165166
166 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);167 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
167 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;168 await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;
168169
169 const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();170 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);
170 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(alice.address);171 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(alice.address);
171172
172 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)173 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
180 const alice = privateKey('//Alice');181 const alice = privateKey('//Alice');
181 const bob = privateKey('//Bob');182 const bob = privateKey('//Bob');
182183
183 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);184 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
184 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;185 await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
185186
186 // 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.)
195 const bob = privateKey('//Bob');196 const bob = privateKey('//Bob');
196 const charlie = privateKey('//Charlie');197 const charlie = privateKey('//Charlie');
197198
198 const collection = (await api.query.common.collectionById(collectionId)).unwrap();199 const collection = await queryCollectionExpectSuccess(api, collectionId);
199 expect(collection.owner.toString()).to.be.deep.eq(alice.address);200 expect(collection.owner.toString()).to.be.deep.eq(alice.address);
200201
201 const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);202 const changeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, bob.address);
202 await submitTransactionAsync(alice, changeOwnerTx);203 await submitTransactionAsync(alice, changeOwnerTx);
203204
204 const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);205 const badChangeOwnerTx = api.tx.unique.changeCollectionOwner(collectionId, alice.address);
205 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;206 await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;
206207
207 const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();208 const collectionAfterOwnerChange = await queryCollectionExpectSuccess(api, collectionId);
208 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);209 expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
209210
210 await setCollectionSponsorExpectFailure(collectionId, charlie.address, '//Alice');211 await setCollectionSponsorExpectFailure(collectionId, charlie.address, '//Alice');
219 ownerCanTransfer: true,220 ownerCanTransfer: true,
220 ownerCanDestroy: true,221 ownerCanDestroy: true,
221 };222 };
222 const tx1 = api.tx.nft.setCollectionLimits(223 const tx1 = api.tx.unique.setCollectionLimits(
223 collectionId,224 collectionId,
224 collectionLimits,225 collectionLimits,
225 );226 );
modifiedtests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth
10import chaiAsPromised from 'chai-as-promised';10import chaiAsPromised from 'chai-as-promised';
11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';
12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
13import {createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage} from '../util/helpers';13import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage} from '../util/helpers';
1414
15chai.use(chaiAsPromised);15chai.use(chaiAsPromised);
16const expect = chai.expect;16const expect = chai.expect;
29 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(uniqueEventMessage(events));
35 expect(msg).to.be.contain(checkSection);35 expect(msg).to.be.contain(checkSection);
36 expect(msg).to.be.contain(checkTreasury);36 expect(msg).to.be.contain(checkTreasury);
37 expect(msg).to.be.contain(checkSystem);37 expect(msg).to.be.contain(checkSystem);
modifiedtests/src/check-event/createCollectionEvent.test.tsdiffbeforeafterboth
10import chaiAsPromised from 'chai-as-promised';10import chaiAsPromised from 'chai-as-promised';
11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';
12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
13import {nftEventMessage} from '../util/helpers';13import {uniqueEventMessage} from '../util/helpers';
1414
15chai.use(chaiAsPromised);15chai.use(chaiAsPromised);
16const expect = chai.expect;16const expect = chai.expect;
27 });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(uniqueEventMessage(events));
33 expect(msg).to.be.contain(checkSection);33 expect(msg).to.be.contain(checkSection);
34 expect(msg).to.be.contain(checkTreasury);34 expect(msg).to.be.contain(checkTreasury);
35 expect(msg).to.be.contain(checkSystem);35 expect(msg).to.be.contain(checkSystem);
modifiedtests/src/check-event/createItemEvent.test.tsdiffbeforeafterboth
10import chaiAsPromised from 'chai-as-promised';10import chaiAsPromised from 'chai-as-promised';
11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';
12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
13import {createCollectionExpectSuccess, nftEventMessage, normalizeAccountId} from '../util/helpers';13import {createCollectionExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';
1414
15chai.use(chaiAsPromised);15chai.use(chaiAsPromised);
16const expect = chai.expect;16const expect = chai.expect;
28 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(uniqueEventMessage(events));
34 expect(msg).to.be.contain(checkSection);34 expect(msg).to.be.contain(checkSection);
35 expect(msg).to.be.contain(checkTreasury);35 expect(msg).to.be.contain(checkTreasury);
36 expect(msg).to.be.contain(checkSystem);36 expect(msg).to.be.contain(checkSystem);
modifiedtests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth
10import chaiAsPromised from 'chai-as-promised';10import chaiAsPromised from 'chai-as-promised';
11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';
12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
13import {createCollectionExpectSuccess, nftEventMessage, normalizeAccountId} from '../util/helpers';13import {createCollectionExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';
1414
15chai.use(chaiAsPromised);15chai.use(chaiAsPromised);
16const expect = chai.expect;16const expect = chai.expect;
29 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(uniqueEventMessage(events));
35 expect(msg).to.be.contain(checkSection);35 expect(msg).to.be.contain(checkSection);
36 expect(msg).to.be.contain(checkTreasury);36 expect(msg).to.be.contain(checkTreasury);
37 expect(msg).to.be.contain(checkSystem);37 expect(msg).to.be.contain(checkSystem);
modifiedtests/src/check-event/destroyCollectionEvent.test.tsdiffbeforeafterboth
10import chaiAsPromised from 'chai-as-promised';10import chaiAsPromised from 'chai-as-promised';
11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';
12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
13import {createCollectionExpectSuccess, nftEventMessage} from '../util/helpers';13import {createCollectionExpectSuccess, uniqueEventMessage} from '../util/helpers';
1414
15chai.use(chaiAsPromised);15chai.use(chaiAsPromised);
16const expect = chai.expect;16const expect = chai.expect;
27 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(uniqueEventMessage(events));
33 expect(msg).to.be.contain(checkTreasury);33 expect(msg).to.be.contain(checkTreasury);
34 expect(msg).to.be.contain(checkSystem);34 expect(msg).to.be.contain(checkSystem);
35 });35 });
modifiedtests/src/check-event/transferEvent.test.tsdiffbeforeafterboth
10import chaiAsPromised from 'chai-as-promised';10import chaiAsPromised from 'chai-as-promised';
11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';
12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
13import {createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage, normalizeAccountId} from '../util/helpers';13import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';
1414
15chai.use(chaiAsPromised);15chai.use(chaiAsPromised);
16const expect = chai.expect;16const expect = chai.expect;
31 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(uniqueEventMessage(events));
37 expect(msg).to.be.contain(checkSection);37 expect(msg).to.be.contain(checkSection);
38 expect(msg).to.be.contain(checkTreasury);38 expect(msg).to.be.contain(checkTreasury);
39 expect(msg).to.be.contain(checkSystem);39 expect(msg).to.be.contain(checkSystem);
modifiedtests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth
10import chaiAsPromised from 'chai-as-promised';10import chaiAsPromised from 'chai-as-promised';
11import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';
12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';12import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
13import {createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage, normalizeAccountId} from '../util/helpers';13import {createCollectionExpectSuccess, createItemExpectSuccess, uniqueEventMessage, normalizeAccountId} from '../util/helpers';
1414
15chai.use(chaiAsPromised);15chai.use(chaiAsPromised);
16const expect = chai.expect;16const expect = chai.expect;
31 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(uniqueEventMessage(events));
37 expect(msg).to.be.contain(checkSection);37 expect(msg).to.be.contain(checkSection);
38 expect(msg).to.be.contain(checkTreasury);38 expect(msg).to.be.contain(checkTreasury);
39 expect(msg).to.be.contain(checkSystem);39 expect(msg).to.be.contain(checkSystem);
modifiedtests/src/collision-tests/admVsOwnerChanges.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
1616
17chai.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;
2222
23before(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});
3030
31describe('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-length
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 () => {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 () => {
3434
35 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');
4242
43 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*/
modifiedtests/src/collision-tests/admVsOwnerData.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
1616
17chai.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;
2121
22before(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});
2828
29describe('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-length
40 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-length
42 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 values
49 await waitNewBlocks(2);49 await waitNewBlocks(2);
50 });50 });
51 });51 });
52});52});
53*/53*/
modifiedtests/src/collision-tests/admVsOwnerTake.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
1616
17chai.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;
2222
23before(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});
3030
31describe('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-length
33 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-expression
50 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*/
modifiedtests/src/collision-tests/adminDestroyCollection.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
1515
16chai.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;
2121
22before(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});
2929
30describe('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-length
32 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-expression
49 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*/
modifiedtests/src/collision-tests/adminLimitsOff.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
1515
16chai.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;
2424
25before(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});
3535
36describe('Admin limit exceeded collection: ', () => {36describe('Admin limit exceeded collection: ', () => {
37 // tslint:disable-next-line: max-line-length37 // tslint:disable-next-line: max-line-length
38 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();
4141
42 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);
4444
45 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);
5151
52 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;
6161
62 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*/
modifiedtests/src/collision-tests/adminRightsOff.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
1616
17chai.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;
2121
22before(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});
2828
29describe('Deprivation of admin rights: ', () => {29describe('Deprivation of admin rights: ', () => {
30 // tslint:disable-next-line: max-line-length30 // tslint:disable-next-line: max-line-length
31 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*/
modifiedtests/src/collision-tests/setSponsorNewOwner.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
1515
16chai.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;
2121
22before(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});
2929
30describe('Sponsored with new owner ', () => {30describe('Sponsored with new owner ', () => {
31 // tslint:disable-next-line: max-line-length31 // tslint:disable-next-line: max-line-length
32 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*/
modifiedtests/src/collision-tests/sponsorPayments.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
2020
21chai.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;
2525
26before(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});
3232
33describe('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-length
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 () => {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');
4343
44 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-expression
53 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-expression
55 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*/
modifiedtests/src/collision-tests/tokenLimitsOff.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
1919
20chai.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;
2525
26const 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;
3232
33before(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});
4040
41describe('Token limit exceeded collection: ', () => {41describe('Token limit exceeded collection: ', () => {
42 // tslint:disable-next-line: max-line-length42 // tslint:disable-next-line: max-line-length
43 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-keys
56 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-expression
64 expect(subTxTesult.success).to.be.true;64 expect(subTxTesult.success).to.be.true;
65 await waitNewBlocks(2);65 await waitNewBlocks(2);
6666
67 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.unique
69 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);69 .createMultipleItems(collectionId, normalizeAccountId(Ferdie.address), args);
70 const mintItemTwo = api.tx.nft70 const mintItemTwo = api.tx.unique
71 .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*/
8585
modifiedtests/src/collision-tests/turnsOffMinting.test.tsdiffbeforeafterboth
1/* broken by design1/* broken by design
2// substrate transactions are sequential, not parallel2// substrate transactions are sequential, not parallel
3// the order of execution is indeterminate3// the order of execution is indeterminate
44
5import { 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';
1717
18chai.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;
2222
23before(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});
2929
30describe('Turns off minting mode: ', () => {30describe('Turns off minting mode: ', () => {
31 // tslint:disable-next-line: max-line-length31 // tslint:disable-next-line: max-line-length
32 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);
3737
38 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-expression
47 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*/
modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
20 addToAllowListExpectSuccess,20 addToAllowListExpectSuccess,
21 normalizeAccountId,21 normalizeAccountId,
22 addCollectionAdminExpectSuccess,22 addCollectionAdminExpectSuccess,
23 getCreatedCollectionCount,
23} from './util/helpers';24} from './util/helpers';
24import {Keyring} from '@polkadot/api';25import {Keyring} from '@polkadot/api';
25import {IKeyringPair} from '@polkadot/types/types';26import {IKeyringPair} from '@polkadot/types/types';
75 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);76 const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);
7677
77 // Transfer this tokens from unused address to Alice78 // Transfer this tokens from unused address to Alice
78 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);
79 const events = await submitTransactionAsync(zeroBalance, zeroToAlice);80 const events = await submitTransactionAsync(zeroBalance, zeroToAlice);
80 const result = getGenericResult(events);81 const result = getGenericResult(events);
81 expect(result.success).to.be.true;82 expect(result.success).to.be.true;
102 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);103 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);
103104
104 // Transfer this tokens from unused address to Alice105 // Transfer this tokens from unused address to Alice
105 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);
106 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);107 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);
107 const result1 = getGenericResult(events1);108 const result1 = getGenericResult(events1);
108 expect(result1.success).to.be.true;109 expect(result1.success).to.be.true;
128 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);129 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);
129130
130 // Transfer this tokens from unused address to Alice131 // Transfer this tokens from unused address to Alice
131 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);
132 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);133 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);
133 const result1 = getGenericResult(events1);134 const result1 = getGenericResult(events1);
134135
183184
184 // Transfer this token from Alice to unused address and back185 // Transfer this token from Alice to unused address and back
185 // Alice to Zero gets sponsored186 // Alice to Zero gets sponsored
186 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);
187 const events1 = await submitTransactionAsync(alice, aliceToZero);188 const events1 = await submitTransactionAsync(alice, aliceToZero);
188 const result1 = getGenericResult(events1);189 const result1 = getGenericResult(events1);
189190
190 // Second transfer should fail191 // Second transfer should fail
191 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();
192 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);
193 const badTransaction = async function () {194 const badTransaction = async function () {
194 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);195 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);
195 };196 };
221 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);222 const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);
222223
223 // Transfer this tokens in parts from unused address to Alice224 // Transfer this tokens in parts from unused address to Alice
224 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);
225 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);226 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);
226 const result1 = getGenericResult(events1);227 const result1 = getGenericResult(events1);
227 expect(result1.success).to.be.true;228 expect(result1.success).to.be.true;
251 const zeroBalance = await findUnusedAddress(api);252 const zeroBalance = await findUnusedAddress(api);
252253
253 // Mint token for alice254 // Mint token for alice
254 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', alice.address);255 const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);
255256
256 // Transfer this token from Alice to unused address and back
257 // Alice to Zero gets sponsored
258 const aliceToZero = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);257 const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 1);
258
259 // Zero to alice gets sponsored
259 const events1 = await submitTransactionAsync(alice, aliceToZero);260 const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);
260 const result1 = getGenericResult(events1);261 const result1 = getGenericResult(events1);
261 expect(result1.success).to.be.true;262 expect(result1.success).to.be.true;
262263
263 // Second transfer should fail264 // Second transfer should fail
264 const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();265 const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
265 const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(alice.address), collectionId, itemId, 1);
266 const badTransaction = async function () {
267 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);
268 };
269 await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');266 await expect(submitTransactionExpectFailAsync(zeroBalance, zeroToAlice)).to.be.rejectedWith('Inability to pay some fees');
270 const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();267 const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
268 expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
271269
272 // Try again after Zero gets some balance - now it should succeed270 // Try again after Zero gets some balance - now it should succeed
273 const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);271 const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
276 const result2 = getGenericResult(events2);274 const result2 = getGenericResult(events2);
277 expect(result2.success).to.be.true;275 expect(result2.success).to.be.true;
278
279 expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
280 });276 });
281 });277 });
282278
335 // Find the collection that never existed331 // Find the collection that never existed
336 let collectionId = 0;332 let collectionId = 0;
337 await usingApi(async (api) => {333 await usingApi(async (api) => {
338 collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;334 collectionId = await getCreatedCollectionCount(api) + 1;
339 });335 });
340336
341 await confirmSponsorshipExpectFailure(collectionId, '//Bob');337 await confirmSponsorshipExpectFailure(collectionId, '//Bob');
modifiedtests/src/contracts.test.tsdiffbeforeafterboth
73 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);
7878
79 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;
107107
108 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;
139139
140 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;
197197
198 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;
215215
216 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 });
225225
226 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);
230230
231 expect(await isAllowlisted(collectionId, bob.address)).to.be.false;231 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.false;
232232
233 {233 {
234 const transferTx = contract.tx.toggleAllowList(value, gasLimit, collectionId, bob.address, true);234 const transferTx = contract.tx.toggleAllowList(value, gasLimit, collectionId, bob.address, true);
235 const events = await submitTransactionAsync(alice, transferTx);235 const events = await submitTransactionAsync(alice, transferTx);
236 const result = getGenericResult(events);236 const result = getGenericResult(events);
237 expect(result.success).to.be.true;237 expect(result.success).to.be.true;
238238
239 expect(await isAllowlisted(collectionId, bob.address)).to.be.true;239 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.true;
240 }240 }
241 {241 {
242 const transferTx = contract.tx.toggleAllowList(value, gasLimit, collectionId, bob.address, false);242 const transferTx = contract.tx.toggleAllowList(value, gasLimit, collectionId, bob.address, false);
243 const events = await submitTransactionAsync(alice, transferTx);243 const events = await submitTransactionAsync(alice, transferTx);
244 const result = getGenericResult(events);244 const result = getGenericResult(events);
245 expect(result.success).to.be.true;245 expect(result.success).to.be.true;
246246
247 expect(await isAllowlisted(collectionId, bob.address)).to.be.false;247 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.false;
248 }248 }
249 });249 });
250 });250 });
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
20 getLastTokenId,20 getLastTokenId,
21 getVariableMetadata,21 getVariableMetadata,
22 getConstMetadata,22 getConstMetadata,
23 getCreatedCollectionCount,
23} from './util/helpers';24} from './util/helpers';
2425
25chai.use(chaiAsPromised);26chai.use(chaiAsPromised);
33 expect(itemsListIndexBefore).to.be.equal(0);34 expect(itemsListIndexBefore).to.be.equal(0);
34 const alice = privateKey('//Alice');35 const alice = privateKey('//Alice');
35 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];36 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];
36 const createMultipleItemsTx = api.tx.nft37 const createMultipleItemsTx = api.tx.unique
37 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);38 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
38 await submitTransactionAsync(alice, createMultipleItemsTx);39 await submitTransactionAsync(alice, createMultipleItemsTx);
39 const itemsListIndexAfter = await getLastTokenId(api, collectionId);40 const itemsListIndexAfter = await getLastTokenId(api, collectionId);
64 {Fungible: {value: 2}},65 {Fungible: {value: 2}},
65 {Fungible: {value: 3}},66 {Fungible: {value: 3}},
66 ];67 ];
67 const createMultipleItemsTx = api.tx.nft68 const createMultipleItemsTx = api.tx.unique
68 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);69 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
69 await submitTransactionAsync(alice, createMultipleItemsTx);70 await submitTransactionAsync(alice, createMultipleItemsTx);
70 const token1Data = await getBalance(api, collectionId, alice.address, 0);71 const token1Data = await getBalance(api, collectionId, alice.address, 0);
84 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},85 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
85 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},86 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
86 ];87 ];
87 const createMultipleItemsTx = api.tx.nft88 const createMultipleItemsTx = api.tx.unique
88 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);89 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
89 await submitTransactionAsync(alice, createMultipleItemsTx);90 await submitTransactionAsync(alice, createMultipleItemsTx);
90 const itemsListIndexAfter = await getLastTokenId(api, collectionId);91 const itemsListIndexAfter = await getLastTokenId(api, collectionId);
116 {NFT: ['A', 'A']},117 {NFT: ['A', 'A']},
117 {NFT: ['B', 'B']},118 {NFT: ['B', 'B']},
118 ];119 ];
119 const createMultipleItemsTx = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);120 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
120 const events = await submitTransactionAsync(alice, createMultipleItemsTx);121 const events = await submitTransactionAsync(alice, createMultipleItemsTx);
121 const result = getGenericResult(events);122 const result = getGenericResult(events);
122 expect(result.success).to.be.true;123 expect(result.success).to.be.true;
143 expect(itemsListIndexBefore).to.be.equal(0);144 expect(itemsListIndexBefore).to.be.equal(0);
144 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);145 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
145 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];146 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];
146 const createMultipleItemsTx = api.tx.nft147 const createMultipleItemsTx = api.tx.unique
147 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);148 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
148 await submitTransactionAsync(bob, createMultipleItemsTx);149 await submitTransactionAsync(bob, createMultipleItemsTx);
149 const itemsListIndexAfter = await getLastTokenId(api, collectionId);150 const itemsListIndexAfter = await getLastTokenId(api, collectionId);
174 {Fungible: {value: 2}},175 {Fungible: {value: 2}},
175 {Fungible: {value: 3}},176 {Fungible: {value: 3}},
176 ];177 ];
177 const createMultipleItemsTx = api.tx.nft178 const createMultipleItemsTx = api.tx.unique
178 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);179 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
179 await submitTransactionAsync(bob, createMultipleItemsTx);180 await submitTransactionAsync(bob, createMultipleItemsTx);
180 const token1Data = await getBalance(api, collectionId, bob.address, 0);181 const token1Data = await getBalance(api, collectionId, bob.address, 0);
194 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},195 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
195 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},196 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
196 ];197 ];
197 const createMultipleItemsTx = api.tx.nft198 const createMultipleItemsTx = api.tx.unique
198 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);199 .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
199 await submitTransactionAsync(bob, createMultipleItemsTx);200 await submitTransactionAsync(bob, createMultipleItemsTx);
200 const itemsListIndexAfter = await getLastTokenId(api, collectionId);201 const itemsListIndexAfter = await getLastTokenId(api, collectionId);
233 const itemsListIndexBefore = await getLastTokenId(api, collectionId);234 const itemsListIndexBefore = await getLastTokenId(api, collectionId);
234 expect(itemsListIndexBefore).to.be.equal(0);235 expect(itemsListIndexBefore).to.be.equal(0);
235 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];236 const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];
236 const createMultipleItemsTx = api.tx.nft237 const createMultipleItemsTx = api.tx.unique
237 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);238 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
238 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;239 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
239 });240 });
249 {Fungible: {value: 2}},250 {Fungible: {value: 2}},
250 {Fungible: {value: 3}},251 {Fungible: {value: 3}},
251 ];252 ];
252 const createMultipleItemsTx = api.tx.nft253 const createMultipleItemsTx = api.tx.unique
253 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);254 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
254 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;255 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
255 });256 });
265 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},266 {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
266 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},267 {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
267 ];268 ];
268 const createMultipleItemsTx = api.tx.nft269 const createMultipleItemsTx = api.tx.unique
269 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);270 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
270 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;271 await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
271 });272 });
272 });273 });
273274
274 it('Create token in not existing collection', async () => {275 it('Create token in not existing collection', async () => {
275 await usingApi(async (api: ApiPromise) => {276 await usingApi(async (api: ApiPromise) => {
276 const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;277 const collectionId = await getCreatedCollectionCount(api) + 1;
277 const createMultipleItemsTx = api.tx.nft278 const createMultipleItemsTx = api.tx.unique
278 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);279 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);
279 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;280 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
280 });281 });
290 {NFT: ['B'.repeat(2049), 'B'.repeat(2049)]},291 {NFT: ['B'.repeat(2049), 'B'.repeat(2049)]},
291 {NFT: ['C'.repeat(2049), 'C'.repeat(2049)]},292 {NFT: ['C'.repeat(2049), 'C'.repeat(2049)]},
292 ];293 ];
293 const createMultipleItemsTx = api.tx.nft294 const createMultipleItemsTx = api.tx.unique
294 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);295 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
295 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;296 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
296297
302 {ReFungible: ['2'.repeat(2049), '2'.repeat(2049), 10]},303 {ReFungible: ['2'.repeat(2049), '2'.repeat(2049), 10]},
303 {ReFungible: ['3'.repeat(2049), '3'.repeat(2049), 10]},304 {ReFungible: ['3'.repeat(2049), '3'.repeat(2049), 10]},
304 ];305 ];
305 const createMultipleItemsTxFungible = api.tx.nft306 const createMultipleItemsTxFungible = api.tx.unique
306 .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);307 .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);
307 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;308 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;
308 });309 });
311 it('Create tokens with different types', async () => {312 it('Create tokens with different types', async () => {
312 await usingApi(async (api: ApiPromise) => {313 await usingApi(async (api: ApiPromise) => {
313 const collectionId = await createCollectionExpectSuccess();314 const collectionId = await createCollectionExpectSuccess();
314 const createMultipleItemsTx = api.tx.nft315 const createMultipleItemsTx = api.tx.unique
315 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);316 .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);
316 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;317 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
317 // garbage collection :-D318 // garbage collection :-D
327 {NFT: ['B', 'B'.repeat(2049)]},328 {NFT: ['B', 'B'.repeat(2049)]},
328 {NFT: ['C'.repeat(2049), 'C']},329 {NFT: ['C'.repeat(2049), 'C']},
329 ];330 ];
330 const createMultipleItemsTx = await api.tx.nft331 const createMultipleItemsTx = await api.tx.unique
331 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);332 .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
332 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;333 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
333 });334 });
344 {NFT: ['A', 'A']},345 {NFT: ['A', 'A']},
345 {NFT: ['B', 'B']},346 {NFT: ['B', 'B']},
346 ];347 ];
347 const createMultipleItemsTx = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);348 const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
348 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;349 await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
349 });350 });
350 });351 });
modifiedtests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth
14 createItemExpectSuccess,14 createItemExpectSuccess,
15 getGenericResult,15 getGenericResult,
16 transferExpectSuccess,16 transferExpectSuccess,
17 UNIQUE,
17} from './util/helpers';18} from './util/helpers';
1819
19import {default as waitNewBlocks} from './substrate/wait-new-blocks';20import {default as waitNewBlocks} from './substrate/wait-new-blocks';
169 const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();170 const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
170 await transferExpectSuccess(collectionId, tokenId, alice, bob, 1, 'NFT');171 await transferExpectSuccess(collectionId, tokenId, alice, bob, 1, 'NFT');
171 const aliceBalanceAfter: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();172 const aliceBalanceAfter: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
172 const fee = aliceBalanceBefore - aliceBalanceAfter;173 const fee = Number(aliceBalanceBefore - aliceBalanceAfter) / Number(UNIQUE);
173174
174 // console.log(fee.toString());
175 const expectedTransferFee = 0.1;175 const expectedTransferFee = 0.1;
176 const tolerance = 0.001;176 const tolerance = 0.001;
177 expect(Number(fee) / 1e15 - expectedTransferFee).to.be.lessThan(tolerance);177 expect(Number(fee) / Number(UNIQUE) - expectedTransferFee).to.be.lessThan(tolerance);
178 });178 });
179 });179 });
180180
modifiedtests/src/destroyCollection.test.tsdiffbeforeafterboth
13 destroyCollectionExpectFailure,13 destroyCollectionExpectFailure,
14 setCollectionLimitsExpectSuccess,14 setCollectionLimitsExpectSuccess,
15 addCollectionAdminExpectSuccess,15 addCollectionAdminExpectSuccess,
16 getCreatedCollectionCount,
16} from './util/helpers';17} from './util/helpers';
1718
18chai.use(chaiAsPromised);19chai.use(chaiAsPromised);
46 it('(!negative test!) Destroy a collection that never existed', async () => {47 it('(!negative test!) Destroy a collection that never existed', async () => {
47 await usingApi(async (api) => {48 await usingApi(async (api) => {
48 // Find the collection that never existed49 // Find the collection that never existed
49 const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;50 const collectionId = await getCreatedCollectionCount(api) + 1;
50 await destroyCollectionExpectFailure(collectionId);51 await destroyCollectionExpectFailure(collectionId);
51 });52 });
52 });53 });
modifiedtests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth
2import {getBalanceSingle, transferBalanceExpectSuccess} from '../../substrate/get-balance';2import {getBalanceSingle, transferBalanceExpectSuccess} from '../../substrate/get-balance';
3import privateKey from '../../substrate/privateKey';3import privateKey from '../../substrate/privateKey';
4import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, getTokenOwner, setCollectionSponsorExpectSuccess, transferExpectSuccess, transferFromExpectSuccess} from '../../util/helpers';4import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, getTokenOwner, setCollectionSponsorExpectSuccess, transferExpectSuccess, transferFromExpectSuccess} from '../../util/helpers';
5import {collectionIdToAddress, contractHelpers, createEthAccountWithBalance, executeEthTxOnSub, GAS_ARGS, itWeb3, subToEth, subToEthLowercase} from '../util/helpers';5import {collectionIdToAddress, contractHelpers, createEthAccountWithBalance, executeEthTxOnSub, GAS_ARGS, itWeb3, subToEth, subToEthLowercase, transferBalanceToEth} from '../util/helpers';
6import {evmToAddress} from '@polkadot/util-crypto';6import {evmToAddress} from '@polkadot/util-crypto';
7import nonFungibleAbi from '../nonFungibleAbi.json';7import nonFungibleAbi from '../nonFungibleAbi.json';
8import fungibleAbi from '../fungibleAbi.json';8import fungibleAbi from '../fungibleAbi.json';
1212
13describe('Matcher contract usage', () => {13describe('Matcher contract usage', () => {
14 itWeb3('With UNQ', async ({api, web3}) => {14 itWeb3('With UNQ', async ({api, web3}) => {
15 const alice = privateKey('//Alice');
16 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
17 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId));
15 const matcherOwner = await createEthAccountWithBalance(api, web3);18 const matcherOwner = await createEthAccountWithBalance(api, web3);
19 const helpers = contractHelpers(web3, matcherOwner);
20
16 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {21 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
17 from: matcherOwner,22 from: matcherOwner,
18 ...GAS_ARGS,23 ...GAS_ARGS,
19 });24 });
20 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});25 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});
21 const helpers = contractHelpers(web3, matcherOwner);26
22 await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});27 await transferBalanceToEth(api, alice, matcher.options.address);
23 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});28 await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});
2429
25 const alice = privateKey('//Alice');
26 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});30 await transferBalanceToEth(api, alice, subToEth(alice.address));
27 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
28 await setCollectionSponsorExpectSuccess(collectionId, alice.address);31 await setCollectionSponsorExpectSuccess(collectionId, alice.address);
29 await confirmSponsorshipExpectSuccess(collectionId);32 await confirmSponsorshipExpectSuccess(collectionId);
3033
31 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});34 const seller = privateKey('//Seller/' + Date.now());
32 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));35 await addToAllowListExpectSuccess(alice, collectionId, {Ethereum:subToEth(seller.address)});
33
34 const seller = privateKey('//Bob');
35 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});36 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});
36 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));
3737
38 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);38 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
3939
40 // To transfer item to matcher it first needs to be transfered to EVM account of bob40 // To transfer item to matcher it first needs to be transfered to EVM account of seller
41 await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});41 await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});
42
43 // Token is owned by seller initially
44 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});42 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});
4543
46 // Ask44 // Ask
55 // Buy53 // Buy
56 {54 {
57 const sellerBalanceBeforePurchase = await getBalanceSingle(api, seller.address);55 const sellerBalanceBeforePurchase = await getBalanceSingle(api, seller.address);
58 // There is two functions named 'buy', so we should provide full signature
59 await executeEthTxOnSub(api, alice, matcher, m => m['buy(address,uint256)'](evmCollection.options.address, tokenId), {value: PRICE});56 await executeEthTxOnSub(api, alice, matcher, m => m.buy(evmCollection.options.address, tokenId), {value: PRICE});
60 expect(await getBalanceSingle(api, seller.address) - sellerBalanceBeforePurchase === PRICE);57 expect(await getBalanceSingle(api, seller.address) - sellerBalanceBeforePurchase === PRICE);
61 }58 }
6259
137 });133 });
138134
139 itWeb3('With escrow', async ({api, web3}) => {135 itWeb3('With escrow', async ({api, web3}) => {
136 const alice = privateKey('//Alice');
137 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
138 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId));
140 const matcherOwner = await createEthAccountWithBalance(api, web3);139 const matcherOwner = await createEthAccountWithBalance(api, web3);
140 const helpers = contractHelpers(web3, matcherOwner);
141 const escrow = await createEthAccountWithBalance(api, web3);141 const escrow = await createEthAccountWithBalance(api, web3);
142
142 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {143 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {
143 from: matcherOwner,144 from: matcherOwner,
144 ...GAS_ARGS,145 ...GAS_ARGS,
145 });146 });
146 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner});147 const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner});
147 await matcher.methods.setEscrow(escrow).send({from: matcherOwner});148 await matcher.methods.setEscrow(escrow).send({from: matcherOwner});
148 const helpers = contractHelpers(web3, matcherOwner);149
149 await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});150 await transferBalanceToEth(api, alice, matcher.options.address);
150 await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});151 await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});
151152
152 const alice = privateKey('//Alice');
153 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});153 await transferBalanceToEth(api, alice, subToEth(alice.address));
154 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
155 await setCollectionSponsorExpectSuccess(collectionId, alice.address);154 await setCollectionSponsorExpectSuccess(collectionId, alice.address);
156 await confirmSponsorshipExpectSuccess(collectionId);155 await confirmSponsorshipExpectSuccess(collectionId);
157
158 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});
159 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));
160156
161 const seller = privateKey('//Bob');157 const seller = privateKey('//Seller/' + Date.now());
162 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});158 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});
163 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));159 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));
164160
165 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);161 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
166162
167 // To transfer item to matcher it first needs to be transfered to EVM account of bob163 // To transfer item to matcher it first needs to be transfered to EVM account of seller
168 await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});164 await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});
169
170 // Token is owned by seller initially
171 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});165 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});
172166
173 // Ask167 // Ask
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
70 const alice = privateKey('//Alice');70 const alice = privateKey('//Alice');
7171
72 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);
7676
109 const alice = privateKey('//Alice');109 const alice = privateKey('//Alice');
110110
111 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);
115115
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
88 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}));
9090
91 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);
9393
94 {94 {
127127
128 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);
132132
133 {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});
192192
193 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);
195195
196 {196 {
modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
228 return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, ...GAS_ARGS});228 return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, ...GAS_ARGS});
229}229}
230230
231/**
232 * Execute ethereum method call using substrate account
233 * @param to target contract
234 * @param mkTx - closure, receiving `contract.methods`, and returning method call,
235 * to be used as following (assuming `to` = erc20 contract):
236 * `m => m.transfer(to, amount)`
237 *
238 * # Example
239 * ```ts
240 * executeEthTxOnSub(api, alice, erc20Contract, m => m.transfer(target, amount));
241 * ```
242 */
231export async function executeEthTxOnSub(api: ApiPromise, from: IKeyringPair, to: any, mkTx: (methods: any) => any, {value = 0}: {value?: bigint | number} = { }) {243export async function executeEthTxOnSub(api: ApiPromise, from: IKeyringPair, to: any, mkTx: (methods: any) => any, {value = 0}: {value?: bigint | number} = { }) {
232 const tx = api.tx.evm.call(244 const tx = api.tx.evm.call(
233 subToEth(from.address),245 subToEth(from.address),
246 return (await getBalance(api, [evmToAddress(address)]))[0];258 return (await getBalance(api, [evmToAddress(address)]))[0];
247}259}
248260
261/**
262 * Measure how much gas given closure consumes
263 *
264 * @param user which user balance will be checked
265 */
249export async function recordEthFee(api: ApiPromise, user: string, call: () => Promise<any>): Promise<bigint> {266export async function recordEthFee(api: ApiPromise, user: string, call: () => Promise<any>): Promise<bigint> {
250 const before = await ethBalanceViaSub(api, user);267 const before = await ethBalanceViaSub(api, user);
251268
modifiedtests/src/interfaces/augment-api-consts.tsdiffbeforeafterboth
159 [key: string]: Codec;159 [key: string]: Codec;
160 };160 };
161 vesting: {161 vesting: {
162 maxVestingSchedules: u32 & AugmentedConst<ApiType>;
163 /**162 /**
164 * The minimum amount transferred to call `vested_transfer`.163 * The minimum amount transferred to call `vested_transfer`.
165 **/164 **/
modifiedtests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth
241 **/241 **/
242 [key: string]: AugmentedError<ApiType>;242 [key: string]: AugmentedError<ApiType>;
243 };243 };
244 nft: {
245 /**
246 * Decimal_points parameter must be lower than MAX_DECIMAL_POINTS constant, currently it is 30.
247 **/
248 CollectionDecimalPointLimitExceeded: AugmentedError<ApiType>;
249 /**
250 * Collection limit bounds per collection exceeded
251 **/
252 CollectionLimitBoundsExceeded: AugmentedError<ApiType>;
253 /**
254 * This address is not set as sponsor, use setCollectionSponsor first.
255 **/
256 ConfirmUnsetSponsorFail: AugmentedError<ApiType>;
257 /**
258 * Length of items properties must be greater than 0.
259 **/
260 EmptyArgument: AugmentedError<ApiType>;
261 /**
262 * Tried to enable permissions which are only permitted to be disabled
263 **/
264 OwnerPermissionsCantBeReverted: AugmentedError<ApiType>;
265 /**
266 * Generic error
267 **/
268 [key: string]: AugmentedError<ApiType>;
269 };
270 nonfungible: {244 nonfungible: {
271 /**245 /**
272 * Used amount > 1 with NFT246 * Used amount > 1 with NFT
395 **/369 **/
396 [key: string]: AugmentedError<ApiType>;370 [key: string]: AugmentedError<ApiType>;
397 };371 };
398 scheduler: {
399 /**
400 * Failed to schedule a call
401 **/
402 FailedToSchedule: AugmentedError<ApiType>;
403 /**
404 * Cannot find the scheduled call.
405 **/
406 NotFound: AugmentedError<ApiType>;
407 /**
408 * Reschedule failed because it does not change scheduled time.
409 **/
410 RescheduleNoChange: AugmentedError<ApiType>;
411 /**
412 * Given target block number is in the past.
413 **/
414 TargetBlockNumberInPast: AugmentedError<ApiType>;
415 /**
416 * Generic error
417 **/
418 [key: string]: AugmentedError<ApiType>;
419 };
420 sudo: {372 sudo: {
421 /**373 /**
422 * Sender must be the Sudo account374 * Sender must be the Sudo account
475 **/427 **/
476 [key: string]: AugmentedError<ApiType>;428 [key: string]: AugmentedError<ApiType>;
477 };429 };
430 unique: {
431 /**
432 * Decimal_points parameter must be lower than MAX_DECIMAL_POINTS constant, currently it is 30.
433 **/
434 CollectionDecimalPointLimitExceeded: AugmentedError<ApiType>;
435 /**
436 * Collection limit bounds per collection exceeded
437 **/
438 CollectionLimitBoundsExceeded: AugmentedError<ApiType>;
439 /**
440 * This address is not set as sponsor, use setCollectionSponsor first.
441 **/
442 ConfirmUnsetSponsorFail: AugmentedError<ApiType>;
443 /**
444 * Length of items properties must be greater than 0.
445 **/
446 EmptyArgument: AugmentedError<ApiType>;
447 /**
448 * Tried to enable permissions which are only permitted to be disabled
449 **/
450 OwnerPermissionsCantBeReverted: AugmentedError<ApiType>;
451 /**
452 * Generic error
453 **/
454 [key: string]: AugmentedError<ApiType>;
455 };
478 vesting: {456 vesting: {
479 /**457 /**
480 * Amount being transferred is too low to create a vesting schedule.458 * The vested transfer amount is too low
481 **/459 **/
482 AmountLow: AugmentedError<ApiType>;460 AmountLow: AugmentedError<ApiType>;
483 /**461 /**
484 * The account already has `MaxVestingSchedules` count of schedules and thus462 * Insufficient amount of balance to lock
485 * cannot add another one. Consider merging existing schedules in order to add another.463 **/
486 **/
487 AtMaxVestingSchedules: AugmentedError<ApiType>;464 InsufficientBalanceToLock: AugmentedError<ApiType>;
488 /**465 /**
489 * Failed to create a new schedule because some parameter was invalid.466 * Failed because the maximum vesting schedules was exceeded
490 **/467 **/
491 InvalidScheduleParams: AugmentedError<ApiType>;468 MaxVestingSchedulesExceeded: AugmentedError<ApiType>;
492 /**469 /**
493 * The account given is not vesting.470 * This account have too many vesting schedules
494 **/471 **/
472 TooManyVestingSchedules: AugmentedError<ApiType>;
473 /**
474 * Vesting period is zero
475 **/
495 NotVesting: AugmentedError<ApiType>;476 ZeroVestingPeriod: AugmentedError<ApiType>;
496 /**477 /**
497 * An index was out of bounds of the vesting schedules.478 * Number of vests is zero
498 **/479 **/
499 ScheduleIndexOutOfBounds: AugmentedError<ApiType>;480 ZeroVestingPeriodCount: AugmentedError<ApiType>;
500 /**481 /**
501 * Generic error482 * Generic error
502 **/483 **/
modifiedtests/src/interfaces/augment-api-events.tsdiffbeforeafterboth
2/* eslint-disable */2/* eslint-disable */
33
4import type { EthereumLog, EvmCoreErrorExitReason } from './ethereum';4import type { EthereumLog, EvmCoreErrorExitReason } from './ethereum';
5import type { PalletCommonAccountBasicCrossAccountIdRepr } from './nft';5import type { PalletCommonAccountBasicCrossAccountIdRepr } from './unique';
6import type { ApiTypes } from '@polkadot/api/types';6import type { ApiTypes } from '@polkadot/api/types';
7import type { Bytes, Null, Option, Result, U256, U8aFixed, u128, u32, u64, u8 } from '@polkadot/types';7import type { Null, Option, Result, U256, U8aFixed, u128, u32, u64, u8 } from '@polkadot/types';
8import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';8import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';
9import type { FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, SpRuntimeDispatchError, XcmV1MultiLocation, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation } from '@polkadot/types/lookup';9import type { FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, SpRuntimeDispatchError, XcmV1MultiLocation, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation } from '@polkadot/types/lookup';
10import type { ITuple } from '@polkadot/types/types';
1110
12declare module '@polkadot/api/types/events' {11declare module '@polkadot/api/types/events' {
13 export interface AugmentedEvents<ApiType> {12 export interface AugmentedEvents<ApiType> {
389 **/388 **/
390 [key: string]: AugmentedEvent<ApiType>;389 [key: string]: AugmentedEvent<ApiType>;
391 };390 };
392 scheduler: {
393 /**
394 * Canceled some task. \[when, index\]
395 **/
396 Canceled: AugmentedEvent<ApiType, [u32, u32]>;
397 /**
398 * Dispatched some task. \[task, id, result\]
399 **/
400 Dispatched: AugmentedEvent<ApiType, [ITuple<[u32, u32]>, Option<Bytes>, Result<Null, SpRuntimeDispatchError>]>;
401 /**
402 * Scheduled some task. \[when, index\]
403 **/
404 Scheduled: AugmentedEvent<ApiType, [u32, u32]>;
405 /**
406 * Generic event
407 **/
408 [key: string]: AugmentedEvent<ApiType>;
409 };
410 sudo: {391 sudo: {
411 /**392 /**
412 * The \[sudoer\] just switched identity; the old key is supplied.393 * The \[sudoer\] just switched identity; the old key is supplied.
491 [key: string]: AugmentedEvent<ApiType>;472 [key: string]: AugmentedEvent<ApiType>;
492 };473 };
493 vesting: {474 vesting: {
494 /**475 /**
495 * An \[account\] has become fully vested.476 * Claimed vesting. \[who, locked_amount\]
496 **/477 **/
497 VestingCompleted: AugmentedEvent<ApiType, [AccountId32]>;478 Claimed: AugmentedEvent<ApiType, [AccountId32, u128]>;
498 /**479 /**
499 * The amount vested has been updated. This could indicate a change in funds available.480 * Added new vesting schedule. \[from, to, vesting_schedule\]
500 * The balance given is the amount which is left unvested (and thus locked).481 **/
501 * \[account, unvested\]
502 **/
503 VestingUpdated: AugmentedEvent<ApiType, [AccountId32, u128]>;482 VestingScheduleAdded: AugmentedEvent<ApiType, [AccountId32, AccountId32, OrmlVestingVestingSchedule]>;
483 /**
484 * Updated vesting schedules. \[who\]
485 **/
486 VestingSchedulesUpdated: AugmentedEvent<ApiType, [AccountId32]>;
504 /**487 /**
505 * Generic event488 * Generic event
506 **/489 **/
modifiedtests/src/interfaces/augment-api-query.tsdiffbeforeafterboth
2/* eslint-disable */2/* eslint-disable */
33
4import type { EthereumBlock, EthereumReceipt, EthereumTransactionLegacyTransaction, FpRpcTransactionStatus } from './ethereum';4import type { EthereumBlock, EthereumReceipt, EthereumTransactionLegacyTransaction, FpRpcTransactionStatus } from './ethereum';
5import type { NftDataStructsCollection, PalletCommonAccountBasicCrossAccountIdRepr, PalletNonfungibleItemData, PalletRefungibleItemData, PalletUnqSchedulerCallSpec, PalletUnqSchedulerReleases, PalletUnqSchedulerScheduledV2 } from './nft';
6import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundStatus, CumulusPalletXcmpQueueOutboundStatus, CumulusPalletXcmpQueueQueueConfigData, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1PersistedValidationData } from './polkadot';5import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundStatus, CumulusPalletXcmpQueueOutboundStatus, CumulusPalletXcmpQueueQueueConfigData, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1PersistedValidationData } from './polkadot';
6import type { PalletCommonAccountBasicCrossAccountIdRepr, PalletNonfungibleItemData, PalletRefungibleItemData, UpDataStructsCollection, UpDataStructsCollectionStats } from './unique';
7import type { ApiTypes } from '@polkadot/api/types';7import type { ApiTypes } from '@polkadot/api/types';
8import type { BTreeMap, Bytes, Option, U256, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types';8import type { BTreeMap, Bytes, Option, U256, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types';
9import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';9import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';
10import type { FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletTransactionPaymentReleases, PalletTreasuryProposal, PalletVestingReleases, PalletVestingVestingInfo, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV1UpgradeRestriction, SpRuntimeGenericDigest } from '@polkadot/types/lookup';10import type { FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletTransactionPaymentReleases, PalletTreasuryProposal, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV1UpgradeRestriction, SpRuntimeGenericDigest } from '@polkadot/types/lookup';
11import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';11import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
1212
13declare module '@polkadot/api/types/storage' {13declare module '@polkadot/api/types/storage' {
58 /**58 /**
59 * Collection info59 * Collection info
60 **/60 **/
61 collectionById: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<NftDataStructsCollection>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;61 collectionById: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<UpDataStructsCollection>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
62 createdCollectionCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;62 createdCollectionCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
63 destroyedCollectionCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;63 destroyedCollectionCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
64 /**
65 * Not used by code, exists only to provide some types to metadata
66 **/
67 dummyStorageValue: AugmentedQuery<ApiType, () => Observable<Option<ITuple<[UpDataStructsCollectionStats, u32, u32]>>>, []> & QueryableStorageEntry<ApiType, []>;
64 /**68 /**
65 * List of collection admins69 * List of collection admins
66 **/70 **/
171 **/175 **/
172 [key: string]: QueryableStorageEntry<ApiType>;176 [key: string]: QueryableStorageEntry<ApiType>;
173 };177 };
174 nft: {
175 /**
176 * Used for migrations
177 **/
178 chainVersion: AugmentedQuery<ApiType, () => Observable<u64>, []> & QueryableStorageEntry<ApiType, []>;
179 /**
180 * (Collection id (controlled?2), who created (real))
181 * TODO: Off chain worker should remove from this map when collection gets removed
182 **/
183 createItemBasket: AugmentedQuery<ApiType, (arg: ITuple<[u32, AccountId32]> | [u32 | AnyNumber | Uint8Array, AccountId32 | string | Uint8Array]) => Observable<u32>, [ITuple<[u32, AccountId32]>]> & QueryableStorageEntry<ApiType, [ITuple<[u32, AccountId32]>]>;
184 /**
185 * Collection id (controlled?2), owning user (real)
186 **/
187 fungibleTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: AccountId32 | string | Uint8Array) => Observable<u32>, [u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, AccountId32]>;
188 /**
189 * Collection id (controlled?2), token id (controlled?2)
190 **/
191 nftTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
192 /**
193 * Collection id (controlled?2), token id (controlled?2)
194 **/
195 reFungibleTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
196 /**
197 * Variable metadata sponsoring
198 * Collection id (controlled?2), token id (controlled?2)
199 **/
200 variableMetaDataBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<u32>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
201 /**
202 * Generic query
203 **/
204 [key: string]: QueryableStorageEntry<ApiType>;
205 };
206 nftPayment: {
207 /**
208 * Generic query
209 **/
210 [key: string]: QueryableStorageEntry<ApiType>;
211 };
212 nonfungible: {178 nonfungible: {
213 accountBalance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u32>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;179 accountBalance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u32>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
214 allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletCommonAccountBasicCrossAccountIdRepr>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;180 allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletCommonAccountBasicCrossAccountIdRepr>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
383 **/349 **/
384 [key: string]: QueryableStorageEntry<ApiType>;350 [key: string]: QueryableStorageEntry<ApiType>;
385 };351 };
386 scheduler: {
387 /**
388 * Items to be executed, indexed by the block number that they should be executed on.
389 **/
390 agenda: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<Option<PalletUnqSchedulerScheduledV2>>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
391 /**
392 * Lookup from identity to the block number and index of the task.
393 **/
394 lookup: AugmentedQuery<ApiType, (arg: Bytes | string | Uint8Array) => Observable<Option<ITuple<[u32, u32]>>>, [Bytes]> & QueryableStorageEntry<ApiType, [Bytes]>;
395 specAgenda: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<Option<PalletUnqSchedulerCallSpec>>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
396 /**
397 * Storage version of the pallet.
398 *
399 * New networks start with last version.
400 **/
401 storageVersion: AugmentedQuery<ApiType, () => Observable<PalletUnqSchedulerReleases>, []> & QueryableStorageEntry<ApiType, []>;
402 /**
403 * Generic query
404 **/
405 [key: string]: QueryableStorageEntry<ApiType>;
406 };
407 sudo: {352 sudo: {
408 /**353 /**
409 * The `AccountId` of the sudo key.354 * The `AccountId` of the sudo key.
537 **/482 **/
538 [key: string]: QueryableStorageEntry<ApiType>;483 [key: string]: QueryableStorageEntry<ApiType>;
539 };484 };
540 vesting: {485 unique: {
541 /**486 /**
542 * Storage version of the pallet.487 * Used for migrations
543 * 488 **/
544 * New networks start with latest version, as determined by the genesis build.
545 **/
546 storageVersion: AugmentedQuery<ApiType, () => Observable<PalletVestingReleases>, []> & QueryableStorageEntry<ApiType, []>;489 chainVersion: AugmentedQuery<ApiType, () => Observable<u64>, []> & QueryableStorageEntry<ApiType, []>;
547 /**490 /**
548 * Information regarding the vesting of a given account.491 * (Collection id (controlled?2), who created (real))
549 **/492 * TODO: Off chain worker should remove from this map when collection gets removed
493 **/
550 vesting: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<Vec<PalletVestingVestingInfo>>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;494 createItemBasket: AugmentedQuery<ApiType, (arg: ITuple<[u32, AccountId32]> | [u32 | AnyNumber | Uint8Array, AccountId32 | string | Uint8Array]) => Observable<Option<u32>>, [ITuple<[u32, AccountId32]>]> & QueryableStorageEntry<ApiType, [ITuple<[u32, AccountId32]>]>;
495 fungibleApproveBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: AccountId32 | string | Uint8Array) => Observable<Option<u32>>, [u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, AccountId32]>;
496 /**
497 * Collection id (controlled?2), owning user (real)
498 **/
499 fungibleTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: AccountId32 | string | Uint8Array) => Observable<Option<u32>>, [u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, AccountId32]>;
500 /**
501 * Approval sponsoring
502 **/
503 nftApproveBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<u32>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
504 /**
505 * Collection id (controlled?2), token id (controlled?2)
506 **/
507 nftTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<u32>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
508 refungibleApproveBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: AccountId32 | string | Uint8Array) => Observable<Option<u32>>, [u32, u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, u32, AccountId32]>;
509 /**
510 * Collection id (controlled?2), token id (controlled?2)
511 **/
512 reFungibleTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: AccountId32 | string | Uint8Array) => Observable<Option<u32>>, [u32, u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, u32, AccountId32]>;
513 /**
514 * Variable metadata sponsoring
515 * Collection id (controlled?2), token id (controlled?2)
516 **/
517 variableMetaDataBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<u32>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
551 /**518 /**
552 * Generic query519 * Generic query
553 **/520 **/
554 [key: string]: QueryableStorageEntry<ApiType>;521 [key: string]: QueryableStorageEntry<ApiType>;
555 };522 };
523 vesting: {
524 /**
525 * Vesting schedules of an account.
526 *
527 * VestingSchedules: map AccountId => Vec<VestingSchedule>
528 **/
529 vestingSchedules: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Vec<OrmlVestingVestingSchedule>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
530 /**
531 * Generic query
532 **/
533 [key: string]: QueryableStorageEntry<ApiType>;
534 };
556 xcmpQueue: {535 xcmpQueue: {
557 /**536 /**
558 * Inbound aggregate XCMP messages. It can only be one per ParaId/block.537 * Inbound aggregate XCMP messages. It can only be one per ParaId/block.
modifiedtests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth
1// Auto-generated via `yarn polkadot-types-from-chain`, do not edit1// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
2/* eslint-disable */2/* eslint-disable */
33
4import type { NftDataStructsCollectionId, NftDataStructsTokenId, PalletCommonAccountBasicCrossAccountIdRepr } from './nft';4import type { PalletCommonAccountBasicCrossAccountIdRepr, UpDataStructsCollection, UpDataStructsCollectionId, UpDataStructsCollectionStats, UpDataStructsTokenId } from './unique';
5import type { Bytes, HashMap, Json, Metadata, Null, Option, StorageKey, Text, U256, U64, Vec, bool, u128, u32, u64 } from '@polkadot/types';5import type { Bytes, HashMap, Json, Metadata, Null, Option, StorageKey, Text, U256, U64, Vec, bool, u128, u32, u64 } from '@polkadot/types';
6import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';6import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
7import type { EpochAuthorship } from '@polkadot/types/interfaces/babe';7import type { EpochAuthorship } from '@polkadot/types/interfaces/babe';
355 **/355 **/
356 version: AugmentedRpc<() => Observable<Text>>;356 version: AugmentedRpc<() => Observable<Text>>;
357 };357 };
358 nft: {
359 /**
360 * Get amount of different user tokens
361 **/
362 accountBalance: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u32>>;
363 /**
364 * Get tokens owned by account
365 **/
366 accountTokens: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<NftDataStructsTokenId>>>;
367 /**
368 * Get admin list
369 **/
370 adminlist: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletCommonAccountBasicCrossAccountIdRepr>>>;
371 /**
372 * Get allowed amount
373 **/
374 allowance: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, sender: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, spender: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
375 /**
376 * Get allowlist
377 **/
378 allowlist: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletCommonAccountBasicCrossAccountIdRepr>>>;
379 /**
380 * Get amount of specific account token
381 **/
382 balance: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
383 /**
384 * Get tokens contained in collection
385 **/
386 collectionTokens: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<NftDataStructsTokenId>>>;
387 /**
388 * Get token constant metadata
389 **/
390 constMetadata: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Bytes>>;
391 /**
392 * Get last token id
393 **/
394 lastTokenId: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<NftDataStructsTokenId>>;
395 /**
396 * Check if token exists
397 **/
398 tokenExists: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<bool>>;
399 /**
400 * Get token owner
401 **/
402 tokenOwner: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<PalletCommonAccountBasicCrossAccountIdRepr>>;
403 /**
404 * Get token variable metadata
405 **/
406 variableMetadata: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Bytes>>;
407 };
408 offchain: {358 offchain: {
409 /**359 /**
410 * Get offchain local storage under given key and prefix360 * Get offchain local storage under given key and prefix
597 **/547 **/
598 version: AugmentedRpc<() => Observable<Text>>;548 version: AugmentedRpc<() => Observable<Text>>;
599 };549 };
550 unique: {
551 /**
552 * Get amount of different user tokens
553 **/
554 accountBalance: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u32>>;
555 /**
556 * Get tokens owned by account
557 **/
558 accountTokens: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsTokenId>>>;
559 /**
560 * Get admin list
561 **/
562 adminlist: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletCommonAccountBasicCrossAccountIdRepr>>>;
563 /**
564 * Get allowed amount
565 **/
566 allowance: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, sender: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, spender: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: UpDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
567 /**
568 * Check if user is allowed to use collection
569 **/
570 allowed: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<bool>>;
571 /**
572 * Get allowlist
573 **/
574 allowlist: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletCommonAccountBasicCrossAccountIdRepr>>>;
575 /**
576 * Get amount of specific account token
577 **/
578 balance: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: UpDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
579 /**
580 * Get collection by specified id
581 **/
582 collectionById: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<UpDataStructsCollection>>>;
583 /**
584 * Get collection stats
585 **/
586 collectionStats: AugmentedRpc<(at?: Hash | string | Uint8Array) => Observable<UpDataStructsCollectionStats>>;
587 /**
588 * Get tokens contained in collection
589 **/
590 collectionTokens: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsTokenId>>>;
591 /**
592 * Get token constant metadata
593 **/
594 constMetadata: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: UpDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Bytes>>;
595 /**
596 * Get last token id
597 **/
598 lastTokenId: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<UpDataStructsTokenId>>;
599 /**
600 * Check if token exists
601 **/
602 tokenExists: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: UpDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<bool>>;
603 /**
604 * Get token owner
605 **/
606 tokenOwner: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: UpDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<PalletCommonAccountBasicCrossAccountIdRepr>>;
607 /**
608 * Get token variable metadata
609 **/
610 variableMetadata: AugmentedRpc<(collection: UpDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: UpDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Bytes>>;
611 };
600 web3: {612 web3: {
601 /**613 /**
602 * Returns current client version.614 * Returns current client version.
modifiedtests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth
2/* eslint-disable */2/* eslint-disable */
33
4import type { EthereumTransactionLegacyTransaction } from './ethereum';4import type { EthereumTransactionLegacyTransaction } from './ethereum';
5import type { NftDataStructsAccessMode, NftDataStructsCollectionLimits, NftDataStructsCollectionMode, NftDataStructsCreateItemData, NftDataStructsMetaUpdatePermission, NftDataStructsSchemaVersion, PalletCommonAccountBasicCrossAccountIdRepr } from './nft';5import type { CumulusPrimitivesParachainInherentParachainInherentData } from './polkadot';
6import type { CumulusPrimitivesParachainInherentParachainInherentData } from './polkadot';6import type { PalletCommonAccountBasicCrossAccountIdRepr, UpDataStructsAccessMode, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCreateItemData, UpDataStructsMetaUpdatePermission, UpDataStructsSchemaVersion } from './unique';
7import type { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';7import type { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';
8import type { Bytes, Compact, Option, U256, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types';8import type { Bytes, Compact, Option, U256, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types';
9import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';9import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
10import type { AccountId32, Call, H160, H256, MultiAddress, Perbill } from '@polkadot/types/interfaces/runtime';10import type { AccountId32, Call, H160, H256, MultiAddress, Perbill } from '@polkadot/types/interfaces/runtime';
11import type { PalletVestingVestingInfo, SpCoreChangesTrieChangesTrieConfiguration, XcmV1MultiLocation, XcmV2WeightLimit, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';11import type { SpCoreChangesTrieChangesTrieConfiguration, XcmV1MultiLocation, XcmV2WeightLimit, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
12import type { AnyNumber, ITuple } from '@polkadot/types/types';12import type { AnyNumber, ITuple } from '@polkadot/types/types';
1313
14declare module '@polkadot/api/types/submittable' {14declare module '@polkadot/api/types/submittable' {
201 **/201 **/
202 [key: string]: SubmittableExtrinsicFunction<ApiType>;202 [key: string]: SubmittableExtrinsicFunction<ApiType>;
203 };203 };
204 nft: {
205 /**
206 * Adds an admin of the Collection.
207 * NFT Collection can be controlled by multiple admin addresses (some which can also be servers, for example). Admins can issue and burn NFTs, as well as add and remove other admins, but cannot change NFT or Collection ownership.
208 *
209 * # Permissions
210 *
211 * * Collection Owner.
212 * * Collection Admin.
213 *
214 * # Arguments
215 *
216 * * collection_id: ID of the Collection to add admin for.
217 *
218 * * new_admin_id: Address of new admin to add.
219 **/
220 addCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newAdminId: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
221 /**
222 * Add an address to allow list.
223 *
224 * # Permissions
225 *
226 * * Collection Owner
227 * * Collection Admin
228 *
229 * # Arguments
230 *
231 * * collection_id.
232 *
233 * * address.
234 **/
235 addToAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
236 /**
237 * Set, change, or remove approved address to transfer the ownership of the NFT.
238 *
239 * # Permissions
240 *
241 * * Collection Owner
242 * * Collection Admin
243 * * Current NFT owner
244 *
245 * # Arguments
246 *
247 * * approved: Address that is approved to transfer this NFT or zero (if needed to remove approval).
248 *
249 * * collection_id.
250 *
251 * * item_id: ID of the item.
252 **/
253 approve: AugmentedSubmittable<(spender: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletCommonAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
254 /**
255 * Destroys a concrete instance of NFT on behalf of the owner
256 * See also: [`approve`]
257 *
258 * # Permissions
259 *
260 * * Collection Owner.
261 * * Collection Admin.
262 * * Current NFT Owner.
263 *
264 * # Arguments
265 *
266 * * collection_id: ID of the collection.
267 *
268 * * item_id: ID of NFT to burn.
269 *
270 * * from: owner of item
271 **/
272 burnFrom: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, from: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, u32, u128]>;
273 /**
274 * Destroys a concrete instance of NFT.
275 *
276 * # Permissions
277 *
278 * * Collection Owner.
279 * * Collection Admin.
280 * * Current NFT Owner.
281 *
282 * # Arguments
283 *
284 * * collection_id: ID of the collection.
285 *
286 * * item_id: ID of NFT to burn.
287 **/
288 burnItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u128]>;
289 /**
290 * Change the owner of the collection.
291 *
292 * # Permissions
293 *
294 * * Collection Owner.
295 *
296 * # Arguments
297 *
298 * * collection_id.
299 *
300 * * new_owner.
301 **/
302 changeCollectionOwner: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newOwner: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, AccountId32]>;
303 /**
304 * # Permissions
305 *
306 * * Sponsor.
307 *
308 * # Arguments
309 *
310 * * collection_id.
311 **/
312 confirmSponsorship: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
313 /**
314 * This method creates a Collection of NFTs. Each Token may have multiple properties encoded as an array of bytes of certain length. The initial owner and admin of the collection are set to the address that signed the transaction. Both addresses can be changed later.
315 *
316 * # Permissions
317 *
318 * * Anyone.
319 *
320 * # Arguments
321 *
322 * * collection_name: UTF-16 string with collection name (limit 64 characters), will be stored as zero-terminated.
323 *
324 * * collection_description: UTF-16 string with collection description (limit 256 characters), will be stored as zero-terminated.
325 *
326 * * token_prefix: UTF-8 string with token prefix.
327 *
328 * * mode: [CollectionMode] collection type and type dependent data.
329 **/
330 createCollection: AugmentedSubmittable<(collectionName: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], collectionDescription: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], tokenPrefix: Bytes | string | Uint8Array, mode: NftDataStructsCollectionMode | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<u16>, Vec<u16>, Bytes, NftDataStructsCollectionMode]>;
331 /**
332 * This method creates a concrete instance of NFT Collection created with CreateCollection method.
333 *
334 * # Permissions
335 *
336 * * Collection Owner.
337 * * Collection Admin.
338 * * Anyone if
339 * * Allow List is enabled, and
340 * * Address is added to allow list, and
341 * * MintPermission is enabled (see SetMintPermission method)
342 *
343 * # Arguments
344 *
345 * * collection_id: ID of the collection.
346 *
347 * * owner: Address, initial owner of the NFT.
348 *
349 * * data: Token data to store on chain.
350 **/
351 createItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, data: NftDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, NftDataStructsCreateItemData]>;
352 /**
353 * This method creates multiple items in a collection created with CreateCollection method.
354 *
355 * # Permissions
356 *
357 * * Collection Owner.
358 * * Collection Admin.
359 * * Anyone if
360 * * Allow List is enabled, and
361 * * Address is added to allow list, and
362 * * MintPermission is enabled (see SetMintPermission method)
363 *
364 * # Arguments
365 *
366 * * collection_id: ID of the collection.
367 *
368 * * itemsData: Array items properties. Each property is an array of bytes itself, see [create_item].
369 *
370 * * owner: Address, initial owner of the NFT.
371 **/
372 createMultipleItems: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemsData: Vec<NftDataStructsCreateItemData> | (NftDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, Vec<NftDataStructsCreateItemData>]>;
373 /**
374 * **DANGEROUS**: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.
375 *
376 * # Permissions
377 *
378 * * Collection Owner.
379 *
380 * # Arguments
381 *
382 * * collection_id: collection to destroy.
383 **/
384 destroyCollection: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
385 /**
386 * Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which case only Collection Owner will be able to add an Admin.
387 *
388 * # Permissions
389 *
390 * * Collection Owner.
391 * * Collection Admin.
392 *
393 * # Arguments
394 *
395 * * collection_id: ID of the Collection to remove admin for.
396 *
397 * * account_id: Address of admin to remove.
398 **/
399 removeCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, accountId: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
400 /**
401 * Switch back to pay-per-own-transaction model.
402 *
403 * # Permissions
404 *
405 * * Collection owner.
406 *
407 * # Arguments
408 *
409 * * collection_id.
410 **/
411 removeCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
412 /**
413 * Remove an address from allow list.
414 *
415 * # Permissions
416 *
417 * * Collection Owner
418 * * Collection Admin
419 *
420 * # Arguments
421 *
422 * * collection_id.
423 *
424 * * address.
425 **/
426 removeFromAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
427 setCollectionLimits: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newLimit: NftDataStructsCollectionLimits | { accountTokenOwnershipLimit?: any; sponsoredDataSize?: any; sponsoredDataRateLimit?: any; tokenLimit?: any; sponsorTransferTimeout?: any; ownerCanTransfer?: any; ownerCanDestroy?: any; transfersEnabled?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsCollectionLimits]>;
428 /**
429 * # Permissions
430 *
431 * * Collection Owner
432 *
433 * # Arguments
434 *
435 * * collection_id.
436 *
437 * * new_sponsor.
438 **/
439 setCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newSponsor: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, AccountId32]>;
440 /**
441 * Set const on-chain data schema.
442 *
443 * # Permissions
444 *
445 * * Collection Owner
446 * * Collection Admin
447 *
448 * # Arguments
449 *
450 * * collection_id.
451 *
452 * * schema: String representing the const on-chain data schema.
453 **/
454 setConstOnChainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
455 /**
456 * Set meta_update_permission value for particular collection
457 *
458 * # Permissions
459 *
460 * * Collection Owner.
461 *
462 * # Arguments
463 *
464 * * collection_id: ID of the collection.
465 *
466 * * value: New flag value.
467 **/
468 setMetaUpdatePermissionFlag: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, value: NftDataStructsMetaUpdatePermission | 'ItemOwner' | 'Admin' | 'None' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsMetaUpdatePermission]>;
469 /**
470 * Allows Anyone to create tokens if:
471 * * Allow List is enabled, and
472 * * Address is added to allow list, and
473 * * This method was called with True parameter
474 *
475 * # Permissions
476 * * Collection Owner
477 *
478 * # Arguments
479 *
480 * * collection_id.
481 *
482 * * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.
483 **/
484 setMintPermission: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mintPermission: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;
485 /**
486 * Set off-chain data schema.
487 *
488 * # Permissions
489 *
490 * * Collection Owner
491 * * Collection Admin
492 *
493 * # Arguments
494 *
495 * * collection_id.
496 *
497 * * schema: String representing the offchain data schema.
498 **/
499 setOffchainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
500 /**
501 * Toggle between normal and allow list access for the methods with access for `Anyone`.
502 *
503 * # Permissions
504 *
505 * * Collection Owner.
506 *
507 * # Arguments
508 *
509 * * collection_id.
510 *
511 * * mode: [AccessMode]
512 **/
513 setPublicAccessMode: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mode: NftDataStructsAccessMode | 'Normal' | 'AllowList' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsAccessMode]>;
514 /**
515 * Set schema standard
516 * ImageURL
517 * Unique
518 *
519 * # Permissions
520 *
521 * * Collection Owner
522 * * Collection Admin
523 *
524 * # Arguments
525 *
526 * * collection_id.
527 *
528 * * schema: SchemaVersion: enum
529 **/
530 setSchemaVersion: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, version: NftDataStructsSchemaVersion | 'ImageURL' | 'Unique' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsSchemaVersion]>;
531 /**
532 * Set transfers_enabled value for particular collection
533 *
534 * # Permissions
535 *
536 * * Collection Owner.
537 *
538 * # Arguments
539 *
540 * * collection_id: ID of the collection.
541 *
542 * * value: New flag value.
543 **/
544 setTransfersEnabledFlag: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, value: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;
545 /**
546 * Set off-chain data schema.
547 *
548 * # Permissions
549 *
550 * * Collection Owner
551 * * Collection Admin
552 *
553 * # Arguments
554 *
555 * * collection_id.
556 *
557 * * schema: String representing the offchain data schema.
558 **/
559 setVariableMetaData: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, Bytes]>;
560 /**
561 * Set variable on-chain data schema.
562 *
563 * # Permissions
564 *
565 * * Collection Owner
566 * * Collection Admin
567 *
568 * # Arguments
569 *
570 * * collection_id.
571 *
572 * * schema: String representing the variable on-chain data schema.
573 **/
574 setVariableOnChainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
575 /**
576 * Change ownership of the token.
577 *
578 * # Permissions
579 *
580 * * Collection Owner
581 * * Collection Admin
582 * * Current NFT owner
583 *
584 * # Arguments
585 *
586 * * recipient: Address of token recipient.
587 *
588 * * collection_id.
589 *
590 * * item_id: ID of the item
591 * * Non-Fungible Mode: Required.
592 * * Fungible Mode: Ignored.
593 * * Re-Fungible Mode: Required.
594 *
595 * * value: Amount to transfer.
596 * * Non-Fungible Mode: Ignored
597 * * Fungible Mode: Must specify transferred amount
598 * * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)
599 **/
600 transfer: AugmentedSubmittable<(recipient: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletCommonAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
601 /**
602 * Change ownership of a NFT on behalf of the owner. See Approve method for additional information. After this method executes, the approval is removed so that the approved address will not be able to transfer this NFT again from this owner.
603 *
604 * # Permissions
605 * * Collection Owner
606 * * Collection Admin
607 * * Current NFT owner
608 * * Address approved by current NFT owner
609 *
610 * # Arguments
611 *
612 * * from: Address that owns token.
613 *
614 * * recipient: Address of token recipient.
615 *
616 * * collection_id.
617 *
618 * * item_id: ID of the item.
619 *
620 * * value: Amount to transfer.
621 **/
622 transferFrom: AugmentedSubmittable<(from: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, recipient: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
623 /**
624 * Generic tx
625 **/
626 [key: string]: SubmittableExtrinsicFunction<ApiType>;
627 };
628 nftPayment: {
629 /**
630 * Generic tx
631 **/
632 [key: string]: SubmittableExtrinsicFunction<ApiType>;
633 };
634 parachainSystem: {204 parachainSystem: {
635 authorizeUpgrade: AugmentedSubmittable<(codeHash: H256 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H256]>;205 authorizeUpgrade: AugmentedSubmittable<(codeHash: H256 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H256]>;
636 enactAuthorizedUpgrade: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;206 enactAuthorizedUpgrade: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
778 **/348 **/
779 [key: string]: SubmittableExtrinsicFunction<ApiType>;349 [key: string]: SubmittableExtrinsicFunction<ApiType>;
780 };350 };
781 scheduler: {
782 /**
783 * Cancel an anonymously scheduled task.
784 *
785 * # <weight>
786 * - S = Number of already scheduled calls
787 * - Base Weight: 22.15 + 2.869 * S µs
788 * - DB Weight:
789 * - Read: Agenda
790 * - Write: Agenda, Lookup
791 * - Will use base weight of 100 which should be good for up to 30 scheduled calls
792 * # </weight>
793 **/
794 cancel: AugmentedSubmittable<(when: u32 | AnyNumber | Uint8Array, index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
795 /**
796 * Cancel a named scheduled task.
797 *
798 * # <weight>
799 * - S = Number of already scheduled calls
800 * - Base Weight: 24.91 + 2.907 * S µs
801 * - DB Weight:
802 * - Read: Agenda, Lookup
803 * - Write: Agenda, Lookup
804 * - Will use base weight of 100 which should be good for up to 30 scheduled calls
805 * # </weight>
806 **/
807 cancelNamed: AugmentedSubmittable<(id: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
808 /**
809 * Anonymously schedule a task.
810 *
811 * # <weight>
812 * - S = Number of already scheduled calls
813 * - Base Weight: 22.29 + .126 * S µs
814 * - DB Weight:
815 * - Read: Agenda
816 * - Write: Agenda
817 * - Will use base weight of 25 which should be good for up to 30 scheduled calls
818 * # </weight>
819 **/
820 schedule: AugmentedSubmittable<(when: u32 | AnyNumber | Uint8Array, maybePeriodic: Option<ITuple<[u32, u32]>> | null | object | string | Uint8Array, priority: u8 | AnyNumber | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [u32, Option<ITuple<[u32, u32]>>, u8, Call]>;
821 /**
822 * Anonymously schedule a task after a delay.
823 *
824 * # <weight>
825 * Same as [`schedule`].
826 * # </weight>
827 **/
828 scheduleAfter: AugmentedSubmittable<(after: u32 | AnyNumber | Uint8Array, maybePeriodic: Option<ITuple<[u32, u32]>> | null | object | string | Uint8Array, priority: u8 | AnyNumber | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [u32, Option<ITuple<[u32, u32]>>, u8, Call]>;
829 /**
830 * Schedule a named task.
831 *
832 * # <weight>
833 * - S = Number of already scheduled calls
834 * - Base Weight: 29.6 + .159 * S µs
835 * - DB Weight:
836 * - Read: Agenda, Lookup
837 * - Write: Agenda, Lookup
838 * - Will use base weight of 35 which should be good for more than 30 scheduled calls
839 * # </weight>
840 **/
841 scheduleNamed: AugmentedSubmittable<(id: Bytes | string | Uint8Array, when: u32 | AnyNumber | Uint8Array, maybePeriodic: Option<ITuple<[u32, u32]>> | null | object | string | Uint8Array, priority: u8 | AnyNumber | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [Bytes, u32, Option<ITuple<[u32, u32]>>, u8, Call]>;
842 /**
843 * Schedule a named task after a delay.
844 *
845 * # <weight>
846 * Same as [`schedule_named`].
847 * # </weight>
848 **/
849 scheduleNamedAfter: AugmentedSubmittable<(id: Bytes | string | Uint8Array, after: u32 | AnyNumber | Uint8Array, maybePeriodic: Option<ITuple<[u32, u32]>> | null | object | string | Uint8Array, priority: u8 | AnyNumber | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [Bytes, u32, Option<ITuple<[u32, u32]>>, u8, Call]>;
850 /**
851 * Generic tx
852 **/
853 [key: string]: SubmittableExtrinsicFunction<ApiType>;
854 };
855 sudo: {351 sudo: {
856 /**352 /**
857 * Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo353 * Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo
892 * - Weight of derivative `call` execution + 10,000.388 * - Weight of derivative `call` execution + 10,000.
893 * # </weight>389 * # </weight>
894 **/390 **/
895 sudoAs: AugmentedSubmittable<(who: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [MultiAddress, Call]>;391 sudoAs: AugmentedSubmittable<(who: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, ) => SubmittableExtrinsic<ApiType>, [MultiAddress, Call]>;
896 /**392 /**
897 * Authenticates the sudo key and dispatches a function call with `Root` origin.393 * Authenticates the sudo key and dispatches a function call with `Root` origin.
898 * This function does not check the weight of the call, and instead allows the394 * This function does not check the weight of the call, and instead allows the
1094 **/590 **/
1095 [key: string]: SubmittableExtrinsicFunction<ApiType>;591 [key: string]: SubmittableExtrinsicFunction<ApiType>;
1096 };592 };
593 unique: {
594 /**
595 * Adds an admin of the Collection.
596 * NFT Collection can be controlled by multiple admin addresses (some which can also be servers, for example). Admins can issue and burn NFTs, as well as add and remove other admins, but cannot change NFT or Collection ownership.
597 *
598 * # Permissions
599 *
600 * * Collection Owner.
601 * * Collection Admin.
602 *
603 * # Arguments
604 *
605 * * collection_id: ID of the Collection to add admin for.
606 *
607 * * new_admin_id: Address of new admin to add.
608 **/
609 addCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newAdminId: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
610 /**
611 * Add an address to allow list.
612 *
613 * # Permissions
614 *
615 * * Collection Owner
616 * * Collection Admin
617 *
618 * # Arguments
619 *
620 * * collection_id.
621 *
622 * * address.
623 **/
624 addToAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
625 /**
626 * Set, change, or remove approved address to transfer the ownership of the NFT.
627 *
628 * # Permissions
629 *
630 * * Collection Owner
631 * * Collection Admin
632 * * Current NFT owner
633 *
634 * # Arguments
635 *
636 * * approved: Address that is approved to transfer this NFT or zero (if needed to remove approval).
637 *
638 * * collection_id.
639 *
640 * * item_id: ID of the item.
641 **/
642 approve: AugmentedSubmittable<(spender: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletCommonAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
643 /**
644 * Destroys a concrete instance of NFT on behalf of the owner
645 * See also: [`approve`]
646 *
647 * # Permissions
648 *
649 * * Collection Owner.
650 * * Collection Admin.
651 * * Current NFT Owner.
652 *
653 * # Arguments
654 *
655 * * collection_id: ID of the collection.
656 *
657 * * item_id: ID of NFT to burn.
658 *
659 * * from: owner of item
660 **/
661 burnFrom: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, from: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, u32, u128]>;
662 /**
663 * Destroys a concrete instance of NFT.
664 *
665 * # Permissions
666 *
667 * * Collection Owner.
668 * * Collection Admin.
669 * * Current NFT Owner.
670 *
671 * # Arguments
672 *
673 * * collection_id: ID of the collection.
674 *
675 * * item_id: ID of NFT to burn.
676 **/
677 burnItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u128]>;
678 /**
679 * Change the owner of the collection.
680 *
681 * # Permissions
682 *
683 * * Collection Owner.
684 *
685 * # Arguments
686 *
687 * * collection_id.
688 *
689 * * new_owner.
690 **/
691 changeCollectionOwner: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newOwner: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, AccountId32]>;
692 /**
693 * # Permissions
694 *
695 * * Sponsor.
696 *
697 * # Arguments
698 *
699 * * collection_id.
700 **/
701 confirmSponsorship: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
702 /**
703 * This method creates a Collection of NFTs. Each Token may have multiple properties encoded as an array of bytes of certain length. The initial owner of the collection is set to the address that signed the transaction and can be changed later.
704 *
705 * # Permissions
706 *
707 * * Anyone.
708 *
709 * # Arguments
710 *
711 * * collection_name: UTF-16 string with collection name (limit 64 characters), will be stored as zero-terminated.
712 *
713 * * collection_description: UTF-16 string with collection description (limit 256 characters), will be stored as zero-terminated.
714 *
715 * * token_prefix: UTF-8 string with token prefix.
716 *
717 * * mode: [CollectionMode] collection type and type dependent data.
718 **/
719 createCollection: AugmentedSubmittable<(collectionName: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], collectionDescription: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], tokenPrefix: Bytes | string | Uint8Array, mode: UpDataStructsCollectionMode | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<u16>, Vec<u16>, Bytes, UpDataStructsCollectionMode]>;
720 /**
721 * This method creates a concrete instance of NFT Collection created with CreateCollection method.
722 *
723 * # Permissions
724 *
725 * * Collection Owner.
726 * * Collection Admin.
727 * * Anyone if
728 * * Allow List is enabled, and
729 * * Address is added to allow list, and
730 * * MintPermission is enabled (see SetMintPermission method)
731 *
732 * # Arguments
733 *
734 * * collection_id: ID of the collection.
735 *
736 * * owner: Address, initial owner of the NFT.
737 *
738 * * data: Token data to store on chain.
739 **/
740 createItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, data: UpDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, UpDataStructsCreateItemData]>;
741 /**
742 * This method creates multiple items in a collection created with CreateCollection method.
743 *
744 * # Permissions
745 *
746 * * Collection Owner.
747 * * Collection Admin.
748 * * Anyone if
749 * * Allow List is enabled, and
750 * * Address is added to allow list, and
751 * * MintPermission is enabled (see SetMintPermission method)
752 *
753 * # Arguments
754 *
755 * * collection_id: ID of the collection.
756 *
757 * * itemsData: Array items properties. Each property is an array of bytes itself, see [create_item].
758 *
759 * * owner: Address, initial owner of the NFT.
760 **/
761 createMultipleItems: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemsData: Vec<UpDataStructsCreateItemData> | (UpDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, Vec<UpDataStructsCreateItemData>]>;
762 /**
763 * **DANGEROUS**: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.
764 *
765 * # Permissions
766 *
767 * * Collection Owner.
768 *
769 * # Arguments
770 *
771 * * collection_id: collection to destroy.
772 **/
773 destroyCollection: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
774 /**
775 * Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which case only Collection Owner will be able to add an Admin.
776 *
777 * # Permissions
778 *
779 * * Collection Owner.
780 * * Collection Admin.
781 *
782 * # Arguments
783 *
784 * * collection_id: ID of the Collection to remove admin for.
785 *
786 * * account_id: Address of admin to remove.
787 **/
788 removeCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, accountId: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
789 /**
790 * Switch back to pay-per-own-transaction model.
791 *
792 * # Permissions
793 *
794 * * Collection owner.
795 *
796 * # Arguments
797 *
798 * * collection_id.
799 **/
800 removeCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
801 /**
802 * Remove an address from allow list.
803 *
804 * # Permissions
805 *
806 * * Collection Owner
807 * * Collection Admin
808 *
809 * # Arguments
810 *
811 * * collection_id.
812 *
813 * * address.
814 **/
815 removeFromAllowList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
816 setCollectionLimits: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newLimit: UpDataStructsCollectionLimits | { accountTokenOwnershipLimit?: any; sponsoredDataSize?: any; sponsoredDataRateLimit?: any; tokenLimit?: any; sponsorTransferTimeout?: any; sponsorApproveTimeout?: any; ownerCanTransfer?: any; ownerCanDestroy?: any; transfersEnabled?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsCollectionLimits]>;
817 /**
818 * # Permissions
819 *
820 * * Collection Owner
821 *
822 * # Arguments
823 *
824 * * collection_id.
825 *
826 * * new_sponsor.
827 **/
828 setCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newSponsor: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, AccountId32]>;
829 /**
830 * Set const on-chain data schema.
831 *
832 * # Permissions
833 *
834 * * Collection Owner
835 * * Collection Admin
836 *
837 * # Arguments
838 *
839 * * collection_id.
840 *
841 * * schema: String representing the const on-chain data schema.
842 **/
843 setConstOnChainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
844 /**
845 * Set meta_update_permission value for particular collection
846 *
847 * # Permissions
848 *
849 * * Collection Owner.
850 *
851 * # Arguments
852 *
853 * * collection_id: ID of the collection.
854 *
855 * * value: New flag value.
856 **/
857 setMetaUpdatePermissionFlag: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, value: UpDataStructsMetaUpdatePermission | 'ItemOwner' | 'Admin' | 'None' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsMetaUpdatePermission]>;
858 /**
859 * Allows Anyone to create tokens if:
860 * * Allow List is enabled, and
861 * * Address is added to allow list, and
862 * * This method was called with True parameter
863 *
864 * # Permissions
865 * * Collection Owner
866 *
867 * # Arguments
868 *
869 * * collection_id.
870 *
871 * * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.
872 **/
873 setMintPermission: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mintPermission: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;
874 /**
875 * Set off-chain data schema.
876 *
877 * # Permissions
878 *
879 * * Collection Owner
880 * * Collection Admin
881 *
882 * # Arguments
883 *
884 * * collection_id.
885 *
886 * * schema: String representing the offchain data schema.
887 **/
888 setOffchainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
889 /**
890 * Toggle between normal and allow list access for the methods with access for `Anyone`.
891 *
892 * # Permissions
893 *
894 * * Collection Owner.
895 *
896 * # Arguments
897 *
898 * * collection_id.
899 *
900 * * mode: [AccessMode]
901 **/
902 setPublicAccessMode: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mode: UpDataStructsAccessMode | 'Normal' | 'AllowList' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsAccessMode]>;
903 /**
904 * Set schema standard
905 * ImageURL
906 * Unique
907 *
908 * # Permissions
909 *
910 * * Collection Owner
911 * * Collection Admin
912 *
913 * # Arguments
914 *
915 * * collection_id.
916 *
917 * * schema: SchemaVersion: enum
918 **/
919 setSchemaVersion: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, version: UpDataStructsSchemaVersion | 'ImageURL' | 'Unique' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, UpDataStructsSchemaVersion]>;
920 /**
921 * Set transfers_enabled value for particular collection
922 *
923 * # Permissions
924 *
925 * * Collection Owner.
926 *
927 * # Arguments
928 *
929 * * collection_id: ID of the collection.
930 *
931 * * value: New flag value.
932 **/
933 setTransfersEnabledFlag: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, value: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;
934 /**
935 * Set off-chain data schema.
936 *
937 * # Permissions
938 *
939 * * Collection Owner
940 * * Collection Admin
941 *
942 * # Arguments
943 *
944 * * collection_id.
945 *
946 * * schema: String representing the offchain data schema.
947 **/
948 setVariableMetaData: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, Bytes]>;
949 /**
950 * Set variable on-chain data schema.
951 *
952 * # Permissions
953 *
954 * * Collection Owner
955 * * Collection Admin
956 *
957 * # Arguments
958 *
959 * * collection_id.
960 *
961 * * schema: String representing the variable on-chain data schema.
962 **/
963 setVariableOnChainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
964 /**
965 * Change ownership of the token.
966 *
967 * # Permissions
968 *
969 * * Collection Owner
970 * * Collection Admin
971 * * Current NFT owner
972 *
973 * # Arguments
974 *
975 * * recipient: Address of token recipient.
976 *
977 * * collection_id.
978 *
979 * * item_id: ID of the item
980 * * Non-Fungible Mode: Required.
981 * * Fungible Mode: Ignored.
982 * * Re-Fungible Mode: Required.
983 *
984 * * value: Amount to transfer.
985 * * Non-Fungible Mode: Ignored
986 * * Fungible Mode: Must specify transferred amount
987 * * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)
988 **/
989 transfer: AugmentedSubmittable<(recipient: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletCommonAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
990 /**
991 * Change ownership of a NFT on behalf of the owner. See Approve method for additional information. After this method executes, the approval is removed so that the approved address will not be able to transfer this NFT again from this owner.
992 *
993 * # Permissions
994 * * Collection Owner
995 * * Collection Admin
996 * * Current NFT owner
997 * * Address approved by current NFT owner
998 *
999 * # Arguments
1000 *
1001 * * from: Address that owns token.
1002 *
1003 * * recipient: Address of token recipient.
1004 *
1005 * * collection_id.
1006 *
1007 * * item_id: ID of the item.
1008 *
1009 * * value: Amount to transfer.
1010 **/
1011 transferFrom: AugmentedSubmittable<(from: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, recipient: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
1012 /**
1013 * Generic tx
1014 **/
1015 [key: string]: SubmittableExtrinsicFunction<ApiType>;
1016 };
1097 vesting: {1017 vesting: {
1098 /**1018 claim: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
1099 * Force a vested transfer.
1100 *
1101 * The dispatch origin for this call must be _Root_.
1102 *
1103 * - `source`: The account whose funds should be transferred.
1104 * - `target`: The account that should be transferred the vested funds.
1105 * - `schedule`: The vesting schedule attached to the transfer.
1106 *
1107 * Emits `VestingCreated`.
1108 *
1109 * NOTE: This will unlock all schedules through the current block.
1110 *
1111 * # <weight>
1112 * - `O(1)`.
1113 * - DbWeight: 4 Reads, 4 Writes
1114 * - Reads: Vesting Storage, Balances Locks, Target Account, Source Account
1115 * - Writes: Vesting Storage, Balances Locks, Target Account, Source Account
1116 * # </weight>
1117 **/
1118 forceVestedTransfer: AugmentedSubmittable<(source: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, target: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: PalletVestingVestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, MultiAddress, PalletVestingVestingInfo]>;1019 claimFor: AugmentedSubmittable<(dest: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress]>;
1119 /**
1120 * Merge two vesting schedules together, creating a new vesting schedule that unlocks over
1121 * the highest possible start and end blocks. If both schedules have already started the
1122 * current block will be used as the schedule start; with the caveat that if one schedule
1123 * is finished by the current block, the other will be treated as the new merged schedule,
1124 * unmodified.
1125 *
1126 * NOTE: If `schedule1_index == schedule2_index` this is a no-op.
1127 * NOTE: This will unlock all schedules through the current block prior to merging.
1128 * NOTE: If both schedules have ended by the current block, no new schedule will be created
1129 * and both will be removed.
1130 *
1131 * Merged schedule attributes:
1132 * - `starting_block`: `MAX(schedule1.starting_block, scheduled2.starting_block,
1133 * current_block)`.
1134 * - `ending_block`: `MAX(schedule1.ending_block, schedule2.ending_block)`.
1135 * - `locked`: `schedule1.locked_at(current_block) + schedule2.locked_at(current_block)`.
1136 *
1137 * The dispatch origin for this call must be _Signed_.
1138 *
1139 * - `schedule1_index`: index of the first schedule to merge.
1140 * - `schedule2_index`: index of the second schedule to merge.
1141 **/
1142 mergeSchedules: AugmentedSubmittable<(schedule1Index: u32 | AnyNumber | Uint8Array, schedule2Index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
1143 /**
1144 * Unlock any vested funds of the sender account.
1145 *
1146 * The dispatch origin for this call must be _Signed_ and the sender must have funds still
1147 * locked under this pallet.
1148 *
1149 * Emits either `VestingCompleted` or `VestingUpdated`.
1150 *
1151 * # <weight>
1152 * - `O(1)`.
1153 * - DbWeight: 2 Reads, 2 Writes
1154 * - Reads: Vesting Storage, Balances Locks, [Sender Account]
1155 * - Writes: Vesting Storage, Balances Locks, [Sender Account]
1156 * # </weight>
1157 **/
1158 vest: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
1159 /**
1160 * Create a vested transfer.
1161 *
1162 * The dispatch origin for this call must be _Signed_.
1163 *
1164 * - `target`: The account receiving the vested funds.
1165 * - `schedule`: The vesting schedule attached to the transfer.
1166 *
1167 * Emits `VestingCreated`.
1168 *
1169 * NOTE: This will unlock all schedules through the current block.
1170 *
1171 * # <weight>
1172 * - `O(1)`.
1173 * - DbWeight: 3 Reads, 3 Writes
1174 * - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account]
1175 * - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
1176 * # </weight>
1177 **/
1178 vestedTransfer: AugmentedSubmittable<(target: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: PalletVestingVestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, PalletVestingVestingInfo]>;1020 updateVestingSchedules: AugmentedSubmittable<(who: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, vestingSchedules: Vec<OrmlVestingVestingSchedule> | (OrmlVestingVestingSchedule | { start?: any; period?: any; periodCount?: any; perPeriod?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [MultiAddress, Vec<OrmlVestingVestingSchedule>]>;
1179 /**
1180 * Unlock any vested funds of a `target` account.
1181 *
1182 * The dispatch origin for this call must be _Signed_.
1183 *
1184 * - `target`: The account whose vested funds should be unlocked. Must have funds still
1185 * locked under this pallet.
1186 *
1187 * Emits either `VestingCompleted` or `VestingUpdated`.
1188 *
1189 * # <weight>
1190 * - `O(1)`.
1191 * - DbWeight: 3 Reads, 3 Writes
1192 * - Reads: Vesting Storage, Balances Locks, Target Account
1193 * - Writes: Vesting Storage, Balances Locks, Target Account
1194 * # </weight>
1195 **/
1196 vestOther: AugmentedSubmittable<(target: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress]>;1021 vestedTransfer: AugmentedSubmittable<(dest: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: OrmlVestingVestingSchedule | { start?: any; period?: any; periodCount?: any; perPeriod?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, OrmlVestingVestingSchedule]>;
1197 /**1022 /**
1198 * Generic tx1023 * Generic tx
1199 **/1024 **/
modifiedtests/src/interfaces/augment-types.tsdiffbeforeafterboth
2/* eslint-disable */2/* eslint-disable */
33
4import type { EthereumBlock, EthereumLog, EthereumReceipt, EthereumTransactionLegacyTransaction, EvmCoreErrorExitReason, FpRpcTransactionStatus } from './ethereum';4import type { EthereumBlock, EthereumLog, EthereumReceipt, EthereumTransactionLegacyTransaction, EvmCoreErrorExitReason, FpRpcTransactionStatus } from './ethereum';
5import type { NftDataStructsAccessMode, NftDataStructsCollection, NftDataStructsCollectionId, NftDataStructsCollectionLimits, NftDataStructsCollectionMode, NftDataStructsCreateItemData, NftDataStructsMetaUpdatePermission, NftDataStructsSchemaVersion, NftDataStructsSponsorshipState, NftDataStructsTokenId, PalletCommonAccountBasicCrossAccountIdRepr, PalletNonfungibleItemData, PalletRefungibleItemData, PalletUnqSchedulerCallSpec, PalletUnqSchedulerReleases, PalletUnqSchedulerScheduledV2 } from './nft';
6import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundStatus, CumulusPalletXcmpQueueOutboundStatus, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1PersistedValidationData } from './polkadot';5import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundStatus, CumulusPalletXcmpQueueOutboundStatus, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1PersistedValidationData } from './polkadot';
6import type { PalletCommonAccountBasicCrossAccountIdRepr, PalletNonfungibleItemData, PalletRefungibleItemData, PalletUnqSchedulerCallSpec, PalletUnqSchedulerReleases, PalletUnqSchedulerScheduledV2, UpDataStructsAccessMode, UpDataStructsCollection, UpDataStructsCollectionId, UpDataStructsCollectionLimits, UpDataStructsCollectionMode, UpDataStructsCollectionStats, UpDataStructsCreateItemData, UpDataStructsMetaUpdatePermission, UpDataStructsSchemaVersion, UpDataStructsSponsorshipState, UpDataStructsTokenId } from './unique';
7import type { BitVec, Bool, Bytes, Data, I128, I16, I256, I32, I64, I8, Json, Null, Raw, StorageKey, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types';7import type { BitVec, Bool, Bytes, Data, I128, I16, I256, I32, I64, I8, Json, Null, Raw, StorageKey, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types';
8import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets';8import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets';
9import type { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/types/interfaces/attestations';9import type { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/types/interfaces/attestations';
622 NextAuthority: NextAuthority;622 NextAuthority: NextAuthority;
623 NextConfigDescriptor: NextConfigDescriptor;623 NextConfigDescriptor: NextConfigDescriptor;
624 NextConfigDescriptorV1: NextConfigDescriptorV1;624 NextConfigDescriptorV1: NextConfigDescriptorV1;
625 NftDataStructsAccessMode: NftDataStructsAccessMode;
626 NftDataStructsCollection: NftDataStructsCollection;
627 NftDataStructsCollectionId: NftDataStructsCollectionId;
628 NftDataStructsCollectionLimits: NftDataStructsCollectionLimits;
629 NftDataStructsCollectionMode: NftDataStructsCollectionMode;
630 NftDataStructsCreateItemData: NftDataStructsCreateItemData;
631 NftDataStructsMetaUpdatePermission: NftDataStructsMetaUpdatePermission;
632 NftDataStructsSchemaVersion: NftDataStructsSchemaVersion;
633 NftDataStructsSponsorshipState: NftDataStructsSponsorshipState;
634 NftDataStructsTokenId: NftDataStructsTokenId;
635 NodeRole: NodeRole;625 NodeRole: NodeRole;
636 Nominations: Nominations;626 Nominations: Nominations;
637 NominatorIndex: NominatorIndex;627 NominatorIndex: NominatorIndex;
1025 UnlockChunk: UnlockChunk;1015 UnlockChunk: UnlockChunk;
1026 UnrewardedRelayer: UnrewardedRelayer;1016 UnrewardedRelayer: UnrewardedRelayer;
1027 UnrewardedRelayersState: UnrewardedRelayersState;1017 UnrewardedRelayersState: UnrewardedRelayersState;
1018 UpDataStructsAccessMode: UpDataStructsAccessMode;
1019 UpDataStructsCollection: UpDataStructsCollection;
1020 UpDataStructsCollectionId: UpDataStructsCollectionId;
1021 UpDataStructsCollectionLimits: UpDataStructsCollectionLimits;
1022 UpDataStructsCollectionMode: UpDataStructsCollectionMode;
1023 UpDataStructsCollectionStats: UpDataStructsCollectionStats;
1024 UpDataStructsCreateItemData: UpDataStructsCreateItemData;
1025 UpDataStructsMetaUpdatePermission: UpDataStructsMetaUpdatePermission;
1026 UpDataStructsSchemaVersion: UpDataStructsSchemaVersion;
1027 UpDataStructsSponsorshipState: UpDataStructsSponsorshipState;
1028 UpDataStructsTokenId: UpDataStructsTokenId;
1028 UpgradeGoAhead: UpgradeGoAhead;1029 UpgradeGoAhead: UpgradeGoAhead;
1029 UpgradeRestriction: UpgradeRestriction;1030 UpgradeRestriction: UpgradeRestriction;
1030 UpwardMessage: UpwardMessage;1031 UpwardMessage: UpwardMessage;
modifiedtests/src/interfaces/definitions.tsdiffbeforeafterboth
1export {default as nft} from './nft/definitions';1export {default as unique} from './unique/definitions';
2export {default as ethereum} from './ethereum/definitions';2export {default as ethereum} from './ethereum/definitions';
3export {default as polkadot} from './polkadot/definitions';3export {default as polkadot} from './polkadot/definitions';
44
deletedtests/src/interfaces/nft/definitions.tsdiffbeforeafterboth

no changes

deletedtests/src/interfaces/nft/index.tsdiffbeforeafterboth

no changes

deletedtests/src/interfaces/nft/types.tsdiffbeforeafterboth

no changes

modifiedtests/src/interfaces/types.tsdiffbeforeafterboth
1// Auto-generated via `yarn polkadot-types-from-defs`, do not edit1// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
2/* eslint-disable */2/* eslint-disable */
33
4export * from './nft/types';4export * from './unique/types';
5export * from './ethereum/types';5export * from './ethereum/types';
6export * from './polkadot/types';6export * from './polkadot/types';
77
addedtests/src/interfaces/unique/definitions.tsdiffbeforeafterboth

no changes

addedtests/src/interfaces/unique/index.tsdiffbeforeafterboth

no changes

addedtests/src/interfaces/unique/types.tsdiffbeforeafterboth

no changes

modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
35 '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',
42 'nftpayment',
43 'charging',42 'charging',
44];43];
4544
modifiedtests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth
8import chaiAsPromised from 'chai-as-promised';8import chaiAsPromised from 'chai-as-promised';
9import privateKey from './substrate/privateKey';9import privateKey from './substrate/privateKey';
10import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';10import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
11import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId} from './util/helpers';11import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId, queryCollectionExpectSuccess} from './util/helpers';
1212
13chai.use(chaiAsPromised);13chai.use(chaiAsPromised);
14const expect = chai.expect;14const expect = chai.expect;
19 const collectionId = await createCollectionExpectSuccess();19 const collectionId = await createCollectionExpectSuccess();
20 const alice = privateKey('//Alice');20 const alice = privateKey('//Alice');
21 const bob = privateKey('//Bob');21 const bob = privateKey('//Bob');
22 const collection = (await api.query.common.collectionById(collectionId)).unwrap();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 Bob
25 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);
2727
28 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));
3030
31 // then remove bob from admins of collection31 // then remove bob from admins of collection
32 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);
3434
35 const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);35 const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);
43 const alice = privateKey('//Alice');43 const alice = privateKey('//Alice');
44 const bob = privateKey('//Bob');44 const bob = privateKey('//Bob');
45 const charlie = privateKey('//Charlie');45 const charlie = privateKey('//Charlie');
46 const collection = (await api.query.common.collectionById(collectionId)).unwrap();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 Bob
49 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);
5151
52 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);
5454
55 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));
5757
58 // then remove bob from admins of collection58 // then remove bob from admins of collection
59 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);
6161
62 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);
7474
75 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');
8888
89 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;
9191
92 // 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.)
103103
104 await destroyCollectionExpectSuccess(collectionId);104 await destroyCollectionExpectSuccess(collectionId);
105105
106 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;
108108
109 // 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');
120120
121 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);
123123
124 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;
126126
127 // 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.)
modifiedtests/src/removeCollectionSponsor.test.tsdiffbeforeafterboth
18 removeCollectionSponsorExpectFailure,18 removeCollectionSponsorExpectFailure,
19 normalizeAccountId,19 normalizeAccountId,
20 addCollectionAdminExpectSuccess,20 addCollectionAdminExpectSuccess,
21 getCreatedCollectionCount,
21} from './util/helpers';22} from './util/helpers';
22import {Keyring} from '@polkadot/api';23import {Keyring} from '@polkadot/api';
23import {IKeyringPair} from '@polkadot/types/types';24import {IKeyringPair} from '@polkadot/types/types';
5354
54 // Transfer this tokens from unused address to Alice - should fail55 // Transfer this tokens from unused address to Alice - should fail
55 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();
56 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);
57 const badTransaction = async function () {58 const badTransaction = async function () {
58 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);59 await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);
59 };60 };
98 // Find the collection that never existed99 // Find the collection that never existed
99 let collectionId = 0;100 let collectionId = 0;
100 await usingApi(async (api) => {101 await usingApi(async (api) => {
101 collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;102 collectionId = await getCreatedCollectionCount(api) + 1;
102 });103 });
103104
104 await removeCollectionSponsorExpectFailure(collectionId);105 await removeCollectionSponsorExpectFailure(collectionId);
modifiedtests/src/removeFromAllowList.test.tsdiffbeforeafterboth
37 });37 });
3838
39 it('ensure bob is not in allowlist after removal', async () => {39 it('ensure bob is not in allowlist after removal', async () => {
40 await usingApi(async () => {40 await usingApi(async api => {
41 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});41 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
42 await enableAllowListExpectSuccess(alice, collectionId);42 await enableAllowListExpectSuccess(alice, collectionId);
43 await addToAllowListExpectSuccess(alice, collectionId, bob.address);43 await addToAllowListExpectSuccess(alice, collectionId, bob.address);
4444
45 await removeFromAllowListExpectSuccess(alice, collectionId, normalizeAccountId(bob.address));45 await removeFromAllowListExpectSuccess(alice, collectionId, normalizeAccountId(bob.address));
46 expect(await isAllowlisted(collectionId, bob.address)).to.be.false;46 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.false;
47 });47 });
48 });48 });
4949
104 });104 });
105105
106 it('ensure address is not in allowlist after removal', async () => {106 it('ensure address is not in allowlist after removal', async () => {
107 await usingApi(async () => {107 await usingApi(async api => {
108 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});108 const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
109 await enableAllowListExpectSuccess(alice, collectionId);109 await enableAllowListExpectSuccess(alice, collectionId);
110 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);110 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
111 await addToAllowListExpectSuccess(alice, collectionId, charlie.address);111 await addToAllowListExpectSuccess(alice, collectionId, charlie.address);
112 await removeFromAllowListExpectSuccess(bob, collectionId, normalizeAccountId(charlie.address));112 await removeFromAllowListExpectSuccess(bob, collectionId, normalizeAccountId(charlie.address));
113 expect(await isAllowlisted(collectionId, charlie.address)).to.be.false;113 expect(await isAllowlisted(api, collectionId, charlie.address)).to.be.false;
114 });114 });
115 });115 });
116116
modifiedtests/src/scheduler.test.tsdiffbeforeafterboth
1717
18chai.use(chaiAsPromised);18chai.use(chaiAsPromised);
1919
20describe('Integration Test scheduler base transaction', () => {20describe.skip('Integration Test scheduler base transaction', () => {
21 it('User can transfer owned token with delay (scheduler)', async () => {21 it('User can transfer owned token with delay (scheduler)', async () => {
22 await usingApi(async () => {22 await usingApi(async () => {
23 const alice = privateKey('//Alice');23 const alice = privateKey('//Alice');
modifiedtests/src/setCollectionLimits.test.tsdiffbeforeafterboth
41 });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 };
8383
84 // The first time84 // The first time
85 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);
9494
95 // The second time95 // The second time
96 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,
modifiedtests/src/setCollectionSponsor.test.tsdiffbeforeafterboth
11 destroyCollectionExpectSuccess,11 destroyCollectionExpectSuccess,
12 setCollectionSponsorExpectFailure,12 setCollectionSponsorExpectFailure,
13 addCollectionAdminExpectSuccess,13 addCollectionAdminExpectSuccess,
14 getCreatedCollectionCount,
14} from './util/helpers';15} from './util/helpers';
15import {Keyring} from '@polkadot/api';16import {Keyring} from '@polkadot/api';
16import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
77 // Find the collection that never existed78 // Find the collection that never existed
78 let collectionId = 0;79 let collectionId = 0;
79 await usingApi(async (api) => {80 await usingApi(async (api) => {
80 collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;81 collectionId = await getCreatedCollectionCount(api) + 1;
81 });82 });
8283
83 await setCollectionSponsorExpectFailure(collectionId, bob.address);84 await setCollectionSponsorExpectFailure(collectionId, bob.address);
modifiedtests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth
12 createCollectionExpectSuccess,12 createCollectionExpectSuccess,
13 destroyCollectionExpectSuccess,13 destroyCollectionExpectSuccess,
14 addCollectionAdminExpectSuccess,14 addCollectionAdminExpectSuccess,
15 queryCollectionExpectSuccess,
16 getCreatedCollectionCount,
15} from './util/helpers';17} from './util/helpers';
1618
17chai.use(chaiAsPromised);19chai.use(chaiAsPromised);
37 it('Run extrinsic with parameters of the collection id, set the scheme', async () => {39 it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
38 await usingApi(async (api) => {40 await usingApi(async (api) => {
39 const collectionId = await createCollectionExpectSuccess();41 const collectionId = await createCollectionExpectSuccess();
40 const collection = (await api.query.common.collectionById(collectionId)).unwrap();42 const collection = await queryCollectionExpectSuccess(api, collectionId);
41 expect(collection.owner.toString()).to.be.eq(alice.address);43 expect(collection.owner.toString()).to.be.eq(alice.address);
42 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);44 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);
43 await submitTransactionAsync(alice, setShema);45 await submitTransactionAsync(alice, setShema);
44 });46 });
45 });47 });
4648
47 it('Collection admin can set the scheme', async () => {49 it('Collection admin can set the scheme', async () => {
48 await usingApi(async (api) => {50 await usingApi(async (api) => {
49 const collectionId = await createCollectionExpectSuccess();51 const collectionId = await createCollectionExpectSuccess();
50 const collection = (await api.query.common.collectionById(collectionId)).unwrap();52 const collection = await queryCollectionExpectSuccess(api, collectionId);
51 expect(collection.owner.toString()).to.be.eq(alice.address);53 expect(collection.owner.toString()).to.be.eq(alice.address);
52 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);54 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
53 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);55 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);
54 await submitTransactionAsync(bob, setShema);56 await submitTransactionAsync(bob, setShema);
55 });57 });
56 });58 });
5759
58 it('Checking collection data using the ConstOnChainSchema parameter', async () => {60 it('Checking collection data using the ConstOnChainSchema parameter', async () => {
59 await usingApi(async (api) => {61 await usingApi(async (api) => {
60 const collectionId = await createCollectionExpectSuccess();62 const collectionId = await createCollectionExpectSuccess();
61 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);63 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);
62 await submitTransactionAsync(alice, setShema);64 await submitTransactionAsync(alice, setShema);
63 const collection = (await api.query.common.collectionById(collectionId)).unwrap();65 const collection = await queryCollectionExpectSuccess(api, collectionId);
64 expect(collection.constOnChainSchema.toString()).to.be.eq(shema);66 expect(collection.constOnChainSchema.toString()).to.be.eq(shema);
65 });67 });
66 });68 });
71 it('Set a non-existent collection', async () => {73 it('Set a non-existent collection', async () => {
72 await usingApi(async (api) => {74 await usingApi(async (api) => {
73 // tslint:disable-next-line: radix75 // tslint:disable-next-line: radix
74 const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;76 const collectionId = await getCreatedCollectionCount(api) + 1;
75 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);77 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);
76 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;78 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;
77 });79 });
78 });80 });
81 await usingApi(async (api) => {83 await usingApi(async (api) => {
82 const collectionId = await createCollectionExpectSuccess();84 const collectionId = await createCollectionExpectSuccess();
83 await destroyCollectionExpectSuccess(collectionId);85 await destroyCollectionExpectSuccess(collectionId);
84 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);86 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);
85 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;87 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;
86 });88 });
87 });89 });
8890
89 it('Set invalid data in schema (size too large:> 1024b)', async () => {91 it('Set invalid data in schema (size too large:> 1024b)', async () => {
90 await usingApi(async (api) => {92 await usingApi(async (api) => {
91 const collectionId = await createCollectionExpectSuccess();93 const collectionId = await createCollectionExpectSuccess();
92 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, largeShema);94 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, largeShema);
93 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;95 await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;
94 });96 });
95 });97 });
9698
97 it('Execute method not on behalf of the collection owner', async () => {99 it('Execute method not on behalf of the collection owner', async () => {
98 await usingApi(async (api) => {100 await usingApi(async (api) => {
99 const collectionId = await createCollectionExpectSuccess();101 const collectionId = await createCollectionExpectSuccess();
100 const collection = (await api.query.common.collectionById(collectionId)).unwrap();102 const collection = await queryCollectionExpectSuccess(api, collectionId);
101 expect(collection.owner.toString()).to.be.eq(alice.address);103 expect(collection.owner.toString()).to.be.eq(alice.address);
102 const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);104 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, shema);
103 await expect(submitTransactionExpectFailAsync(bob, setShema)).to.be.rejected;105 await expect(submitTransactionExpectFailAsync(bob, setShema)).to.be.rejected;
104 });106 });
105 });107 });
modifiedtests/src/setPublicAccessMode.test.tsdiffbeforeafterboth
19 enableAllowListExpectSuccess,19 enableAllowListExpectSuccess,
20 normalizeAccountId,20 normalizeAccountId,
21 addCollectionAdminExpectSuccess,21 addCollectionAdminExpectSuccess,
22 getCreatedCollectionCount,
22} from './util/helpers';23} from './util/helpers';
2324
24chai.use(chaiAsPromised);25chai.use(chaiAsPromised);
50 const collectionId = await createCollectionExpectSuccess();51 const collectionId = await createCollectionExpectSuccess();
51 await enableAllowListExpectSuccess(alice, collectionId);52 await enableAllowListExpectSuccess(alice, collectionId);
52 await enablePublicMintingExpectSuccess(alice, collectionId);53 await enablePublicMintingExpectSuccess(alice, collectionId);
53 const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(bob.address), 'NFT');54 const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(bob.address), 'NFT');
54 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;55 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
55 });56 });
56 });57 });
60 it('Set a non-existent collection', async () => {61 it('Set a non-existent collection', async () => {
61 await usingApi(async (api: ApiPromise) => {62 await usingApi(async (api: ApiPromise) => {
62 // tslint:disable-next-line: radix63 // tslint:disable-next-line: radix
63 const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;64 const collectionId = await getCreatedCollectionCount(api) + 1;
64 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');65 const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');
65 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;66 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
66 });67 });
67 });68 });
71 // tslint:disable-next-line: no-bitwise72 // tslint:disable-next-line: no-bitwise
72 const collectionId = await createCollectionExpectSuccess();73 const collectionId = await createCollectionExpectSuccess();
73 await destroyCollectionExpectSuccess(collectionId);74 await destroyCollectionExpectSuccess(collectionId);
74 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');75 const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');
75 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;76 await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
76 });77 });
77 });78 });
88 await usingApi(async (api: ApiPromise) => {89 await usingApi(async (api: ApiPromise) => {
89 // tslint:disable-next-line: no-bitwise90 // tslint:disable-next-line: no-bitwise
90 const collectionId = await createCollectionExpectSuccess();91 const collectionId = await createCollectionExpectSuccess();
91 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');92 const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');
92 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;93 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
93 });94 });
94 });95 });
106 // tslint:disable-next-line: no-bitwise107 // tslint:disable-next-line: no-bitwise
107 const collectionId = await createCollectionExpectSuccess();108 const collectionId = await createCollectionExpectSuccess();
108 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);109 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
109 const tx = api.tx.nft.setPublicAccessMode(collectionId, 'AllowList');110 const tx = api.tx.unique.setPublicAccessMode(collectionId, 'AllowList');
110 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;111 await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
111 });112 });
112 });113 });
modifiedtests/src/setSchemaVersion.test.tsdiffbeforeafterboth
41 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);
8585
86 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 });
modifiedtests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth
12 createCollectionExpectSuccess,12 createCollectionExpectSuccess,
13 destroyCollectionExpectSuccess,13 destroyCollectionExpectSuccess,
14 addCollectionAdminExpectSuccess,14 addCollectionAdminExpectSuccess,
15 queryCollectionExpectSuccess,
16 getCreatedCollectionCount,
15} from './util/helpers';17} from './util/helpers';
1618
17chai.use(chaiAsPromised);19chai.use(chaiAsPromised);
37 it('Run extrinsic with parameters of the collection id, set the scheme', async () => {39 it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
38 await usingApi(async (api) => {40 await usingApi(async (api) => {
39 const collectionId = await createCollectionExpectSuccess();41 const collectionId = await createCollectionExpectSuccess();
40 const collection = (await api.query.common.collectionById(collectionId)).unwrap();42 const collection = await queryCollectionExpectSuccess(api, collectionId);
41 expect(collection.owner.toString()).to.be.eq(alice.address);43 expect(collection.owner.toString()).to.be.eq(alice.address);
42 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);44 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
43 await submitTransactionAsync(alice, setSchema);45 await submitTransactionAsync(alice, setSchema);
44 });46 });
45 });47 });
4648
47 it('Checking collection data using the setVariableOnChainSchema parameter', async () => {49 it('Checking collection data using the setVariableOnChainSchema parameter', async () => {
48 await usingApi(async (api) => {50 await usingApi(async (api) => {
49 const collectionId = await createCollectionExpectSuccess();51 const collectionId = await createCollectionExpectSuccess();
50 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);52 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
51 await submitTransactionAsync(alice, setSchema);53 await submitTransactionAsync(alice, setSchema);
52 const collection = (await api.query.common.collectionById(collectionId)).unwrap();54 const collection = await queryCollectionExpectSuccess(api, collectionId);
53 expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);55 expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);
5456
55 });57 });
61 it('Run extrinsic with parameters of the collection id, set the scheme', async () => {63 it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
62 await usingApi(async (api) => {64 await usingApi(async (api) => {
63 const collectionId = await createCollectionExpectSuccess();65 const collectionId = await createCollectionExpectSuccess();
64 const collection = (await api.query.common.collectionById(collectionId)).unwrap();66 const collection = await queryCollectionExpectSuccess(api, collectionId);
65 expect(collection.owner.toString()).to.be.eq(alice.address);67 expect(collection.owner.toString()).to.be.eq(alice.address);
66 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);68 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
67 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);69 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
68 await submitTransactionAsync(bob, setSchema);70 await submitTransactionAsync(bob, setSchema);
69 });71 });
70 });72 });
73 await usingApi(async (api) => {75 await usingApi(async (api) => {
74 const collectionId = await createCollectionExpectSuccess();76 const collectionId = await createCollectionExpectSuccess();
75 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);77 await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
76 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);78 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
77 await submitTransactionAsync(bob, setSchema);79 await submitTransactionAsync(bob, setSchema);
78 const collection = (await api.query.common.collectionById(collectionId)).unwrap();80 const collection = await queryCollectionExpectSuccess(api, collectionId);
79 expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);81 expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);
8082
81 });83 });
87 it('Set a non-existent collection', async () => {89 it('Set a non-existent collection', async () => {
88 await usingApi(async (api) => {90 await usingApi(async (api) => {
89 // tslint:disable-next-line: radix91 // tslint:disable-next-line: radix
90 const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;92 const collectionId = await getCreatedCollectionCount(api) + 1;
91 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);93 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
92 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;94 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
93 });95 });
94 });96 });
97 await usingApi(async (api) => {99 await usingApi(async (api) => {
98 const collectionId = await createCollectionExpectSuccess();100 const collectionId = await createCollectionExpectSuccess();
99 await destroyCollectionExpectSuccess(collectionId);101 await destroyCollectionExpectSuccess(collectionId);
100 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);102 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
101 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;103 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
102 });104 });
103 });105 });
104106
105 it('Set invalid data in schema (size too large:> 1024b)', async () => {107 it('Set invalid data in schema (size too large:> 1024b)', async () => {
106 await usingApi(async (api) => {108 await usingApi(async (api) => {
107 const collectionId = await createCollectionExpectSuccess();109 const collectionId = await createCollectionExpectSuccess();
108 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, largeSchema);110 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, largeSchema);
109 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;111 await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
110 });112 });
111 });113 });
112114
113 it('Execute method not on behalf of the collection owner', async () => {115 it('Execute method not on behalf of the collection owner', async () => {
114 await usingApi(async (api) => {116 await usingApi(async (api) => {
115 const collectionId = await createCollectionExpectSuccess();117 const collectionId = await createCollectionExpectSuccess();
116 const collection = (await api.query.common.collectionById(collectionId)).unwrap();118 const collection = await queryCollectionExpectSuccess(api, collectionId);
117 expect(collection.owner.toString()).to.be.eq(alice.address);119 expect(collection.owner.toString()).to.be.eq(alice.address);
118 const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);120 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, schema);
119 await expect(submitTransactionExpectFailAsync(bob, setSchema)).to.be.rejected;121 await expect(submitTransactionExpectFailAsync(bob, setSchema)).to.be.rejected;
120 });122 });
121 });123 });
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
24 },24 },
25 },25 },
26 rpc: {26 rpc: {
27 nft: defs.nft.rpc,27 unique: defs.unique.rpc,
28 },28 },
29 };29 };
30}30}
modifiedtests/src/toggleContractAllowList.test.tsdiffbeforeafterboth
27 await usingApi(async api => {27 await usingApi(async api => {
28 const [contract, deployer] = await deployFlipper(api);28 const [contract, deployer] = await deployFlipper(api);
2929
30 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();
3434
35 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();
6161
62 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();
7171
72 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();
8181
82 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();
9191
92 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);
106106
107 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();
113113
114 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');
130130
131 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();
135135
136 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);
145145
146 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();
150150
151 expect(enabledBefore).to.be.false;151 expect(enabledBefore).to.be.false;
152 expect(enabled).to.be.false;152 expect(enabled).to.be.false;
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
19 transferExpectFailure,19 transferExpectFailure,
20 transferExpectSuccess,20 transferExpectSuccess,
21 addCollectionAdminExpectSuccess,21 addCollectionAdminExpectSuccess,
22 getCreatedCollectionCount,
23 toSubstrateAddress,
24 getTokenOwner,
25 normalizeAccountId,
26 getBalance as getTokenBalance,
22} from './util/helpers';27} from './util/helpers';
2328
24let alice: IKeyringPair;29let alice: IKeyringPair;
132 it('Transfer with not existed collection_id', async () => {137 it('Transfer with not existed collection_id', async () => {
133 await usingApi(async (api) => {138 await usingApi(async (api) => {
134 // nft139 // nft
135 const nftCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();140 const nftCollectionCount = await getCreatedCollectionCount(api);
136 await transferExpectFailure(nftCollectionCount + 1, 1, alice, bob, 1);141 await transferExpectFailure(nftCollectionCount + 1, 1, alice, bob, 1);
137 // fungible142 // fungible
138 const fungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();143 const fungibleCollectionCount = await getCreatedCollectionCount(api);
139 await transferExpectFailure(fungibleCollectionCount + 1, 0, alice, bob, 1);144 await transferExpectFailure(fungibleCollectionCount + 1, 0, alice, bob, 1);
140 // reFungible145 // reFungible
141 const reFungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();146 const reFungibleCollectionCount = await getCreatedCollectionCount(api);
142 await transferExpectFailure(reFungibleCollectionCount + 1, 1, alice, bob, 1);147 await transferExpectFailure(reFungibleCollectionCount + 1, 1, alice, bob, 1);
143 });148 });
144 });149 });
231 });236 });
232});237});
233238
239describe('Zero value transfer(From)', () => {
240 before(async () => {
241 await usingApi(async () => {
242 alice = privateKey('//Alice');
243 bob = privateKey('//Bob');
244 });
245 });
246
247 it('NFT', async () => {
248 await usingApi(async (api: ApiPromise) => {
249 const nftCollectionId = await createCollectionExpectSuccess();
250 const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
251
252 const transferTx = api.tx.unique.transfer(normalizeAccountId(bob), nftCollectionId, newNftTokenId, 0);
253 await submitTransactionAsync(alice, transferTx);
254 const address = normalizeAccountId(await getTokenOwner(api, nftCollectionId, newNftTokenId));
255
256 expect(toSubstrateAddress(address)).to.be.equal(alice.address);
257 });
258 });
259
260 it('RFT', async () => {
261 await usingApi(async (api: ApiPromise) => {
262 const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
263 const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
264 const balanceBeforeAlice = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(alice), newReFungibleTokenId);
265 const balanceBeforeBob = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(bob), newReFungibleTokenId);
266
267 const transferTx = api.tx.unique.transfer(normalizeAccountId(bob), reFungibleCollectionId, newReFungibleTokenId, 0);
268 await submitTransactionAsync(alice, transferTx);
269
270 const balanceAfterAlice = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(alice), newReFungibleTokenId);
271 const balanceAfterBob = await getTokenBalance(api, reFungibleCollectionId, normalizeAccountId(bob), newReFungibleTokenId);
272
273 expect((balanceBeforeAlice)).to.be.equal(balanceAfterAlice);
274 expect((balanceBeforeBob)).to.be.equal(balanceAfterBob);
275 });
276 });
277
278 it('Fungible', async () => {
279 await usingApi(async (api: ApiPromise) => {
280 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
281 const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
282 const balanceBeforeAlice = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(alice), newFungibleTokenId);
283 const balanceBeforeBob = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(bob), newFungibleTokenId);
284
285 const transferTx = api.tx.unique.transfer(normalizeAccountId(bob), fungibleCollectionId, newFungibleTokenId, 0);
286 await submitTransactionAsync(alice, transferTx);
287
288 const balanceAfterAlice = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(alice), newFungibleTokenId);
289 const balanceAfterBob = await getTokenBalance(api, fungibleCollectionId, normalizeAccountId(bob), newFungibleTokenId);
290
291 expect((balanceBeforeAlice)).to.be.equal(balanceAfterAlice);
292 expect((balanceBeforeBob)).to.be.equal(balanceAfterBob);
293 });
294 });
295});
modifiedtests/src/transferFrom.test.tsdiffbeforeafterboth
19 transferFromExpectSuccess,19 transferFromExpectSuccess,
20 burnItemExpectSuccess,20 burnItemExpectSuccess,
21 setCollectionLimitsExpectSuccess,21 setCollectionLimitsExpectSuccess,
22 getCreatedCollectionCount,
22} from './util/helpers';23} from './util/helpers';
2324
24chai.use(chaiAsPromised);25chai.use(chaiAsPromised);
109 it('transferFrom for a collection that does not exist', async () => {110 it('transferFrom for a collection that does not exist', async () => {
110 await usingApi(async (api: ApiPromise) => {111 await usingApi(async (api: ApiPromise) => {
111 // nft112 // nft
112 const nftCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();113 const nftCollectionCount = await getCreatedCollectionCount(api);
113 await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);114 await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);
114115
115 await transferFromExpectFail(nftCollectionCount + 1, 1, bob, alice, charlie, 1);116 await transferFromExpectFail(nftCollectionCount + 1, 1, bob, alice, charlie, 1);
116117
117 // fungible118 // fungible
118 const fungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();119 const fungibleCollectionCount = await getCreatedCollectionCount(api);
119 await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);120 await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);
120121
121 await transferFromExpectFail(fungibleCollectionCount + 1, 0, bob, alice, charlie, 1);122 await transferFromExpectFail(fungibleCollectionCount + 1, 0, bob, alice, charlie, 1);
122 // reFungible123 // reFungible
123 const reFungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();124 const reFungibleCollectionCount = await getCreatedCollectionCount(api);
124 await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);125 await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);
125126
126 await transferFromExpectFail(reFungibleCollectionCount + 1, 1, bob, alice, charlie, 1);127 await transferFromExpectFail(reFungibleCollectionCount + 1, 1, bob, alice, charlie, 1);
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
11import chai from 'chai';11import chai from 'chai';
12import chaiAsPromised from 'chai-as-promised';12import chaiAsPromised from 'chai-as-promised';
13import {alicesPublicKey} from '../accounts';13import {alicesPublicKey} from '../accounts';
14import {NftDataStructsCollection} from '../interfaces';14import {UpDataStructsCollection} from '../interfaces';
15import privateKey from '../substrate/privateKey';15import privateKey from '../substrate/privateKey';
16import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';16import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';
17import {hexToStr, strToUTF16, utf16ToStr} from './util';17import {hexToStr, strToUTF16, utf16ToStr} from './util';
105}105}
106106
107interface IGetMessage {107interface IGetMessage {
108 checkMsgNftMethod: string;108 checkMsgUnqMethod: string;
109 checkMsgTrsMethod: string;109 checkMsgTrsMethod: string;
110 checkMsgSysMethod: string;110 checkMsgSysMethod: string;
111}111}
133 variableData: number[];133 variableData: number[];
134}134}
135135
136export function nftEventMessage(events: EventRecord[]): IGetMessage {136export function uniqueEventMessage(events: EventRecord[]): IGetMessage {
137 let checkMsgNftMethod = '';137 let checkMsgUnqMethod = '';
138 let checkMsgTrsMethod = '';138 let checkMsgTrsMethod = '';
139 let checkMsgSysMethod = '';139 let checkMsgSysMethod = '';
140 events.forEach(({event: {method, section}}) => {140 events.forEach(({event: {method, section}}) => {
141 if (section === 'common') {141 if (section === 'common') {
142 checkMsgNftMethod = method;142 checkMsgUnqMethod = method;
143 } else if (section === 'treasury') {143 } else if (section === 'treasury') {
144 checkMsgTrsMethod = method;144 checkMsgTrsMethod = method;
145 } else if (section === 'system') {145 } else if (section === 'system') {
146 checkMsgSysMethod = method;146 checkMsgSysMethod = method;
147 } else { return null; }147 } else { return null; }
148 });148 });
149 const result: IGetMessage = {149 const result: IGetMessage = {
150 checkMsgNftMethod,150 checkMsgUnqMethod,
151 checkMsgTrsMethod,151 checkMsgTrsMethod,
152 checkMsgSysMethod,152 checkMsgSysMethod,
153 };153 };
269 let collectionId = 0;269 let collectionId = 0;
270 await usingApi(async (api) => {270 await usingApi(async (api) => {
271 // Get number of collections before the transaction271 // Get number of collections before the transaction
272 const collectionCountBefore = (await api.query.common.createdCollectionCount()).toNumber();272 const collectionCountBefore = await getCreatedCollectionCount(api);
273273
274 // Run the CreateCollection transaction274 // Run the CreateCollection transaction
275 const alicePrivateKey = privateKey('//Alice');275 const alicePrivateKey = privateKey('//Alice');
283 modeprm = {refungible: null};283 modeprm = {refungible: null};
284 }284 }
285285
286 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);
289289
290 // Get number of collections after the transaction290 // Get number of collections after the transaction
291 const collectionCountAfter = (await api.query.common.createdCollectionCount()).toNumber();291 const collectionCountAfter = await getCreatedCollectionCount(api);
292292
293 // Get the collection293 // Get the collection
294 const collection = (await api.query.common.collectionById(result.collectionId)).unwrap();294 const collection = await queryCollectionExpectSuccess(api, result.collectionId);
295295
296 // What to expect296 // What to expect
297 // tslint:disable-next-line:no-unused-expression297 // tslint:disable-next-line:no-unused-expression
325325
326 await usingApi(async (api) => {326 await usingApi(async (api) => {
327 // Get number of collections before the transaction327 // Get number of collections before the transaction
328 const collectionCountBefore = (await api.query.common.createdCollectionCount()).toNumber();328 const collectionCountBefore = await getCreatedCollectionCount(api);
329329
330 // Run the CreateCollection transaction330 // Run the CreateCollection transaction
331 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);
335335
336 // Get number of collections after the transaction336 // Get number of collections after the transaction
337 const collectionCountAfter = (await api.query.common.createdCollectionCount()).toNumber();337 const collectionCountAfter = await getCreatedCollectionCount(api);
338338
339 // What to expect339 // What to expect
340 // tslint:disable-next-line:no-unused-expression340 // tslint:disable-next-line:no-unused-expression
356}356}
357357
358export 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}
361361
362export function findUnusedAddresses(api: ApiPromise, amount: number): Promise<IKeyringPair[]> {362export function findUnusedAddresses(api: ApiPromise, amount: number): Promise<IKeyringPair[]> {
363 return Promise.all(new Array(amount).fill(null).map(() => findUnusedAddress(api, '_' + Date.now())));363 return Promise.all(new Array(amount).fill(null).map(() => findUnusedAddress(api, '_' + Date.now())));
364}364}
365365
366export async function findNotExistingCollection(api: ApiPromise): Promise<number> {366export async function findNotExistingCollection(api: ApiPromise): Promise<number> {
367 const totalNumber = (await api.query.common.createdCollectionCount()).toNumber();367 const totalNumber = await getCreatedCollectionCount(api);
368 const newCollection: number = totalNumber + 1;368 const newCollection: number = totalNumber + 1;
369 return newCollection;369 return newCollection;
370}370}
383 await usingApi(async (api) => {383 await usingApi(async (api) => {
384 // Run the DestroyCollection transaction384 // Run the DestroyCollection transaction
385 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 transaction
394 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;
399399
400 // What to expect400 // What to expect
401 expect((await api.query.common.collectionById(collectionId)).isNone).to.be.true;401 expect(await getDetailedCollectionInfo(api, collectionId)).to.be.null;
402 });402 });
403}403}
404404
405export 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);
410410
414414
415export 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);
420420
427427
428 // Run the transaction428 // Run the transaction
429 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);
433433
434 // Get the collection434 // Get the collection
435 const collection = (await api.query.common.collectionById(collectionId)).unwrap();435 const collection = await queryCollectionExpectSuccess(api, collectionId);
436436
437 // What to expect437 // What to expect
438 expect(result.success).to.be.true;438 expect(result.success).to.be.true;
447447
448 // Run the transaction448 // Run the transaction
449 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);
453453
454 // Get the collection454 // Get the collection
455 const collection = (await api.query.common.collectionById(collectionId)).unwrap();455 const collection = await queryCollectionExpectSuccess(api, collectionId);
456456
457 // What to expect457 // What to expect
458 expect(result.success).to.be.true;458 expect(result.success).to.be.true;
465465
466 // Run the transaction466 // Run the transaction
467 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}
475475
476 // Run the transaction476 // Run the transaction
477 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}
485485
486 // Run the transaction486 // Run the transaction
487 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);
491491
492 // Get the collection492 // Get the collection
493 const collection = (await api.query.common.collectionById(collectionId)).unwrap();493 const collection = await queryCollectionExpectSuccess(api, collectionId);
494494
495 // What to expect495 // What to expect
496 expect(result.success).to.be.true;496 expect(result.success).to.be.true;
506506
507 // Run the transaction507 // Run the transaction
508 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}
513513
514export async function setMetadataUpdatePermissionFlagExpectSuccess(sender: IKeyringPair, collectionId: number, flag: string) {514export async function setMetadataUpdatePermissionFlagExpectSuccess(sender: IKeyringPair, collectionId: number, flag: string) {
515515
516 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);
520520
525export async function setMetadataUpdatePermissionFlagExpectFailure(sender: IKeyringPair, collectionId: number, flag: string) {525export async function setMetadataUpdatePermissionFlagExpectFailure(sender: IKeyringPair, collectionId: number, flag: string) {
526526
527 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);
531531
535535
536export 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);
541541
545545
546export 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);
551551
557557
558 await usingApi(async (api) => {558 await usingApi(async (api) => {
559559
560 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);
563563
569569
570 await usingApi(async (api) => {570 await usingApi(async (api) => {
571571
572 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);
575575
579579
580export 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);
585585
589589
590export 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);
595595
599599
600export 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);
605605
610export 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}
617617
618export 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);
623623
627627
628export 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);
633633
637637
638export 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);
643643
647647
648export 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);
653653
657657
658export 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}
664664
665export 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);
670670
674674
675export 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 adminButnItemExpectSuccess
701 expect(balanceBefore >= BigInt(value)).to.be.true;701 expect(balanceBefore >= BigInt(value)).to.be.true;
702702
703 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 approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);
720 const events = await submitTransactionAsync(owner, approveNftTx);720 const events = await submitTransactionAsync(owner, approveUniqueTx);
721 const result = getGenericResult(events);721 const result = getGenericResult(events);
722 expect(result.success).to.be.true;722 expect(result.success).to.be.true;
723723
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 approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);
734 const events = await submitTransactionAsync(admin, approveNftTx);734 const events = await submitTransactionAsync(admin, approveUniqueTx);
735 const result = getGenericResult(events);735 const result = getGenericResult(events);
736 expect(result.success).to.be.true;736 expect(result.success).to.be.true;
737737
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-expression
783 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-expression
803803
804export 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;
836836
837 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);
840840
841 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-expression
903 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 approveUniqueTx = 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, approveUniqueTx)).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-expression
927 expect(result.success).to.be.false;927 expect(result.success).to.be.false;
934 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}
979979
980export 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});
988988
989 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 }
10151015
1016 const events = await submitTransactionAsync(sender, tx);1016 const events = await submitTransactionAsync(sender, tx);
10371037
1038export 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);
10411041
1042 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) => {
10541054
1055 // Run the transaction1055 // Run the transaction
1056 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);
10591059
1060 // Get the collection1060 // Get the collection
1061 const collection = (await api.query.common.collectionById(collectionId)).unwrap();1061 const collection = await queryCollectionExpectSuccess(api, collectionId);
10621062
1063 // What to expect1063 // What to expect
1064 // tslint:disable-next-line:no-unused-expression1064 // tslint:disable-next-line:no-unused-expression
1074 await usingApi(async (api) => {1074 await usingApi(async (api) => {
10751075
1076 // Run the transaction1076 // Run the transaction
1077 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);
10801080
1100 await usingApi(async (api) => {1100 await usingApi(async (api) => {
11011101
1102 // Run the transaction1102 // Run the transaction
1103 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;
11071107
1108 // Get the collection1108 // Get the collection
1109 const collection = (await api.query.common.collectionById(collectionId)).unwrap();1109 const collection = await queryCollectionExpectSuccess(api, collectionId);
11101110
1111 expect(collection.mintMode.toHuman()).to.be.equal(enabled);1111 expect(collection.mintMode.toHuman()).to.be.equal(enabled);
1112 });1112 });
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 transaction
1122 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-expression
1130export 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 transaction
1133 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-expression
1137 expect(result.success).to.be.false;1137 expect(result.success).to.be.false;
1138 });1138 });
1139}1139}
11401140
1141export async function isAllowlisted(collectionId: number, address: string | CrossAccountId) {1141export async function isAllowlisted(api: ApiPromise, collectionId: number, address: string | CrossAccountId) {
1142 return await usingApi(async (api) => {1142 return (await api.rpc.unique.allowed(collectionId, normalizeAccountId(address))).toJSON();
1143 return (await api.query.common.allowlist(collectionId, normalizeAccountId(address))).toJSON();
1144 });
1145}1143}
11461144
1147export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1145export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {
1148 await usingApi(async (api) => {1146 await usingApi(async (api) => {
1149 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.false;1147 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.false;
11501148
1151 // Run the transaction1149 // Run the transaction
1152 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1150 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));
1153 const events = await submitTransactionAsync(sender, tx);1151 const events = await submitTransactionAsync(sender, tx);
1154 const result = getGenericResult(events);1152 const result = getGenericResult(events);
1155 expect(result.success).to.be.true;1153 expect(result.success).to.be.true;
11561154
1157 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.true;1155 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;
1158 });1156 });
1159}1157}
11601158
1161export async function addToAllowListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1159export async function addToAllowListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {
1162 await usingApi(async (api) => {1160 await usingApi(async (api) => {
11631161
1164 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.true;1162 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;
11651163
1166 // Run the transaction1164 // Run the transaction
1167 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1165 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));
1168 const events = await submitTransactionAsync(sender, tx);1166 const events = await submitTransactionAsync(sender, tx);
1169 const result = getGenericResult(events);1167 const result = getGenericResult(events);
1170 expect(result.success).to.be.true;1168 expect(result.success).to.be.true;
11711169
1172 expect(await isAllowlisted(collectionId, normalizeAccountId(address))).to.be.true;1170 expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;
1173 });1171 });
1174}1172}
11751173
1176export async function addToAllowListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1174export async function addToAllowListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {
1177 await usingApi(async (api) => {1175 await usingApi(async (api) => {
11781176
1179 // Run the transaction1177 // Run the transaction
1180 const tx = api.tx.nft.addToAllowList(collectionId, normalizeAccountId(address));1178 const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));
1181 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1179 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
1182 const result = getGenericResult(events);1180 const result = getGenericResult(events);
11831181
1190export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1188export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {
1191 await usingApi(async (api) => {1189 await usingApi(async (api) => {
1192 // Run the transaction1190 // Run the transaction
1193 const tx = api.tx.nft.removeFromAllowList(collectionId, normalizeAccountId(address));1191 const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));
1194 const events = await submitTransactionAsync(sender, tx);1192 const events = await submitTransactionAsync(sender, tx);
1195 const result = getGenericResult(events);1193 const result = getGenericResult(events);
11961194
1203export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1201export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {
1204 await usingApi(async (api) => {1202 await usingApi(async (api) => {
1205 // Run the transaction1203 // Run the transaction
1206 const tx = api.tx.nft.removeFromAllowList(collectionId, normalizeAccountId(address));1204 const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));
1207 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1205 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
1208 const result = getGenericResult(events);1206 const result = getGenericResult(events);
12091207
1214}1212}
12151213
1216export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)1214export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)
1217 : Promise<NftDataStructsCollection | null> => {1215 : Promise<UpDataStructsCollection | null> => {
1218 return (await api.query.common.collectionById(collectionId)).unwrapOr(null);1216 return (await api.rpc.unique.collectionById(collectionId)).unwrapOr(null);
1219};1217};
12201218
1221export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {1219export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {
1222 // set global object - collectionsCount1220 // set global object - collectionsCount
1223 return (await api.query.common.createdCollectionCount()).toNumber();1221 return (await api.rpc.unique.collectionStats()).created.toNumber();
1224};1222};
12251223
1226export async function queryCollectionExpectSuccess(api: ApiPromise, collectionId: number): Promise<NftDataStructsCollection> {1224export async function queryCollectionExpectSuccess(api: ApiPromise, collectionId: number): Promise<UpDataStructsCollection> {
1227 return (await api.query.common.collectionById(collectionId)).unwrap();1225 return (await api.rpc.unique.collectionById(collectionId)).unwrap();
1228}1226}
12291227
1230export async function waitNewBlocks(blocksCount = 1): Promise<void> {1228export async function waitNewBlocks(blocksCount = 1): Promise<void> {