difftreelog
Merge remote-tracking branch 'origin/develop' into feature/NFTPAR-281_overflow_tests
in: master
36 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -248,13 +248,13 @@
[[package]]
name = "async-process"
-version = "1.0.1"
+version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c8cea09c1fb10a317d1b5af8024eeba256d6554763e85ecd90ff8df31c7bbda"
+checksum = "ef37b86e2fa961bae5a4d212708ea0154f904ce31d1a4a7f47e1bbc33a0c040b"
dependencies = [
"async-io",
"blocking",
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
"event-listener",
"futures-lite",
"once_cell",
@@ -534,9 +534,9 @@
[[package]]
name = "bstr"
-version = "0.2.14"
+version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf"
+checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d"
dependencies = [
"memchr",
]
@@ -1378,7 +1378,7 @@
[[package]]
name = "fork-tree"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
]
@@ -1396,7 +1396,7 @@
[[package]]
name = "frame-benchmarking"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
@@ -1414,7 +1414,7 @@
[[package]]
name = "frame-benchmarking-cli"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"Inflector",
"chrono",
@@ -1437,7 +1437,7 @@
[[package]]
name = "frame-executive"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
@@ -1453,7 +1453,7 @@
[[package]]
name = "frame-metadata"
version = "12.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"serde",
@@ -1464,12 +1464,12 @@
[[package]]
name = "frame-support"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"bitflags",
"frame-metadata",
"frame-support-procedural",
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"log",
"once_cell",
"parity-scale-codec",
@@ -1489,7 +1489,7 @@
[[package]]
name = "frame-support-procedural"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"Inflector",
"frame-support-procedural-tools",
@@ -1501,7 +1501,7 @@
[[package]]
name = "frame-support-procedural-tools"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support-procedural-tools-derive",
"proc-macro-crate",
@@ -1513,7 +1513,7 @@
[[package]]
name = "frame-support-procedural-tools-derive"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"proc-macro2",
"quote",
@@ -1523,10 +1523,10 @@
[[package]]
name = "frame-system"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"parity-scale-codec",
"serde",
"sp-core",
@@ -1539,7 +1539,7 @@
[[package]]
name = "frame-system-benchmarking"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -1553,7 +1553,7 @@
[[package]]
name = "frame-system-rpc-runtime-api"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"sp-api",
@@ -2115,9 +2115,9 @@
[[package]]
name = "hyper"
-version = "0.13.9"
+version = "0.13.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f6ad767baac13b44d4529fcf58ba2cd0995e36e7b435bc5b039de6f47e880dbf"
+checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb"
dependencies = [
"bytes 0.5.6",
"futures-channel",
@@ -2146,7 +2146,7 @@
"bytes 0.5.6",
"ct-logs",
"futures-util",
- "hyper 0.13.9",
+ "hyper 0.13.10",
"log",
"rustls 0.18.1",
"rustls-native-certs",
@@ -2168,9 +2168,9 @@
[[package]]
name = "idna"
-version = "0.2.0"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
+checksum = "de910d521f7cc3135c4de8db1cb910e0b5ed1dc6f57c381cd07e8e661ce10094"
dependencies = [
"matches",
"unicode-bidi",
@@ -2245,9 +2245,9 @@
[[package]]
name = "impl-trait-for-tuples"
-version = "0.2.0"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f65a8ecf74feeacdab8d38cb129e550ca871cccaa7d1921d8636ecd75534903"
+checksum = "d5dacb10c5b3bb92d46ba347505a9041e676bb20ad220101326bffb0c93031ee"
dependencies = [
"proc-macro2",
"quote",
@@ -2553,9 +2553,9 @@
[[package]]
name = "libc"
-version = "0.2.85"
+version = "0.2.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3"
+checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
[[package]]
name = "libloading"
@@ -3631,7 +3631,7 @@
[[package]]
name = "pallet-aura"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
@@ -3650,11 +3650,11 @@
[[package]]
name = "pallet-authorship"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"parity-scale-codec",
"sp-authorship",
"sp-inherents",
@@ -3665,7 +3665,7 @@
[[package]]
name = "pallet-balances"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -3679,7 +3679,7 @@
[[package]]
name = "pallet-contracts"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
@@ -3700,7 +3700,7 @@
[[package]]
name = "pallet-contracts-primitives"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"bitflags",
"parity-scale-codec",
@@ -3711,7 +3711,7 @@
[[package]]
name = "pallet-contracts-proc-macro"
version = "0.1.0"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"proc-macro2",
"quote",
@@ -3721,7 +3721,7 @@
[[package]]
name = "pallet-contracts-rpc"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"jsonrpc-core",
"jsonrpc-core-client",
@@ -3740,7 +3740,7 @@
[[package]]
name = "pallet-contracts-rpc-runtime-api"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"pallet-contracts-primitives",
"parity-scale-codec",
@@ -3752,7 +3752,7 @@
[[package]]
name = "pallet-grandpa"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -3794,7 +3794,7 @@
[[package]]
name = "pallet-randomness-collective-flip"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
@@ -3807,7 +3807,7 @@
[[package]]
name = "pallet-session"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
@@ -3827,7 +3827,7 @@
[[package]]
name = "pallet-sudo"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
@@ -3841,12 +3841,12 @@
[[package]]
name = "pallet-timestamp"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"parity-scale-codec",
"serde",
"sp-inherents",
@@ -3859,7 +3859,7 @@
[[package]]
name = "pallet-transaction-payment"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
@@ -3875,7 +3875,7 @@
[[package]]
name = "pallet-transaction-payment-rpc"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"jsonrpc-core",
"jsonrpc-core-client",
@@ -3892,7 +3892,7 @@
[[package]]
name = "pallet-transaction-payment-rpc-runtime-api"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"pallet-transaction-payment",
"parity-scale-codec",
@@ -3903,11 +3903,11 @@
[[package]]
name = "pallet-treasury"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-support",
"frame-system",
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"pallet-balances",
"parity-scale-codec",
"serde",
@@ -3918,7 +3918,7 @@
[[package]]
name = "pallet-vesting"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"enumflags2",
"frame-support",
@@ -4019,7 +4019,7 @@
dependencies = [
"cfg-if 1.0.0",
"hashbrown",
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"parity-util-mem-derive",
"parking_lot 0.11.1",
"primitive-types",
@@ -5010,7 +5010,7 @@
[[package]]
name = "sc-basic-authorship"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"futures-timer 3.0.2",
@@ -5033,7 +5033,7 @@
[[package]]
name = "sc-block-builder"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"sc-client-api",
@@ -5050,9 +5050,9 @@
[[package]]
name = "sc-chain-spec"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"parity-scale-codec",
"sc-chain-spec-derive",
"sc-consensus-babe",
@@ -5071,7 +5071,7 @@
[[package]]
name = "sc-chain-spec-derive"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -5082,7 +5082,7 @@
[[package]]
name = "sc-cli"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"chrono",
"fdlimit",
@@ -5120,7 +5120,7 @@
[[package]]
name = "sc-client-api"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"derive_more",
"fnv",
@@ -5154,7 +5154,7 @@
[[package]]
name = "sc-client-db"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"blake2-rfc",
"hash-db",
@@ -5184,7 +5184,7 @@
[[package]]
name = "sc-consensus"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"sc-client-api",
"sp-blockchain",
@@ -5195,7 +5195,7 @@
[[package]]
name = "sc-consensus-aura"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"derive_more",
"futures 0.3.12",
@@ -5226,7 +5226,7 @@
[[package]]
name = "sc-consensus-babe"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"derive_more",
"fork-tree",
@@ -5271,7 +5271,7 @@
[[package]]
name = "sc-consensus-epochs"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"fork-tree",
"parity-scale-codec",
@@ -5284,7 +5284,7 @@
[[package]]
name = "sc-consensus-slots"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"futures-timer 3.0.2",
@@ -5310,7 +5310,7 @@
[[package]]
name = "sc-consensus-uncles"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"log",
"sc-client-api",
@@ -5324,7 +5324,7 @@
[[package]]
name = "sc-executor"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"derive_more",
"lazy_static",
@@ -5353,7 +5353,7 @@
[[package]]
name = "sc-executor-common"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"derive_more",
"parity-scale-codec",
@@ -5369,7 +5369,7 @@
[[package]]
name = "sc-executor-wasmi"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"log",
"parity-scale-codec",
@@ -5384,7 +5384,7 @@
[[package]]
name = "sc-executor-wasmtime"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"log",
"parity-scale-codec",
@@ -5402,7 +5402,7 @@
[[package]]
name = "sc-finality-grandpa"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"derive_more",
"finality-grandpa",
@@ -5440,7 +5440,7 @@
[[package]]
name = "sc-informant"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"ansi_term 0.12.1",
"futures 0.3.12",
@@ -5458,7 +5458,7 @@
[[package]]
name = "sc-keystore"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"async-trait",
"derive_more",
@@ -5478,7 +5478,7 @@
[[package]]
name = "sc-light"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"hash-db",
"lazy_static",
@@ -5497,7 +5497,7 @@
[[package]]
name = "sc-network"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"async-std",
"async-trait",
@@ -5549,7 +5549,7 @@
[[package]]
name = "sc-network-gossip"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"futures-timer 3.0.2",
@@ -5565,13 +5565,13 @@
[[package]]
name = "sc-offchain"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"bytes 0.5.6",
"fnv",
"futures 0.3.12",
"futures-timer 3.0.2",
- "hyper 0.13.9",
+ "hyper 0.13.10",
"hyper-rustls",
"log",
"num_cpus",
@@ -5592,7 +5592,7 @@
[[package]]
name = "sc-peerset"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"libp2p",
@@ -5605,7 +5605,7 @@
[[package]]
name = "sc-proposer-metrics"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"log",
"substrate-prometheus-endpoint",
@@ -5614,7 +5614,7 @@
[[package]]
name = "sc-rpc"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"hash-db",
@@ -5648,7 +5648,7 @@
[[package]]
name = "sc-rpc-api"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"derive_more",
"futures 0.3.12",
@@ -5672,7 +5672,7 @@
[[package]]
name = "sc-rpc-server"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.1.30",
"jsonrpc-core",
@@ -5690,7 +5690,7 @@
[[package]]
name = "sc-service"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"directories 3.0.1",
"exit-future",
@@ -5753,7 +5753,7 @@
[[package]]
name = "sc-state-db"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"log",
"parity-scale-codec",
@@ -5768,7 +5768,7 @@
[[package]]
name = "sc-telemetry"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"chrono",
"futures 0.3.12",
@@ -5790,7 +5790,7 @@
[[package]]
name = "sc-tracing"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"ansi_term 0.12.1",
"atty",
@@ -5818,7 +5818,7 @@
[[package]]
name = "sc-tracing-proc-macro"
version = "2.0.0"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -5829,7 +5829,7 @@
[[package]]
name = "sc-transaction-graph"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"derive_more",
"futures 0.3.12",
@@ -5851,7 +5851,7 @@
[[package]]
name = "sc-transaction-pool"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"futures-diagnose",
@@ -6014,9 +6014,9 @@
[[package]]
name = "serde_json"
-version = "1.0.61"
+version = "1.0.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a"
+checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486"
dependencies = [
"itoa",
"ryu",
@@ -6102,9 +6102,9 @@
[[package]]
name = "signal-hook"
-version = "0.1.17"
+version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729"
+checksum = "780f5e3fe0c66f67197236097d89de1e86216f1f6fdeaf47c442f854ab46c240"
dependencies = [
"libc",
"signal-hook-registry",
@@ -6206,7 +6206,7 @@
[[package]]
name = "sp-allocator"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"log",
"sp-core",
@@ -6218,7 +6218,7 @@
[[package]]
name = "sp-api"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"hash-db",
"parity-scale-codec",
@@ -6234,7 +6234,7 @@
[[package]]
name = "sp-api-proc-macro"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"blake2-rfc",
"proc-macro-crate",
@@ -6246,7 +6246,7 @@
[[package]]
name = "sp-application-crypto"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"serde",
@@ -6258,7 +6258,7 @@
[[package]]
name = "sp-arithmetic"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"integer-sqrt",
"num-traits",
@@ -6271,7 +6271,7 @@
[[package]]
name = "sp-authorship"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"sp-inherents",
@@ -6282,7 +6282,7 @@
[[package]]
name = "sp-block-builder"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"sp-api",
@@ -6294,7 +6294,7 @@
[[package]]
name = "sp-blockchain"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"log",
@@ -6312,7 +6312,7 @@
[[package]]
name = "sp-chain-spec"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"serde",
"serde_json",
@@ -6321,7 +6321,7 @@
[[package]]
name = "sp-consensus"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"futures-timer 3.0.2",
@@ -6347,7 +6347,7 @@
[[package]]
name = "sp-consensus-aura"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"sp-api",
@@ -6361,7 +6361,7 @@
[[package]]
name = "sp-consensus-babe"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"merlin",
"parity-scale-codec",
@@ -6381,7 +6381,7 @@
[[package]]
name = "sp-consensus-slots"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"sp-runtime",
@@ -6390,7 +6390,7 @@
[[package]]
name = "sp-consensus-vrf"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"schnorrkel",
@@ -6402,7 +6402,7 @@
[[package]]
name = "sp-core"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"base58",
"blake2-rfc",
@@ -6446,7 +6446,7 @@
[[package]]
name = "sp-database"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"kvdb",
"parking_lot 0.11.1",
@@ -6455,7 +6455,7 @@
[[package]]
name = "sp-debug-derive"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"proc-macro2",
"quote",
@@ -6465,7 +6465,7 @@
[[package]]
name = "sp-externalities"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"environmental",
"parity-scale-codec",
@@ -6476,7 +6476,7 @@
[[package]]
name = "sp-finality-grandpa"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"finality-grandpa",
"log",
@@ -6493,7 +6493,7 @@
[[package]]
name = "sp-inherents"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"parking_lot 0.11.1",
@@ -6505,7 +6505,7 @@
[[package]]
name = "sp-io"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"hash-db",
@@ -6529,7 +6529,7 @@
[[package]]
name = "sp-keyring"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"lazy_static",
"sp-core",
@@ -6540,7 +6540,7 @@
[[package]]
name = "sp-keystore"
version = "0.8.0"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"async-trait",
"derive_more",
@@ -6557,7 +6557,7 @@
[[package]]
name = "sp-offchain"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"sp-api",
"sp-core",
@@ -6567,7 +6567,7 @@
[[package]]
name = "sp-panic-handler"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"backtrace",
]
@@ -6575,7 +6575,7 @@
[[package]]
name = "sp-rpc"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"serde",
"sp-core",
@@ -6584,11 +6584,11 @@
[[package]]
name = "sp-runtime"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"either",
"hash256-std-hasher",
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"log",
"parity-scale-codec",
"parity-util-mem",
@@ -6605,9 +6605,9 @@
[[package]]
name = "sp-runtime-interface"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"parity-scale-codec",
"primitive-types",
"sp-externalities",
@@ -6622,7 +6622,7 @@
[[package]]
name = "sp-runtime-interface-proc-macro"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"Inflector",
"proc-macro-crate",
@@ -6634,7 +6634,7 @@
[[package]]
name = "sp-sandbox"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"sp-core",
@@ -6647,7 +6647,7 @@
[[package]]
name = "sp-serializer"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"serde",
"serde_json",
@@ -6656,7 +6656,7 @@
[[package]]
name = "sp-session"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"sp-api",
@@ -6669,7 +6669,7 @@
[[package]]
name = "sp-staking"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"parity-scale-codec",
"sp-runtime",
@@ -6679,7 +6679,7 @@
[[package]]
name = "sp-state-machine"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"hash-db",
"log",
@@ -6701,12 +6701,12 @@
[[package]]
name = "sp-std"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
[[package]]
name = "sp-storage"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"impl-serde",
"parity-scale-codec",
@@ -6719,7 +6719,7 @@
[[package]]
name = "sp-tasks"
version = "2.0.0"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"log",
"sp-core",
@@ -6732,9 +6732,9 @@
[[package]]
name = "sp-timestamp"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"parity-scale-codec",
"sp-api",
"sp-inherents",
@@ -6746,7 +6746,7 @@
[[package]]
name = "sp-tracing"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"log",
"parity-scale-codec",
@@ -6759,7 +6759,7 @@
[[package]]
name = "sp-transaction-pool"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"derive_more",
"futures 0.3.12",
@@ -6775,7 +6775,7 @@
[[package]]
name = "sp-trie"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"hash-db",
"memory-db",
@@ -6789,7 +6789,7 @@
[[package]]
name = "sp-utils"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"futures 0.3.12",
"futures-core",
@@ -6801,7 +6801,7 @@
[[package]]
name = "sp-version"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"impl-serde",
"parity-scale-codec",
@@ -6813,9 +6813,9 @@
[[package]]
name = "sp-wasm-interface"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
- "impl-trait-for-tuples 0.2.0",
+ "impl-trait-for-tuples 0.2.1",
"parity-scale-codec",
"sp-std",
"wasmi",
@@ -6934,7 +6934,7 @@
[[package]]
name = "substrate-build-script-utils"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"platforms",
]
@@ -6942,7 +6942,7 @@
[[package]]
name = "substrate-frame-rpc-system"
version = "2.0.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"frame-system-rpc-runtime-api",
"futures 0.3.12",
@@ -6965,12 +6965,12 @@
[[package]]
name = "substrate-prometheus-endpoint"
version = "0.8.1"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#0e070672cf7a7bec72fb3f26188915cfb43c440f"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=unique#c8641b52ea9acfd2cee6df8653b453edbe0bbed7"
dependencies = [
"async-std",
"derive_more",
"futures-util",
- "hyper 0.13.9",
+ "hyper 0.13.10",
"log",
"prometheus",
"tokio 0.2.25",
@@ -7599,9 +7599,9 @@
[[package]]
name = "unicode-normalization"
-version = "0.1.16"
+version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606"
+checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef"
dependencies = [
"tinyvec",
]
@@ -7676,7 +7676,7 @@
checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e"
dependencies = [
"form_urlencoded",
- "idna 0.2.0",
+ "idna 0.2.1",
"matches",
"percent-encoding 2.1.0",
]
Dockerfilediffbeforeafterboth--- a/Dockerfile
+++ b/Dockerfile
@@ -1,9 +1,9 @@
# ===== BUILD ======
-FROM phusion/baseimage:0.10.2 as builder
+FROM phusion/baseimage:18.04-1.0.0 as builder
LABEL maintainer="gz@usetech.com"
-ENV WASM_TOOLCHAIN=nightly-2020-10-01
+ENV WASM_TOOLCHAIN=nightly-2021-01-27
ARG PROFILE=release
@@ -37,7 +37,7 @@
# ===== RUN ======
-FROM phusion/baseimage:0.10.2
+FROM phusion/baseimage:18.04-1.0.0
ARG PROFILE=release
COPY --from=builder /nft_parachain/target/$PROFILE/nft /usr/local/bin
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -54,6 +54,7 @@
mod default_weights;
pub const MAX_DECIMAL_POINTS: DecimalPoints = 30;
+pub const MAX_REFUNGIBLE_PIECES: u128 = 1_000_000_000_000_000_000_000;
pub const MAX_SPONSOR_TIMEOUT: u32 = 10_368_000;
pub const MAX_TOKEN_OWNERSHIP: u32 = 10_000_000;
@@ -71,8 +72,7 @@
NFT,
// decimal points
Fungible(DecimalPoints),
- // decimal points
- ReFungible(DecimalPoints),
+ ReFungible,
}
impl Default for CollectionMode {
@@ -87,7 +87,7 @@
CollectionMode::Invalid => 0,
CollectionMode::NFT => 1,
CollectionMode::Fungible(_) => 2,
- CollectionMode::ReFungible(_) => 3,
+ CollectionMode::ReFungible => 3,
}
}
}
@@ -185,6 +185,8 @@
// Timeouts for item types in passed blocks
pub sponsor_transfer_timeout: u32,
+ pub owner_can_transfer: bool,
+ pub owner_can_destroy: bool,
}
impl Default for CollectionLimits {
@@ -193,7 +195,10 @@
account_token_ownership_limit: 10_000_000,
token_limit: u32::max_value(),
sponsored_data_size: u32::max_value(),
- sponsor_transfer_timeout: 14400 }
+ sponsor_transfer_timeout: 14400,
+ owner_can_transfer: true,
+ owner_can_destroy: true
+ }
}
}
@@ -266,6 +271,7 @@
pub struct CreateReFungibleData {
pub const_data: Vec<u8>,
pub variable_data: Vec<u8>,
+ pub pieces: u128,
}
#[derive(Encode, Decode, Debug, Clone, PartialEq)]
@@ -377,7 +383,9 @@
/// Collection limit bounds per collection exceeded
CollectionLimitBoundsExceeded,
/// Schema data size limit bound exceeded
- SchemaDataLimitExceeded
+ SchemaDataLimitExceeded,
+ /// Maximum refungibility exceeded
+ WrongRefungiblePieces
}
}
@@ -548,7 +556,6 @@
let decimal_points = match mode {
CollectionMode::Fungible(points) => points,
- CollectionMode::ReFungible(points) => points,
_ => 0
};
@@ -590,7 +597,7 @@
sponsor_confirmed: false,
variable_on_chain_schema: Vec::new(),
const_on_chain_schema: Vec::new(),
- limits: CollectionLimits::default(),
+ limits: CollectionLimits::default()
};
// Add new collection to map
@@ -933,7 +940,7 @@
Self::can_create_items_in_collection(collection_id, &target_collection, &sender, &owner)?;
Self::validate_create_item_args(&target_collection, &data)?;
- Self::create_item_no_validation(collection_id, &target_collection, owner, data)?;
+ Self::create_item_no_validation(collection_id, owner, data)?;
Ok(())
}
@@ -973,7 +980,7 @@
Self::validate_create_item_args(&target_collection, data)?;
}
for data in &items_data {
- Self::create_item_no_validation(collection_id, &target_collection, owner.clone(), data.clone())?;
+ Self::create_item_no_validation(collection_id, owner.clone(), data.clone())?;
}
Ok(())
@@ -1012,7 +1019,7 @@
{
CollectionMode::NFT => Self::burn_nft_item(collection_id, item_id)?,
CollectionMode::Fungible(_) => Self::burn_fungible_item(&sender, collection_id, value)?,
- CollectionMode::ReFungible(_) => Self::burn_refungible_item(collection_id, item_id, &sender)?,
+ CollectionMode::ReFungible => Self::burn_refungible_item(collection_id, item_id, &sender)?,
_ => ()
};
@@ -1154,7 +1161,7 @@
{
CollectionMode::NFT => Self::transfer_nft(collection_id, item_id, from, recipient)?,
CollectionMode::Fungible(_) => Self::transfer_fungible(collection_id, value, &from, &recipient)?,
- CollectionMode::ReFungible(_) => Self::transfer_refungible(collection_id, item_id, value, from.clone(), recipient)?,
+ CollectionMode::ReFungible => Self::transfer_refungible(collection_id, item_id, value, from.clone(), recipient)?,
_ => ()
};
@@ -1211,7 +1218,7 @@
match target_collection.mode
{
CollectionMode::NFT => Self::set_nft_variable_data(collection_id, item_id, data)?,
- CollectionMode::ReFungible(_) => Self::set_re_fungible_variable_data(collection_id, item_id, data)?,
+ CollectionMode::ReFungible => Self::set_re_fungible_variable_data(collection_id, item_id, data)?,
CollectionMode::Fungible(_) => fail!(Error::<T>::CantStoreMetadataInFungibleTokens),
_ => fail!(Error::<T>::UnexpectedCollectionType)
};
@@ -1551,7 +1558,7 @@
{
CollectionMode::NFT => Self::transfer_nft(collection_id, item_id, sender.clone(), recipient)?,
CollectionMode::Fungible(_) => Self::transfer_fungible(collection_id, value, &sender, &recipient)?,
- CollectionMode::ReFungible(_) => Self::transfer_refungible(collection_id, item_id, value, sender.clone(), recipient)?,
+ CollectionMode::ReFungible => Self::transfer_refungible(collection_id, item_id, value, sender.clone(), recipient)?,
_ => ()
};
@@ -1603,12 +1610,16 @@
fail!(Error::<T>::NotFungibleDataUsedToMintFungibleCollectionToken);
}
},
- CollectionMode::ReFungible(_) => {
+ CollectionMode::ReFungible => {
if let CreateItemData::ReFungible(data) = data {
// check sizes
ensure!(ChainLimit::get().custom_data_limit >= data.const_data.len() as u32, Error::<T>::TokenConstDataLimitExceeded);
ensure!(ChainLimit::get().custom_data_limit >= data.variable_data.len() as u32, Error::<T>::TokenVariableDataLimitExceeded);
+
+ // Check refungibility limits
+ ensure!(data.pieces <= MAX_REFUNGIBLE_PIECES, Error::<T>::WrongRefungiblePieces);
+ ensure!(data.pieces > 0, Error::<T>::WrongRefungiblePieces);
} else {
fail!(Error::<T>::NotReFungibleDataUsedToMintReFungibleCollectionToken);
}
@@ -1619,7 +1630,7 @@
Ok(())
}
- fn create_item_no_validation(collection_id: CollectionId, collection: &CollectionType<T::AccountId>, owner: T::AccountId, data: CreateItemData) -> DispatchResult {
+ fn create_item_no_validation(collection_id: CollectionId, owner: T::AccountId, data: CreateItemData) -> DispatchResult {
match data
{
CreateItemData::NFT(data) => {
@@ -1636,8 +1647,7 @@
},
CreateItemData::ReFungible(data) => {
let mut owner_list = Vec::new();
- let value = (10 as u128).pow(collection.decimal_points as u32);
- owner_list.push(Ownership {owner: owner.clone(), fraction: value});
+ owner_list.push(Ownership {owner: owner.clone(), fraction: data.pieces});
let item = ReFungibleItemType {
owner: owner_list,
@@ -1866,7 +1876,7 @@
CollectionMode::Fungible(_) => {
<FungibleItemList<T>>::contains_key(collection_id, &subject)
}
- CollectionMode::ReFungible(_) => {
+ CollectionMode::ReFungible => {
<ReFungibleItemList<T>>::get(collection_id, item_id)
.owner
.iter()
@@ -1895,7 +1905,7 @@
{
CollectionMode::NFT => <NftItemList<T>>::contains_key(collection_id, item_id),
CollectionMode::Fungible(_) => <FungibleItemList<T>>::contains_key(collection_id, owner),
- CollectionMode::ReFungible(_) => <ReFungibleItemList<T>>::contains_key(collection_id, item_id),
+ CollectionMode::ReFungible => <ReFungibleItemList<T>>::contains_key(collection_id, item_id),
_ => false
};
@@ -2421,7 +2431,7 @@
sponsored
}
- CollectionMode::ReFungible(_) => {
+ CollectionMode::ReFungible => {
// get correct limit
let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
pallets/nft/src/tests.rsdiffbeforeafterboth--- a/pallets/nft/src/tests.rs
+++ b/pallets/nft/src/tests.rs
@@ -35,7 +35,7 @@
}
fn default_re_fungible_data () -> CreateReFungibleData {
- CreateReFungibleData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1] }
+ CreateReFungibleData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1], pieces: 1023 }
}
fn create_test_collection_for_owner(mode: &CollectionMode, owner: u64, id: CollectionId) -> CollectionId {
@@ -114,26 +114,6 @@
}
#[test]
-fn create_re_fungible_collection_fails_with_large_decimal_numbers() {
- new_test_ext().execute_with(|| {
- default_limits();
-
- let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();
- let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();
- let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();
-
- let origin1 = Origin::signed(1);
- assert_noop!(TemplateModule::create_collection(
- origin1,
- col_name1,
- col_desc1,
- token_prefix1,
- CollectionMode::ReFungible(MAX_DECIMAL_POINTS + 1)
- ), Error::<Test>::CollectionDecimalPointLimitExceeded);
- });
-}
-
-#[test]
fn create_nft_item() {
new_test_ext().execute_with(|| {
default_limits();
@@ -176,7 +156,7 @@
fn create_refungible_item() {
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let data = default_re_fungible_data();
create_test_item(collection_id, &data.clone().into());
@@ -192,7 +172,7 @@
TemplateModule::refungible_item_id(collection_id, 1).owner[0],
Ownership {
owner: 1,
- fraction: 1000
+ fraction: 1023
}
);
});
@@ -203,7 +183,7 @@
new_test_ext().execute_with(|| {
default_limits();
- create_test_collection(&CollectionMode::ReFungible(3), 1);
+ create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
@@ -224,7 +204,7 @@
item.owner[0],
Ownership {
owner: 1,
- fraction: 1000
+ fraction: 1023
}
);
}
@@ -312,7 +292,7 @@
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let data = default_re_fungible_data();
create_test_item(collection_id, &data.clone().into());
@@ -331,23 +311,23 @@
TemplateModule::refungible_item_id(collection_id, 1).owner[0],
Ownership {
owner: 1,
- fraction: 1000
+ fraction: 1023
}
);
- assert_eq!(TemplateModule::balance_count(1, 1), 1000);
+ assert_eq!(TemplateModule::balance_count(1, 1), 1023);
assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
// change owner scenario
- assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 1000));
+ assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 1023));
assert_eq!(
TemplateModule::refungible_item_id(1, 1).owner[0],
Ownership {
owner: 2,
- fraction: 1000
+ fraction: 1023
}
);
assert_eq!(TemplateModule::balance_count(1, 1), 0);
- assert_eq!(TemplateModule::balance_count(1, 2), 1000);
+ assert_eq!(TemplateModule::balance_count(1, 2), 1023);
// assert_eq!(TemplateModule::address_tokens(1, 1), []);
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
@@ -357,7 +337,7 @@
TemplateModule::refungible_item_id(1, 1).owner[0],
Ownership {
owner: 2,
- fraction: 500
+ fraction: 523
}
);
assert_eq!(
@@ -367,7 +347,7 @@
fraction: 500
}
);
- assert_eq!(TemplateModule::balance_count(1, 2), 500);
+ assert_eq!(TemplateModule::balance_count(1, 2), 523);
assert_eq!(TemplateModule::balance_count(1, 3), 500);
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
assert_eq!(TemplateModule::address_tokens(1, 3), [1]);
@@ -378,7 +358,7 @@
TemplateModule::refungible_item_id(1, 1).owner[0],
Ownership {
owner: 2,
- fraction: 300
+ fraction: 323
}
);
assert_eq!(
@@ -388,7 +368,7 @@
fraction: 700
}
);
- assert_eq!(TemplateModule::balance_count(1, 2), 300);
+ assert_eq!(TemplateModule::balance_count(1, 2), 323);
assert_eq!(TemplateModule::balance_count(1, 3), 700);
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
assert_eq!(TemplateModule::address_tokens(1, 3), [1]);
@@ -517,7 +497,7 @@
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
let origin2 = Origin::signed(2);
@@ -525,7 +505,7 @@
let data = default_re_fungible_data();
create_test_item(collection_id, &data.into());
- assert_eq!(TemplateModule::balance_count(1, 1), 1000);
+ assert_eq!(TemplateModule::balance_count(1, 1), 1023);
assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
assert_ok!(TemplateModule::set_mint_permission(
@@ -543,8 +523,8 @@
assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 3));
// do approve
- assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 1000));
- assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1000);
+ assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 1023));
+ assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1023);
assert_ok!(TemplateModule::transfer_from(
origin2.clone(),
@@ -554,14 +534,14 @@
1,
100
));
- assert_eq!(TemplateModule::balance_count(1, 1), 900);
+ assert_eq!(TemplateModule::balance_count(1, 1), 923);
assert_eq!(TemplateModule::balance_count(1, 3), 100);
assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
assert_eq!(TemplateModule::address_tokens(1, 3), [1]);
assert_eq!(
TemplateModule::approved(1, (1, 1, 2)),
- 900
+ 923
);
});
}
@@ -717,7 +697,7 @@
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
assert_ok!(TemplateModule::set_mint_permission(
@@ -738,12 +718,12 @@
create_test_item(collection_id, &data.into());
// check balance (collection with id = 1, user id = 2)
- assert_eq!(TemplateModule::balance_count(1, 1), 1000);
+ assert_eq!(TemplateModule::balance_count(1, 1), 1023);
// burn item
- assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 1000));
+ assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 1023));
assert_noop!(
- TemplateModule::burn_item(origin1.clone(), 1, 1, 1000),
+ TemplateModule::burn_item(origin1.clone(), 1, 1, 1023),
Error::<Test>::TokenNotFound
);
@@ -807,7 +787,7 @@
let nft_collection_id = create_test_collection(&CollectionMode::NFT, 1);
let fungible_collection_id = create_test_collection(&CollectionMode::Fungible(3), 2);
- let re_fungible_collection_id = create_test_collection(&CollectionMode::ReFungible(3), 3);
+ let re_fungible_collection_id = create_test_collection(&CollectionMode::ReFungible, 3);
// check balance before
assert_eq!(TemplateModule::balance_count(nft_collection_id, 1), 0);
@@ -826,7 +806,7 @@
// check balance (collection with id = 1, user id = 1)
assert_eq!(TemplateModule::balance_count(nft_collection_id, 1), 1);
assert_eq!(TemplateModule::balance_count(fungible_collection_id, 1), 5);
- assert_eq!(TemplateModule::balance_count(re_fungible_collection_id, 1), 1000);
+ assert_eq!(TemplateModule::balance_count(re_fungible_collection_id, 1), 1023);
assert_eq!(TemplateModule::nft_item_id(nft_collection_id, 1).owner, 1);
assert_eq!(TemplateModule::fungible_item_id(fungible_collection_id, 1).value, 5);
assert_eq!(TemplateModule::refungible_item_id(re_fungible_collection_id, 1).owner[0].owner, 1);
@@ -1905,7 +1885,7 @@
new_test_ext().execute_with(|| {
default_limits();
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
@@ -1982,7 +1962,7 @@
}));
- let collection_id = create_test_collection(&CollectionMode::ReFungible(3), 1);
+ let collection_id = create_test_collection(&CollectionMode::ReFungible, 1);
let origin1 = Origin::signed(1);
runtime_types.jsondiffbeforeafterboth--- a/runtime_types.json
+++ b/runtime_types.json
@@ -1,27 +1,4 @@
{
- "Schedule": {
- "version": "u32",
- "put_code_per_byte_cost": "Gas",
- "grow_mem_cost": "Gas",
- "regular_op_cost": "Gas",
- "return_data_per_byte_cost": "Gas",
- "event_data_per_byte_cost": "Gas",
- "event_per_topic_cost": "Gas",
- "event_base_cost": "Gas",
- "call_base_cost": "Gas",
- "instantiate_base_cost": "Gas",
- "dispatch_base_cost": "Gas",
- "sandbox_data_read_cost": "Gas",
- "sandbox_data_write_cost": "Gas",
- "transfer_cost": "Gas",
- "instantiate_cost": "Gas",
- "max_event_topics": "u32",
- "max_stack_height": "u32",
- "max_memory_pages": "u32",
- "max_table_size": "u32",
- "enable_println": "bool",
- "max_subject_len": "u32"
- },
"AccessMode": {
"_enum": [
"Normal",
@@ -34,7 +11,7 @@
"Invalid": null,
"NFT": null,
"Fungible": "DecimalPoints",
- "ReFungible": "DecimalPoints"
+ "ReFungible": null
}
},
"Ownership": {
@@ -84,7 +61,8 @@
},
"CreateReFungibleData": {
"const_data": "Vec<u8>",
- "variable_data": "Vec<u8>"
+ "variable_data": "Vec<u8>",
+ "pieces": "u128"
},
"CreateItemData": {
"_enum": {
@@ -117,15 +95,8 @@
"AccountTokenOwnershipLimit": "u32",
"SponsoredMintSize": "u32",
"TokenLimit": "u32",
- "SponsorTimeout": "u32"
- },
- "AccountInfo": "AccountInfoWithProviders",
- "AccountInfoWithProviders": {
- "nonce": "Index",
- "consumers": "RefCount",
- "providers": "RefCount",
- "data": "AccountData"
+ "SponsorTimeout": "u32",
+ "OwnerCanTransfer": "bool",
+ "OwnerCanDestroy": "bool"
}
-
- }
-
\ No newline at end of file
+}
\ No newline at end of file
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -1,4 +1,9 @@
-import { ApiPromise } from '@polkadot/api';
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import { ApiPromise } from '@polkadot/api';
import BN from 'bn.js';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -112,18 +117,18 @@
];
const collectionId = await createCollectionExpectSuccess();
- const chainLimit = await api.query.nft.chainLimit() as unknown as { collections_admins_limit: BN };
- const chainLimitNumber = chainLimit.collections_admins_limit.toNumber();
- expect(chainLimitNumber).to.be.equal(5);
+ const chainLimit = await api.query.nft.chainLimit() as unknown as { CollectionAdminsLimit: BN };
+ const chainAdminLimit = chainLimit.CollectionAdminsLimit.toNumber();
+ expect(chainAdminLimit).to.be.equal(5);
- for (let i = 0; i < chainLimitNumber; i++) {
+ for (let i = 0; i < chainAdminLimit; i++) {
const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, accounts[i]);
await submitTransactionAsync(Alice, changeAdminTx);
const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
expect(adminListAfterAddAdmin).to.be.contains(accounts[i]);
}
- const tx = api.tx.nft.addCollectionAdmin(collectionId, accounts[chainLimitNumber]);
+ const tx = api.tx.nft.addCollectionAdmin(collectionId, accounts[chainAdminLimit]);
await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
});
});
tests/src/addToContractWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/addToContractWhiteList.test.ts
+++ b/tests/src/addToContractWhiteList.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from "chai";
import chaiAsPromised from 'chai-as-promised';
import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
tests/src/addToWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/addToWhiteList.test.ts
+++ b/tests/src/addToWhiteList.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -34,7 +34,7 @@
await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
});
@@ -56,7 +56,7 @@
await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 0);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 1);
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 0);
@@ -95,7 +95,7 @@
await approveExpectFail(fungibleCollectionId, 1, Alice, Bob);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await destroyCollectionExpectSuccess(reFungibleCollectionId);
await approveExpectFail(reFungibleCollectionId, 1, Alice, Bob);
});
@@ -113,7 +113,7 @@
await approveExpectFail(fungibleCollectionId, 2, Alice, Bob);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await approveExpectFail(reFungibleCollectionId, 2, Alice, Bob);
});
});
@@ -132,7 +132,7 @@
await approveExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice);
// reFungible
const reFungibleCollectionId =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice);
});
tests/src/burnItem.test.tsdiffbeforeafterboth--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
import { Keyring } from "@polkadot/api";
import { IKeyringPair } from "@polkadot/types/types";
@@ -70,7 +75,7 @@
});
it('Burn item in ReFungible collection', async () => {
const createMode = 'ReFungible';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 2 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
@@ -91,7 +96,7 @@
it('Burn owned portion of item in ReFungible collection', async () => {
const createMode = 'ReFungible';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 2 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
@@ -107,7 +112,7 @@
const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
const events2 = await submitTransactionAsync(bob, tx);
const result2 = getGenericResult(events2);
-
+
// Get balances
const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
// console.log(balance);
tests/src/change-collection-owner.test.tsdiffbeforeafterboth--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -1,4 +1,9 @@
-import chai from 'chai';
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -115,7 +115,7 @@
});
it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
@@ -247,7 +247,7 @@
});
it('ReFungible: Sponsoring is rate limited', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
tests/src/contracts.test.tsdiffbeforeafterboth--- a/tests/src/contracts.test.ts
+++ b/tests/src/contracts.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from "chai";
import chaiAsPromised from 'chai-as-promised';
import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
tests/src/createCollection.test.tsdiffbeforeafterboth--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -28,7 +28,7 @@
await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
});
it('Create new ReFungible collection', async () => {
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
});
});
tests/src/createItem.test.tsdiffbeforeafterboth--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { default as usingApi } from './substrate/substrate-api';
import { Keyring } from "@polkadot/api";
import { IKeyringPair } from "@polkadot/types/types";
@@ -28,7 +33,7 @@
});
it('Create new item in ReFungible collection', async () => {
const createMode = 'ReFungible';
- const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
+ const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
await createItemExpectSuccess(alice, newCollectionID, createMode);
});
});
tests/src/createMultipleItems.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -56,14 +56,14 @@
it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {
await usingApi(async (api: ApiPromise) => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
const Alice = privateKey('//Alice');
const args = [
- { Refungible: ['0x31', '0x31'] },
- { Refungible: ['0x32', '0x32'] },
- { Refungible: ['0x33', '0x33'] },
+ {refungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}},
+ {refungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
+ {refungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
];
const createMultipleItemsTx = await api.tx.nft
.createMultipleItems(collectionId, Alice.address, args);
@@ -137,7 +137,7 @@
// ReFungible
const collectionIdReFungible =
- await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const argsReFungible = [
{ ReFungible: ['1'.repeat(2049), '1'.repeat(2049)] },
{ ReFungible: ['2'.repeat(2049), '2'.repeat(2049)] },
tests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth--- a/tests/src/creditFeesToTreasury.test.ts
+++ b/tests/src/creditFeesToTreasury.test.ts
@@ -17,6 +17,8 @@
transferExpectSuccess
} from './util/helpers';
+import { default as waitNewBlocks } from './substrate/wait-new-blocks';
+
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -37,6 +39,8 @@
it('Total issuance does not change', async () => {
await usingApi(async (api) => {
+ await waitNewBlocks(api, 1);
+
const totalBefore = new BigNumber((await api.query.balances.totalIssuance()).toString());
const alicePrivateKey = privateKey('//Alice');
@@ -54,6 +58,8 @@
it('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async () => {
await usingApi(async (api) => {
+ await waitNewBlocks(api, 1);
+
const alicePrivateKey = privateKey('//Alice');
const treasuryBalanceBefore = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
const aliceBalanceBefore = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
@@ -74,6 +80,8 @@
it('Treasury balance increased by failed tx fee', async () => {
await usingApi(async (api) => {
+ await waitNewBlocks(api, 1);
+
const bobPrivateKey = privateKey('//Bob');
const treasuryBalanceBefore = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
const bobBalanceBefore = new BigNumber((await api.query.system.account(bobsPublicKey)).data.free.toString());
@@ -92,6 +100,8 @@
it('NFT Transactions also send fees to Treasury', async () => {
await usingApi(async (api) => {
+ await waitNewBlocks(api, 1);
+
const treasuryBalanceBefore = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
const aliceBalanceBefore = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
@@ -108,15 +118,12 @@
it('Fees are sane', async () => {
await usingApi(async (api) => {
- const treasuryBalanceBefore = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
const aliceBalanceBefore = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
await createCollectionExpectSuccess();
- const treasuryBalanceAfter = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
const aliceBalanceAfter = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
const fee = aliceBalanceBefore.minus(aliceBalanceAfter);
- const treasuryIncrease = treasuryBalanceAfter.minus(treasuryBalanceBefore);
expect(fee.dividedBy(1e15).toNumber()).to.be.lessThan(saneMaximumFee);
expect(fee.dividedBy(1e15).toNumber()).to.be.greaterThan(saneMinimumFee);
tests/src/destroyCollection.test.tsdiffbeforeafterboth--- a/tests/src/destroyCollection.test.ts
+++ b/tests/src/destroyCollection.test.ts
@@ -1,12 +1,14 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi, submitTransactionAsync } from "./substrate/substrate-api";
-import { createCollectionExpectSuccess, createCollectionExpectFailure, destroyCollectionExpectSuccess, destroyCollectionExpectFailure } from "./util/helpers";
-import type { AccountId, EventRecord } from '@polkadot/types/interfaces';
-import privateKey from './substrate/privateKey';
+import { default as usingApi } from "./substrate/substrate-api";
+import { createCollectionExpectSuccess, destroyCollectionExpectSuccess, destroyCollectionExpectFailure } from "./util/helpers";
chai.use(chaiAsPromised);
-const expect = chai.expect;
describe('integration test: ext. destroyCollection():', () => {
it('NFT collection can be destroyed', async () => {
@@ -18,7 +20,7 @@
await destroyCollectionExpectSuccess(collectionId);
});
it('ReFungible collection can be destroyed', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await destroyCollectionExpectSuccess(collectionId);
});
});
tests/src/enableContractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/enableContractSponsoring.test.ts
+++ b/tests/src/enableContractSponsoring.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/removeCollectionAdmin.test.ts
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -1,5 +1,9 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { ApiPromise } from '@polkadot/api';
-import BN from 'bn.js';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
tests/src/removeFromContractWhiteList.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/removeFromContractWhiteList.test.ts
@@ -0,0 +1,72 @@
+import privateKey from "./substrate/privateKey";
+import usingApi from "./substrate/substrate-api";
+import { deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess } from "./util/contracthelpers";
+import { addToContractWhiteListExpectSuccess, isWhitelistedInContract, removeFromContractWhiteListExpectFailure, removeFromContractWhiteListExpectSuccess, toggleContractWhitelistExpectSuccess } from "./util/helpers";
+import { IKeyringPair } from '@polkadot/types/types';
+import { expect } from "chai";
+
+describe('Integration Test removeFromContractWhiteList', () => {
+ let bob: IKeyringPair;
+
+ before(() => {
+ bob = privateKey('//Bob');
+ });
+
+ it('user is no longer whitelisted after removal', async () => {
+ await usingApi(async (api) => {
+ const [flipper, deployer] = await deployFlipper(api);
+
+ await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+
+ expect(await isWhitelistedInContract(flipper.address, bob.address)).to.be.false;
+ });
+ });
+
+ it('user can\'t execute contract after removal', async () => {
+ await usingApi(async (api) => {
+ const [flipper, deployer] = await deployFlipper(api);
+ await toggleContractWhitelistExpectSuccess(deployer, flipper.address, true);
+
+ await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await toggleFlipValueExpectSuccess(bob, flipper);
+
+ await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await toggleFlipValueExpectFailure(bob, flipper);
+ });
+ });
+
+ it('can be called twice', async () => {
+ await usingApi(async (api) => {
+ const [flipper, deployer] = await deployFlipper(api);
+
+ await addToContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ await removeFromContractWhiteListExpectSuccess(deployer, flipper.address, bob.address);
+ });
+ });
+});
+
+describe('Negative Integration Test removeFromContractWhiteList', () => {
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+
+ before(() => {
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ });
+
+ it('fails when called with non-contract address', async () => {
+ await usingApi(async () => {
+ await removeFromContractWhiteListExpectFailure(alice, alice.address, bob.address);
+ });
+ });
+
+ it('fails when executed by non owner', async () => {
+ await usingApi(async (api) => {
+ const [flipper, _] = await deployFlipper(api);
+
+ await removeFromContractWhiteListExpectFailure(alice, flipper.address, bob.address);
+ });
+ });
+});
tests/src/removeFromWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/removeFromWhiteList.test.ts
+++ b/tests/src/removeFromWhiteList.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { default as usingApi } from './substrate/substrate-api';
tests/src/setCollectionLimits.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
import { ApiPromise, Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
tests/src/setCollectionSponsor.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionSponsor.test.ts
+++ b/tests/src/setCollectionSponsor.test.ts
@@ -9,7 +9,6 @@
import { createCollectionExpectSuccess, setCollectionSponsorExpectSuccess, destroyCollectionExpectSuccess, setCollectionSponsorExpectFailure } from "./util/helpers";
import { Keyring } from "@polkadot/api";
import { IKeyringPair } from "@polkadot/types/types";
-import type { AccountId } from '@polkadot/types/interfaces';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -34,7 +33,7 @@
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
});
it('Set ReFungible collection sponsor', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: {type: 'ReFungible', decimalPoints: 0} });
+ const collectionId = await createCollectionExpectSuccess({ mode: {type: 'ReFungible'} });
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
});
tests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setConstOnChainSchema.test.ts
+++ b/tests/src/setConstOnChainSchema.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
tests/src/setContractSponsoringRateLimit.test.tsdiffbeforeafterboth--- a/tests/src/setContractSponsoringRateLimit.test.ts
+++ b/tests/src/setContractSponsoringRateLimit.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
tests/src/setMintPermission.test.tsdiffbeforeafterboth--- a/tests/src/setMintPermission.test.ts
+++ b/tests/src/setMintPermission.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
tests/src/setPublicAccessMode.test.tsdiffbeforeafterboth--- a/tests/src/setPublicAccessMode.test.ts
+++ b/tests/src/setPublicAccessMode.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion
import { ApiPromise, Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
tests/src/setSchemaVersion.test.tsdiffbeforeafterboth--- a/tests/src/setSchemaVersion.test.ts
+++ b/tests/src/setSchemaVersion.test.ts
@@ -1,7 +1,11 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion
import { ApiPromise, Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
-import BN from 'bn.js';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
tests/src/setVariableMetaData.test.tsdiffbeforeafterboth--- a/tests/src/setVariableMetaData.test.ts
+++ b/tests/src/setVariableMetaData.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
tests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setVariableOnChainSchema.test.ts
+++ b/tests/src/setVariableOnChainSchema.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import { Keyring } from '@polkadot/api';
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
tests/src/toggleContractWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/toggleContractWhiteList.test.ts
+++ b/tests/src/toggleContractWhiteList.test.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import chai from "chai";
import chaiAsPromised from 'chai-as-promised';
import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -63,7 +63,7 @@
});
});
- it('Create collection, balance transfers and check balance', async () => {
+ it('User can transfer owned token', async () => {
await usingApi(async (api) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
@@ -77,10 +77,10 @@
await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await transferExpectSuccess(reFungibleCollectionId,
- newReFungibleTokenId, Alice, Bob, 1, 'ReFungible');
+ newReFungibleTokenId, Alice, Bob, 100, 'ReFungible');
});
});
});
@@ -119,7 +119,7 @@
await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await destroyCollectionExpectSuccess(reFungibleCollectionId);
await transferExpectFail(reFungibleCollectionId,
@@ -134,7 +134,7 @@
await transferExpectFail(fungibleCollectionId, 2, Alice, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await transferExpectFail(reFungibleCollectionId,
2, Alice, Bob, 1, 'ReFungible');
});
@@ -151,7 +151,7 @@
await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);
await transferExpectFail(reFungibleCollectionId,
@@ -168,7 +168,7 @@
await transferExpectFail(fungibleCollectionId, newFungibleTokenId, Charlie, Bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await transferExpectFail(reFungibleCollectionId,
newReFungibleTokenId, Charlie, Bob, 1, 'ReFungible');
tests/src/transferFrom.test.tsdiffbeforeafterboth--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -15,6 +15,7 @@
destroyCollectionExpectSuccess,
transferFromExpectFail,
transferFromExpectSuccess,
+ burnItemExpectSuccess,
} from './util/helpers';
chai.use(chaiAsPromised);
@@ -25,7 +26,7 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
+ const Charlie = privateKey('//Charlie');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -40,11 +41,11 @@
await transferFromExpectSuccess(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
+ await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 100);
await transferFromExpectSuccess(reFungibleCollectionId,
- newReFungibleTokenId, Bob, Alice, Charlie, 1, 'ReFungible');
+ newReFungibleTokenId, Bob, Alice, Charlie, 100, 'ReFungible');
});
});
});
@@ -54,7 +55,7 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
+ const Charlie = privateKey('//Charlie');
// nft
const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
await approveExpectFail(nftCollectionCount + 1, 1, Alice, Bob);
@@ -96,7 +97,7 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
+ const Charlie = privateKey('//Charlie');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -109,7 +110,7 @@
await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await transferFromExpectFail(reFungibleCollectionId,
newReFungibleTokenId, Bob, Alice, Charlie, 1);
@@ -120,7 +121,7 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
+ const Charlie = privateKey('//Charlie');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -135,7 +136,7 @@
await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 2);
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
await transferFromExpectFail(reFungibleCollectionId,
@@ -147,8 +148,8 @@
await usingApi(async (api: ApiPromise) => {
const Alice = privateKey('//Alice');
const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
- const Dave = privateKey('//DAVE');
+ const Charlie = privateKey('//Charlie');
+ const Dave = privateKey('//Dave');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
@@ -174,7 +175,7 @@
}
// reFungible
const reFungibleCollectionId = await
- createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
try {
await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Dave, Bob);
@@ -185,4 +186,83 @@
}
});
});
+ it( 'transferFrom burnt token before approve NFT', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ const Charlie = privateKey('//Charlie');
+ // nft
+ const nftCollectionId = await createCollectionExpectSuccess();
+ const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+ await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);
+ await approveExpectFail(nftCollectionId, newNftTokenId, Alice, Bob);
+ await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
+ });
+ });
+ it( 'transferFrom burnt token before approve Fungible', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ const Charlie = privateKey('//Charlie');
+ const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+ const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+ await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, 10);
+ await approveExpectFail(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
+ await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
+
+ });
+ });
+ it( 'transferFrom burnt token before approve ReFungible', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ const Charlie = privateKey('//Charlie');
+ const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+ await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);
+ await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
+ await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
+
+ });
+ });
+
+ it( 'transferFrom burnt token after approve NFT', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ const Charlie = privateKey('//Charlie');
+ // nft
+ const nftCollectionId = await createCollectionExpectSuccess();
+ const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+ await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
+ await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);
+ await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
+ });
+ });
+ it( 'transferFrom burnt token after approve Fungible', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ const Charlie = privateKey('//Charlie');
+ const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+ const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+ await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
+ await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, 10);
+ await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
+
+ });
+ });
+ it( 'transferFrom burnt token after approve ReFungible', async () => {
+ await usingApi(async (api: ApiPromise) => {
+ const Alice = privateKey('//Alice');
+ const Bob = privateKey('//Bob');
+ const Charlie = privateKey('//Charlie');
+ const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+ const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+ await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
+ await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 1);
+ await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
+
+ });
+ });
});
tests/src/types.tsdiffbeforeafterboth--- a/tests/src/types.ts
+++ b/tests/src/types.ts
@@ -1,3 +1,8 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
import BN from 'bn.js';
export interface ICollectionInterface {
tests/src/util/helpers.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { ApiPromise, Keyring } from '@polkadot/api';7import { Enum, Struct } from '@polkadot/types/codec';8import type { AccountId, EventRecord } from '@polkadot/types/interfaces';9import { u128 } from '@polkadot/types/primitive';10import { IKeyringPair } from '@polkadot/types/types';11import { BigNumber } from 'bignumber.js';12import BN from 'bn.js';13import chai from 'chai';14import chaiAsPromised from 'chai-as-promised';15import { alicesPublicKey, nullPublicKey } from '../accounts';16import privateKey from '../substrate/privateKey';17import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';18import { ICollectionInterface } from '../types';19import { hexToStr, strToUTF16, utf16ToStr } from './util';2021chai.use(chaiAsPromised);22const expect = chai.expect;2324export const U128_MAX = (1n << 128n) - 1n;2526type GenericResult = {27 success: boolean,28};2930interface CreateCollectionResult {31 success: boolean;32 collectionId: number;33}3435interface CreateItemResult {36 success: boolean;37 collectionId: number;38 itemId: number;39}4041interface IReFungibleOwner {42 Fraction: BN;43 Owner: number[];44}4546interface ITokenDataType {47 Owner: number[];48 ConstData: number[];49 VariableData: number[];50}5152interface IFungibleTokenDataType {53 Value: BN;54}5556export interface IReFungibleTokenDataType {57 Owner: IReFungibleOwner[];58 ConstData: number[];59 VariableData: number[];60}6162export function getGenericResult(events: EventRecord[]): GenericResult {63 const result: GenericResult = {64 success: false,65 };66 events.forEach(({ phase, event: { data, method, section } }) => {67 // console.log(` ${phase}: ${section}.${method}:: ${data}`);68 if (method === 'ExtrinsicSuccess') {69 result.success = true;70 }71 });72 return result;73}7475export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {76 let success = false;77 let collectionId: number = 0;78 events.forEach(({ phase, event: { data, method, section } }) => {79 // console.log(` ${phase}: ${section}.${method}:: ${data}`);80 if (method == 'ExtrinsicSuccess') {81 success = true;82 } else if ((section == 'nft') && (method == 'Created')) {83 collectionId = parseInt(data[0].toString());84 }85 });86 const result: CreateCollectionResult = {87 success,88 collectionId,89 };90 return result;91}9293export function getCreateItemResult(events: EventRecord[]): CreateItemResult {94 let success = false;95 let collectionId: number = 0;96 let itemId: number = 0;97 events.forEach(({ phase, event: { data, method, section } }) => {98 // console.log(` ${phase}: ${section}.${method}:: ${data}`);99 if (method == 'ExtrinsicSuccess') {100 success = true;101 } else if ((section == 'nft') && (method == 'ItemCreated')) {102 collectionId = parseInt(data[0].toString());103 itemId = parseInt(data[1].toString());104 }105 });106 const result: CreateItemResult = {107 success,108 collectionId,109 itemId,110 };111 return result;112}113114interface Invalid {115 type: 'Invalid';116}117118interface Nft {119 type: 'NFT';120}121122interface Fungible {123 type: 'Fungible';124 decimalPoints: number;125}126127interface ReFungible {128 type: 'ReFungible';129 decimalPoints: number;130}131132interface Nft {133 type: 'NFT'134}135136interface Fungible {137 type: 'Fungible',138 decimalPoints: number139}140141interface ReFungible {142 type: 'ReFungible',143 decimalPoints: number144}145146type CollectionMode = Nft | Fungible | ReFungible | Invalid;147148export type CreateCollectionParams = {149 mode: CollectionMode,150 name: string,151 description: string,152 tokenPrefix: string,153};154155const defaultCreateCollectionParams: CreateCollectionParams = {156 description: 'description',157 mode: { type: 'NFT' },158 name: 'name',159 tokenPrefix: 'prefix',160}161162export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {163 const {name, description, mode, tokenPrefix } = {...defaultCreateCollectionParams, ...params};164165 let collectionId: number = 0;166 await usingApi(async (api) => {167 // Get number of collections before the transaction168 const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);169170 // Run the CreateCollection transaction171 const alicePrivateKey = privateKey('//Alice');172173 let modeprm = {};174 if (mode.type === 'NFT') {175 modeprm = {nft: null};176 } else if (mode.type === 'Fungible') {177 modeprm = {fungible: mode.decimalPoints};178 } else if (mode.type === 'ReFungible') {179 modeprm = {refungible: mode.decimalPoints};180 } else if (mode.type === 'Invalid') {181 modeprm = {invalid: null};182 }183184 const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);185 const events = await submitTransactionAsync(alicePrivateKey, tx);186 const result = getCreateCollectionResult(events);187188 // Get number of collections after the transaction189 const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);190191 // Get the collection192 const collection: any = (await api.query.nft.collection(result.collectionId)).toJSON();193194 // What to expect195 // tslint:disable-next-line:no-unused-expression196 expect(result.success).to.be.true;197 expect(result.collectionId).to.be.equal(BcollectionCount);198 // tslint:disable-next-line:no-unused-expression199 expect(collection).to.be.not.null;200 expect(BcollectionCount).to.be.equal(AcollectionCount + 1, 'Error: NFT collection NOT created.');201 expect(collection.Owner).to.be.equal(alicesPublicKey);202 expect(utf16ToStr(collection.Name)).to.be.equal(name);203 expect(utf16ToStr(collection.Description)).to.be.equal(description);204 expect(hexToStr(collection.TokenPrefix)).to.be.equal(tokenPrefix);205206 collectionId = result.collectionId;207 });208209 return collectionId;210}211212export async function createCollectionExpectFailure(params: Partial<CreateCollectionParams> = {}) {213 const {name, description, mode, tokenPrefix } = {...defaultCreateCollectionParams, ...params};214215 let modeprm = {};216 if (mode.type === 'NFT') {217 modeprm = {nft: null};218 } else if (mode.type === 'Fungible') {219 modeprm = {fungible: mode.decimalPoints};220 } else if (mode.type === 'ReFungible') {221 modeprm = {refungible: mode.decimalPoints};222 } else if (mode.type === 'Invalid') {223 modeprm = {invalid: null};224 }225226 await usingApi(async (api) => {227 // Get number of collections before the transaction228 const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());229230 // Run the CreateCollection transaction231 const alicePrivateKey = privateKey('//Alice');232 const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);233 const events = await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;234 const result = getCreateCollectionResult(events);235236 // Get number of collections after the transaction237 const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());238239 // What to expect240 // tslint:disable-next-line:no-unused-expression241 expect(result.success).to.be.false;242 expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Collection with incorrect data created.');243 });244}245246export async function findUnusedAddress(api: ApiPromise): Promise<IKeyringPair> {247 let bal = new BigNumber(0);248 let unused;249 do {250 const randomSeed = 'seed' + Math.floor(Math.random() * Math.floor(10000));251 const keyring = new Keyring({ type: 'sr25519' });252 unused = keyring.addFromUri(`//${randomSeed}`);253 bal = new BigNumber((await api.query.system.account(unused.address)).data.free.toString());254 } while (bal.toFixed() != '0');255 return unused;256}257258export async function getAllowance(collectionId: number, tokenId: number, owner: string, approved: string) {259 return await usingApi(async (api) => {260 const bn = await api.query.nft.allowances(collectionId, [tokenId, owner, approved]) as unknown as BN;261 return BigInt(bn.toString());262 });263}264265export async function findNotExistingCollection(api: ApiPromise): Promise<number> {266 const totalNumber = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10) as unknown as number;267 const newCollection: number = totalNumber + 1;268 return newCollection;269}270271function getDestroyResult(events: EventRecord[]): boolean {272 let success: boolean = false;273 events.forEach(({ phase, event: { data, method, section } }) => {274 // console.log(` ${phase}: ${section}.${method}:: ${data}`);275 if (method == 'ExtrinsicSuccess') {276 success = true;277 }278 });279 return success;280}281282export async function destroyCollectionExpectFailure(collectionId: number, senderSeed: string = '//Alice') {283 await usingApi(async (api) => {284 // Run the DestroyCollection transaction285 const alicePrivateKey = privateKey(senderSeed);286 const tx = api.tx.nft.destroyCollection(collectionId);287 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;288 });289}290291export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed: string = '//Alice') {292 await usingApi(async (api) => {293 // Run the DestroyCollection transaction294 const alicePrivateKey = privateKey(senderSeed);295 const tx = api.tx.nft.destroyCollection(collectionId);296 const events = await submitTransactionAsync(alicePrivateKey, tx);297 const result = getDestroyResult(events);298299 // Get the collection300 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();301302 // What to expect303 expect(result).to.be.true;304 expect(collection).to.be.not.null;305 expect(collection.Owner).to.be.equal(nullPublicKey);306 });307}308309export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) {310 await usingApi(async (api) => {311312 // Run the transaction313 const alicePrivateKey = privateKey('//Alice');314 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);315 const events = await submitTransactionAsync(alicePrivateKey, tx);316 const result = getGenericResult(events);317318 // Get the collection319 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();320321 // What to expect322 expect(result.success).to.be.true;323 expect(collection.Sponsor.toString()).to.be.equal(sponsor.toString());324 expect(collection.SponsorConfirmed).to.be.false;325 });326}327328export async function removeCollectionSponsorExpectSuccess(collectionId: number) {329 await usingApi(async (api) => {330331 // Run the transaction332 const alicePrivateKey = privateKey('//Alice');333 const tx = api.tx.nft.removeCollectionSponsor(collectionId);334 const events = await submitTransactionAsync(alicePrivateKey, tx);335 const result = getGenericResult(events);336337 // Get the collection338 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();339340 // What to expect341 expect(result.success).to.be.true;342 expect(collection.Sponsor).to.be.equal(nullPublicKey);343 expect(collection.SponsorConfirmed).to.be.false;344 });345}346347export async function removeCollectionSponsorExpectFailure(collectionId: number) {348 await usingApi(async (api) => {349350 // Run the transaction351 const alicePrivateKey = privateKey('//Alice');352 const tx = api.tx.nft.removeCollectionSponsor(collectionId);353 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;354 });355}356357export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed: string = '//Alice') {358 await usingApi(async (api) => {359360 // Run the transaction361 const alicePrivateKey = privateKey(senderSeed);362 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);363 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;364 });365}366367export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed: string = '//Alice') {368 await usingApi(async (api) => {369370 // Run the transaction371 const sender = privateKey(senderSeed);372 const tx = api.tx.nft.confirmSponsorship(collectionId);373 const events = await submitTransactionAsync(sender, tx);374 const result = getGenericResult(events);375376 // Get the collection377 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();378379 // What to expect380 expect(result.success).to.be.true;381 expect(collection.Sponsor).to.be.equal(sender.address);382 expect(collection.SponsorConfirmed).to.be.true;383 });384}385386export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed: string = '//Alice') {387 await usingApi(async (api) => {388389 // Run the transaction390 const sender = privateKey(senderSeed);391 const tx = api.tx.nft.confirmSponsorship(collectionId);392 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;393 });394}395396export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {397 await usingApi(async (api) => {398 const tx = api.tx.nft.enableContractSponsoring(contractAddress, enable);399 const events = await submitTransactionAsync(sender, tx);400 const result = getGenericResult(events);401402 expect(result.success).to.be.true;403 });404}405406export async function enableContractSponsoringExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {407 await usingApi(async (api) => {408 const tx = api.tx.nft.enableContractSponsoring(contractAddress, enable);409 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;410 const result = getGenericResult(events);411412 expect(result.success).to.be.false;413 });414}415416export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {417 await usingApi(async (api) => {418 const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);419 const events = await submitTransactionAsync(sender, tx);420 const result = getGenericResult(events);421422 expect(result.success).to.be.true;423 });424}425426export async function setContractSponsoringRateLimitExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {427 await usingApi(async (api) => {428 const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);429 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;430 const result = getGenericResult(events);431432 expect(result.success).to.be.false;433 });434}435436export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {437 await usingApi(async (api) => {438 const tx = api.tx.nft.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex'));439 const events = await submitTransactionAsync(sender, tx);440 const result = getGenericResult(events);441442 expect(result.success).to.be.true;443 });444}445446export async function setVariableMetaDataExpectFailure(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {447 await usingApi(async (api) => {448 const tx = api.tx.nft.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex'));449 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;450 });451}452453export interface CreateFungibleData {454 readonly Value: bigint;455}456457export interface CreateReFungibleData { }458export interface CreateNftData { }459460export type CreateItemData = {461 NFT: CreateNftData;462} | {463 Fungible: CreateFungibleData;464} | {465 ReFungible: CreateReFungibleData;466};467468export async function burnItemExpectSuccess(owner: IKeyringPair, collectionId: number, tokenId: number, value = 0) {469 await usingApi(async (api) => {470 const tx = api.tx.nft.burnItem(collectionId, tokenId, value);471 const events = await submitTransactionAsync(owner, tx);472 const result = getGenericResult(events);473 // Get the item474 const item: any = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON();475 // What to expect476 // tslint:disable-next-line:no-unused-expression477 expect(result.success).to.be.true;478 // tslint:disable-next-line:no-unused-expression479 expect(item).to.be.not.null;480 expect(item.Owner).to.be.equal(nullPublicKey);481 });482}483484export async function485approveExpectSuccess(collectionId: number,486 tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1) {487 await usingApi(async (api: ApiPromise) => {488 const allowanceBefore =489 await api.query.nft.allowances(collectionId, [tokenId, owner.address, approved.address]) as unknown as BN;490 const approveNftTx = await api.tx.nft.approve(approved.address, collectionId, tokenId, amount);491 const events = await submitTransactionAsync(owner, approveNftTx);492 const result = getCreateItemResult(events);493 // tslint:disable-next-line:no-unused-expression494 expect(result.success).to.be.true;495 const allowanceAfter =496 await api.query.nft.allowances(collectionId, [tokenId, owner.address, approved.address]) as unknown as BN;497 expect(allowanceAfter.sub(allowanceBefore).toString()).to.be.equal(amount.toString());498 });499}500501export async function502transferFromExpectSuccess(collectionId: number,503 tokenId: number,504 accountApproved: IKeyringPair,505 accountFrom: IKeyringPair,506 accountTo: IKeyringPair,507 value: number | bigint = 1,508 type: string = 'NFT') {509 await usingApi(async (api: ApiPromise) => {510 let balanceBefore = new BN(0);511 if (type === 'Fungible') {512 balanceBefore = await api.query.nft.balance(collectionId, accountTo.address) as unknown as BN;513 }514 const transferFromTx = await api.tx.nft.transferFrom(515 accountFrom.address, accountTo.address, collectionId, tokenId, value);516 const events = await submitTransactionAsync(accountApproved, transferFromTx);517 const result = getCreateItemResult(events);518 // tslint:disable-next-line:no-unused-expression519 expect(result.success).to.be.true;520 if (type === 'NFT') {521 const nftItemData = await api.query.nft.nftItemList(collectionId, tokenId) as unknown as ITokenDataType;522 expect(nftItemData.Owner.toString()).to.be.equal(accountTo.address);523 }524 if (type === 'Fungible') {525 const balanceAfter = await api.query.nft.balance(collectionId, accountTo.address) as unknown as BN;526 expect(balanceAfter.sub(balanceBefore).toString()).to.be.equal(value.toString());527 }528 if (type === 'ReFungible') {529 const nftItemData =530 await api.query.nft.reFungibleItemList(collectionId, tokenId) as unknown as IReFungibleTokenDataType;531 expect(nftItemData.Owner[0].Owner.toString()).to.be.equal(accountTo.address);532 expect(nftItemData.Owner[0].Fraction.toNumber()).to.be.equal(value);533 }534 });535}536537export async function538transferFromExpectFail(collectionId: number,539 tokenId: number,540 accountApproved: IKeyringPair,541 accountFrom: IKeyringPair,542 accountTo: IKeyringPair,543 value: number | bigint = 1) {544 await usingApi(async (api: ApiPromise) => {545 const transferFromTx = await api.tx.nft.transferFrom(546 accountFrom.address, accountTo.address, collectionId, tokenId, value);547 const events = await expect(submitTransactionExpectFailAsync(accountApproved, transferFromTx)).to.be.rejected;548 const result = getCreateCollectionResult(events);549 // tslint:disable-next-line:no-unused-expression550 expect(result.success).to.be.false;551 });552}553554export async function555transferExpectSuccess(collectionId: number,556 tokenId: number,557 sender: IKeyringPair,558 recipient: IKeyringPair,559 value: number | bigint = 1,560 type: string = 'NFT') {561 await usingApi(async (api: ApiPromise) => {562 let balanceBefore = new BN(0);563 if (type === 'Fungible') {564 balanceBefore = await api.query.nft.balance(collectionId, recipient.address) as unknown as BN;565 }566 const transferTx = await api.tx.nft.transfer(recipient.address, collectionId, tokenId, value);567 const events = await submitTransactionAsync(sender, transferTx);568 const result = getCreateItemResult(events);569 // tslint:disable-next-line:no-unused-expression570 expect(result.success).to.be.true;571 if (type === 'NFT') {572 const nftItemData = await api.query.nft.nftItemList(collectionId, tokenId) as unknown as ITokenDataType;573 expect(nftItemData.Owner.toString()).to.be.equal(recipient.address);574 }575 if (type === 'Fungible') {576 const balanceAfter = await api.query.nft.balance(collectionId, recipient.address) as unknown as BN;577 expect(balanceAfter.sub(balanceBefore).toString()).to.be.equal(value.toString());578 }579 if (type === 'ReFungible') {580 const nftItemData =581 await api.query.nft.reFungibleItemList(collectionId, tokenId) as unknown as IReFungibleTokenDataType;582 expect(nftItemData.Owner[0].Owner.toString()).to.be.equal(recipient.address);583 expect(nftItemData.Owner[0].Fraction.toNumber()).to.be.equal(value);584 }585 });586}587588export async function589transferExpectFail(collectionId: number,590 tokenId: number,591 sender: IKeyringPair,592 recipient: IKeyringPair,593 value: number | bigint = 1,594 type: string = 'NFT') {595 await usingApi(async (api: ApiPromise) => {596 const transferTx = await api.tx.nft.transfer(recipient.address, collectionId, tokenId, value);597 const events = await expect(submitTransactionExpectFailAsync(sender, transferTx)).to.be.rejected;598 if (events && Array.isArray(events)) {599 const result = getCreateCollectionResult(events);600 // tslint:disable-next-line:no-unused-expression601 expect(result.success).to.be.false;602 }603 });604}605606export async function607approveExpectFail(collectionId: number,608 tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1) {609 await usingApi(async (api: ApiPromise) => {610 const approveNftTx = await api.tx.nft.approve(approved.address, collectionId, tokenId, amount);611 const events = await expect(submitTransactionExpectFailAsync(owner, approveNftTx)).to.be.rejected;612 const result = getCreateCollectionResult(events);613 // tslint:disable-next-line:no-unused-expression614 expect(result.success).to.be.false;615 });616}617618export async function getFungibleBalance(619 collectionId: number,620 owner: string,621) {622 return await usingApi(async (api) => {623 const response = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON() as unknown as {Value: string};624 return BigInt(response.Value);625 });626}627628export async function createFungibleItemExpectSuccess(629 sender: IKeyringPair,630 collectionId: number,631 data: CreateFungibleData,632 owner: string = sender.address,633) {634 return await usingApi(async (api) => {635 const tx = api.tx.nft.createItem(collectionId, owner, { Fungible: data });636637 const events = await submitTransactionAsync(sender, tx);638 const result = getCreateItemResult(events);639640 expect(result.success).to.be.true;641 return result.itemId;642 });643}644645export async function createItemExpectSuccess(646 sender: IKeyringPair, collectionId: number, createMode: string, owner: string = '') {647 let newItemId: number = 0;648 await usingApi(async (api) => {649 const AItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString(), 10);650 const Aitem: any = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON();651 const AItemBalance = new BigNumber(Aitem.Value);652653 if (owner === '') {654 owner = sender.address;655 }656657 let tx;658 if (createMode === 'Fungible') {659 const createData = {fungible: {value: 10}};660 tx = api.tx.nft.createItem(collectionId, owner, createData);661 } else {662 tx = api.tx.nft.createItem(collectionId, owner, createMode);663 }664 const events = await submitTransactionAsync(sender, tx);665 const result = getCreateItemResult(events);666667 const BItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString(), 10);668 const Bitem: any = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON();669 const BItemBalance = new BigNumber(Bitem.Value);670671 // What to expect672 // tslint:disable-next-line:no-unused-expression673 expect(result.success).to.be.true;674 if (createMode === 'Fungible') {675 expect(BItemBalance.minus(AItemBalance).toNumber()).to.be.equal(10);676 } else {677 expect(BItemCount).to.be.equal(AItemCount + 1);678 }679 expect(collectionId).to.be.equal(result.collectionId);680 expect(BItemCount).to.be.equal(result.itemId);681 newItemId = result.itemId;682 });683 return newItemId;684}685686export async function createItemExpectFailure(687 sender: IKeyringPair, collectionId: number, createMode: string, owner: string = sender.address) {688 await usingApi(async (api) => {689 const tx = api.tx.nft.createItem(collectionId, owner, createMode);690 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;691 const result = getCreateItemResult(events);692693 expect(result.success).to.be.false;694 });695}696697export async function setPublicAccessModeExpectSuccess(698 sender: IKeyringPair, collectionId: number,699 accessMode: 'Normal' | 'WhiteList',700) {701 await usingApi(async (api) => {702703 // Run the transaction704 const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);705 const events = await submitTransactionAsync(sender, tx);706 const result = getGenericResult(events);707708 // Get the collection709 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();710711 // What to expect712 // tslint:disable-next-line:no-unused-expression713 expect(result.success).to.be.true;714 expect(collection.Access).to.be.equal(accessMode);715 });716}717718export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {719 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');720}721722export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {723 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');724}725726export async function setMintPermissionExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {727 await usingApi(async (api) => {728729 // Run the transaction730 const tx = api.tx.nft.setMintPermission(collectionId, enabled);731 const events = await submitTransactionAsync(sender, tx);732 const result = getGenericResult(events);733734 // Get the collection735 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();736737 // What to expect738 // tslint:disable-next-line:no-unused-expression739 expect(result.success).to.be.true;740 expect(collection.MintMode).to.be.equal(enabled);741 });742}743744export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {745 await setMintPermissionExpectSuccess(sender, collectionId, true);746}747748export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {749 await usingApi(async (api) => {750 // Run the transaction751 const tx = api.tx.nft.setMintPermission(collectionId, enabled);752 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;753 const result = getCreateCollectionResult(events);754 // tslint:disable-next-line:no-unused-expression755 expect(result.success).to.be.false;756 });757}758759export async function isWhitelisted(collectionId: number, address: string) {760 let whitelisted: boolean = false;761 await usingApi(async (api) => {762 whitelisted = (await api.query.nft.whiteList(collectionId, address)).toJSON() as unknown as boolean;763 });764 return whitelisted;765}766767export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {768 await usingApi(async (api) => {769770 const whiteListedBefore = (await api.query.nft.whiteList(collectionId, address)).toJSON();771772 // Run the transaction773 const tx = api.tx.nft.addToWhiteList(collectionId, address);774 const events = await submitTransactionAsync(sender, tx);775 const result = getGenericResult(events);776777 const whiteListedAfter = (await api.query.nft.whiteList(collectionId, address)).toJSON();778779 // What to expect780 // tslint:disable-next-line:no-unused-expression781 expect(result.success).to.be.true;782 // tslint:disable-next-line: no-unused-expression783 expect(whiteListedBefore).to.be.false;784 // tslint:disable-next-line: no-unused-expression785 expect(whiteListedAfter).to.be.true;786 });787}788789export async function removeFromWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {790 await usingApi(async (api) => {791 // Run the transaction792 const tx = api.tx.nft.removeFromWhiteList(collectionId, address);793 const events = await submitTransactionAsync(sender, tx);794 const result = getGenericResult(events);795796 // What to expect797 // tslint:disable-next-line:no-unused-expression798 expect(result.success).to.be.true;799 });800}801802export async function removeFromWhiteListExpectFailure(sender: IKeyringPair, collectionId: number, address: string) {803 await usingApi(async (api) => {804 // Run the transaction805 const tx = api.tx.nft.removeFromWhiteList(collectionId, address);806 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;807 const result = getGenericResult(events);808809 // What to expect810 // tslint:disable-next-line:no-unused-expression811 expect(result.success).to.be.false;812 });813}814815export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)816 : Promise<ICollectionInterface | null> => {817 return await api.query.nft.collection(collectionId) as unknown as ICollectionInterface;818};819820export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {821 // set global object - collectionsCount822 return (await api.query.nft.createdCollectionCount() as unknown as BN).toNumber();823};1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { ApiPromise, Keyring } from '@polkadot/api';7import { Enum, Struct } from '@polkadot/types/codec';8import type { AccountId, EventRecord } from '@polkadot/types/interfaces';9import { u128 } from '@polkadot/types/primitive';10import { IKeyringPair } from '@polkadot/types/types';11import { BigNumber } from 'bignumber.js';12import BN from 'bn.js';13import chai from 'chai';14import chaiAsPromised from 'chai-as-promised';15import { alicesPublicKey, nullPublicKey } from '../accounts';16import privateKey from '../substrate/privateKey';17import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';18import { ICollectionInterface } from '../types';19import { hexToStr, strToUTF16, utf16ToStr } from './util';2021chai.use(chaiAsPromised);22const expect = chai.expect;2324export const U128_MAX = (1n << 128n) - 1n;2526type GenericResult = {27 success: boolean,28};2930interface CreateCollectionResult {31 success: boolean;32 collectionId: number;33}3435interface CreateItemResult {36 success: boolean;37 collectionId: number;38 itemId: number;39}4041interface IReFungibleOwner {42 Fraction: BN;43 Owner: number[];44}4546interface ITokenDataType {47 Owner: number[];48 ConstData: number[];49 VariableData: number[];50}5152interface IFungibleTokenDataType {53 Value: BN;54}5556export interface IReFungibleTokenDataType {57 Owner: IReFungibleOwner[];58 ConstData: number[];59 VariableData: number[];60}6162export function getGenericResult(events: EventRecord[]): GenericResult {63 const result: GenericResult = {64 success: false,65 };66 events.forEach(({ phase, event: { data, method, section } }) => {67 // console.log(` ${phase}: ${section}.${method}:: ${data}`);68 if (method === 'ExtrinsicSuccess') {69 result.success = true;70 }71 });72 return result;73}7475export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {76 let success = false;77 let collectionId: number = 0;78 events.forEach(({ phase, event: { data, method, section } }) => {79 // console.log(` ${phase}: ${section}.${method}:: ${data}`);80 if (method == 'ExtrinsicSuccess') {81 success = true;82 } else if ((section == 'nft') && (method == 'Created')) {83 collectionId = parseInt(data[0].toString());84 }85 });86 const result: CreateCollectionResult = {87 success,88 collectionId,89 };90 return result;91}9293export function getCreateItemResult(events: EventRecord[]): CreateItemResult {94 let success = false;95 let collectionId: number = 0;96 let itemId: number = 0;97 events.forEach(({ phase, event: { data, method, section } }) => {98 // console.log(` ${phase}: ${section}.${method}:: ${data}`);99 if (method == 'ExtrinsicSuccess') {100 success = true;101 } else if ((section == 'nft') && (method == 'ItemCreated')) {102 collectionId = parseInt(data[0].toString());103 itemId = parseInt(data[1].toString());104 }105 });106 const result: CreateItemResult = {107 success,108 collectionId,109 itemId,110 };111 return result;112}113114interface Invalid {115 type: 'Invalid';116}117118interface Nft {119 type: 'NFT';120}121122interface Fungible {123 type: 'Fungible';124 decimalPoints: number;125}126127interface ReFungible {128 type: 'ReFungible';129}130131type CollectionMode = Nft | Fungible | ReFungible | Invalid;132133export type CreateCollectionParams = {134 mode: CollectionMode,135 name: string,136 description: string,137 tokenPrefix: string,138};139140const defaultCreateCollectionParams: CreateCollectionParams = {141 description: 'description',142 mode: { type: 'NFT' },143 name: 'name',144 tokenPrefix: 'prefix',145}146147export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {148 const {name, description, mode, tokenPrefix } = {...defaultCreateCollectionParams, ...params};149150 let collectionId: number = 0;151 await usingApi(async (api) => {152 // Get number of collections before the transaction153 const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);154155 // Run the CreateCollection transaction156 const alicePrivateKey = privateKey('//Alice');157158 let modeprm = {};159 if (mode.type === 'NFT') {160 modeprm = {nft: null};161 } else if (mode.type === 'Fungible') {162 modeprm = {fungible: mode.decimalPoints};163 } else if (mode.type === 'ReFungible') {164 modeprm = {refungible: null};165 } else if (mode.type === 'Invalid') {166 modeprm = {invalid: null};167 }168169 const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);170 const events = await submitTransactionAsync(alicePrivateKey, tx);171 const result = getCreateCollectionResult(events);172173 // Get number of collections after the transaction174 const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);175176 // Get the collection177 const collection: any = (await api.query.nft.collection(result.collectionId)).toJSON();178179 // What to expect180 // tslint:disable-next-line:no-unused-expression181 expect(result.success).to.be.true;182 expect(result.collectionId).to.be.equal(BcollectionCount);183 // tslint:disable-next-line:no-unused-expression184 expect(collection).to.be.not.null;185 expect(BcollectionCount).to.be.equal(AcollectionCount + 1, 'Error: NFT collection NOT created.');186 expect(collection.Owner).to.be.equal(alicesPublicKey);187 expect(utf16ToStr(collection.Name)).to.be.equal(name);188 expect(utf16ToStr(collection.Description)).to.be.equal(description);189 expect(hexToStr(collection.TokenPrefix)).to.be.equal(tokenPrefix);190191 collectionId = result.collectionId;192 });193194 return collectionId;195}196197export async function createCollectionExpectFailure(params: Partial<CreateCollectionParams> = {}) {198 const {name, description, mode, tokenPrefix } = {...defaultCreateCollectionParams, ...params};199200 let modeprm = {};201 if (mode.type === 'NFT') {202 modeprm = {nft: null};203 } else if (mode.type === 'Fungible') {204 modeprm = {fungible: mode.decimalPoints};205 } else if (mode.type === 'ReFungible') {206 modeprm = {refungible: null};207 } else if (mode.type === 'Invalid') {208 modeprm = {invalid: null};209 }210211 await usingApi(async (api) => {212 // Get number of collections before the transaction213 const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());214215 // Run the CreateCollection transaction216 const alicePrivateKey = privateKey('//Alice');217 const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);218 const events = await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;219 const result = getCreateCollectionResult(events);220221 // Get number of collections after the transaction222 const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());223224 // What to expect225 // tslint:disable-next-line:no-unused-expression226 expect(result.success).to.be.false;227 expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Collection with incorrect data created.');228 });229}230231export async function findUnusedAddress(api: ApiPromise): Promise<IKeyringPair> {232 let bal = new BigNumber(0);233 let unused;234 do {235 const randomSeed = 'seed' + Math.floor(Math.random() * Math.floor(10000));236 const keyring = new Keyring({ type: 'sr25519' });237 unused = keyring.addFromUri(`//${randomSeed}`);238 bal = new BigNumber((await api.query.system.account(unused.address)).data.free.toString());239 } while (bal.toFixed() != '0');240 return unused;241}242243export async function getAllowance(collectionId: number, tokenId: number, owner: string, approved: string) {244 return await usingApi(async (api) => {245 const bn = await api.query.nft.allowances(collectionId, [tokenId, owner, approved]) as unknown as BN;246 return BigInt(bn.toString());247 });248}249250export async function findNotExistingCollection(api: ApiPromise): Promise<number> {251 const totalNumber = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10) as unknown as number;252 const newCollection: number = totalNumber + 1;253 return newCollection;254}255256function getDestroyResult(events: EventRecord[]): boolean {257 let success: boolean = false;258 events.forEach(({ phase, event: { data, method, section } }) => {259 // console.log(` ${phase}: ${section}.${method}:: ${data}`);260 if (method == 'ExtrinsicSuccess') {261 success = true;262 }263 });264 return success;265}266267export async function destroyCollectionExpectFailure(collectionId: number, senderSeed: string = '//Alice') {268 await usingApi(async (api) => {269 // Run the DestroyCollection transaction270 const alicePrivateKey = privateKey(senderSeed);271 const tx = api.tx.nft.destroyCollection(collectionId);272 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;273 });274}275276export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed: string = '//Alice') {277 await usingApi(async (api) => {278 // Run the DestroyCollection transaction279 const alicePrivateKey = privateKey(senderSeed);280 const tx = api.tx.nft.destroyCollection(collectionId);281 const events = await submitTransactionAsync(alicePrivateKey, tx);282 const result = getDestroyResult(events);283284 // Get the collection285 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();286287 // What to expect288 expect(result).to.be.true;289 expect(collection).to.be.not.null;290 expect(collection.Owner).to.be.equal(nullPublicKey);291 });292}293294export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) {295 await usingApi(async (api) => {296297 // Run the transaction298 const alicePrivateKey = privateKey('//Alice');299 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);300 const events = await submitTransactionAsync(alicePrivateKey, tx);301 const result = getGenericResult(events);302303 // Get the collection304 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();305306 // What to expect307 expect(result.success).to.be.true;308 expect(collection.Sponsor.toString()).to.be.equal(sponsor.toString());309 expect(collection.SponsorConfirmed).to.be.false;310 });311}312313export async function removeCollectionSponsorExpectSuccess(collectionId: number) {314 await usingApi(async (api) => {315316 // Run the transaction317 const alicePrivateKey = privateKey('//Alice');318 const tx = api.tx.nft.removeCollectionSponsor(collectionId);319 const events = await submitTransactionAsync(alicePrivateKey, tx);320 const result = getGenericResult(events);321322 // Get the collection323 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();324325 // What to expect326 expect(result.success).to.be.true;327 expect(collection.Sponsor).to.be.equal(nullPublicKey);328 expect(collection.SponsorConfirmed).to.be.false;329 });330}331332export async function removeCollectionSponsorExpectFailure(collectionId: number) {333 await usingApi(async (api) => {334335 // Run the transaction336 const alicePrivateKey = privateKey('//Alice');337 const tx = api.tx.nft.removeCollectionSponsor(collectionId);338 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;339 });340}341342export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed: string = '//Alice') {343 await usingApi(async (api) => {344345 // Run the transaction346 const alicePrivateKey = privateKey(senderSeed);347 const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);348 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;349 });350}351352export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed: string = '//Alice') {353 await usingApi(async (api) => {354355 // Run the transaction356 const sender = privateKey(senderSeed);357 const tx = api.tx.nft.confirmSponsorship(collectionId);358 const events = await submitTransactionAsync(sender, tx);359 const result = getGenericResult(events);360361 // Get the collection362 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();363364 // What to expect365 expect(result.success).to.be.true;366 expect(collection.Sponsor).to.be.equal(sender.address);367 expect(collection.SponsorConfirmed).to.be.true;368 });369}370371372export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed: string = '//Alice') {373 await usingApi(async (api) => {374375 // Run the transaction376 const sender = privateKey(senderSeed);377 const tx = api.tx.nft.confirmSponsorship(collectionId);378 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;379 });380}381382export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {383 await usingApi(async (api) => {384 const tx = api.tx.nft.enableContractSponsoring(contractAddress, enable);385 const events = await submitTransactionAsync(sender, tx);386 const result = getGenericResult(events);387388 expect(result.success).to.be.true;389 });390}391392export async function enableContractSponsoringExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {393 await usingApi(async (api) => {394 const tx = api.tx.nft.enableContractSponsoring(contractAddress, enable);395 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;396 const result = getGenericResult(events);397398 expect(result.success).to.be.false;399 });400}401402export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {403 await usingApi(async (api) => {404 const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);405 const events = await submitTransactionAsync(sender, tx);406 const result = getGenericResult(events);407408 expect(result.success).to.be.true;409 });410}411412export async function setContractSponsoringRateLimitExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {413 await usingApi(async (api) => {414 const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);415 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;416 const result = getGenericResult(events);417418 expect(result.success).to.be.false;419 });420}421422export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enabled: boolean) {423 await usingApi(async (api) => {424 const tx = api.tx.nft.toggleContractWhiteList(contractAddress, true);425 const events = await submitTransactionAsync(sender, tx);426 const result = getGenericResult(events);427428 expect(result.success).to.be.true;429 });430}431432export async function isWhitelistedInContract(contractAddress: AccountId | string, user: string) {433 let whitelisted: boolean = false;434 await usingApi(async (api) => {435 whitelisted = (await api.query.nft.contractWhiteList(contractAddress, user)).toJSON() as boolean;436 });437 return whitelisted;438}439440export async function addToContractWhiteListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: string) {441 await usingApi(async (api) => {442 const tx = api.tx.nft.addToContractWhiteList(contractAddress, user);443 const events = await submitTransactionAsync(sender, tx);444 const result = getGenericResult(events);445446 expect(result.success).to.be.true;447 });448}449450export async function removeFromContractWhiteListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: string) {451 await usingApi(async (api) => {452 const tx = api.tx.nft.removeFromContractWhiteList(contractAddress, user);453 const events = await submitTransactionAsync(sender, tx);454 const result = getGenericResult(events);455456 expect(result.success).to.be.true;457 });458}459460export async function removeFromContractWhiteListExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, user: string) {461 await usingApi(async (api) => {462 const tx = api.tx.nft.removeFromContractWhiteList(contractAddress, user);463 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;464 const result = getGenericResult(events);465466 expect(result.success).to.be.false;467 });468}469470export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {471 await usingApi(async (api) => {472 const tx = api.tx.nft.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex'));473 const events = await submitTransactionAsync(sender, tx);474 const result = getGenericResult(events);475476 expect(result.success).to.be.true;477 });478}479480export async function setVariableMetaDataExpectFailure(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {481 await usingApi(async (api) => {482 const tx = api.tx.nft.setVariableMetaData(collectionId, itemId, '0x' + Buffer.from(data).toString('hex'));483 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;484 });485}486487export interface CreateFungibleData {488 readonly Value: bigint;489}490491export interface CreateReFungibleData { }492export interface CreateNftData { }493494export type CreateItemData = {495 NFT: CreateNftData;496} | {497 Fungible: CreateFungibleData;498} | {499 ReFungible: CreateReFungibleData;500};501502export async function burnItemExpectSuccess(owner: IKeyringPair, collectionId: number, tokenId: number, value = 0) {503 await usingApi(async (api) => {504 const tx = api.tx.nft.burnItem(collectionId, tokenId, value);505 const events = await submitTransactionAsync(owner, tx);506 const result = getGenericResult(events);507 // Get the item508 const item: any = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON();509 // What to expect510 // tslint:disable-next-line:no-unused-expression511 expect(result.success).to.be.true;512 // tslint:disable-next-line:no-unused-expression513 expect(item).to.be.not.null;514 expect(item.Owner).to.be.equal(nullPublicKey);515 });516}517518export async function519approveExpectSuccess(collectionId: number,520 tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1) { //alice,bob521 await usingApi(async (api: ApiPromise) => {522 const allowanceBefore =523 await api.query.nft.allowances(collectionId, [tokenId, owner.address, approved.address]) as unknown as BN;524 const approveNftTx = await api.tx.nft.approve(approved.address, collectionId, tokenId, amount);525 const events = await submitTransactionAsync(owner, approveNftTx);526 const result = getCreateItemResult(events);527 // tslint:disable-next-line:no-unused-expression528 expect(result.success).to.be.true;529 const allowanceAfter =530 await api.query.nft.allowances(collectionId, [tokenId, owner.address, approved.address]) as unknown as BN;531 expect(allowanceAfter.sub(allowanceBefore).toString()).to.be.equal(amount.toString());532 });533}534535export async function536transferFromExpectSuccess(collectionId: number,537 tokenId: number,538 accountApproved: IKeyringPair, //bob539 accountFrom: IKeyringPair, //alice540 accountTo: IKeyringPair, //charlie541 value: number | bigint = 1,542 type: string = 'NFT') {543 await usingApi(async (api: ApiPromise) => {544 let balanceBefore = new BN(0);545 if (type === 'Fungible') {546 balanceBefore = await api.query.nft.balance(collectionId, accountTo.address) as unknown as BN;547 }548 const transferFromTx = await api.tx.nft.transferFrom(549 accountFrom.address, accountTo.address, collectionId, tokenId, value);550 const events = await submitTransactionAsync(accountApproved, transferFromTx);551 const result = getCreateItemResult(events);552 // tslint:disable-next-line:no-unused-expression553 expect(result.success).to.be.true;554 if (type === 'NFT') {555 const nftItemData = await api.query.nft.nftItemList(collectionId, tokenId) as unknown as ITokenDataType;556 expect(nftItemData.Owner.toString()).to.be.equal(accountTo.address);557 }558 if (type === 'Fungible') {559 const balanceAfter = await api.query.nft.balance(collectionId, accountTo.address) as unknown as BN;560 expect(balanceAfter.sub(balanceBefore).toString()).to.be.equal(value.toString());561 }562 if (type === 'ReFungible') {563 const nftItemData =564 await api.query.nft.reFungibleItemList(collectionId, tokenId) as unknown as IReFungibleTokenDataType;565 expect(nftItemData.Owner[0].Owner.toString()).to.be.equal(accountTo.address);566 expect(nftItemData.Owner[0].Fraction.toNumber()).to.be.equal(value);567 }568 });569}570571export async function572transferFromExpectFail(collectionId: number,573 tokenId: number,574 accountApproved: IKeyringPair,575 accountFrom: IKeyringPair,576 accountTo: IKeyringPair,577 value: number | bigint = 1) {578 await usingApi(async (api: ApiPromise) => {579 const transferFromTx = await api.tx.nft.transferFrom(580 accountFrom.address, accountTo.address, collectionId, tokenId, value);581 const events = await expect(submitTransactionExpectFailAsync(accountApproved, transferFromTx)).to.be.rejected;582 const result = getCreateCollectionResult(events);583 // tslint:disable-next-line:no-unused-expression584 expect(result.success).to.be.false;585 });586}587588export async function589transferExpectSuccess(collectionId: number,590 tokenId: number,591 sender: IKeyringPair,592 recipient: IKeyringPair,593 value: number | bigint = 1,594 type: string = 'NFT') {595 await usingApi(async (api: ApiPromise) => {596 let balanceBefore = new BN(0);597 if (type === 'Fungible') {598 balanceBefore = await api.query.nft.balance(collectionId, recipient.address) as unknown as BN;599 }600 const transferTx = await api.tx.nft.transfer(recipient.address, collectionId, tokenId, value);601 const events = await submitTransactionAsync(sender, transferTx);602 const result = getCreateItemResult(events);603 // tslint:disable-next-line:no-unused-expression604 expect(result.success).to.be.true;605 if (type === 'NFT') {606 const nftItemData = await api.query.nft.nftItemList(collectionId, tokenId) as unknown as ITokenDataType;607 expect(nftItemData.Owner.toString()).to.be.equal(recipient.address);608 }609 if (type === 'Fungible') {610 const balanceAfter = await api.query.nft.balance(collectionId, recipient.address) as unknown as BN;611 expect(balanceAfter.sub(balanceBefore).toString()).to.be.equal(value.toString());612 }613 if (type === 'ReFungible') {614 const nftItemData =615 await api.query.nft.reFungibleItemList(collectionId, tokenId) as unknown as IReFungibleTokenDataType;616 expect(nftItemData.Owner[0].Owner.toString()).to.be.equal(recipient.address);617 expect(nftItemData.Owner[0].Fraction.toNumber()).to.be.equal(value);618 }619 });620}621622export async function623transferExpectFail(collectionId: number,624 tokenId: number,625 sender: IKeyringPair,626 recipient: IKeyringPair,627 value: number | bigint = 1,628 type: string = 'NFT') {629 await usingApi(async (api: ApiPromise) => {630 const transferTx = await api.tx.nft.transfer(recipient.address, collectionId, tokenId, value);631 const events = await expect(submitTransactionExpectFailAsync(sender, transferTx)).to.be.rejected;632 if (events && Array.isArray(events)) {633 const result = getCreateCollectionResult(events);634 // tslint:disable-next-line:no-unused-expression635 expect(result.success).to.be.false;636 }637 });638}639640export async function641approveExpectFail(collectionId: number,642 tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1) {643 await usingApi(async (api: ApiPromise) => {644 const approveNftTx = await api.tx.nft.approve(approved.address, collectionId, tokenId, amount);645 const events = await expect(submitTransactionExpectFailAsync(owner, approveNftTx)).to.be.rejected;646 const result = getCreateCollectionResult(events);647 // tslint:disable-next-line:no-unused-expression648 expect(result.success).to.be.false;649 });650}651652export async function getFungibleBalance(653 collectionId: number,654 owner: string,655) {656 return await usingApi(async (api) => {657 const response = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON() as unknown as {Value: string};658 return BigInt(response.Value);659 });660}661662export async function createFungibleItemExpectSuccess(663 sender: IKeyringPair,664 collectionId: number,665 data: CreateFungibleData,666 owner: string = sender.address,667) {668 return await usingApi(async (api) => {669 const tx = api.tx.nft.createItem(collectionId, owner, { Fungible: data });670671 const events = await submitTransactionAsync(sender, tx);672 const result = getCreateItemResult(events);673674 expect(result.success).to.be.true;675 return result.itemId;676 });677}678679export async function createItemExpectSuccess(680 sender: IKeyringPair, collectionId: number, createMode: string, owner: string = '') {681 let newItemId: number = 0;682 await usingApi(async (api) => {683 const AItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString(), 10);684 const Aitem: any = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON();685 const AItemBalance = new BigNumber(Aitem.Value);686687 if (owner === '') {688 owner = sender.address;689 }690691 let tx;692 if (createMode === 'Fungible') {693 const createData = {fungible: {value: 10}};694 tx = api.tx.nft.createItem(collectionId, owner, createData);695 } else if (createMode === 'ReFungible') {696 const createData = {refungible: {const_data: [], variable_data: [], pieces: 100}};697 tx = api.tx.nft.createItem(collectionId, owner, createData);698 } else {699 tx = api.tx.nft.createItem(collectionId, owner, createMode);700 }701 const events = await submitTransactionAsync(sender, tx);702 const result = getCreateItemResult(events);703704 const BItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString(), 10);705 const Bitem: any = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON();706 const BItemBalance = new BigNumber(Bitem.Value);707708 // What to expect709 // tslint:disable-next-line:no-unused-expression710 expect(result.success).to.be.true;711 if (createMode === 'Fungible') {712 expect(BItemBalance.minus(AItemBalance).toNumber()).to.be.equal(10);713 } else {714 expect(BItemCount).to.be.equal(AItemCount + 1);715 }716 expect(collectionId).to.be.equal(result.collectionId);717 expect(BItemCount).to.be.equal(result.itemId);718 newItemId = result.itemId;719 });720 return newItemId;721}722723export async function createItemExpectFailure(724 sender: IKeyringPair, collectionId: number, createMode: string, owner: string = sender.address) {725 await usingApi(async (api) => {726 const tx = api.tx.nft.createItem(collectionId, owner, createMode);727 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;728 const result = getCreateItemResult(events);729730 expect(result.success).to.be.false;731 });732}733734export async function setPublicAccessModeExpectSuccess(735 sender: IKeyringPair, collectionId: number,736 accessMode: 'Normal' | 'WhiteList',737) {738 await usingApi(async (api) => {739740 // Run the transaction741 const tx = api.tx.nft.setPublicAccessMode(collectionId, accessMode);742 const events = await submitTransactionAsync(sender, tx);743 const result = getGenericResult(events);744745 // Get the collection746 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();747748 // What to expect749 // tslint:disable-next-line:no-unused-expression750 expect(result.success).to.be.true;751 expect(collection.Access).to.be.equal(accessMode);752 });753}754755export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {756 await setPublicAccessModeExpectSuccess(sender, collectionId, 'WhiteList');757}758759export async function disableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {760 await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');761}762763export async function setMintPermissionExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {764 await usingApi(async (api) => {765766 // Run the transaction767 const tx = api.tx.nft.setMintPermission(collectionId, enabled);768 const events = await submitTransactionAsync(sender, tx);769 const result = getGenericResult(events);770771 // Get the collection772 const collection: any = (await api.query.nft.collection(collectionId)).toJSON();773774 // What to expect775 // tslint:disable-next-line:no-unused-expression776 expect(result.success).to.be.true;777 expect(collection.MintMode).to.be.equal(enabled);778 });779}780781export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {782 await setMintPermissionExpectSuccess(sender, collectionId, true);783}784785export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {786 await usingApi(async (api) => {787 // Run the transaction788 const tx = api.tx.nft.setMintPermission(collectionId, enabled);789 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;790 const result = getCreateCollectionResult(events);791 // tslint:disable-next-line:no-unused-expression792 expect(result.success).to.be.false;793 });794}795796export async function isWhitelisted(collectionId: number, address: string) {797 let whitelisted: boolean = false;798 await usingApi(async (api) => {799 whitelisted = (await api.query.nft.whiteList(collectionId, address)).toJSON() as unknown as boolean;800 });801 return whitelisted;802}803804export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {805 await usingApi(async (api) => {806807 const whiteListedBefore = (await api.query.nft.whiteList(collectionId, address)).toJSON();808809 // Run the transaction810 const tx = api.tx.nft.addToWhiteList(collectionId, address);811 const events = await submitTransactionAsync(sender, tx);812 const result = getGenericResult(events);813814 const whiteListedAfter = (await api.query.nft.whiteList(collectionId, address)).toJSON();815816 // What to expect817 // tslint:disable-next-line:no-unused-expression818 expect(result.success).to.be.true;819 // tslint:disable-next-line: no-unused-expression820 expect(whiteListedBefore).to.be.false;821 // tslint:disable-next-line: no-unused-expression822 expect(whiteListedAfter).to.be.true;823 });824}825826export async function removeFromWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {827 await usingApi(async (api) => {828 // Run the transaction829 const tx = api.tx.nft.removeFromWhiteList(collectionId, address);830 const events = await submitTransactionAsync(sender, tx);831 const result = getGenericResult(events);832833 // What to expect834 // tslint:disable-next-line:no-unused-expression835 expect(result.success).to.be.true;836 });837}838839export async function removeFromWhiteListExpectFailure(sender: IKeyringPair, collectionId: number, address: string) {840 await usingApi(async (api) => {841 // Run the transaction842 const tx = api.tx.nft.removeFromWhiteList(collectionId, address);843 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;844 const result = getGenericResult(events);845846 // What to expect847 // tslint:disable-next-line:no-unused-expression848 expect(result.success).to.be.false;849 });850}851852export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)853 : Promise<ICollectionInterface | null> => {854 return await api.query.nft.collection(collectionId) as unknown as ICollectionInterface;855};856857export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {858 // set global object - collectionsCount859 return (await api.query.nft.createdCollectionCount() as unknown as BN).toNumber();860};