difftreelog
Merge pull request #12 from usetech-llc/feature/NFTPAR-116_substrate2_release
in: master
Feature/nftpar 116 substrate2 release
18 files changed
Cargo.lockdiffbeforeafterboth16source = "registry+https://github.com/rust-lang/crates.io-index"16source = "registry+https://github.com/rust-lang/crates.io-index"17checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"17checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"18dependencies = [18dependencies = [19 "gimli",19 "gimli 0.22.0",20]20]212122[[package]]22[[package]]361 "cfg-if 1.0.0",361 "cfg-if 1.0.0",362 "libc",362 "libc",363 "miniz_oxide",363 "miniz_oxide",364 "object",364 "object 0.21.1",365 "rustc-demangle",365 "rustc-demangle",366]366]367367383source = "registry+https://github.com/rust-lang/crates.io-index"383source = "registry+https://github.com/rust-lang/crates.io-index"384checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"384checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"385386[[package]]387name = "bincode"388version = "1.3.1"389source = "registry+https://github.com/rust-lang/crates.io-index"390checksum = "f30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896d"391dependencies = [392 "byteorder 1.3.4",393 "serde",394]385395386[[package]]396[[package]]387name = "bindgen"397name = "bindgen"790source = "registry+https://github.com/rust-lang/crates.io-index"800source = "registry+https://github.com/rust-lang/crates.io-index"791checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"801checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634"802803[[package]]804name = "cranelift-bforest"805version = "0.66.0"806source = "registry+https://github.com/rust-lang/crates.io-index"807checksum = "8dcc286b052ee24a1e5a222e7c1125e6010ad35b0f248709b9b3737a8fedcfdf"808dependencies = [809 "cranelift-entity",810]811812[[package]]813name = "cranelift-codegen"814version = "0.66.0"815source = "registry+https://github.com/rust-lang/crates.io-index"816checksum = "9d9badfe36176cb653506091693bc2bb1970c9bddfcd6ec7fac404f7eaec6f38"817dependencies = [818 "byteorder 1.3.4",819 "cranelift-bforest",820 "cranelift-codegen-meta",821 "cranelift-codegen-shared",822 "cranelift-entity",823 "gimli 0.21.0",824 "log",825 "regalloc",826 "serde",827 "smallvec 1.4.2",828 "target-lexicon",829 "thiserror",830]831832[[package]]833name = "cranelift-codegen-meta"834version = "0.66.0"835source = "registry+https://github.com/rust-lang/crates.io-index"836checksum = "3c3f460031861e4f4ad510be62b2ae50bba6cc886b598a36f9c0a970feab9598"837dependencies = [838 "cranelift-codegen-shared",839 "cranelift-entity",840]841842[[package]]843name = "cranelift-codegen-shared"844version = "0.66.0"845source = "registry+https://github.com/rust-lang/crates.io-index"846checksum = "76ad12409e922e7697cd0bdc7dc26992f64a77c31880dfe5e3c7722f4710206d"847848[[package]]849name = "cranelift-entity"850version = "0.66.0"851source = "registry+https://github.com/rust-lang/crates.io-index"852checksum = "d97cdc58972ea065d107872cfb9079f4c92ade78a8af85aaff519a65b5d13f71"853dependencies = [854 "serde",855]856857[[package]]858name = "cranelift-frontend"859version = "0.66.0"860source = "registry+https://github.com/rust-lang/crates.io-index"861checksum = "2ef419efb4f94ecc02e5d9fbcc910d2bb7f0040e2de570e63a454f883bc891d6"862dependencies = [863 "cranelift-codegen",864 "log",865 "smallvec 1.4.2",866 "target-lexicon",867]868869[[package]]870name = "cranelift-native"871version = "0.66.0"872source = "registry+https://github.com/rust-lang/crates.io-index"873checksum = "6e69d44d59826eef6794066ac2c0f4ad3975f02d97030c60dbc04e3886adf36e"874dependencies = [875 "cranelift-codegen",876 "raw-cpuid",877 "target-lexicon",878]879880[[package]]881name = "cranelift-wasm"882version = "0.66.0"883source = "registry+https://github.com/rust-lang/crates.io-index"884checksum = "979df666b1304624abe99738e9e0e7c7479ee5523ba4b8b237df9ff49996acbb"885dependencies = [886 "cranelift-codegen",887 "cranelift-entity",888 "cranelift-frontend",889 "log",890 "serde",891 "thiserror",892 "wasmparser 0.59.0",893]792894793[[package]]895[[package]]794name = "crc32fast"896name = "crc32fast"1078 "serde",1180 "serde",1079]1181]11821183[[package]]1184name = "errno"1185version = "0.2.6"1186source = "registry+https://github.com/rust-lang/crates.io-index"1187checksum = "6eab5ee3df98a279d9b316b1af6ac95422127b1290317e6d18c1743c99418b01"1188dependencies = [1189 "errno-dragonfly",1190 "libc",1191 "winapi 0.3.9",1192]11931194[[package]]1195name = "errno-dragonfly"1196version = "0.1.1"1197source = "registry+https://github.com/rust-lang/crates.io-index"1198checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067"1199dependencies = [1200 "gcc",1201 "libc",1202]108012031081[[package]]1204[[package]]1082name = "event-listener"1205name = "event-listener"1121source = "registry+https://github.com/rust-lang/crates.io-index"1244source = "registry+https://github.com/rust-lang/crates.io-index"1122checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"1245checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"12461247[[package]]1248name = "fallible-iterator"1249version = "0.2.0"1250source = "registry+https://github.com/rust-lang/crates.io-index"1251checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"112312521124[[package]]1253[[package]]1125name = "fastrand"1254name = "fastrand"1139 "libc",1268 "libc",1140]1269]12701271[[package]]1272name = "file-per-thread-logger"1273version = "0.1.4"1274source = "registry+https://github.com/rust-lang/crates.io-index"1275checksum = "4fdbe0d94371f9ce939b555dd342d0686cc4c0cadbcd4b61d70af5ff97eb4126"1276dependencies = [1277 "env_logger",1278 "log",1279]114112801142[[package]]1281[[package]]1143name = "finality-grandpa"1282name = "finality-grandpa"1217 "sp-storage",1356 "sp-storage",1218]1357]13581359[[package]]1360name = "frame-benchmarking-cli"1361version = "2.0.0"1362source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"1363dependencies = [1364 "frame-benchmarking",1365 "parity-scale-codec",1366 "sc-cli",1367 "sc-client-db",1368 "sc-executor",1369 "sc-service",1370 "sp-core",1371 "sp-externalities",1372 "sp-runtime",1373 "sp-state-machine",1374 "structopt",1375]121913761220[[package]]1377[[package]]1221name = "frame-executive"1378name = "frame-executive"1318 "sp-version",1475 "sp-version",1319]1476]14771478[[package]]1479name = "frame-system-benchmarking"1480version = "2.0.0"1481source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"1482dependencies = [1483 "frame-benchmarking",1484 "frame-support",1485 "frame-system",1486 "parity-scale-codec",1487 "sp-core",1488 "sp-runtime",1489 "sp-std",1490]132014911321[[package]]1492[[package]]1322name = "frame-system-rpc-runtime-api"1493name = "frame-system-rpc-runtime-api"1634 "polyval",1805 "polyval",1635]1806]18071808[[package]]1809name = "gimli"1810version = "0.21.0"1811source = "registry+https://github.com/rust-lang/crates.io-index"1812checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c"1813dependencies = [1814 "fallible-iterator",1815 "indexmap",1816 "stable_deref_trait",1817]163618181637[[package]]1819[[package]]1638name = "gimli"1820name = "gimli"2013dependencies = [2195dependencies = [2014 "autocfg 1.0.1",2196 "autocfg 1.0.1",2015 "hashbrown 0.9.1",2197 "hashbrown 0.9.1",2198 "serde",2016]2199]201722002018[[package]]2201[[package]]2073 "either",2256 "either",2074]2257]22582259[[package]]2260name = "itertools"2261version = "0.9.0"2262source = "registry+https://github.com/rust-lang/crates.io-index"2263checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"2264dependencies = [2265 "either",2266]207522672076[[package]]2268[[package]]2077name = "itoa"2269name = "itoa"2295source = "registry+https://github.com/rust-lang/crates.io-index"2487source = "registry+https://github.com/rust-lang/crates.io-index"2296checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"2488checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"24892490[[package]]2491name = "leb128"2492version = "0.2.4"2493source = "registry+https://github.com/rust-lang/crates.io-index"2494checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a"229724952298[[package]]2496[[package]]2299name = "libc"2497name = "libc"2851source = "registry+https://github.com/rust-lang/crates.io-index"3049source = "registry+https://github.com/rust-lang/crates.io-index"2852checksum = "adb241df5c4caeb888755363fc95f8a896618dc0d435e9e775f7930cb099beab"3050checksum = "adb241df5c4caeb888755363fc95f8a896618dc0d435e9e775f7930cb099beab"30513052[[package]]3053name = "mach"3054version = "0.3.2"3055source = "registry+https://github.com/rust-lang/crates.io-index"3056checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"3057dependencies = [3058 "libc",3059]285330602854[[package]]3061[[package]]2855name = "matchers"3062name = "matchers"3041 "winapi 0.3.9",3248 "winapi 0.3.9",3042]3249]32503251[[package]]3252name = "more-asserts"3253version = "0.2.1"3254source = "registry+https://github.com/rust-lang/crates.io-index"3255checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238"304332563044[[package]]3257[[package]]3045name = "multihash"3258name = "multihash"3127name = "nft"3340name = "nft"3128version = "2.0.0"3341version = "2.0.0"3129dependencies = [3342dependencies = [3343 "frame-benchmarking",3344 "frame-benchmarking-cli",3130 "futures 0.3.6",3345 "futures 0.3.6",3131 "jsonrpc-core",3346 "jsonrpc-core",3132 "log",3347 "log",3165name = "nft-runtime"3380name = "nft-runtime"3166version = "2.0.0"3381version = "2.0.0"3167dependencies = [3382dependencies = [3383 "frame-benchmarking",3168 "frame-executive",3384 "frame-executive",3169 "frame-support",3385 "frame-support",3170 "frame-system",3386 "frame-system",3387 "frame-system-benchmarking",3171 "frame-system-rpc-runtime-api",3388 "frame-system-rpc-runtime-api",3389 "hex-literal",3172 "pallet-aura",3390 "pallet-aura",3173 "pallet-balances",3391 "pallet-balances",3174 "pallet-contracts",3392 "pallet-contracts",3295 "libc",3513 "libc",3296]3514]35153516[[package]]3517name = "object"3518version = "0.19.0"3519source = "registry+https://github.com/rust-lang/crates.io-index"3520checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2"35213522[[package]]3523name = "object"3524version = "0.20.0"3525source = "registry+https://github.com/rust-lang/crates.io-index"3526checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"3527dependencies = [3528 "crc32fast",3529 "indexmap",3530 "wasmparser 0.57.0",3531]329735323298[[package]]3533[[package]]3299name = "object"3534name = "object"3498name = "pallet-nft"3733name = "pallet-nft"3499version = "2.0.0"3734version = "2.0.0"3500dependencies = [3735dependencies = [3736 "frame-benchmarking",3501 "frame-support",3737 "frame-support",3502 "frame-system",3738 "frame-system",3503 "log",3739 "log",3569 "parity-scale-codec",3805 "parity-scale-codec",3570 "serde",3806 "serde",3571 "sp-inherents",3807 "sp-inherents",3808 "sp-io",3572 "sp-runtime",3809 "sp-runtime",3573 "sp-std",3810 "sp-std",3574 "sp-timestamp",3811 "sp-timestamp",4098dependencies = [4335dependencies = [4099 "bytes 0.5.6",4336 "bytes 0.5.6",4100 "heck",4337 "heck",4101 "itertools",4338 "itertools 0.8.2",4102 "log",4339 "log",4103 "multimap",4340 "multimap",4104 "petgraph",4341 "petgraph",4115checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72"4352checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72"4116dependencies = [4353dependencies = [4117 "anyhow",4354 "anyhow",4118 "itertools",4355 "itertools 0.8.2",4119 "proc-macro2",4356 "proc-macro2",4120 "quote",4357 "quote",4121 "syn",4358 "syn",4367 "rand_core 0.3.1",4604 "rand_core 0.3.1",4368]4605]46064607[[package]]4608name = "raw-cpuid"4609version = "7.0.3"4610source = "registry+https://github.com/rust-lang/crates.io-index"4611checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf"4612dependencies = [4613 "bitflags",4614 "cc",4615 "rustc_version",4616]436946174370[[package]]4618[[package]]4371name = "rawpointer"4619name = "rawpointer"4444 "syn",4692 "syn",4445]4693]46944695[[package]]4696name = "regalloc"4697version = "0.0.27"4698source = "registry+https://github.com/rust-lang/crates.io-index"4699checksum = "b9ba8aaf5fe7cf307c6dbdaeed85478961d29e25e3bee5169e11b92fa9f027a8"4700dependencies = [4701 "log",4702 "rustc-hash",4703 "smallvec 1.4.2",4704]444647054447[[package]]4706[[package]]4448name = "regex"4707name = "regex"4472source = "registry+https://github.com/rust-lang/crates.io-index"4731source = "registry+https://github.com/rust-lang/crates.io-index"4473checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c"4732checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c"47334734[[package]]4735name = "region"4736version = "2.2.0"4737source = "registry+https://github.com/rust-lang/crates.io-index"4738checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0"4739dependencies = [4740 "bitflags",4741 "libc",4742 "mach",4743 "winapi 0.3.9",4744]447447454475[[package]]4746[[package]]4476name = "remove_dir_all"4747name = "remove_dir_all"4895 "parking_lot 0.10.2",5166 "parking_lot 0.10.2",4896 "sc-executor-common",5167 "sc-executor-common",4897 "sc-executor-wasmi",5168 "sc-executor-wasmi",5169 "sc-executor-wasmtime",4898 "sp-api",5170 "sp-api",4899 "sp-core",5171 "sp-core",4900 "sp-externalities",5172 "sp-externalities",4940 "wasmi",5212 "wasmi",4941]5213]52145215[[package]]5216name = "sc-executor-wasmtime"5217version = "0.8.0"5218source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"5219dependencies = [5220 "log",5221 "parity-scale-codec",5222 "parity-wasm",5223 "pwasm-utils",5224 "sc-executor-common",5225 "scoped-tls",5226 "sp-allocator",5227 "sp-core",5228 "sp-runtime-interface",5229 "sp-wasm-interface",5230 "wasmtime",5231]494252324943[[package]]5233[[package]]4944name = "sc-finality-grandpa"5234name = "sc-finality-grandpa"5413 "zeroize",5703 "zeroize",5414]5704]57055706[[package]]5707name = "scoped-tls"5708version = "1.0.0"5709source = "registry+https://github.com/rust-lang/crates.io-index"5710checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"541557115416[[package]]5712[[package]]5417name = "scopeguard"5713name = "scopeguard"5425source = "registry+https://github.com/rust-lang/crates.io-index"5721source = "registry+https://github.com/rust-lang/crates.io-index"5426checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"5722checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"57235724[[package]]5725name = "scroll"5726version = "0.10.2"5727source = "registry+https://github.com/rust-lang/crates.io-index"5728checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec"5729dependencies = [5730 "scroll_derive",5731]57325733[[package]]5734name = "scroll_derive"5735version = "0.10.3"5736source = "registry+https://github.com/rust-lang/crates.io-index"5737checksum = "6dfde5d1531034db129e95c76ac857e2baecea3443579d493d02224950b0fb6d"5738dependencies = [5739 "proc-macro2",5740 "quote",5741 "syn",5742]542757435428[[package]]5744[[package]]5429name = "sct"5745name = "sct"6458[[package]]6774[[package]]6459name = "substrate-wasm-builder-runner"6775name = "substrate-wasm-builder-runner"6460version = "1.0.6"6776version = "1.0.6"6461source = "git+https://github.com/usetech-llc/substrate.git?branch=v2.0.0_release#a200cdb93c6af5763b9c7bf313fa708764ac88ca"6777source = "registry+https://github.com/rust-lang/crates.io-index"6778checksum = "d2a965994514ab35d3893e9260245f2947fd1981cdd4fffd2c6e6d1a9ce02e6a"646267796463[[package]]6780[[package]]6464name = "subtle"6781name = "subtle"6501source = "registry+https://github.com/rust-lang/crates.io-index"6818source = "registry+https://github.com/rust-lang/crates.io-index"6502checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60"6819checksum = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60"68206821[[package]]6822name = "target-lexicon"6823version = "0.10.0"6824source = "registry+https://github.com/rust-lang/crates.io-index"6825checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d"650368266504[[package]]6827[[package]]6505name = "tempfile"6828name = "tempfile"7324 "parity-wasm",7647 "parity-wasm",7325]7648]76497650[[package]]7651name = "wasmparser"7652version = "0.57.0"7653source = "registry+https://github.com/rust-lang/crates.io-index"7654checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6"76557656[[package]]7657name = "wasmparser"7658version = "0.59.0"7659source = "registry+https://github.com/rust-lang/crates.io-index"7660checksum = "a950e6a618f62147fd514ff445b2a0b53120d382751960797f85f058c7eda9b9"76617662[[package]]7663name = "wasmtime"7664version = "0.19.0"7665source = "registry+https://github.com/rust-lang/crates.io-index"7666checksum = "1cd3c4f449382779ef6e0a7c3ec6752ae614e20a42e4100000c3efdc973100e2"7667dependencies = [7668 "anyhow",7669 "backtrace",7670 "cfg-if 0.1.10",7671 "lazy_static",7672 "libc",7673 "log",7674 "region",7675 "rustc-demangle",7676 "smallvec 1.4.2",7677 "target-lexicon",7678 "wasmparser 0.59.0",7679 "wasmtime-environ",7680 "wasmtime-jit",7681 "wasmtime-profiling",7682 "wasmtime-runtime",7683 "wat",7684 "winapi 0.3.9",7685]76867687[[package]]7688name = "wasmtime-debug"7689version = "0.19.0"7690source = "registry+https://github.com/rust-lang/crates.io-index"7691checksum = "6e634af9067a3af6cf2c7d33dc3b84767ddaf5d010ba68e80eecbcea73d4a349"7692dependencies = [7693 "anyhow",7694 "gimli 0.21.0",7695 "more-asserts",7696 "object 0.20.0",7697 "target-lexicon",7698 "thiserror",7699 "wasmparser 0.59.0",7700 "wasmtime-environ",7701]77027703[[package]]7704name = "wasmtime-environ"7705version = "0.19.0"7706source = "registry+https://github.com/rust-lang/crates.io-index"7707checksum = "08f85619a94ee4034bd5bb87fc3dcf71fd2237b81c840809da1201061eec9ab3"7708dependencies = [7709 "anyhow",7710 "base64 0.12.3",7711 "bincode",7712 "cfg-if 0.1.10",7713 "cranelift-codegen",7714 "cranelift-entity",7715 "cranelift-frontend",7716 "cranelift-wasm",7717 "directories",7718 "errno",7719 "file-per-thread-logger",7720 "indexmap",7721 "libc",7722 "log",7723 "more-asserts",7724 "rayon",7725 "serde",7726 "sha2 0.8.2",7727 "thiserror",7728 "toml",7729 "wasmparser 0.59.0",7730 "winapi 0.3.9",7731 "zstd",7732]77337734[[package]]7735name = "wasmtime-jit"7736version = "0.19.0"7737source = "registry+https://github.com/rust-lang/crates.io-index"7738checksum = "e914c013c7a9f15f4e429d5431f2830fb8adb56e40567661b69c5ec1d645be23"7739dependencies = [7740 "anyhow",7741 "cfg-if 0.1.10",7742 "cranelift-codegen",7743 "cranelift-entity",7744 "cranelift-frontend",7745 "cranelift-native",7746 "cranelift-wasm",7747 "gimli 0.21.0",7748 "log",7749 "more-asserts",7750 "object 0.20.0",7751 "region",7752 "target-lexicon",7753 "thiserror",7754 "wasmparser 0.59.0",7755 "wasmtime-debug",7756 "wasmtime-environ",7757 "wasmtime-obj",7758 "wasmtime-profiling",7759 "wasmtime-runtime",7760 "winapi 0.3.9",7761]77627763[[package]]7764name = "wasmtime-obj"7765version = "0.19.0"7766source = "registry+https://github.com/rust-lang/crates.io-index"7767checksum = "e81d8e02e9bc9fe2da9b6d48bbc217f96e089f7df613f11a28a3958abc44641e"7768dependencies = [7769 "anyhow",7770 "more-asserts",7771 "object 0.20.0",7772 "target-lexicon",7773 "wasmtime-debug",7774 "wasmtime-environ",7775]77767777[[package]]7778name = "wasmtime-profiling"7779version = "0.19.0"7780source = "registry+https://github.com/rust-lang/crates.io-index"7781checksum = "1e8d4d1af8dd5f7096cfcc89dd668d358e52980c38cce199643372ffd6590e27"7782dependencies = [7783 "anyhow",7784 "cfg-if 0.1.10",7785 "gimli 0.21.0",7786 "lazy_static",7787 "libc",7788 "object 0.19.0",7789 "scroll",7790 "serde",7791 "target-lexicon",7792 "wasmtime-environ",7793 "wasmtime-runtime",7794]77957796[[package]]7797name = "wasmtime-runtime"7798version = "0.19.0"7799source = "registry+https://github.com/rust-lang/crates.io-index"7800checksum = "3a25f140bbbaadb07c531cba99ce1a966dba216138dc1b2a0ddecec851a01a93"7801dependencies = [7802 "backtrace",7803 "cc",7804 "cfg-if 0.1.10",7805 "indexmap",7806 "lazy_static",7807 "libc",7808 "log",7809 "memoffset",7810 "more-asserts",7811 "region",7812 "thiserror",7813 "wasmtime-environ",7814 "winapi 0.3.9",7815]78167817[[package]]7818name = "wast"7819version = "26.0.0"7820source = "registry+https://github.com/rust-lang/crates.io-index"7821checksum = "d54b3678343bfdf1768c16308a4b53823b70f7bb148d3d38225123d4306ec731"7822dependencies = [7823 "leb128",7824]78257826[[package]]7827name = "wat"7828version = "1.0.27"7829source = "registry+https://github.com/rust-lang/crates.io-index"7830checksum = "26b2dccbce4d0e14875091846e110a2369267b18ddd0d6423479b88dad914d71"7831dependencies = [7832 "wast",7833]732678347327[[package]]7835[[package]]7328name = "web-sys"7836name = "web-sys"7490 "synstructure",7998 "synstructure",7491]7999]80008001[[package]]8002name = "zstd"8003version = "0.5.3+zstd.1.4.5"8004source = "registry+https://github.com/rust-lang/crates.io-index"8005checksum = "01b32eaf771efa709e8308605bbf9319bf485dc1503179ec0469b611937c0cd8"8006dependencies = [8007 "zstd-safe",8008]80098010[[package]]8011name = "zstd-safe"8012version = "2.0.5+zstd.1.4.5"8013source = "registry+https://github.com/rust-lang/crates.io-index"8014checksum = "1cfb642e0d27f64729a639c52db457e0ae906e7bc6f5fe8f5c453230400f1055"8015dependencies = [8016 "libc",8017 "zstd-sys",8018]80198020[[package]]8021name = "zstd-sys"8022version = "1.4.17+zstd.1.4.5"8023source = "registry+https://github.com/rust-lang/crates.io-index"8024checksum = "b89249644df056b522696b1bb9e7c18c87e8ffa3e2f0dc3b0155875d6498f01b"8025dependencies = [8026 "cc",8027 "glob",8028 "itertools 0.9.0",8029 "libc",8030]74928031README.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.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -8,9 +8,9 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
-use contracts_rpc_runtime_api::ContractExecResult;
-use grandpa::fg_primitives;
-use grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
+use pallet_contracts_rpc_runtime_api::ContractExecResult;
+use pallet_grandpa::fg_primitives;
+use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
@@ -29,8 +29,8 @@
use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates.
-pub use balances::Call as BalancesCall;
-pub use contracts::Schedule as ContractsSchedule;
+pub use pallet_balances::Call as BalancesCall;
+pub use pallet_contracts::Schedule as ContractsSchedule;
pub use frame_support::{
construct_runtime,
dispatch::DispatchResult,
@@ -49,14 +49,14 @@
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
use sp_runtime::Perbill;
-use system::{self as system};
+use frame_system::{self as system};
-pub use timestamp::Call as TimestampCall;
+pub use pallet_timestamp::Call as TimestampCall;
/// Re-export a nft pallet
/// TODO: Check this re-export. Is this safe and good style?
-extern crate nft;
-pub use nft::*;
+extern crate pallet_nft;
+pub use pallet_nft::*;
/// An index to a block.
pub type BlockNumber = u32;
@@ -84,6 +84,8 @@
/// Digest item type.
pub type DigestItem = generic::DigestItem<Hash>;
+mod nft_weights;
+
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
@@ -201,16 +203,16 @@
/// What to do if an account is fully reaped from the system.
type OnKilledAccount = ();
/// The data to be stored in an account.
- type AccountData = balances::AccountData<Balance>;
+ type AccountData = pallet_balances::AccountData<Balance>;
/// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = ();
}
-impl aura::Trait for Runtime {
+impl pallet_aura::Trait for Runtime {
type AuthorityId = AuraId;
}
-impl grandpa::Trait for Runtime {
+impl pallet_grandpa::Trait for Runtime {
type Event = Event;
type Call = Call;
@@ -233,7 +235,7 @@
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
}
-impl timestamp::Trait for Runtime {
+impl pallet_timestamp::Trait for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = Aura;
@@ -247,7 +249,7 @@
pub const MaxLocks: u32 = 50;
}
-impl balances::Trait for Runtime {
+impl pallet_balances::Trait for Runtime {
type MaxLocks = MaxLocks;
/// The type for recording an account's balance.
type Balance = Balance;
@@ -270,45 +272,46 @@
pub const SurchargeReward: Balance = 150 * MILLICENTS;
}
-impl contracts::Trait for Runtime {
+impl pallet_contracts::Trait for Runtime {
type Time = Timestamp;
type Randomness = RandomnessCollectiveFlip;
type Currency = Balances;
type Event = Event;
- type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;
- type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;
+ type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminer<Runtime>;
+ type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter<Runtime>;
type RentPayment = ();
- type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;
+ type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap;
type TombstoneDeposit = TombstoneDeposit;
- type StorageSizeOffset = contracts::DefaultStorageSizeOffset;
+ type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset;
type RentByteFee = RentByteFee;
type RentDepositOffset = RentDepositOffset;
type SurchargeReward = SurchargeReward;
- type MaxDepth = contracts::DefaultMaxDepth;
- type MaxValueSize = contracts::DefaultMaxValueSize;
- type WeightPrice = transaction_payment::Module<Self>;
+ type MaxDepth = pallet_contracts::DefaultMaxDepth;
+ type MaxValueSize = pallet_contracts::DefaultMaxValueSize;
+ type WeightPrice = pallet_transaction_payment::Module<Self>;
}
parameter_types! {
- pub const TransactionByteFee: Balance = 1;
+ pub const TransactionByteFee: Balance = 10 * MILLICENTS;
}
-impl transaction_payment::Trait for Runtime {
- type Currency = balances::Module<Runtime>;
+impl pallet_transaction_payment::Trait for Runtime {
+ type Currency = pallet_balances::Module<Runtime>;
type OnTransactionPayment = ();
type TransactionByteFee = TransactionByteFee;
type WeightToFee = IdentityFee<Balance>;
- type FeeMultiplierUpdate = ();
+ type FeeMultiplierUpdate = ();
}
-impl sudo::Trait for Runtime {
+impl pallet_sudo::Trait for Runtime {
type Event = Event;
type Call = Call;
}
/// Used for the module nft in `./nft.rs`
-impl nft::Trait for Runtime {
+impl pallet_nft::Trait for Runtime {
type Event = Event;
+ type WeightInfo = nft_weights::WeightInfo;
}
construct_runtime!(
@@ -318,15 +321,15 @@
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{Module, Call, Config, Storage, Event<T>},
- RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
- Contracts: contracts::{Module, Call, Config, Storage, Event<T>},
- Timestamp: timestamp::{Module, Call, Storage, Inherent},
- Aura: aura::{Module, Config<T>, Inherent},
- Grandpa: grandpa::{Module, Call, Storage, Config, Event},
- Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},
- TransactionPayment: transaction_payment::{Module, Storage},
- Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},
- Nft: nft::{Module, Call, Config<T>, Storage, Event<T>},
+ RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
+ Contracts: pallet_contracts::{Module, Call, Config, Storage, Event<T>},
+ Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
+ Aura: pallet_aura::{Module, Config<T>, Inherent},
+ Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
+ Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
+ TransactionPayment: pallet_transaction_payment::{Module, Storage},
+ Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
+ Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},
}
);
@@ -348,7 +351,7 @@
system::CheckEra<Runtime>,
system::CheckNonce<Runtime>,
system::CheckWeight<Runtime>,
- nft::ChargeTransactionPayment<Runtime>,
+ pallet_nft::ChargeTransactionPayment<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
@@ -360,7 +363,7 @@
impl_runtime_apis! {
- impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
+ impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>
for Runtime
{
fn call(
@@ -385,13 +388,13 @@
fn get_storage(
address: AccountId,
key: [u8; 32],
- ) -> contracts_primitives::GetStorageResult {
+ ) -> pallet_contracts_primitives::GetStorageResult {
Contracts::get_storage(address, key)
}
fn rent_projection(
address: AccountId,
- ) -> contracts_primitives::RentProjectionResult<BlockNumber> {
+ ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
Contracts::rent_projection(address)
}
}
@@ -510,13 +513,42 @@
}
}
- impl transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
+ impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {
fn query_info(
uxt: <Block as BlockT>::Extrinsic,
len: u32,
- ) -> transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
+ ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
TransactionPayment::query_info(uxt, len)
}
}
+ #[cfg(feature = "runtime-benchmarks")]
+ impl frame_benchmarking::Benchmark<Block> for Runtime {
+ fn dispatch_benchmark(
+ config: frame_benchmarking::BenchmarkConfig
+ ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
+ use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
+
+ let whitelist: Vec<TrackedStorageKey> = vec![
+ // Alice account
+ hex_literal::hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d").to_vec().into(),
+ // // Total Issuance
+ // hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
+ // // Execution Phase
+ // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
+ // // Event Count
+ // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
+ // // System Events
+ // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
+ ];
+
+ let mut batches = Vec::<BenchmarkBatch>::new();
+ let params = (&config, &whitelist);
+
+ add_benchmark!(params, batches, pallet_nft, Nft);
+
+ if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
+ Ok(batches)
+ }
+ }
}
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))
+ }
+}