difftreelog
Merge pull request #12 from usetech-llc/feature/NFTPAR-116_substrate2_release
in: master
Feature/nftpar 116 substrate2 release
18 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -16,7 +16,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
dependencies = [
- "gimli",
+ "gimli 0.22.0",
]
[[package]]
@@ -361,7 +361,7 @@
"cfg-if 1.0.0",
"libc",
"miniz_oxide",
- "object",
+ "object 0.21.1",
"rustc-demangle",
]
@@ -384,6 +384,16 @@
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
+name = "bincode"
+version = "1.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d"
+dependencies = [
+ "byteorder 1.3.4",
+ "serde",
+]
+
+[[package]]
name = "bindgen"
version = "0.54.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -791,6 +801,98 @@
checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"
[[package]]
+name = "cranelift-bforest"
+version = "0.66.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8dcc286b052ee24a1e5a222e7c1125e6010ad35b0f248709b9b3737a8fedcfdf"
+dependencies = [
+ "cranelift-entity",
+]
+
+[[package]]
+name = "cranelift-codegen"
+version = "0.66.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d9badfe36176cb653506091693bc2bb1970c9bddfcd6ec7fac404f7eaec6f38"
+dependencies = [
+ "byteorder 1.3.4",
+ "cranelift-bforest",
+ "cranelift-codegen-meta",
+ "cranelift-codegen-shared",
+ "cranelift-entity",
+ "gimli 0.21.0",
+ "log",
+ "regalloc",
+ "serde",
+ "smallvec 1.4.2",
+ "target-lexicon",
+ "thiserror",
+]
+
+[[package]]
+name = "cranelift-codegen-meta"
+version = "0.66.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c3f460031861e4f4ad510be62b2ae50bba6cc886b598a36f9c0a970feab9598"
+dependencies = [
+ "cranelift-codegen-shared",
+ "cranelift-entity",
+]
+
+[[package]]
+name = "cranelift-codegen-shared"
+version = "0.66.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "76ad12409e922e7697cd0bdc7dc26992f64a77c31880dfe5e3c7722f4710206d"
+
+[[package]]
+name = "cranelift-entity"
+version = "0.66.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d97cdc58972ea065d107872cfb9079f4c92ade78a8af85aaff519a65b5d13f71"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "cranelift-frontend"
+version = "0.66.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2ef419efb4f94ecc02e5d9fbcc910d2bb7f0040e2de570e63a454f883bc891d6"
+dependencies = [
+ "cranelift-codegen",
+ "log",
+ "smallvec 1.4.2",
+ "target-lexicon",
+]
+
+[[package]]
+name = "cranelift-native"
+version = "0.66.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e69d44d59826eef6794066ac2c0f4ad3975f02d97030c60dbc04e3886adf36e"
+dependencies = [
+ "cranelift-codegen",
+ "raw-cpuid",
+ "target-lexicon",
+]
+
+[[package]]
+name = "cranelift-wasm"
+version = "0.66.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "979df666b1304624abe99738e9e0e7c7479ee5523ba4b8b237df9ff49996acbb"
+dependencies = [
+ "cranelift-codegen",
+ "cranelift-entity",
+ "cranelift-frontend",
+ "log",
+ "serde",
+ "thiserror",
+ "wasmparser 0.59.0",
+]
+
+[[package]]
name = "crc32fast"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1079,6 +1181,27 @@
]
[[package]]
+name = "errno"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6eab5ee3df98a279d9b316b1af6ac95422127b1290317e6d18c1743c99418b01"
+dependencies = [
+ "errno-dragonfly",
+ "libc",
+ "winapi 0.3.9",
+]
+
+[[package]]
+name = "errno-dragonfly"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067"
+dependencies = [
+ "gcc",
+ "libc",
+]
+
+[[package]]
name = "event-listener"
version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1122,6 +1245,12 @@
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
+name = "fallible-iterator"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
+
+[[package]]
name = "fastrand"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1140,6 +1269,16 @@
]
[[package]]
+name = "file-per-thread-logger"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fdbe0d94371f9ce939b555dd342d0686cc4c0cadbcd4b61d70af5ff97eb4126"
+dependencies = [
+ "env_logger",
+ "log",
+]
+
+[[package]]
name = "finality-grandpa"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1218,6 +1357,24 @@
]
[[package]]
+name = "frame-benchmarking-cli"
+version = "2.0.0"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"
+dependencies = [
+ "frame-benchmarking",
+ "parity-scale-codec",
+ "sc-cli",
+ "sc-client-db",
+ "sc-executor",
+ "sc-service",
+ "sp-core",
+ "sp-externalities",
+ "sp-runtime",
+ "sp-state-machine",
+ "structopt",
+]
+
+[[package]]
name = "frame-executive"
version = "2.0.0"
source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"
@@ -1319,6 +1476,20 @@
]
[[package]]
+name = "frame-system-benchmarking"
+version = "2.0.0"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"
+dependencies = [
+ "frame-benchmarking",
+ "frame-support",
+ "frame-system",
+ "parity-scale-codec",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
name = "frame-system-rpc-runtime-api"
version = "2.0.0"
source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"
@@ -1636,6 +1807,17 @@
[[package]]
name = "gimli"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c"
+dependencies = [
+ "fallible-iterator",
+ "indexmap",
+ "stable_deref_trait",
+]
+
+[[package]]
+name = "gimli"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
@@ -2013,6 +2195,7 @@
dependencies = [
"autocfg 1.0.1",
"hashbrown 0.9.1",
+ "serde",
]
[[package]]
@@ -2074,6 +2257,15 @@
]
[[package]]
+name = "itertools"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
+dependencies = [
+ "either",
+]
+
+[[package]]
name = "itoa"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2296,6 +2488,12 @@
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
+name = "leb128"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a"
+
+[[package]]
name = "libc"
version = "0.2.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2852,6 +3050,15 @@
checksum = "adb241df5c4caeb888755363fc95f8a896618dc0d435e9e775f7930cb099beab"
[[package]]
+name = "mach"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
+dependencies = [
+ "libc",
+]
+
+[[package]]
name = "matchers"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3042,6 +3249,12 @@
]
[[package]]
+name = "more-asserts"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238"
+
+[[package]]
name = "multihash"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3127,6 +3340,8 @@
name = "nft"
version = "2.0.0"
dependencies = [
+ "frame-benchmarking",
+ "frame-benchmarking-cli",
"futures 0.3.6",
"jsonrpc-core",
"log",
@@ -3165,10 +3380,13 @@
name = "nft-runtime"
version = "2.0.0"
dependencies = [
+ "frame-benchmarking",
"frame-executive",
"frame-support",
"frame-system",
+ "frame-system-benchmarking",
"frame-system-rpc-runtime-api",
+ "hex-literal",
"pallet-aura",
"pallet-balances",
"pallet-contracts",
@@ -3297,6 +3515,23 @@
[[package]]
name = "object"
+version = "0.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2"
+
+[[package]]
+name = "object"
+version = "0.20.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
+dependencies = [
+ "crc32fast",
+ "indexmap",
+ "wasmparser 0.57.0",
+]
+
+[[package]]
+name = "object"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693"
@@ -3498,6 +3733,7 @@
name = "pallet-nft"
version = "2.0.0"
dependencies = [
+ "frame-benchmarking",
"frame-support",
"frame-system",
"log",
@@ -3569,6 +3805,7 @@
"parity-scale-codec",
"serde",
"sp-inherents",
+ "sp-io",
"sp-runtime",
"sp-std",
"sp-timestamp",
@@ -4098,7 +4335,7 @@
dependencies = [
"bytes 0.5.6",
"heck",
- "itertools",
+ "itertools 0.8.2",
"log",
"multimap",
"petgraph",
@@ -4115,7 +4352,7 @@
checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72"
dependencies = [
"anyhow",
- "itertools",
+ "itertools 0.8.2",
"proc-macro2",
"quote",
"syn",
@@ -4368,6 +4605,17 @@
]
[[package]]
+name = "raw-cpuid"
+version = "7.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf"
+dependencies = [
+ "bitflags",
+ "cc",
+ "rustc_version",
+]
+
+[[package]]
name = "rawpointer"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4445,6 +4693,17 @@
]
[[package]]
+name = "regalloc"
+version = "0.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9ba8aaf5fe7cf307c6dbdaeed85478961d29e25e3bee5169e11b92fa9f027a8"
+dependencies = [
+ "log",
+ "rustc-hash",
+ "smallvec 1.4.2",
+]
+
+[[package]]
name = "regex"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4473,6 +4732,18 @@
checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c"
[[package]]
+name = "region"
+version = "2.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0"
+dependencies = [
+ "bitflags",
+ "libc",
+ "mach",
+ "winapi 0.3.9",
+]
+
+[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4895,6 +5166,7 @@
"parking_lot 0.10.2",
"sc-executor-common",
"sc-executor-wasmi",
+ "sc-executor-wasmtime",
"sp-api",
"sp-core",
"sp-externalities",
@@ -4941,6 +5213,24 @@
]
[[package]]
+name = "sc-executor-wasmtime"
+version = "0.8.0"
+source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"
+dependencies = [
+ "log",
+ "parity-scale-codec",
+ "parity-wasm",
+ "pwasm-utils",
+ "sc-executor-common",
+ "scoped-tls",
+ "sp-allocator",
+ "sp-core",
+ "sp-runtime-interface",
+ "sp-wasm-interface",
+ "wasmtime",
+]
+
+[[package]]
name = "sc-finality-grandpa"
version = "0.8.0"
source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"
@@ -5414,6 +5704,12 @@
]
[[package]]
+name = "scoped-tls"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
+
+[[package]]
name = "scopeguard"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5426,6 +5722,26 @@
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
+name = "scroll"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec"
+dependencies = [
+ "scroll_derive",
+]
+
+[[package]]
+name = "scroll_derive"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6dfde5d1531034db129e95c76ac857e2baecea3443579d493d02224950b0fb6d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "sct"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -6458,7 +6774,8 @@
[[package]]
name = "substrate-wasm-builder-runner"
version = "1.0.6"
-source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a"
[[package]]
name = "subtle"
@@ -6502,6 +6819,12 @@
checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60"
[[package]]
+name = "target-lexicon"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d"
+
+[[package]]
name = "tempfile"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -7325,6 +7648,191 @@
]
[[package]]
+name = "wasmparser"
+version = "0.57.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6"
+
+[[package]]
+name = "wasmparser"
+version = "0.59.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a950e6a618f62147fd514ff445b2a0b53120d382751960797f85f058c7eda9b9"
+
+[[package]]
+name = "wasmtime"
+version = "0.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cd3c4f449382779ef6e0a7c3ec6752ae614e20a42e4100000c3efdc973100e2"
+dependencies = [
+ "anyhow",
+ "backtrace",
+ "cfg-if 0.1.10",
+ "lazy_static",
+ "libc",
+ "log",
+ "region",
+ "rustc-demangle",
+ "smallvec 1.4.2",
+ "target-lexicon",
+ "wasmparser 0.59.0",
+ "wasmtime-environ",
+ "wasmtime-jit",
+ "wasmtime-profiling",
+ "wasmtime-runtime",
+ "wat",
+ "winapi 0.3.9",
+]
+
+[[package]]
+name = "wasmtime-debug"
+version = "0.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e634af9067a3af6cf2c7d33dc3b84767ddaf5d010ba68e80eecbcea73d4a349"
+dependencies = [
+ "anyhow",
+ "gimli 0.21.0",
+ "more-asserts",
+ "object 0.20.0",
+ "target-lexicon",
+ "thiserror",
+ "wasmparser 0.59.0",
+ "wasmtime-environ",
+]
+
+[[package]]
+name = "wasmtime-environ"
+version = "0.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08f85619a94ee4034bd5bb87fc3dcf71fd2237b81c840809da1201061eec9ab3"
+dependencies = [
+ "anyhow",
+ "base64 0.12.3",
+ "bincode",
+ "cfg-if 0.1.10",
+ "cranelift-codegen",
+ "cranelift-entity",
+ "cranelift-frontend",
+ "cranelift-wasm",
+ "directories",
+ "errno",
+ "file-per-thread-logger",
+ "indexmap",
+ "libc",
+ "log",
+ "more-asserts",
+ "rayon",
+ "serde",
+ "sha2 0.8.2",
+ "thiserror",
+ "toml",
+ "wasmparser 0.59.0",
+ "winapi 0.3.9",
+ "zstd",
+]
+
+[[package]]
+name = "wasmtime-jit"
+version = "0.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e914c013c7a9f15f4e429d5431f2830fb8adb56e40567661b69c5ec1d645be23"
+dependencies = [
+ "anyhow",
+ "cfg-if 0.1.10",
+ "cranelift-codegen",
+ "cranelift-entity",
+ "cranelift-frontend",
+ "cranelift-native",
+ "cranelift-wasm",
+ "gimli 0.21.0",
+ "log",
+ "more-asserts",
+ "object 0.20.0",
+ "region",
+ "target-lexicon",
+ "thiserror",
+ "wasmparser 0.59.0",
+ "wasmtime-debug",
+ "wasmtime-environ",
+ "wasmtime-obj",
+ "wasmtime-profiling",
+ "wasmtime-runtime",
+ "winapi 0.3.9",
+]
+
+[[package]]
+name = "wasmtime-obj"
+version = "0.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e81d8e02e9bc9fe2da9b6d48bbc217f96e089f7df613f11a28a3958abc44641e"
+dependencies = [
+ "anyhow",
+ "more-asserts",
+ "object 0.20.0",
+ "target-lexicon",
+ "wasmtime-debug",
+ "wasmtime-environ",
+]
+
+[[package]]
+name = "wasmtime-profiling"
+version = "0.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e8d4d1af8dd5f7096cfcc89dd668d358e52980c38cce199643372ffd6590e27"
+dependencies = [
+ "anyhow",
+ "cfg-if 0.1.10",
+ "gimli 0.21.0",
+ "lazy_static",
+ "libc",
+ "object 0.19.0",
+ "scroll",
+ "serde",
+ "target-lexicon",
+ "wasmtime-environ",
+ "wasmtime-runtime",
+]
+
+[[package]]
+name = "wasmtime-runtime"
+version = "0.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a25f140bbbaadb07c531cba99ce1a966dba216138dc1b2a0ddecec851a01a93"
+dependencies = [
+ "backtrace",
+ "cc",
+ "cfg-if 0.1.10",
+ "indexmap",
+ "lazy_static",
+ "libc",
+ "log",
+ "memoffset",
+ "more-asserts",
+ "region",
+ "thiserror",
+ "wasmtime-environ",
+ "winapi 0.3.9",
+]
+
+[[package]]
+name = "wast"
+version = "26.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d54b3678343bfdf1768c16308a4b53823b70f7bb148d3d38225123d4306ec731"
+dependencies = [
+ "leb128",
+]
+
+[[package]]
+name = "wat"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26b2dccbce4d0e14875091846e110a2369267b18ddd0d6423479b88dad914d71"
+dependencies = [
+ "wast",
+]
+
+[[package]]
name = "web-sys"
version = "0.3.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -7489,3 +7997,34 @@
"syn",
"synstructure",
]
+
+[[package]]
+name = "zstd"
+version = "0.5.3+zstd.1.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "01b32eaf771efa709e8308605bbf9319bf485dc1503179ec0469b611937c0cd8"
+dependencies = [
+ "zstd-safe",
+]
+
+[[package]]
+name = "zstd-safe"
+version = "2.0.5+zstd.1.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1cfb642e0d27f64729a639c52db457e0ae906e7bc6f5fe8f5c453230400f1055"
+dependencies = [
+ "libc",
+ "zstd-sys",
+]
+
+[[package]]
+name = "zstd-sys"
+version = "1.4.17+zstd.1.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b89249644df056b522696b1bb9e7c18c87e8ffa3e2f0dc3b0155875d6498f01b"
+dependencies = [
+ "cc",
+ "glob",
+ "itertools 0.9.0",
+ "libc",
+]
README.mddiffbeforeafterboth--- a/README.md
+++ b/README.md
@@ -115,6 +115,22 @@
Additional CLI usage options are available and may be shown by running `cargo run -- --help`.
+## Benchmarks
+
+First of all, add rust toolchain and make it default.
+```bash
+rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-01
+```
+
+Then in "/node/src" run build command below
+```bash
+cargo +nightly-2020-10-01 build --release --features runtime-benchmarks
+```
+
+Run benchmark
+```bash
+target/release/nft benchmark --chain dev --pallet "pallet_nft" --extrinsic "*" --repeat 1
+```
## UI custom types
```
doc/milestone_1.mddiffbeforeafterboth--- /dev/null
+++ b/doc/milestone_1.md
@@ -0,0 +1,65 @@
+## Milestone 1
+
+**User Paid Fees and Sponsored. Finish/Debug white listing and spam/DOS protection**
+
+Implementation of two models
+If collection sponsor is set and confirmed for collection instance that means Sponsored Economic Model has chosen. Otherwise default economic model User Paid Fees is set.
+For Sponsored Economic Model exists timeouts for token transactions. For every NFT type timeouts defined separately. Timeouts and white list limits together prevented spam and malicious actions.
+
+Set sponsor
+`nft`.`set_collection_sponsor`
+Confirm sponsor
+`nft`.`confirm_sponsorship`
+
+A white list mode presented by collection property `access` and can be enabled with `set_public_access_mode`. Rules provide spam/DOS protection
+While collection in the white list mode rules below are active:
+Owner can add address to white list
+Admin can add address to white list
+Non-privileged user cannot add address to white list
+Owner can remove address from white list
+Admin can remove address from white list
+Non-privileged user cannot remove address from white list
+If Public Access mode is set to WhiteList, tokens can’t be transferred from a non-whitelisted address with transfer or transferFrom
+If Public Access mode is set to WhiteList, tokens can’t be transferred to a non-whitelisted address with transfer or transferFrom
+If Public Access mode is set to WhiteList, tokens can’t be destroyed by a non-whitelisted address (even if it owned them before enabling WhiteList mode)
+If Public Access mode is set to WhiteList, token transfers can’t be Approved by a non-whitelisted address (see Approve method).
+If Public Access mode is set to WhiteList, tokens can be transferred to a whitelisted address with transfer or transferFrom
+If Public Access mode is set to WhiteList, tokens can be transferred from a whitelisted address with transfer or transferFrom
+If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by owner.
+If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by admin.
+If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and white listed address.
+If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-white listed address.
+If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by owner.
+If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by admin.
+If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-white listed address.
+If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by non-privileged and white listed address.
+
+**Add missing custom types (CollectionMode, FungibleItemType, ReFungibleItemType)**
+
+Follow types defined
+```
+pub struct NftItemType<AccountId> {
+ pub collection: u64,
+ pub owner: AccountId,
+ pub data: Vec<u8>,
+}
+pub struct FungibleItemType<AccountId> {
+ pub collection: u64,
+ pub owner: AccountId,
+ pub value: u128,
+}
+pub struct ReFungibleItemType<AccountId> {
+ pub collection: u64,
+ pub owner: Vec<Ownership<AccountId>>,
+ pub data: Vec<u8>,
+}
+```
+
+**Add substrate bounds for number of collections, owned tokens, and number of collection admins.**
+
+Bounds defined in chain specification and can be set with 'sudo' privileges `nft`.`set_chain_limits`.
+
+**Add/document extra genesis**
+
+Extra genesis defined in `node/src/chain_spec.rs` file. Configuration consist from 5 items:
+Collection list, Nft items list, Fungible items list, Refungible items list, Chain limits
\ No newline at end of file
node/Cargo.tomldiffbeforeafterboth--- a/node/Cargo.toml
+++ b/node/Cargo.toml
@@ -27,131 +27,36 @@
structopt = '0.3.8'
jsonrpc-core = '15.0.0'
-[dependencies.nft-runtime]
-path = '../runtime'
-version = '2.0.0'
-
-[dependencies.sc-basic-authorship]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sc-cli]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sc-client-api]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sc-consensus]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.pallet-contracts-rpc]
-git = 'https://github.com/usetech-llc/substrate.git'
-version = '0.8.0'
-branch = 'v2.0.0_release'
-
-[dependencies.sc-rpc]
-git = 'https://github.com/usetech-llc/substrate.git'
-version = '2.0.0'
-branch = 'v2.0.0_release'
-
-[dependencies.sp-api]
-git = 'https://github.com/usetech-llc/substrate.git'
-version = '2.0.0'
-branch = 'v2.0.0_release'
-
-[dependencies.sp-blockchain]
-git = 'https://github.com/usetech-llc/substrate.git'
-version = '2.0.0'
-branch = 'v2.0.0_release'
-
-[dependencies.sp-block-builder]
-git = 'https://github.com/usetech-llc/substrate.git'
-version = '2.0.0'
-branch = 'v2.0.0_release'
-
-[dependencies.sc-rpc-api]
-git = 'https://github.com/usetech-llc/substrate.git'
-version = '0.8.0'
-branch = 'v2.0.0_release'
-
-[dependencies.substrate-frame-rpc-system]
-git = 'https://github.com/usetech-llc/substrate.git'
-version = '2.0.0'
-branch = 'v2.0.0_release'
-
-[dependencies.pallet-transaction-payment-rpc]
-git = 'https://github.com/usetech-llc/substrate.git'
-version = '2.0.0'
-branch = 'v2.0.0_release'
-
-[dependencies.sc-consensus-aura]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sc-executor]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sc-finality-grandpa]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sc-network]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sc-service]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sc-transaction-pool]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-consensus]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sp-consensus-aura]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sp-core]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-finality-grandpa]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-inherents]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-runtime]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
+# Substrate dependencies
+nft-runtime = { path = '../runtime', version = '2.0.0' }
+frame-benchmarking = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+frame-benchmarking-cli = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+pallet-transaction-payment-rpc = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sc-basic-authorship = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sc-cli = { features = ['wasmtime'], version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sc-client-api = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sc-consensus = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sc-consensus-aura = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sc-executor = { features = ['wasmtime'], version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sc-finality-grandpa = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sc-rpc = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sc-rpc-api = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sc-service = { features = ['wasmtime'], version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sc-transaction-pool = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-api = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-block-builder = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-blockchain = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-consensus = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-consensus-aura = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-core = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-finality-grandpa = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-inherents = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-runtime = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sp-transaction-pool = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+sc-network = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+substrate-frame-rpc-system = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
+pallet-contracts-rpc = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release'}
-[dependencies.sp-transaction-pool]
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
+[features]
+default = []
+runtime-benchmarks = ['nft-runtime/runtime-benchmarks']
node/src/chain_spec.rsdiffbeforeafterboth--- a/node/src/chain_spec.rs
+++ b/node/src/chain_spec.rs
@@ -39,69 +39,94 @@
}
pub fn development_config() -> Result<ChainSpec, String> {
- Ok(ChainSpec::from_genesis(
- "Development",
- "dev",
- ChainType::Development,
- || {
- testnet_genesis(
- vec![authority_keys_from_seed("Alice")],
- get_account_id_from_seed::<sr25519::Public>("Alice"),
- vec![
- get_account_id_from_seed::<sr25519::Public>("Alice"),
- get_account_id_from_seed::<sr25519::Public>("Bob"),
- get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
- get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
- ],
- true,
- )
- },
- vec![],
- None,
- None,
- None,
- None,
- ))
+ let wasm_binary = WASM_BINARY.ok_or("Development wasm binary not available".to_string())?;
+
+ Ok(ChainSpec::from_genesis(
+ // Name
+ "Development",
+ // ID
+ "dev",
+ ChainType::Development,
+ move || testnet_genesis(
+ wasm_binary,
+ // Initial PoA authorities
+ vec![
+ authority_keys_from_seed("Alice"),
+ ],
+ // Sudo account
+ get_account_id_from_seed::<sr25519::Public>("Alice"),
+ // Pre-funded accounts
+ vec![
+ get_account_id_from_seed::<sr25519::Public>("Alice"),
+ get_account_id_from_seed::<sr25519::Public>("Bob"),
+ get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
+ get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
+ ],
+ true,
+ ),
+ // Bootnodes
+ vec![],
+ // Telemetry
+ None,
+ // Protocol ID
+ None,
+ // Properties
+ None,
+ // Extensions
+ None,
+ ))
}
pub fn local_testnet_config() -> Result<ChainSpec, String> {
- Ok(ChainSpec::from_genesis(
- "Local Testnet",
- "local_testnet",
- ChainType::Local,
- || {
- testnet_genesis(
- vec![
- authority_keys_from_seed("Alice"),
- authority_keys_from_seed("Bob"),
- ],
- get_account_id_from_seed::<sr25519::Public>("Alice"),
- vec![
- get_account_id_from_seed::<sr25519::Public>("Alice"),
- get_account_id_from_seed::<sr25519::Public>("Bob"),
- get_account_id_from_seed::<sr25519::Public>("Charlie"),
- get_account_id_from_seed::<sr25519::Public>("Dave"),
- get_account_id_from_seed::<sr25519::Public>("Eve"),
- get_account_id_from_seed::<sr25519::Public>("Ferdie"),
- get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
- get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
- get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
- get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
- get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
- get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
- ],
- true,
- )
- },
- vec![],
- None,
- None,
- None,
- None,
- ))
+ let wasm_binary = WASM_BINARY.ok_or("Development wasm binary not available".to_string())?;
+
+ Ok(ChainSpec::from_genesis(
+ // Name
+ "Local Testnet",
+ // ID
+ "local_testnet",
+ ChainType::Local,
+ move || testnet_genesis(
+ wasm_binary,
+ // Initial PoA authorities
+ vec![
+ authority_keys_from_seed("Alice"),
+ authority_keys_from_seed("Bob"),
+ ],
+ // Sudo account
+ get_account_id_from_seed::<sr25519::Public>("Alice"),
+ // Pre-funded accounts
+ vec![
+ get_account_id_from_seed::<sr25519::Public>("Alice"),
+ get_account_id_from_seed::<sr25519::Public>("Bob"),
+ get_account_id_from_seed::<sr25519::Public>("Charlie"),
+ get_account_id_from_seed::<sr25519::Public>("Dave"),
+ get_account_id_from_seed::<sr25519::Public>("Eve"),
+ get_account_id_from_seed::<sr25519::Public>("Ferdie"),
+ get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
+ get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
+ get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
+ get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
+ get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
+ get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
+ ],
+ true,
+ ),
+ // Bootnodes
+ vec![],
+ // Telemetry
+ None,
+ // Protocol ID
+ None,
+ // Properties
+ None,
+ // Extensions
+ None,
+ ))
}
fn testnet_genesis(
+ wasm_binary: &[u8],
initial_authorities: Vec<(AuraId, GrandpaId)>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
@@ -109,27 +134,27 @@
) -> GenesisConfig {
GenesisConfig {
system: Some(SystemConfig {
- code: WASM_BINARY.to_vec(),
+ code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}),
- balances: Some(BalancesConfig {
+ pallet_balances: Some(BalancesConfig {
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, 1 << 100))
.collect(),
}),
- aura: Some(AuraConfig {
+ pallet_aura: Some(AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
}),
- grandpa: Some(GrandpaConfig {
+ pallet_grandpa: Some(GrandpaConfig {
authorities: initial_authorities
.iter()
.map(|x| (x.1.clone(), 1))
.collect(),
}),
- sudo: Some(SudoConfig { key: root_key }),
- nft: Some(NftConfig {
+ pallet_sudo: Some(SudoConfig { key: root_key }),
+ pallet_nft: Some(NftConfig {
collection: vec![(
1,
CollectionType {
@@ -160,7 +185,7 @@
refungible_sponsor_transfer_timeout: 15,
},
}),
- contracts: Some(ContractsConfig {
+ pallet_contracts: Some(ContractsConfig {
current_schedule: ContractsSchedule {
enable_println,
..Default::default()
node/src/cli.rsdiffbeforeafterboth--- a/node/src/cli.rs
+++ b/node/src/cli.rs
@@ -34,6 +34,6 @@
Revert(sc_cli::RevertCmd),
// The custom benchmark subcommmand benchmarking runtime pallets.
- // #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
- // Benchmark(frame_benchmarking_cli::BenchmarkCmd),
+ #[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
+ Benchmark(frame_benchmarking_cli::BenchmarkCmd),
}
node/src/command.rsdiffbeforeafterboth--- a/node/src/command.rs
+++ b/node/src/command.rs
@@ -19,7 +19,7 @@
use crate::cli::{Cli, Subcommand};
use sc_cli::{SubstrateCli, RuntimeVersion, Role, ChainSpec};
use sc_service::PartialComponents;
-// use nft_runtime::Block;
+use nft_runtime::Block;
impl SubstrateCli for Cli {
fn impl_name() -> String {
@@ -114,16 +114,16 @@
Ok((cmd.run(client, backend), task_manager))
})
},
- // Some(Subcommand::Benchmark(cmd)) => {
- // if cfg!(feature = "runtime-benchmarks") {
- // let runner = cli.create_runner(cmd)?;
+ Some(Subcommand::Benchmark(cmd)) => {
+ if cfg!(feature = "runtime-benchmarks") {
+ let runner = cli.create_runner(cmd)?;
- // runner.sync_run(|config| cmd.run::<Block, service::Executor>(config))
- // } else {
- // Err("Benchmarking wasn't enabled when building the node. \
- // You can enable it with `--features runtime-benchmarks`.".into())
- // }
- // },
+ runner.sync_run(|config| cmd.run::<Block, service::Executor>(config))
+ } else {
+ Err("Benchmarking wasn't enabled when building the node. \
+ You can enable it with `--features runtime-benchmarks`.".into())
+ }
+ },
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| match config.role {
node/src/service.rsdiffbeforeafterboth--- a/node/src/service.rs
+++ b/node/src/service.rs
@@ -16,7 +16,7 @@
pub Executor,
nft_runtime::api::dispatch,
nft_runtime::native_version,
- // frame_benchmarking::benchmarking::HostFunctions,
+ frame_benchmarking::benchmarking::HostFunctions,
);
type FullClient = sc_service::TFullClient<Block, RuntimeApi, Executor>;
pallets/nft/Cargo.tomldiffbeforeafterboth--- a/pallets/nft/Cargo.toml
+++ b/pallets/nft/Cargo.toml
@@ -1,8 +1,22 @@
+[package]
+authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
+description = 'FRAME pallet nft'
+edition = '2018'
+homepage = 'https://substrate.io'
+license = 'Unlicense'
+name = 'pallet-nft'
+repository = 'https://github.com/substrate-developer-hub/nft/'
+version = '2.0.0'
+
+[package.metadata.docs.rs]
+targets = ['x86_64-unknown-linux-gnu']
+
+# alias "parity-scale-code" to "codec"
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
-version = '1.3.0'
+version = '1.3.4'
[dependencies.frame-support]
default-features = false
@@ -15,6 +29,7 @@
git = 'https://github.com/usetech-llc/substrate.git'
branch = 'v2.0.0_release'
version = '2.0.0'
+
[dev-dependencies.sp-core]
default-features = false
git = 'https://github.com/usetech-llc/substrate.git'
@@ -51,17 +66,12 @@
branch = 'v2.0.0_release'
version = '2.0.0'
-[package]
-authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
-description = 'FRAME pallet nft'
-edition = '2018'
-homepage = 'https://substrate.io'
-license = 'Unlicense'
-name = 'pallet-nft'
-repository = 'https://github.com/substrate-developer-hub/nft/'
-version = '2.0.0'
-[package.metadata.docs.rs]
-targets = ['x86_64-unknown-linux-gnu']
+[dependencies.frame-benchmarking]
+version = "2.0.0"
+default-features = false
+git = 'https://github.com/usetech-llc/substrate.git'
+branch = 'v2.0.0_release'
+optional = true
[features]
default = ['std']
@@ -70,6 +80,8 @@
"serde/std",
'frame-support/std',
'frame-system/std',
+ 'sp-std/std',
'sp-runtime/std',
- 'sp-std/std',
+ 'frame-benchmarking/std',
]
+runtime-benchmarks = ["frame-benchmarking"]
pallets/nft/src/benchmarking.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/nft/src/benchmarking.rs
@@ -0,0 +1,294 @@
+#[cfg(feature = "runtime-benchmarks")]
+// mod benchmarking {
+ use super::*;
+ use sp_std::prelude::*;
+ use frame_system::RawOrigin;
+ // use frame_support::{ensure, traits::OnFinalize};
+ use frame_benchmarking::{benchmarks, account, whitelisted_caller}; // , TrackedStorageKey,
+ use crate::Module as Nft;
+
+ const SEED: u32 = 1;
+
+ benchmarks! {
+
+ _ {}
+
+ create_collection {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = account("caller", 0, SEED);
+ }: create_collection(RawOrigin::Signed(caller.clone()), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode)
+ verify {
+ assert_eq!(Nft::<T>::collection(2).owner, caller);
+ }
+
+ destroy_collection {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ }: destroy_collection(RawOrigin::Signed(caller.clone()), 2)
+
+ add_to_white_list {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ let whitelist_account: T::AccountId = account("admin", 0, SEED);
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ }: add_to_white_list(RawOrigin::Signed(caller.clone()), 2, whitelist_account)
+
+ remove_from_white_list {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ let whitelist_account: T::AccountId = account("admin", 0, SEED);
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::add_to_white_list(RawOrigin::Signed(caller.clone()).into(), 2, whitelist_account.clone())?;
+ }: remove_from_white_list(RawOrigin::Signed(caller.clone()), 2, whitelist_account)
+
+ set_public_access_mode {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ }: set_public_access_mode(RawOrigin::Signed(caller.clone()), 2, AccessMode::WhiteList)
+
+ set_mint_permission {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ }: set_mint_permission(RawOrigin::Signed(caller.clone()), 2, true)
+
+ change_collection_owner {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ let new_owner: T::AccountId = account("admin", 0, SEED);
+ }: change_collection_owner(RawOrigin::Signed(caller.clone()), 2, new_owner)
+
+ add_collection_admin {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ let new_admin: T::AccountId = account("admin", 0, SEED);
+ }: add_collection_admin(RawOrigin::Signed(caller.clone()), 2, new_admin)
+
+ remove_collection_admin {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ let new_admin: T::AccountId = account("admin", 0, SEED);
+ Nft::<T>::add_collection_admin(RawOrigin::Signed(caller.clone()).into(), 2, new_admin.clone())?;
+ }: remove_collection_admin(RawOrigin::Signed(caller.clone()), 2, new_admin)
+
+ set_collection_sponsor {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ }: set_collection_sponsor(RawOrigin::Signed(caller.clone()), 2, caller.clone())
+
+ confirm_sponsorship {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone())?;
+ }: confirm_sponsorship(RawOrigin::Signed(caller.clone()), 2)
+
+ remove_collection_sponsor {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone())?;
+ Nft::<T>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), 2)?;
+ }: remove_collection_sponsor(RawOrigin::Signed(caller.clone()), 2)
+
+ // nft item
+ create_item_nft {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+
+ }: create_item(RawOrigin::Signed(caller.clone()), 2, [1,2,3].to_vec(), caller.clone())
+
+ #[extra]
+ create_item_nft_large {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ let mut item_large: Vec<u8> = Vec::new();
+ for i in 0..1998 {
+ item_large.push(10);
+ }
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+
+ }: create_item(RawOrigin::Signed(caller.clone()), 2, item_large, caller.clone())
+
+ // fungible item
+ create_item_fungible {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::Fungible(3);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+
+ }: create_item(RawOrigin::Signed(caller.clone()), 2, [].to_vec(), caller.clone())
+
+ // refungible item
+ create_item_refungible {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::ReFungible(3, 3);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+
+ }: create_item(RawOrigin::Signed(caller.clone()), 2, [1,2,3].to_vec(), caller.clone())
+
+ burn_item {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, [1, 2, 3].to_vec(), caller.clone())?;
+
+ }: burn_item(RawOrigin::Signed(caller.clone()), 2, 1)
+
+ transfer_nft {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(2000);
+ let recipient: T::AccountId = account("recipient", 0, SEED);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, [1, 2, 3].to_vec(), caller.clone())?;
+
+ }: transfer(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1, 1)
+
+ transfer_fungible {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::Fungible(3);
+ let recipient: T::AccountId = account("recipient", 0, SEED);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, [].to_vec(), caller.clone())?;
+
+ }: transfer(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1, 1)
+
+ transfer_refungible {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::ReFungible(3,3);
+ let recipient: T::AccountId = account("recipient", 0, SEED);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, [1,2,3].to_vec(), caller.clone())?;
+
+ }: transfer(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1, 1)
+
+ approve {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::ReFungible(3,3);
+ let recipient: T::AccountId = account("recipient", 0, SEED);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, [1,2,3].to_vec(), caller.clone())?;
+
+ }: approve(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1)
+
+ // Nft
+ transfer_from_nft {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::NFT(300);
+ let recipient: T::AccountId = account("recipient", 0, SEED);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, [1,2,3].to_vec(), caller.clone())?;
+ Nft::<T>::approve(RawOrigin::Signed(caller.clone()).into(), recipient.clone(), 2, 1)?;
+
+ }: transfer_from(RawOrigin::Signed(caller.clone()), caller.clone(), recipient.clone(), 2, 1, 1)
+
+ // Fungible
+ transfer_from_fungible {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::Fungible(3);
+ let recipient: T::AccountId = account("recipient", 0, SEED);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, [].to_vec(), caller.clone())?;
+ Nft::<T>::approve(RawOrigin::Signed(caller.clone()).into(), recipient.clone(), 2, 1)?;
+
+ }: transfer_from(RawOrigin::Signed(caller.clone()), caller.clone(), recipient.clone(), 2, 1, 1)
+
+ // ReFungible
+ transfer_from_refungible {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::ReFungible(3,3);
+ let recipient: T::AccountId = account("recipient", 0, SEED);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+ Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, [1,2,3].to_vec(), caller.clone())?;
+ Nft::<T>::approve(RawOrigin::Signed(caller.clone()).into(), recipient.clone(), 2, 1)?;
+
+ }: transfer_from(RawOrigin::Signed(caller.clone()), caller.clone(), recipient.clone(), 2, 1, 1)
+
+ set_offchain_schema {
+ let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();
+ let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();
+ let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();
+ let mode: CollectionMode = CollectionMode::ReFungible(3,3);
+ let caller: T::AccountId = T::AccountId::from(whitelisted_caller());
+ Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;
+
+ }: set_offchain_schema(RawOrigin::Signed(caller.clone()), 2, [1,2,3].to_vec())
+ }
\ No newline at end of file
pallets/nft/src/default_weights.rsdiffbeforeafterboth--- /dev/null
+++ b/pallets/nft/src/default_weights.rs
@@ -0,0 +1,95 @@
+use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
+
+impl crate::WeightInfo for () {
+ fn create_collection() -> Weight {
+ (70_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(7 as Weight))
+ .saturating_add(DbWeight::get().writes(5 as Weight))
+ }
+ fn destroy_collection() -> Weight {
+ (90_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(5 as Weight))
+ }
+ fn add_to_white_list() -> Weight {
+ (30_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(3 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn remove_from_white_list() -> Weight {
+ (35_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(3 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn set_public_access_mode() -> Weight {
+ (27_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn set_mint_permission() -> Weight {
+ (27_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn change_collection_owner() -> Weight {
+ (27_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn add_collection_admin() -> Weight {
+ (32_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(3 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn remove_collection_admin() -> Weight {
+ (50_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn set_collection_sponsor() -> Weight {
+ (32_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn confirm_sponsorship() -> Weight {
+ (22_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn remove_collection_sponsor() -> Weight {
+ (24_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn create_item(s: usize, ) -> Weight {
+ (130_000_000 as Weight)
+ .saturating_add((2135 as Weight).saturating_mul(s as Weight))
+ .saturating_add(DbWeight::get().reads(10 as Weight))
+ .saturating_add(DbWeight::get().writes(8 as Weight))
+ }
+ fn burn_item() -> Weight {
+ (170_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(9 as Weight))
+ .saturating_add(DbWeight::get().writes(7 as Weight))
+ }
+ fn transfer() -> Weight {
+ (125_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(7 as Weight))
+ .saturating_add(DbWeight::get().writes(7 as Weight))
+ }
+ fn approve() -> Weight {
+ (45_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(3 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn transfer_from() -> Weight {
+ (150_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(9 as Weight))
+ .saturating_add(DbWeight::get().writes(8 as Weight))
+ }
+ fn set_offchain_schema() -> Weight {
+ (33_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+}
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -22,6 +22,7 @@
},
IsSubType, StorageValue,
};
+// use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
use frame_system::{self as system, ensure_signed, ensure_root};
use sp_runtime::sp_std::prelude::Vec;
@@ -43,6 +44,8 @@
#[cfg(test)]
mod tests;
+mod default_weights;
+
// Structs
// #region
@@ -181,10 +184,37 @@
pub refungible_sponsor_transfer_timeout: u32,
}
-pub trait Trait: system::Trait {
+pub trait WeightInfo {
+ fn create_collection() -> Weight;
+ fn destroy_collection() -> Weight;
+ fn add_to_white_list() -> Weight;
+ fn remove_from_white_list() -> Weight;
+ fn set_public_access_mode() -> Weight;
+ fn set_mint_permission() -> Weight;
+ fn change_collection_owner() -> Weight;
+ fn add_collection_admin() -> Weight;
+ fn remove_collection_admin() -> Weight;
+ fn set_collection_sponsor() -> Weight;
+ fn confirm_sponsorship() -> Weight;
+ fn remove_collection_sponsor() -> Weight;
+ fn create_item(s: usize, ) -> Weight;
+ fn burn_item() -> Weight;
+ fn transfer() -> Weight;
+ fn approve() -> Weight;
+ fn transfer_from() -> Weight;
+ fn set_offchain_schema() -> Weight;
+}
+
+pub trait Trait: system::Trait + Sized {
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
+
+ /// Weight information for extrinsics in this pallet.
+ type WeightInfo: WeightInfo;
}
+#[cfg(feature = "runtime-benchmarks")]
+mod benchmarking;
+
// #endregion
decl_storage! {
@@ -322,7 +352,7 @@
///
/// * mode: [CollectionMode] collection type and type dependent data.
// returns collection ID
- #[weight = 0]
+ #[weight = T::WeightInfo::create_collection()]
pub fn create_collection(origin,
collection_name: Vec<u16>,
collection_description: Vec<u16>,
@@ -418,7 +448,7 @@
/// # Arguments
///
/// * collection_id: collection to destroy.
- #[weight = 0]
+ #[weight = T::WeightInfo::destroy_collection()]
pub fn destroy_collection(origin, collection_id: u64) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -465,7 +495,7 @@
/// * collection_id.
///
/// * address.
- #[weight = 0]
+ #[weight = T::WeightInfo::add_to_white_list()]
pub fn add_to_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{
let sender = ensure_signed(origin)?;
@@ -500,7 +530,7 @@
/// * collection_id.
///
/// * address.
- #[weight = 0]
+ #[weight = T::WeightInfo::remove_from_white_list()]
pub fn remove_from_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{
let sender = ensure_signed(origin)?;
@@ -529,7 +559,7 @@
/// * collection_id.
///
/// * mode: [AccessMode]
- #[weight = 0]
+ #[weight = T::WeightInfo::set_public_access_mode()]
pub fn set_public_access_mode(origin, collection_id: u64, mode: AccessMode) -> DispatchResult
{
let sender = ensure_signed(origin)?;
@@ -555,7 +585,7 @@
/// * collection_id.
///
/// * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.
- #[weight = 0]
+ #[weight = T::WeightInfo::set_mint_permission()]
pub fn set_mint_permission(origin, collection_id: u64, mint_permission: bool) -> DispatchResult
{
let sender = ensure_signed(origin)?;
@@ -579,7 +609,7 @@
/// * collection_id.
///
/// * new_owner.
- #[weight = 0]
+ #[weight = T::WeightInfo::change_collection_owner()]
pub fn change_collection_owner(origin, collection_id: u64, new_owner: T::AccountId) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -604,7 +634,7 @@
/// * collection_id: ID of the Collection to add admin for.
///
/// * new_admin_id: Address of new admin to add.
- #[weight = 0]
+ #[weight = T::WeightInfo::add_collection_admin()]
pub fn add_collection_admin(origin, collection_id: u64, new_admin_id: T::AccountId) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -638,7 +668,7 @@
/// * collection_id: ID of the Collection to remove admin for.
///
/// * account_id: Address of admin to remove.
- #[weight = 0]
+ #[weight = T::WeightInfo::remove_collection_admin()]
pub fn remove_collection_admin(origin, collection_id: u64, account_id: T::AccountId) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -663,7 +693,7 @@
/// * collection_id.
///
/// * new_sponsor.
- #[weight = 0]
+ #[weight = T::WeightInfo::set_collection_sponsor()]
pub fn set_collection_sponsor(origin, collection_id: u64, new_sponsor: T::AccountId) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -685,7 +715,7 @@
/// # Arguments
///
/// * collection_id.
- #[weight = 0]
+ #[weight = T::WeightInfo::confirm_sponsorship()]
pub fn confirm_sponsorship(origin, collection_id: u64) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -710,7 +740,7 @@
/// # Arguments
///
/// * collection_id.
- #[weight = 0]
+ #[weight = T::WeightInfo::remove_collection_sponsor()]
pub fn remove_collection_sponsor(origin, collection_id: u64) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -743,7 +773,13 @@
/// * properties: Array of bytes that contains NFT properties. Since NFT Module is agnostic of properties meaning, it is treated purely as an array of bytes.
///
/// * owner: Address, initial owner of the NFT.
- #[weight = 0]
+ // #[weight =
+ // (130_000_000 as Weight)
+ // .saturating_add((2135 as Weight).saturating_mul((properties.len() as u64) as Weight))
+ // .saturating_add(RocksDbWeight::get().reads(10 as Weight))
+ // .saturating_add(RocksDbWeight::get().writes(8 as Weight))]
+
+ #[weight = T::WeightInfo::create_item(properties.len())]
pub fn create_item(origin, collection_id: u64, properties: Vec<u8>, owner: T::AccountId) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -826,7 +862,7 @@
/// * collection_id: ID of the collection.
///
/// * item_id: ID of NFT to burn.
- #[weight = 0]
+ #[weight = T::WeightInfo::burn_item()]
pub fn burn_item(origin, collection_id: u64, item_id: u64) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -879,7 +915,7 @@
/// * Non-Fungible Mode: Ignored
/// * Fungible Mode: Must specify transferred amount
/// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)
- #[weight = 0]
+ #[weight = T::WeightInfo::transfer()]
pub fn transfer(origin, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -921,7 +957,7 @@
/// * collection_id.
///
/// * item_id: ID of the item.
- #[weight = 0]
+ #[weight = T::WeightInfo::approve()]
pub fn approve(origin, approved: T::AccountId, collection_id: u64, item_id: u64) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -979,7 +1015,7 @@
/// * item_id: ID of the item.
///
/// * value: Amount to transfer.
- #[weight = 0]
+ #[weight = T::WeightInfo::transfer_from()]
pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64 ) -> DispatchResult {
let sender = ensure_signed(origin)?;
@@ -989,8 +1025,11 @@
if <ApprovedList<T>>::contains_key(collection_id, (item_id, from.clone())) {
let list_itm = <ApprovedList<T>>::get(collection_id, (item_id, from.clone()));
let opt_item = list_itm.iter().find(|i| i.approved == sender.clone());
- appoved_transfer = opt_item.is_some();
- ensure!(opt_item.unwrap().amount >= value, "Requested value more than approved");
+ if opt_item.is_some()
+ {
+ appoved_transfer = true;
+ ensure!(opt_item.unwrap().amount >= value, "Requested value more than approved");
+ }
}
// Transfer permissions check
@@ -1048,7 +1087,7 @@
/// * collection_id.
///
/// * schema: String representing the offchain data schema.
- #[weight = 0]
+ #[weight = T::WeightInfo::set_offchain_schema()]
pub fn set_offchain_schema(
origin,
collection_id: u64,
@@ -1936,3 +1975,5 @@
}
}
// #endregion
+
+
pallets/nft/src/mock.rsdiffbeforeafterboth--- a/pallets/nft/src/mock.rs
+++ b/pallets/nft/src/mock.rs
@@ -35,30 +35,31 @@
}
impl system::Trait for Test {
- type Origin = Origin;
- type Call = ();
- type Index = u64;
- type BlockNumber = u64;
- type Hash = H256;
- type Hashing = BlakeTwo256;
- type AccountId = u64;
- type Lookup = IdentityLookup<Self::AccountId>;
- type Header = Header;
- type Event = ();
- type BlockHashCount = BlockHashCount;
- type MaximumBlockWeight = MaximumBlockWeight;
- type MaximumBlockLength = MaximumBlockLength;
- type AvailableBlockRatio = AvailableBlockRatio;
- type BaseCallFilter = ();
- type DbWeight = RocksDbWeight;
- type BlockExecutionWeight = BlockExecutionWeight;
- type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
- type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
- type Version = ();
- type ModuleToIndex = ();
- type AccountData = ();
- type OnNewAccount = ();
- type OnKilledAccount = ();
+ type BaseCallFilter = ();
+ type Origin = Origin;
+ type Call = ();
+ type Index = u64;
+ type BlockNumber = u64;
+ type Hash = H256;
+ type Hashing = BlakeTwo256;
+ type AccountId = u64;
+ type Lookup = IdentityLookup<Self::AccountId>;
+ type Header = Header;
+ type Event = ();
+ type BlockHashCount = BlockHashCount;
+ type MaximumBlockWeight = MaximumBlockWeight;
+ type DbWeight = ();
+ type BlockExecutionWeight = ();
+ type ExtrinsicBaseWeight = ();
+ type MaximumExtrinsicWeight = MaximumBlockWeight;
+ type MaximumBlockLength = MaximumBlockLength;
+ type AvailableBlockRatio = AvailableBlockRatio;
+ type Version = ();
+ type PalletInfo = ();
+ type AccountData = ();
+ type OnNewAccount = ();
+ type OnKilledAccount = ();
+ type SystemWeightInfo = ();
}
impl Trait for Test {
type Event = ();
pallets/nft/src/tests.rsdiffbeforeafterboth--- a/pallets/nft/src/tests.rs
+++ b/pallets/nft/src/tests.rs
@@ -177,7 +177,7 @@
assert_eq!(TemplateModule::fungible_item_id(1, 1).value, 1000);
assert_eq!(TemplateModule::balance_count(1, 1), 0);
assert_eq!(TemplateModule::balance_count(1, 2), 1000);
- assert_eq!(TemplateModule::address_tokens(1, 1), []);
+ // assert_eq!(TemplateModule::address_tokens(1, 1), []);
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
// split item scenario
@@ -260,7 +260,7 @@
);
assert_eq!(TemplateModule::balance_count(1, 1), 0);
assert_eq!(TemplateModule::balance_count(1, 2), 1000);
- assert_eq!(TemplateModule::address_tokens(1, 1), []);
+ // assert_eq!(TemplateModule::address_tokens(1, 1), []);
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
// split item scenario
@@ -350,7 +350,7 @@
assert_eq!(TemplateModule::nft_item_id(1, 1).owner, 2);
assert_eq!(TemplateModule::balance_count(1, 1), 0);
assert_eq!(TemplateModule::balance_count(1, 2), 1);
- assert_eq!(TemplateModule::address_tokens(1, 1), []);
+ // assert_eq!(TemplateModule::address_tokens(1, 1), []);
assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
});
}
@@ -632,7 +632,7 @@
));
assert_eq!(TemplateModule::balance_count(1, 1), 0);
assert_eq!(TemplateModule::balance_count(1, 3), 1000);
- assert_eq!(TemplateModule::address_tokens(1, 1), []);
+ // assert_eq!(TemplateModule::address_tokens(1, 1), []);
assert_eq!(TemplateModule::address_tokens(1, 3), [2]);
assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 0);
@@ -2162,7 +2162,7 @@
assert_noop!(
TemplateModule::create_item(origin2.clone(), 1, [1, 2, 3].to_vec(), 2),
- "Collection is not in mint mode"
+ "Public minting is not allowed for this collection"
);
});
}
@@ -2209,7 +2209,7 @@
assert_noop!(
TemplateModule::create_item(origin2.clone(), 1, [1, 2, 3].to_vec(), 2),
- "Collection is not in mint mode"
+ "Public minting is not allowed for this collection"
);
});
}
runtime/Cargo.tomldiffbeforeafterboth--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -1,194 +1,3 @@
-[dependencies.aura]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'pallet-aura'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.balances]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'pallet-balances'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.codec]
-default-features = false
-features = ['derive']
-package = 'parity-scale-codec'
-version = '1.3.0'
-
-[dependencies.contracts]
-git = 'https://github.com/usetech-llc/substrate.git'
-default-features = false
-package = 'pallet-contracts'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.contracts-primitives]
-git = 'https://github.com/usetech-llc/substrate.git'
-default-features = false
-package = 'pallet-contracts-primitives'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.contracts-rpc-runtime-api]
-git = 'https://github.com/usetech-llc/substrate.git'
-default-features = false
-package = 'pallet-contracts-rpc-runtime-api'
-version = '0.8.0'
-branch = 'v2.0.0_release'
-
-[dependencies.frame-executive]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.frame-support]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.grandpa]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'pallet-grandpa'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.randomness-collective-flip]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'pallet-randomness-collective-flip'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.serde]
-features = ['derive']
-optional = true
-version = '1.0.101'
-
-[dependencies.sp-api]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-block-builder]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-consensus-aura]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '0.8.0'
-
-[dependencies.sp-core]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-inherents]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-offchain]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-runtime]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-session]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-std]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-transaction-pool]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sp-version]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.sudo]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'pallet-sudo'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.system]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'frame-system'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.nft]
-default-features = false
-package = 'pallet-nft'
-path = '../pallets/nft'
-version = '2.0.0'
-
-[dependencies.timestamp]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'pallet-timestamp'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.transaction-payment]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'pallet-transaction-payment'
-branch = 'v2.0.0_release'
-version = '2.0.0'
-
-[dependencies.frame-system-rpc-runtime-api]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-version = '2.0.0'
-branch = 'v2.0.0_release'
-
-[dependencies.transaction-payment-rpc-runtime-api]
-default-features = false
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'pallet-transaction-payment-rpc-runtime-api'
-version = '2.0.0'
-branch = 'v2.0.0_release'
-
-[build-dependencies.wasm-builder-runner]
-git = 'https://github.com/usetech-llc/substrate.git'
-package = 'substrate-wasm-builder-runner'
-version = '1.0.5'
-branch = 'v2.0.0_release'
-
[package]
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
edition = '2018'
@@ -201,21 +10,85 @@
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
+[build-dependencies]
+wasm-builder-runner = { package = 'substrate-wasm-builder-runner', version = '1.0.5' }
+
+# alias "parity-scale-code" to "codec"
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '1.3.4'
+
+[dependencies]
+hex-literal = { optional = true, version = '0.3.1' }
+serde = { features = ['derive'], optional = true, version = '1.0.101' }
+
+# local dependencies
+pallet-nft = { path = '../pallets/nft', default-features = false, version = '2.0.0' }
+
+# Substrate dependencies
+frame-benchmarking = { default-features = false, optional = true, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+frame-executive = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+frame-support = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+frame-system = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+frame-system-benchmarking = { default-features = false, optional = true, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+frame-system-rpc-runtime-api = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-aura = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-balances = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-contracts = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-contracts-primitives = { default-features = false, version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-contracts-rpc-runtime-api = { default-features = false, version = '0.8.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-grandpa = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-randomness-collective-flip = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-sudo = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-timestamp = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-transaction-payment = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-api = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-block-builder = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-consensus-aura = { default-features = false, version = '0.8.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-core = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-inherents = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-offchain = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-runtime = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-session = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-std = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-transaction-pool = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+sp-version = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'v2.0.0_release' }
+
[features]
default = ['std']
+runtime-benchmarks = [
+ 'hex-literal',
+ 'frame-benchmarking',
+ 'frame-support/runtime-benchmarks',
+ 'frame-system-benchmarking',
+ 'frame-system/runtime-benchmarks',
+ 'pallet-balances/runtime-benchmarks',
+ 'pallet-timestamp/runtime-benchmarks',
+ 'pallet-nft/runtime-benchmarks',
+ 'sp-runtime/runtime-benchmarks',
+]
std = [
- 'aura/std',
- 'balances/std',
'codec/std',
- 'contracts/std',
- 'contracts-primitives/std',
- 'contracts-rpc-runtime-api/std',
+ 'serde',
'frame-executive/std',
'frame-support/std',
+ 'frame-system/std',
'frame-system-rpc-runtime-api/std',
- 'grandpa/std',
- 'randomness-collective-flip/std',
- 'serde',
+ 'pallet-aura/std',
+ 'pallet-balances/std',
+ 'pallet-contracts/std',
+ 'pallet-contracts-primitives/std',
+ 'pallet-contracts-rpc-runtime-api/std',
+ 'pallet-grandpa/std',
+ 'pallet-randomness-collective-flip/std',
+ 'pallet-sudo/std',
+ 'pallet-timestamp/std',
+ 'pallet-transaction-payment/std',
+ 'pallet-transaction-payment-rpc-runtime-api/std',
+ 'pallet-nft/std',
'sp-api/std',
'sp-block-builder/std',
'sp-consensus-aura/std',
@@ -227,10 +100,4 @@
'sp-std/std',
'sp-transaction-pool/std',
'sp-version/std',
- 'sudo/std',
- 'system/std',
- 'timestamp/std',
- 'transaction-payment/std',
- 'transaction-payment-rpc-runtime-api/std',
- 'nft/std',
]
runtime/build.rsdiffbeforeafterboth--- a/runtime/build.rs
+++ b/runtime/build.rs
@@ -3,7 +3,7 @@
fn main() {
WasmBuilder::new()
.with_current_project()
- .with_wasm_builder_from_crates("1.0.11")
+ .with_wasm_builder_from_crates("2.0.0")
.export_heap_base()
.import_memory()
.build()
runtime/src/lib.rsdiffbeforeafterboth1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit = "256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use contracts_rpc_runtime_api::ContractExecResult;12use grandpa::fg_primitives;13use grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};14use sp_api::impl_runtime_apis;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;16use sp_core::{crypto::KeyTypeId, OpaqueMetadata};17use sp_runtime::{18 create_runtime_str, generic, impl_opaque_keys,19 traits::{20 BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating,21 Verify,22 },23 transaction_validity::{TransactionSource, TransactionValidity},24 ApplyExtrinsicResult, MultiSignature,25};26use sp_std::prelude::*;27#[cfg(feature = "std")]28use sp_version::NativeVersion;29use sp_version::RuntimeVersion;3031// A few exports that help ease life for downstream crates.32pub use balances::Call as BalancesCall;33pub use contracts::Schedule as ContractsSchedule;34pub use frame_support::{35 construct_runtime,36 dispatch::DispatchResult,37 parameter_types,38 traits::{39 Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,40 WithdrawReason,41 },42 weights::{43 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},44 DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,45 WeightToFeePolynomial,46 },47 StorageValue,48};49#[cfg(any(feature = "std", test))]50pub use sp_runtime::BuildStorage;51use sp_runtime::Perbill;52use system::{self as system};5354pub use timestamp::Call as TimestampCall;5556/// Re-export a nft pallet57/// TODO: Check this re-export. Is this safe and good style?58extern crate nft;59pub use nft::*;6061/// An index to a block.62pub type BlockNumber = u32;6364/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.65pub type Signature = MultiSignature;6667/// Some way of identifying an account on the chain. We intentionally make it equivalent68/// to the public key of our transaction signing scheme.69pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;7071/// The type for looking up accounts. We don't expect more than 4 billion of them, but you72/// never know...73pub type AccountIndex = u32;7475/// Balance of an account.76pub type Balance = u128;7778/// Index of a transaction in the chain.79pub type Index = u32;8081/// A hash of some data used by the chain.82pub type Hash = sp_core::H256;8384/// Digest item type.85pub type DigestItem = generic::DigestItem<Hash>;8687/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know88/// the specifics of the runtime. They can then be made to be agnostic over specific formats89/// of data like extrinsics, allowing for them to continue syncing the network through upgrades90/// to even the core data structures.91pub mod opaque {92 use super::*;9394 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;9596 /// Opaque block header type.97 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;98 /// Opaque block type.99 pub type Block = generic::Block<Header, UncheckedExtrinsic>;100 /// Opaque block identifier type.101 pub type BlockId = generic::BlockId<Block>;102103 impl_opaque_keys! {104 pub struct SessionKeys {105 pub aura: Aura,106 pub grandpa: Grandpa,107 }108 }109}110111/// This runtime version.112pub const VERSION: RuntimeVersion = RuntimeVersion {113 spec_name: create_runtime_str!("nft"),114 impl_name: create_runtime_str!("nft"),115 authoring_version: 1,116 spec_version: 2,117 impl_version: 1,118 apis: RUNTIME_API_VERSIONS,119 transaction_version: 1,120};121122pub const MILLISECS_PER_BLOCK: u64 = 6000;123124pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;125126// These time units are defined in number of blocks.127pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);128pub const HOURS: BlockNumber = MINUTES * 60;129pub const DAYS: BlockNumber = HOURS * 24;130131/// The version information used to identify this runtime when compiled natively.132#[cfg(feature = "std")]133pub fn native_version() -> NativeVersion {134 NativeVersion {135 runtime_version: VERSION,136 can_author_with: Default::default(),137 }138}139140parameter_types! {141 pub const BlockHashCount: BlockNumber = 2400;142 /// We allow for 2 seconds of compute with a 6 second average block time.143 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;144 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);145 /// Assume 10% of weight for average on_initialize calls.146 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()147 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();148 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;149 pub const Version: RuntimeVersion = VERSION;150}151152impl system::Trait for Runtime {153 /// The basic call filter to use in dispatchable.154 type BaseCallFilter = ();155 /// The identifier used to distinguish between accounts.156 type AccountId = AccountId;157 /// The aggregated dispatch type that is available for extrinsics.158 type Call = Call;159 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.160 type Lookup = IdentityLookup<AccountId>;161 /// The index type for storing how many extrinsics an account has signed.162 type Index = Index;163 /// The index type for blocks.164 type BlockNumber = BlockNumber;165 /// The type for hashing blocks and tries.166 type Hash = Hash;167 /// The hashing algorithm used.168 type Hashing = BlakeTwo256;169 /// The header type.170 type Header = generic::Header<BlockNumber, BlakeTwo256>;171 /// The ubiquitous event type.172 type Event = Event;173 /// The ubiquitous origin type.174 type Origin = Origin;175 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).176 type BlockHashCount = BlockHashCount;177 /// Maximum weight of each block.178 type MaximumBlockWeight = MaximumBlockWeight;179 /// The weight of database operations that the runtime can invoke.180 type DbWeight = RocksDbWeight;181 /// The weight of the overhead invoked on the block import process, independent of the182 /// extrinsics included in that block.183 type BlockExecutionWeight = BlockExecutionWeight;184 /// The base weight of any extrinsic processed by the runtime, independent of the185 /// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)186 type ExtrinsicBaseWeight = ExtrinsicBaseWeight;187 /// The maximum weight that a single extrinsic of `Normal` dispatch class can have,188 /// idependent of the logic of that extrinsics. (Roughly max block weight - average on189 /// initialize cost).190 type MaximumExtrinsicWeight = MaximumExtrinsicWeight;191 /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.192 type MaximumBlockLength = MaximumBlockLength;193 /// Portion of the block weight that is available to all normal transactions.194 type AvailableBlockRatio = AvailableBlockRatio;195 /// Version of the runtime.196 type Version = Version;197 /// This type is being generated by `construct_runtime!`.198 type PalletInfo = PalletInfo;199 /// What to do if a new account is created.200 type OnNewAccount = ();201 /// What to do if an account is fully reaped from the system.202 type OnKilledAccount = ();203 /// The data to be stored in an account.204 type AccountData = balances::AccountData<Balance>;205 /// Weight information for the extrinsics of this pallet.206 type SystemWeightInfo = ();207}208209impl aura::Trait for Runtime {210 type AuthorityId = AuraId;211}212213impl grandpa::Trait for Runtime {214 type Event = Event;215 type Call = Call;216217 type KeyOwnerProofSystem = ();218219 type KeyOwnerProof =220 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;221222 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(223 KeyTypeId,224 GrandpaId,225 )>>::IdentificationTuple;226227 type HandleEquivocation = ();228229 type WeightInfo = ();230}231232parameter_types! {233 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;234}235236impl timestamp::Trait for Runtime {237 /// A timestamp: milliseconds since the unix epoch.238 type Moment = u64;239 type OnTimestampSet = Aura;240 type MinimumPeriod = MinimumPeriod;241 type WeightInfo = ();242}243244parameter_types! {245 // pub const ExistentialDeposit: u128 = 500;246 pub const ExistentialDeposit: u128 = 0;247 pub const MaxLocks: u32 = 50;248}249250impl balances::Trait for Runtime {251 type MaxLocks = MaxLocks;252 /// The type for recording an account's balance.253 type Balance = Balance;254 /// The ubiquitous event type.255 type Event = Event;256 type DustRemoval = ();257 type ExistentialDeposit = ExistentialDeposit;258 type AccountStore = System;259 type WeightInfo = ();260}261262pub const MILLICENTS: Balance = 1_000_000_000;263pub const CENTS: Balance = 1_000 * MILLICENTS;264pub const DOLLARS: Balance = 100 * CENTS;265266parameter_types! {267 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;268 pub const RentByteFee: Balance = 4 * MILLICENTS;269 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;270 pub const SurchargeReward: Balance = 150 * MILLICENTS;271}272273impl contracts::Trait for Runtime {274 type Time = Timestamp;275 type Randomness = RandomnessCollectiveFlip;276 type Currency = Balances;277 type Event = Event;278 type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;279 type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;280 type RentPayment = ();281 type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;282 type TombstoneDeposit = TombstoneDeposit;283 type StorageSizeOffset = contracts::DefaultStorageSizeOffset;284 type RentByteFee = RentByteFee;285 type RentDepositOffset = RentDepositOffset;286 type SurchargeReward = SurchargeReward;287 type MaxDepth = contracts::DefaultMaxDepth;288 type MaxValueSize = contracts::DefaultMaxValueSize;289 type WeightPrice = transaction_payment::Module<Self>;290}291292parameter_types! {293 pub const TransactionByteFee: Balance = 1;294}295296impl transaction_payment::Trait for Runtime {297 type Currency = balances::Module<Runtime>;298 type OnTransactionPayment = ();299 type TransactionByteFee = TransactionByteFee;300 type WeightToFee = IdentityFee<Balance>;301 type FeeMultiplierUpdate = ();302}303304impl sudo::Trait for Runtime {305 type Event = Event;306 type Call = Call;307}308309/// Used for the module nft in `./nft.rs`310impl nft::Trait for Runtime {311 type Event = Event;312}313314construct_runtime!(315 pub enum Runtime where316 Block = Block,317 NodeBlock = opaque::Block,318 UncheckedExtrinsic = UncheckedExtrinsic319 {320 System: system::{Module, Call, Config, Storage, Event<T>},321 RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},322 Contracts: contracts::{Module, Call, Config, Storage, Event<T>},323 Timestamp: timestamp::{Module, Call, Storage, Inherent},324 Aura: aura::{Module, Config<T>, Inherent},325 Grandpa: grandpa::{Module, Call, Storage, Config, Event},326 Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},327 TransactionPayment: transaction_payment::{Module, Storage},328 Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},329 Nft: nft::{Module, Call, Config<T>, Storage, Event<T>},330 }331);332333/// The address format for describing accounts.334pub type Address = AccountId;335/// Block header type as expected by this runtime.336pub type Header = generic::Header<BlockNumber, BlakeTwo256>;337/// Block type as expected by this runtime.338pub type Block = generic::Block<Header, UncheckedExtrinsic>;339/// A Block signed with a Justification340pub type SignedBlock = generic::SignedBlock<Block>;341/// BlockId type as expected by this runtime.342pub type BlockId = generic::BlockId<Block>;343/// The SignedExtension to the basic transaction logic.344pub type SignedExtra = (345 system::CheckSpecVersion<Runtime>,346 system::CheckTxVersion<Runtime>,347 system::CheckGenesis<Runtime>,348 system::CheckEra<Runtime>,349 system::CheckNonce<Runtime>,350 system::CheckWeight<Runtime>,351 nft::ChargeTransactionPayment<Runtime>,352);353/// Unchecked extrinsic type as expected by this runtime.354pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;355/// Extrinsic type that has already been checked.356pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;357/// Executive: handles dispatch to the various modules.358pub type Executive =359 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;360361impl_runtime_apis! {362363 impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>364 for Runtime365 {366 fn call(367 origin: AccountId,368 dest: AccountId,369 value: Balance,370 gas_limit: u64,371 input_data: Vec<u8>,372 ) -> ContractExecResult {373 let (exec_result, gas_consumed) =374 Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);375 match exec_result {376 Ok(v) => ContractExecResult::Success {377 flags: v.flags.bits(),378 data: v.data,379 gas_consumed: gas_consumed,380 },381 Err(_) => ContractExecResult::Error,382 }383 }384385 fn get_storage(386 address: AccountId,387 key: [u8; 32],388 ) -> contracts_primitives::GetStorageResult {389 Contracts::get_storage(address, key)390 }391392 fn rent_projection(393 address: AccountId,394 ) -> contracts_primitives::RentProjectionResult<BlockNumber> {395 Contracts::rent_projection(address)396 }397 }398399 impl sp_api::Core<Block> for Runtime {400 fn version() -> RuntimeVersion {401 VERSION402 }403404 fn execute_block(block: Block) {405 Executive::execute_block(block)406 }407408 fn initialize_block(header: &<Block as BlockT>::Header) {409 Executive::initialize_block(header)410 }411 }412413 impl sp_api::Metadata<Block> for Runtime {414 fn metadata() -> OpaqueMetadata {415 Runtime::metadata().into()416 }417 }418419 impl sp_block_builder::BlockBuilder<Block> for Runtime {420 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {421 Executive::apply_extrinsic(extrinsic)422 }423424 fn finalize_block() -> <Block as BlockT>::Header {425 Executive::finalize_block()426 }427428 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {429 data.create_extrinsics()430 }431432 fn check_inherents(433 block: Block,434 data: sp_inherents::InherentData,435 ) -> sp_inherents::CheckInherentsResult {436 data.check_extrinsics(&block)437 }438439 fn random_seed() -> <Block as BlockT>::Hash {440 RandomnessCollectiveFlip::random_seed()441 }442 }443444 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {445 fn validate_transaction(446 source: TransactionSource,447 tx: <Block as BlockT>::Extrinsic,448 ) -> TransactionValidity {449 Executive::validate_transaction(source, tx)450 }451 }452453 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {454 fn offchain_worker(header: &<Block as BlockT>::Header) {455 Executive::offchain_worker(header)456 }457 }458459 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {460 fn slot_duration() -> u64 {461 Aura::slot_duration()462 }463464 fn authorities() -> Vec<AuraId> {465 Aura::authorities()466 }467 }468469 impl sp_session::SessionKeys<Block> for Runtime {470 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {471 opaque::SessionKeys::generate(seed)472 }473474 fn decode_session_keys(475 encoded: Vec<u8>,476 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {477 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)478 }479 }480481 impl fg_primitives::GrandpaApi<Block> for Runtime {482 fn grandpa_authorities() -> GrandpaAuthorityList {483 Grandpa::grandpa_authorities()484 }485486 fn submit_report_equivocation_unsigned_extrinsic(487 _equivocation_proof: fg_primitives::EquivocationProof<488 <Block as BlockT>::Hash,489 NumberFor<Block>,490 >,491 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,492 ) -> Option<()> {493 None494 }495496 fn generate_key_ownership_proof(497 _set_id: fg_primitives::SetId,498 _authority_id: GrandpaId,499 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {500 // NOTE: this is the only implementation possible since we've501 // defined our key owner proof type as a bottom type (i.e. a type502 // with no values).503 None504 }505 }506 507 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {508 fn account_nonce(account: AccountId) -> Index {509 System::account_nonce(account)510 }511 }512513 impl transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {514 fn query_info(515 uxt: <Block as BlockT>::Extrinsic,516 len: u32,517 ) -> transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {518 TransactionPayment::query_info(uxt, len)519 }520 }521522}1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit = "256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use pallet_contracts_rpc_runtime_api::ContractExecResult;12use pallet_grandpa::fg_primitives;13use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};14use sp_api::impl_runtime_apis;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;16use sp_core::{crypto::KeyTypeId, OpaqueMetadata};17use sp_runtime::{18 create_runtime_str, generic, impl_opaque_keys,19 traits::{20 BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating,21 Verify,22 },23 transaction_validity::{TransactionSource, TransactionValidity},24 ApplyExtrinsicResult, MultiSignature,25};26use sp_std::prelude::*;27#[cfg(feature = "std")]28use sp_version::NativeVersion;29use sp_version::RuntimeVersion;3031// A few exports that help ease life for downstream crates.32pub use pallet_balances::Call as BalancesCall;33pub use pallet_contracts::Schedule as ContractsSchedule;34pub use frame_support::{35 construct_runtime,36 dispatch::DispatchResult,37 parameter_types,38 traits::{39 Currency, ExistenceRequirement, Get, KeyOwnerProofSystem, OnUnbalanced, Randomness,40 WithdrawReason,41 },42 weights::{43 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},44 DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,45 WeightToFeePolynomial,46 },47 StorageValue,48};49#[cfg(any(feature = "std", test))]50pub use sp_runtime::BuildStorage;51use sp_runtime::Perbill;52use frame_system::{self as system};5354pub use pallet_timestamp::Call as TimestampCall;5556/// Re-export a nft pallet57/// TODO: Check this re-export. Is this safe and good style?58extern crate pallet_nft;59pub use pallet_nft::*;6061/// An index to a block.62pub type BlockNumber = u32;6364/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.65pub type Signature = MultiSignature;6667/// Some way of identifying an account on the chain. We intentionally make it equivalent68/// to the public key of our transaction signing scheme.69pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;7071/// The type for looking up accounts. We don't expect more than 4 billion of them, but you72/// never know...73pub type AccountIndex = u32;7475/// Balance of an account.76pub type Balance = u128;7778/// Index of a transaction in the chain.79pub type Index = u32;8081/// A hash of some data used by the chain.82pub type Hash = sp_core::H256;8384/// Digest item type.85pub type DigestItem = generic::DigestItem<Hash>;8687mod nft_weights;8889/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know90/// the specifics of the runtime. They can then be made to be agnostic over specific formats91/// of data like extrinsics, allowing for them to continue syncing the network through upgrades92/// to even the core data structures.93pub mod opaque {94 use super::*;9596 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;9798 /// Opaque block header type.99 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;100 /// Opaque block type.101 pub type Block = generic::Block<Header, UncheckedExtrinsic>;102 /// Opaque block identifier type.103 pub type BlockId = generic::BlockId<Block>;104105 impl_opaque_keys! {106 pub struct SessionKeys {107 pub aura: Aura,108 pub grandpa: Grandpa,109 }110 }111}112113/// This runtime version.114pub const VERSION: RuntimeVersion = RuntimeVersion {115 spec_name: create_runtime_str!("nft"),116 impl_name: create_runtime_str!("nft"),117 authoring_version: 1,118 spec_version: 2,119 impl_version: 1,120 apis: RUNTIME_API_VERSIONS,121 transaction_version: 1,122};123124pub const MILLISECS_PER_BLOCK: u64 = 6000;125126pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;127128// These time units are defined in number of blocks.129pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);130pub const HOURS: BlockNumber = MINUTES * 60;131pub const DAYS: BlockNumber = HOURS * 24;132133/// The version information used to identify this runtime when compiled natively.134#[cfg(feature = "std")]135pub fn native_version() -> NativeVersion {136 NativeVersion {137 runtime_version: VERSION,138 can_author_with: Default::default(),139 }140}141142parameter_types! {143 pub const BlockHashCount: BlockNumber = 2400;144 /// We allow for 2 seconds of compute with a 6 second average block time.145 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;146 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);147 /// Assume 10% of weight for average on_initialize calls.148 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()149 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();150 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;151 pub const Version: RuntimeVersion = VERSION;152}153154impl system::Trait for Runtime {155 /// The basic call filter to use in dispatchable.156 type BaseCallFilter = ();157 /// The identifier used to distinguish between accounts.158 type AccountId = AccountId;159 /// The aggregated dispatch type that is available for extrinsics.160 type Call = Call;161 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.162 type Lookup = IdentityLookup<AccountId>;163 /// The index type for storing how many extrinsics an account has signed.164 type Index = Index;165 /// The index type for blocks.166 type BlockNumber = BlockNumber;167 /// The type for hashing blocks and tries.168 type Hash = Hash;169 /// The hashing algorithm used.170 type Hashing = BlakeTwo256;171 /// The header type.172 type Header = generic::Header<BlockNumber, BlakeTwo256>;173 /// The ubiquitous event type.174 type Event = Event;175 /// The ubiquitous origin type.176 type Origin = Origin;177 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).178 type BlockHashCount = BlockHashCount;179 /// Maximum weight of each block.180 type MaximumBlockWeight = MaximumBlockWeight;181 /// The weight of database operations that the runtime can invoke.182 type DbWeight = RocksDbWeight;183 /// The weight of the overhead invoked on the block import process, independent of the184 /// extrinsics included in that block.185 type BlockExecutionWeight = BlockExecutionWeight;186 /// The base weight of any extrinsic processed by the runtime, independent of the187 /// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)188 type ExtrinsicBaseWeight = ExtrinsicBaseWeight;189 /// The maximum weight that a single extrinsic of `Normal` dispatch class can have,190 /// idependent of the logic of that extrinsics. (Roughly max block weight - average on191 /// initialize cost).192 type MaximumExtrinsicWeight = MaximumExtrinsicWeight;193 /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.194 type MaximumBlockLength = MaximumBlockLength;195 /// Portion of the block weight that is available to all normal transactions.196 type AvailableBlockRatio = AvailableBlockRatio;197 /// Version of the runtime.198 type Version = Version;199 /// This type is being generated by `construct_runtime!`.200 type PalletInfo = PalletInfo;201 /// What to do if a new account is created.202 type OnNewAccount = ();203 /// What to do if an account is fully reaped from the system.204 type OnKilledAccount = ();205 /// The data to be stored in an account.206 type AccountData = pallet_balances::AccountData<Balance>;207 /// Weight information for the extrinsics of this pallet.208 type SystemWeightInfo = ();209}210211impl pallet_aura::Trait for Runtime {212 type AuthorityId = AuraId;213}214215impl pallet_grandpa::Trait for Runtime {216 type Event = Event;217 type Call = Call;218219 type KeyOwnerProofSystem = ();220221 type KeyOwnerProof =222 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;223224 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(225 KeyTypeId,226 GrandpaId,227 )>>::IdentificationTuple;228229 type HandleEquivocation = ();230231 type WeightInfo = ();232}233234parameter_types! {235 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;236}237238impl pallet_timestamp::Trait for Runtime {239 /// A timestamp: milliseconds since the unix epoch.240 type Moment = u64;241 type OnTimestampSet = Aura;242 type MinimumPeriod = MinimumPeriod;243 type WeightInfo = ();244}245246parameter_types! {247 // pub const ExistentialDeposit: u128 = 500;248 pub const ExistentialDeposit: u128 = 0;249 pub const MaxLocks: u32 = 50;250}251252impl pallet_balances::Trait for Runtime {253 type MaxLocks = MaxLocks;254 /// The type for recording an account's balance.255 type Balance = Balance;256 /// The ubiquitous event type.257 type Event = Event;258 type DustRemoval = ();259 type ExistentialDeposit = ExistentialDeposit;260 type AccountStore = System;261 type WeightInfo = ();262}263264pub const MILLICENTS: Balance = 1_000_000_000;265pub const CENTS: Balance = 1_000 * MILLICENTS;266pub const DOLLARS: Balance = 100 * CENTS;267268parameter_types! {269 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;270 pub const RentByteFee: Balance = 4 * MILLICENTS;271 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;272 pub const SurchargeReward: Balance = 150 * MILLICENTS;273}274275impl pallet_contracts::Trait for Runtime {276 type Time = Timestamp;277 type Randomness = RandomnessCollectiveFlip;278 type Currency = Balances;279 type Event = Event;280 type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminer<Runtime>;281 type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter<Runtime>;282 type RentPayment = ();283 type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap;284 type TombstoneDeposit = TombstoneDeposit;285 type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset;286 type RentByteFee = RentByteFee;287 type RentDepositOffset = RentDepositOffset;288 type SurchargeReward = SurchargeReward;289 type MaxDepth = pallet_contracts::DefaultMaxDepth;290 type MaxValueSize = pallet_contracts::DefaultMaxValueSize;291 type WeightPrice = pallet_transaction_payment::Module<Self>;292}293294parameter_types! {295 pub const TransactionByteFee: Balance = 10 * MILLICENTS;296}297298impl pallet_transaction_payment::Trait for Runtime {299 type Currency = pallet_balances::Module<Runtime>;300 type OnTransactionPayment = ();301 type TransactionByteFee = TransactionByteFee;302 type WeightToFee = IdentityFee<Balance>;303 type FeeMultiplierUpdate = ();304}305306impl pallet_sudo::Trait for Runtime {307 type Event = Event;308 type Call = Call;309}310311/// Used for the module nft in `./nft.rs`312impl pallet_nft::Trait for Runtime {313 type Event = Event;314 type WeightInfo = nft_weights::WeightInfo;315}316317construct_runtime!(318 pub enum Runtime where319 Block = Block,320 NodeBlock = opaque::Block,321 UncheckedExtrinsic = UncheckedExtrinsic322 {323 System: system::{Module, Call, Config, Storage, Event<T>},324 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},325 Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},326 Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},327 Aura: pallet_aura::{Module, Config<T>, Inherent},328 Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},329 Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},330 TransactionPayment: pallet_transaction_payment::{Module, Storage},331 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},332 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},333 }334);335336/// The address format for describing accounts.337pub type Address = AccountId;338/// Block header type as expected by this runtime.339pub type Header = generic::Header<BlockNumber, BlakeTwo256>;340/// Block type as expected by this runtime.341pub type Block = generic::Block<Header, UncheckedExtrinsic>;342/// A Block signed with a Justification343pub type SignedBlock = generic::SignedBlock<Block>;344/// BlockId type as expected by this runtime.345pub type BlockId = generic::BlockId<Block>;346/// The SignedExtension to the basic transaction logic.347pub type SignedExtra = (348 system::CheckSpecVersion<Runtime>,349 system::CheckTxVersion<Runtime>,350 system::CheckGenesis<Runtime>,351 system::CheckEra<Runtime>,352 system::CheckNonce<Runtime>,353 system::CheckWeight<Runtime>,354 pallet_nft::ChargeTransactionPayment<Runtime>,355);356/// Unchecked extrinsic type as expected by this runtime.357pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;358/// Extrinsic type that has already been checked.359pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;360/// Executive: handles dispatch to the various modules.361pub type Executive =362 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;363364impl_runtime_apis! {365366 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>367 for Runtime368 {369 fn call(370 origin: AccountId,371 dest: AccountId,372 value: Balance,373 gas_limit: u64,374 input_data: Vec<u8>,375 ) -> ContractExecResult {376 let (exec_result, gas_consumed) =377 Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);378 match exec_result {379 Ok(v) => ContractExecResult::Success {380 flags: v.flags.bits(),381 data: v.data,382 gas_consumed: gas_consumed,383 },384 Err(_) => ContractExecResult::Error,385 }386 }387388 fn get_storage(389 address: AccountId,390 key: [u8; 32],391 ) -> pallet_contracts_primitives::GetStorageResult {392 Contracts::get_storage(address, key)393 }394395 fn rent_projection(396 address: AccountId,397 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {398 Contracts::rent_projection(address)399 }400 }401402 impl sp_api::Core<Block> for Runtime {403 fn version() -> RuntimeVersion {404 VERSION405 }406407 fn execute_block(block: Block) {408 Executive::execute_block(block)409 }410411 fn initialize_block(header: &<Block as BlockT>::Header) {412 Executive::initialize_block(header)413 }414 }415416 impl sp_api::Metadata<Block> for Runtime {417 fn metadata() -> OpaqueMetadata {418 Runtime::metadata().into()419 }420 }421422 impl sp_block_builder::BlockBuilder<Block> for Runtime {423 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {424 Executive::apply_extrinsic(extrinsic)425 }426427 fn finalize_block() -> <Block as BlockT>::Header {428 Executive::finalize_block()429 }430431 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {432 data.create_extrinsics()433 }434435 fn check_inherents(436 block: Block,437 data: sp_inherents::InherentData,438 ) -> sp_inherents::CheckInherentsResult {439 data.check_extrinsics(&block)440 }441442 fn random_seed() -> <Block as BlockT>::Hash {443 RandomnessCollectiveFlip::random_seed()444 }445 }446447 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {448 fn validate_transaction(449 source: TransactionSource,450 tx: <Block as BlockT>::Extrinsic,451 ) -> TransactionValidity {452 Executive::validate_transaction(source, tx)453 }454 }455456 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {457 fn offchain_worker(header: &<Block as BlockT>::Header) {458 Executive::offchain_worker(header)459 }460 }461462 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {463 fn slot_duration() -> u64 {464 Aura::slot_duration()465 }466467 fn authorities() -> Vec<AuraId> {468 Aura::authorities()469 }470 }471472 impl sp_session::SessionKeys<Block> for Runtime {473 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {474 opaque::SessionKeys::generate(seed)475 }476477 fn decode_session_keys(478 encoded: Vec<u8>,479 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {480 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)481 }482 }483484 impl fg_primitives::GrandpaApi<Block> for Runtime {485 fn grandpa_authorities() -> GrandpaAuthorityList {486 Grandpa::grandpa_authorities()487 }488489 fn submit_report_equivocation_unsigned_extrinsic(490 _equivocation_proof: fg_primitives::EquivocationProof<491 <Block as BlockT>::Hash,492 NumberFor<Block>,493 >,494 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,495 ) -> Option<()> {496 None497 }498499 fn generate_key_ownership_proof(500 _set_id: fg_primitives::SetId,501 _authority_id: GrandpaId,502 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {503 // NOTE: this is the only implementation possible since we've504 // defined our key owner proof type as a bottom type (i.e. a type505 // with no values).506 None507 }508 }509 510 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {511 fn account_nonce(account: AccountId) -> Index {512 System::account_nonce(account)513 }514 }515516 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {517 fn query_info(518 uxt: <Block as BlockT>::Extrinsic,519 len: u32,520 ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {521 TransactionPayment::query_info(uxt, len)522 }523 }524525 #[cfg(feature = "runtime-benchmarks")]526 impl frame_benchmarking::Benchmark<Block> for Runtime {527 fn dispatch_benchmark(528 config: frame_benchmarking::BenchmarkConfig529 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {530 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};531532 let whitelist: Vec<TrackedStorageKey> = vec![533 // Alice account534 hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),535 // // Total Issuance536 // hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),537 // // Execution Phase538 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),539 // // Event Count540 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),541 // // System Events542 // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),543 ];544545 let mut batches = Vec::<BenchmarkBatch>::new();546 let params = (&config, &whitelist);547548 add_benchmark!(params, batches, pallet_nft, Nft);549550 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }551 Ok(batches)552 }553 }554}runtime/src/nft_weights.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/src/nft_weights.rs
@@ -0,0 +1,96 @@
+use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
+
+pub struct WeightInfo;
+impl pallet_nft::WeightInfo for WeightInfo {
+ fn create_collection() -> Weight {
+ (70_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(7 as Weight))
+ .saturating_add(DbWeight::get().writes(5 as Weight))
+ }
+ fn destroy_collection() -> Weight {
+ (90_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(5 as Weight))
+ }
+ fn add_to_white_list() -> Weight {
+ (30_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(3 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn remove_from_white_list() -> Weight {
+ (35_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(3 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn set_public_access_mode() -> Weight {
+ (27_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn set_mint_permission() -> Weight {
+ (27_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn change_collection_owner() -> Weight {
+ (27_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn add_collection_admin() -> Weight {
+ (32_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(3 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn remove_collection_admin() -> Weight {
+ (50_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn set_collection_sponsor() -> Weight {
+ (32_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn confirm_sponsorship() -> Weight {
+ (22_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn remove_collection_sponsor() -> Weight {
+ (24_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(1 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn create_item(s: usize, ) -> Weight {
+ (130_000_000 as Weight)
+ .saturating_add((2135 as Weight).saturating_mul(s as Weight))
+ .saturating_add(DbWeight::get().reads(10 as Weight))
+ .saturating_add(DbWeight::get().writes(8 as Weight))
+ }
+ fn burn_item() -> Weight {
+ (170_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(9 as Weight))
+ .saturating_add(DbWeight::get().writes(7 as Weight))
+ }
+ fn transfer() -> Weight {
+ (125_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(7 as Weight))
+ .saturating_add(DbWeight::get().writes(7 as Weight))
+ }
+ fn approve() -> Weight {
+ (45_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(3 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+ fn transfer_from() -> Weight {
+ (150_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(9 as Weight))
+ .saturating_add(DbWeight::get().writes(8 as Weight))
+ }
+ fn set_offchain_schema() -> Weight {
+ (33_000_000 as Weight)
+ .saturating_add(DbWeight::get().reads(2 as Weight))
+ .saturating_add(DbWeight::get().writes(1 as Weight))
+ }
+}