diff --git a/Cargo.lock b/Cargo.lock index 17cc70e5..77c563fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -343,7 +343,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", - "rand", + "rand 0.8.5", ] [[package]] @@ -358,6 +358,12 @@ version = "6.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f840fb7195bcfc5e17ea40c26e5ce6d5b9ce5d584466e17703209657e459ae0" +[[package]] +name = "array-init" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d62b7694a562cdf5a74227903507c56ab2cc8bdd1f781ed5cb4cf9c9f810bfc" + [[package]] name = "arrayref" version = "0.3.7" @@ -373,6 +379,12 @@ dependencies = [ "nodrop", ] +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "arrayvec" version = "0.7.4" @@ -404,7 +416,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] @@ -486,17 +498,17 @@ dependencies = [ "sp-api", "sp-block-builder", "sp-consensus-aura", - "sp-core", + "sp-core 29.0.0", "sp-genesis-builder", "sp-inherents", "sp-offchain", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", - "sp-std", - "sp-storage", + "sp-std 14.0.0", + "sp-storage 20.0.0", "sp-transaction-pool", "sp-version", - "sp-weights", + "sp-weights 28.0.0", "staging-parachain-info", "staging-xcm", "staging-xcm-builder", @@ -525,9 +537,9 @@ dependencies = [ "parachains-common", "parachains-runtimes-test-utils", "parity-scale-codec", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-parachain-info", "staging-xcm", "staging-xcm-builder", @@ -551,8 +563,8 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -909,7 +921,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" dependencies = [ "bitcoin_hashes", - "rand", + "rand 0.8.5", "rand_core 0.6.4", "serde", "unicode-normalization", @@ -1012,6 +1024,18 @@ dependencies = [ "constant_time_eq 0.3.0", ] +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -1030,6 +1054,15 @@ dependencies = [ "generic-array 0.14.7", ] +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + [[package]] name = "blocking" version = "1.5.1" @@ -1116,7 +1149,7 @@ dependencies = [ "frame-system", "polkadot-primitives", "sp-api", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -1130,8 +1163,8 @@ dependencies = [ "bp-runtime", "frame-support", "sp-api", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -1145,8 +1178,8 @@ dependencies = [ "bp-runtime", "frame-support", "sp-api", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -1162,9 +1195,9 @@ dependencies = [ "scale-info", "serde", "sp-consensus-grandpa", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -1179,8 +1212,8 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-std", + "sp-core 29.0.0", + "sp-std 14.0.0", ] [[package]] @@ -1196,9 +1229,9 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", "scale-info", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -1215,9 +1248,9 @@ dependencies = [ "parity-util-mem", "scale-info", "serde", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -1231,8 +1264,8 @@ dependencies = [ "frame-support", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -1250,13 +1283,13 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", - "trie-db", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", + "trie-db 0.28.0", ] [[package]] @@ -1269,15 +1302,15 @@ dependencies = [ "bp-parachains", "bp-polkadot-core", "bp-runtime", - "ed25519-dalek", + "ed25519-dalek 2.1.1", "finality-grandpa", "parity-scale-codec", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-consensus-grandpa", - "sp-core", - "sp-runtime", - "sp-std", - "sp-trie", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", ] [[package]] @@ -1286,7 +1319,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6663e0179d475e30cfcf28cf597cdc8f4bb1c2c39a557b4cbe0057db0657fb67" dependencies = [ - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -1297,8 +1330,8 @@ checksum = "86ff4abe93be7bc1663adc41817b1aa3476fbec953ce361537419924310d5dd4" dependencies = [ "parity-scale-codec", "scale-info", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", ] [[package]] @@ -1328,11 +1361,11 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-trie", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", "staging-xcm", "staging-xcm-builder", ] @@ -1745,6 +1778,26 @@ dependencies = [ "tiny-keccak", ] +[[package]] +name = "const_env" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e9e4f72c6e3398ca6da372abd9affd8f89781fe728869bbf986206e9af9627e" +dependencies = [ + "const_env_impl", +] + +[[package]] +name = "const_env_impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a4f51209740b5e1589e702b3044cdd4562cef41b6da404904192ffffb852d62" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -2044,8 +2097,8 @@ dependencies = [ "sc-client-api", "sc-service", "sp-blockchain", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "url", ] @@ -2068,8 +2121,8 @@ dependencies = [ "sc-client-api", "sp-api", "sp-consensus", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "tracing", ] @@ -2101,16 +2154,16 @@ dependencies = [ "sc-telemetry", "schnellru", "sp-api", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-block-builder", "sp-blockchain", "sp-consensus", "sp-consensus-aura", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-keystore", - "sp-runtime", - "sp-state-machine", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", "sp-timestamp", "substrate-prometheus-endpoint", "tracing", @@ -2138,10 +2191,10 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-slots", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "sp-timestamp", - "sp-trie", + "sp-trie 30.0.0", "substrate-prometheus-endpoint", "tracing", ] @@ -2157,8 +2210,8 @@ dependencies = [ "cumulus-primitives-parachain-inherent", "sp-consensus", "sp-inherents", - "sp-runtime", - "sp-state-machine", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", "thiserror", ] @@ -2180,9 +2233,9 @@ dependencies = [ "sc-client-api", "sp-blockchain", "sp-consensus", - "sp-core", - "sp-runtime", - "sp-state-machine", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", "tracing", ] @@ -2203,11 +2256,11 @@ dependencies = [ "sp-api", "sp-crypto-hashing", "sp-inherents", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-storage", - "sp-trie", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-std 14.0.0", + "sp-storage 20.0.0", + "sp-trie 30.0.0", "tracing", ] @@ -2227,12 +2280,12 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-overseer", "polkadot-primitives", - "rand", + "rand 0.8.5", "sc-client-api", "sc-consensus", "sp-consensus", "sp-maybe-compressed-blob", - "sp-runtime", + "sp-runtime 32.0.0", "tracing", ] @@ -2268,8 +2321,8 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "sp-transaction-pool", ] @@ -2286,10 +2339,10 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "scale-info", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-consensus-aura", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -2315,17 +2368,17 @@ dependencies = [ "polkadot-runtime-common", "polkadot-runtime-parachains", "scale-info", - "sp-core", - "sp-externalities", + "sp-core 29.0.0", + "sp-externalities 0.26.0", "sp-inherents", - "sp-io", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", "sp-version", "staging-xcm", - "trie-db", + "trie-db 0.28.0", ] [[package]] @@ -2351,8 +2404,8 @@ dependencies = [ "frame-system", "pallet-session", "parity-scale-codec", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -2366,9 +2419,9 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", ] @@ -2390,10 +2443,10 @@ dependencies = [ "polkadot-runtime-common", "polkadot-runtime-parachains", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-executor", ] @@ -2409,8 +2462,8 @@ dependencies = [ "polkadot-primitives", "sp-api", "sp-consensus-aura", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -2425,9 +2478,9 @@ dependencies = [ "polkadot-primitives", "scale-info", "sp-api", - "sp-runtime", - "sp-std", - "sp-trie", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", "staging-xcm", ] @@ -2441,10 +2494,10 @@ dependencies = [ "cumulus-primitives-core", "parity-scale-codec", "scale-info", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-std", - "sp-trie", + "sp-std 14.0.0", + "sp-trie 30.0.0", ] [[package]] @@ -2453,9 +2506,9 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b74f9141190b9f4bf96a947ade46da64097b77f1ebfa8d611c81724250e119" dependencies = [ - "sp-externalities", - "sp-runtime-interface", - "sp-trie", + "sp-externalities 0.26.0", + "sp-runtime-interface 25.0.0", + "sp-trie 30.0.0", ] [[package]] @@ -2471,9 +2524,9 @@ dependencies = [ "parity-scale-codec", "polkadot-runtime-common", "polkadot-runtime-parachains", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -2499,9 +2552,9 @@ dependencies = [ "sc-tracing", "sp-api", "sp-consensus", - "sp-core", - "sp-runtime", - "sp-state-machine", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", ] [[package]] @@ -2519,7 +2572,7 @@ dependencies = [ "sc-client-api", "sp-api", "sp-blockchain", - "sp-state-machine", + "sp-state-machine 0.36.0", "thiserror", ] @@ -2559,7 +2612,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-babe", - "sp-runtime", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "tokio", "tracing", @@ -2581,7 +2634,7 @@ dependencies = [ "parity-scale-codec", "pin-project", "polkadot-overseer", - "rand", + "rand 0.8.5", "sc-client-api", "sc-rpc-api", "sc-service", @@ -2593,10 +2646,10 @@ dependencies = [ "sp-api", "sp-authority-discovery", "sp-consensus-babe", - "sp-core", - "sp-runtime", - "sp-state-machine", - "sp-storage", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-storage 20.0.0", "sp-version", "thiserror", "tokio", @@ -2614,10 +2667,23 @@ dependencies = [ "cumulus-primitives-core", "parity-scale-codec", "polkadot-primitives", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", +] + +[[package]] +name = "curve25519-dalek" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" +dependencies = [ + "byteorder", + "digest 0.8.1", + "rand_core 0.5.1", + "subtle 2.5.0", + "zeroize", ] [[package]] @@ -3064,10 +3130,19 @@ dependencies = [ "digest 0.10.7", "elliptic-curve", "rfc6979", - "signature", + "signature 2.2.0", "spki", ] +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature 1.6.4", +] + [[package]] name = "ed25519" version = "2.2.3" @@ -3075,7 +3150,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8", - "signature", + "signature 2.2.0", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek 3.2.0", + "ed25519 1.5.3", + "sha2 0.9.9", + "zeroize", ] [[package]] @@ -3085,7 +3172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek 4.1.2", - "ed25519", + "ed25519 2.2.3", "rand_core 0.6.4", "serde", "sha2 0.10.8", @@ -3114,7 +3201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek 4.1.2", - "ed25519", + "ed25519 2.2.3", "hashbrown 0.14.3", "hex", "rand_core 0.6.4", @@ -3174,8 +3261,8 @@ dependencies = [ "sc-consensus-grandpa", "sp-authority-discovery", "sp-consensus-babe", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "staging-xcm", "xcm-emulator", ] @@ -3422,6 +3509,12 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + [[package]] name = "fallible-iterator" version = "0.2.0" @@ -3539,7 +3632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", - "rand", + "rand 0.8.5", "rustc-hex", "static_assertions", ] @@ -3616,13 +3709,13 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-application-crypto", - "sp-core", - "sp-io", - "sp-runtime", - "sp-runtime-interface", - "sp-std", - "sp-storage", + "sp-application-crypto 31.0.0", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-runtime-interface 25.0.0", + "sp-std 14.0.0", + "sp-storage 20.0.0", "static_assertions", ] @@ -3647,7 +3740,7 @@ dependencies = [ "linked-hash-map", "log", "parity-scale-codec", - "rand", + "rand 0.8.5", "rand_pcg", "sc-block-builder", "sc-cli", @@ -3660,17 +3753,17 @@ dependencies = [ "serde_json", "sp-api", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-database", - "sp-externalities", + "sp-externalities 0.26.0", "sp-inherents", - "sp-io", - "sp-keystore", - "sp-runtime", - "sp-state-machine", - "sp-storage", - "sp-trie", - "sp-wasm-interface", + "sp-io 31.0.0", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-storage 20.0.0", + "sp-trie 30.0.0", + "sp-wasm-interface 20.0.0", "thiserror", "thousands", ] @@ -3698,11 +3791,11 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-arithmetic", - "sp-core", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", "sp-npos-elections", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -3717,11 +3810,11 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-tracing", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-tracing 16.0.0", ] [[package]] @@ -3759,11 +3852,11 @@ dependencies = [ "log", "parity-scale-codec", "serde", - "sp-core", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-io", - "sp-runtime", - "sp-state-machine", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", "spinners", "substrate-rpc-client", "tokio", @@ -3794,20 +3887,20 @@ dependencies = [ "serde_json", "smallvec", "sp-api", - "sp-arithmetic", - "sp-core", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", "sp-crypto-hashing-proc-macro", - "sp-debug-derive", + "sp-debug-derive 14.0.0", "sp-genesis-builder", "sp-inherents", - "sp-io", + "sp-io 31.0.0", "sp-metadata-ir", - "sp-runtime", + "sp-runtime 32.0.0", "sp-staking", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-weights", + "sp-state-machine 0.36.0", + "sp-std 14.0.0", + "sp-tracing 16.0.0", + "sp-weights 28.0.0", "static_assertions", "tt-call", ] @@ -3869,12 +3962,12 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "sp-version", - "sp-weights", + "sp-weights 28.0.0", ] [[package]] @@ -3888,9 +3981,9 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -3912,8 +4005,8 @@ dependencies = [ "frame-support", "parity-scale-codec", "sp-api", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -4163,7 +4256,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea1015b5a70616b688dc230cfe50c8af89d972cb132d5a622814d29773b10b9" dependencies = [ - "rand", + "rand 0.8.5", "rand_core 0.6.4", ] @@ -4669,6 +4762,206 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "ink" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d4a862aedbfda93175ddf75c9aaa2ae4c4b39ee5cee06c16d50bccce05bf5c7" +dependencies = [ + "derive_more", + "ink_env", + "ink_macro", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage", + "pallet-contracts-uapi-next", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_allocator" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cee56055bac6d928d425e944c5f3b69baa33c9635822fd1c00cd4afc70fde3e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_codegen" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a1f8473fa09e0f9b6f3cb3f8d18c07c14ebf9ea1f7cdfee270f009d45ee8e9" +dependencies = [ + "blake2 0.10.6", + "derive_more", + "either", + "heck 0.4.1", + "impl-serde", + "ink_ir", + "ink_primitives", + "itertools 0.12.1", + "parity-scale-codec", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 2.0.58", +] + +[[package]] +name = "ink_engine" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f357e2e867f4e222ffc4015a6e61d1073548de89f70a4e36a8b0385562777fa" +dependencies = [ + "blake2 0.10.6", + "derive_more", + "ink_primitives", + "pallet-contracts-uapi-next", + "parity-scale-codec", + "secp256k1 0.28.2", + "sha2 0.10.8", + "sha3", +] + +[[package]] +name = "ink_env" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42cec50b7e4f8406aab25801b015d3802a52d76cfbe48ce11cfb4200fa88e296" +dependencies = [ + "blake2 0.10.6", + "cfg-if", + "const_env", + "derive_more", + "ink_allocator", + "ink_engine", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "num-traits", + "pallet-contracts-uapi-next", + "parity-scale-codec", + "paste", + "rlibc", + "scale-decode", + "scale-encode", + "scale-info", + "schnorrkel 0.11.4", + "secp256k1 0.28.2", + "sha2 0.10.8", + "sha3", + "static_assertions", +] + +[[package]] +name = "ink_ir" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1ad2975551c4ed800af971289ed6d2c68ac41ffc03a42010b3e01d7360dfb2" +dependencies = [ + "blake2 0.10.6", + "either", + "impl-serde", + "ink_prelude", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "ink_macro" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aee1a546f37eae3b3cd223832d31702033c5369dcfa3405899587c110a7908d3" +dependencies = [ + "ink_codegen", + "ink_ir", + "ink_primitives", + "parity-scale-codec", + "proc-macro2", + "quote", + "syn 2.0.58", + "synstructure 0.13.1", +] + +[[package]] +name = "ink_metadata" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a98fcc0ff9292ff68c7ee7b84c93533c9ff13859ec3b148faa822e2da9954fe6" +dependencies = [ + "derive_more", + "impl-serde", + "ink_prelude", + "ink_primitives", + "linkme", + "parity-scale-codec", + "scale-info", + "schemars", + "serde", +] + +[[package]] +name = "ink_prelude" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea1734d058c80aa72e59c8ae75624fd8a51791efba21469f273156c0f4cad5c9" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "ink_primitives" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec35ef7f45e67a53b6142d7e7f18e6d9292d76c3a2a1da14cf8423e481813d" +dependencies = [ + "derive_more", + "ink_prelude", + "parity-scale-codec", + "scale-decode", + "scale-encode", + "scale-info", + "xxhash-rust", +] + +[[package]] +name = "ink_storage" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbdb04cad74df858c05bc9cb6f30bbf12da33c3e2cb7ca211749c001fa761aa9" +dependencies = [ + "array-init", + "cfg-if", + "derive_more", + "ink_env", + "ink_metadata", + "ink_prelude", + "ink_primitives", + "ink_storage_traits", + "pallet-contracts-uapi-next", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "ink_storage_traits" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83ce49e3d2935fc1ec3e73117119712b187d3123339f6a31624e92f75fa2293d" +dependencies = [ + "ink_metadata", + "ink_prelude", + "ink_primitives", + "parity-scale-codec", + "scale-info", +] + [[package]] name = "inout" version = "0.1.3" @@ -4726,8 +5019,8 @@ dependencies = [ "sp-consensus-babe", "sp-consensus-beefy", "sp-consensus-grandpa", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "staging-xcm", "staging-xcm-executor", "tracing-subscriber 0.3.18", @@ -4923,7 +5216,7 @@ dependencies = [ "hyper", "jsonrpsee-types 0.20.3", "parking_lot 0.12.1", - "rand", + "rand 0.8.5", "rustc-hash", "serde", "serde_json", @@ -5256,7 +5549,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project", "quick-protobuf", - "rand", + "rand 0.8.5", "rw-stream-sink", "smallvec", "thiserror", @@ -5307,12 +5600,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58 0.4.0", - "ed25519-dalek", + "ed25519-dalek 2.1.1", "log", "multiaddr", "multihash 0.17.0", "quick-protobuf", - "rand", + "rand 0.8.5", "sha2 0.10.8", "thiserror", "zeroize", @@ -5337,7 +5630,7 @@ dependencies = [ "libp2p-swarm", "log", "quick-protobuf", - "rand", + "rand 0.8.5", "sha2 0.10.8", "smallvec", "thiserror", @@ -5359,7 +5652,7 @@ dependencies = [ "libp2p-identity", "libp2p-swarm", "log", - "rand", + "rand 0.8.5", "smallvec", "socket2 0.4.10", "tokio", @@ -5395,7 +5688,7 @@ dependencies = [ "log", "once_cell", "quick-protobuf", - "rand", + "rand 0.8.5", "sha2 0.10.8", "snow", "static_assertions", @@ -5417,7 +5710,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "rand", + "rand 0.8.5", "void", ] @@ -5437,7 +5730,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "quinn-proto", - "rand", + "rand 0.8.5", "rustls 0.20.9", "thiserror", "tokio", @@ -5455,7 +5748,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-swarm", - "rand", + "rand 0.8.5", "smallvec", ] @@ -5474,7 +5767,7 @@ dependencies = [ "libp2p-identity", "libp2p-swarm-derive", "log", - "rand", + "rand 0.8.5", "smallvec", "tokio", "void", @@ -5610,7 +5903,7 @@ dependencies = [ "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", - "rand", + "rand 0.8.5", "serde", "sha2 0.9.9", "typenum", @@ -5680,6 +5973,26 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "linkme" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccb76662d78edc9f9bf56360d6919bdacc8b7761227727e5082f128eeb90bbf5" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dccda732e04fa3baf2e17cf835bfe2601c7c2edafd64417c627dabae3a8cda" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "linregress" version = "0.5.3" @@ -5951,6 +6264,18 @@ dependencies = [ "hash-db", ] +[[package]] +name = "merlin" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.5.1", + "zeroize", +] + [[package]] name = "merlin" version = "3.0.0" @@ -5970,7 +6295,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69672161530e8aeca1d1400fbf3f1a1747ff60ea604265a4e906c2442df20532" dependencies = [ "futures", - "rand", + "rand 0.8.5", "thrift", ] @@ -6017,7 +6342,7 @@ dependencies = [ "lioness", "log", "parking_lot 0.12.1", - "rand", + "rand 0.8.5", "rand_chacha 0.3.1", "rand_distr", "subtle 2.5.0", @@ -6040,9 +6365,9 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-beefy", - "sp-core", + "sp-core 29.0.0", "sp-mmr-primitives", - "sp-runtime", + "sp-runtime 32.0.0", ] [[package]] @@ -6056,9 +6381,9 @@ dependencies = [ "serde", "sp-api", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-mmr-primitives", - "sp-runtime", + "sp-runtime 32.0.0", ] [[package]] @@ -6189,7 +6514,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] @@ -6214,7 +6539,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] @@ -6270,7 +6595,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7bddcd3bf5144b6392de80e04c347cd7fab2508f6df16a85fc496ecd5cec39bc" dependencies = [ - "rand", + "rand 0.8.5", ] [[package]] @@ -6598,11 +6923,11 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6617,8 +6942,8 @@ dependencies = [ "pallet-transaction-payment", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6632,9 +6957,9 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6650,10 +6975,10 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6668,9 +6993,9 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6685,10 +7010,10 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "scale-info", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-consensus-aura", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6702,10 +7027,10 @@ dependencies = [ "pallet-session", "parity-scale-codec", "scale-info", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-authority-discovery", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6719,8 +7044,8 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6738,14 +7063,14 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "scale-info", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-consensus-babe", - "sp-core", - "sp-io", - "sp-runtime", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", "sp-session", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -6764,11 +7089,11 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-tracing", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-tracing 16.0.0", ] [[package]] @@ -6784,8 +7109,8 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6803,10 +7128,10 @@ dependencies = [ "scale-info", "serde", "sp-consensus-beefy", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -6828,11 +7153,11 @@ dependencies = [ "serde", "sp-api", "sp-consensus-beefy", - "sp-core", - "sp-io", - "sp-runtime", - "sp-state-machine", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-std 14.0.0", ] [[package]] @@ -6848,10 +7173,10 @@ dependencies = [ "pallet-treasury", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6871,9 +7196,9 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-consensus-grandpa", - "sp-runtime", - "sp-std", - "sp-trie", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", ] [[package]] @@ -6891,8 +7216,8 @@ dependencies = [ "num-traits", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6912,9 +7237,9 @@ dependencies = [ "pallet-bridge-grandpa", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", - "sp-trie", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", ] [[package]] @@ -6933,9 +7258,9 @@ dependencies = [ "pallet-bridge-messages", "parity-scale-codec", "scale-info", - "sp-arithmetic", - "sp-runtime", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6950,10 +7275,10 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-arithmetic", - "sp-core", - "sp-runtime", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6970,10 +7295,10 @@ dependencies = [ "pallet-treasury", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -6989,11 +7314,11 @@ dependencies = [ "pallet-authorship", "pallet-session", "parity-scale-codec", - "rand", + "rand 0.8.5", "scale-info", - "sp-runtime", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7008,10 +7333,10 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7031,16 +7356,16 @@ dependencies = [ "pallet-contracts-proc-macro", "pallet-contracts-uapi", "parity-scale-codec", - "rand", + "rand 0.8.5", "rand_pcg", "scale-info", "serde", "smallvec", "sp-api", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "wasm-instrument", @@ -7071,6 +7396,17 @@ dependencies = [ "scale-info", ] +[[package]] +name = "pallet-contracts-uapi-next" +version = "6.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd549c16296ea5b2eb7c65c56aba548b286c1be4d7675b424ff6ccb8319c97a9" +dependencies = [ + "bitflags 1.3.2", + "paste", + "polkavm-derive", +] + [[package]] name = "pallet-conviction-voting" version = "29.0.0" @@ -7084,9 +7420,9 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7102,10 +7438,10 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7121,14 +7457,14 @@ dependencies = [ "log", "pallet-election-provider-support-benchmarking", "parity-scale-codec", - "rand", + "rand 0.8.5", "scale-info", - "sp-arithmetic", - "sp-core", - "sp-io", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-io 31.0.0", "sp-npos-elections", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "strum 0.24.1", ] @@ -7143,8 +7479,8 @@ dependencies = [ "frame-system", "parity-scale-codec", "sp-npos-elections", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7159,12 +7495,12 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", + "sp-core 29.0.0", + "sp-io 31.0.0", "sp-npos-elections", - "sp-runtime", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7181,10 +7517,10 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-io", - "sp-runtime", + "sp-io 31.0.0", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7201,14 +7537,14 @@ dependencies = [ "pallet-session", "parity-scale-codec", "scale-info", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-consensus-grandpa", - "sp-core", - "sp-io", - "sp-runtime", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", "sp-session", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7224,9 +7560,9 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7242,12 +7578,12 @@ dependencies = [ "pallet-authorship", "parity-scale-codec", "scale-info", - "sp-application-crypto", - "sp-core", - "sp-io", - "sp-runtime", + "sp-application-crypto 31.0.0", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7261,11 +7597,11 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", + "sp-core 29.0.0", + "sp-io 31.0.0", "sp-keyring", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7280,10 +7616,10 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7299,12 +7635,12 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-weights 28.0.0", ] [[package]] @@ -7319,11 +7655,11 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", + "sp-core 29.0.0", + "sp-io 31.0.0", "sp-mmr-primitives", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7338,9 +7674,9 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7357,8 +7693,8 @@ dependencies = [ "pallet-nfts", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7374,10 +7710,10 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7389,7 +7725,7 @@ dependencies = [ "pallet-nfts", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7403,10 +7739,10 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-arithmetic", - "sp-core", - "sp-runtime", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7421,12 +7757,12 @@ dependencies = [ "pallet-balances", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", - "sp-tracing", + "sp-std 14.0.0", + "sp-tracing 16.0.0", ] [[package]] @@ -7444,10 +7780,10 @@ dependencies = [ "pallet-staking", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-runtime-interface", + "sp-runtime 32.0.0", + "sp-runtime-interface 25.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7459,7 +7795,7 @@ dependencies = [ "pallet-nomination-pools", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7475,9 +7811,9 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-runtime", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7500,9 +7836,9 @@ dependencies = [ "pallet-staking", "parity-scale-codec", "scale-info", - "sp-runtime", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7517,10 +7853,10 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7534,9 +7870,9 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7552,11 +7888,11 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7570,9 +7906,9 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7589,10 +7925,10 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-arithmetic", - "sp-io", - "sp-runtime", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7605,10 +7941,10 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7624,10 +7960,10 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-weights 28.0.0", ] [[package]] @@ -7643,14 +7979,14 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", "sp-session", "sp-staking", - "sp-state-machine", - "sp-std", - "sp-trie", + "sp-state-machine 0.36.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", ] [[package]] @@ -7665,10 +8001,10 @@ dependencies = [ "pallet-session", "pallet-staking", "parity-scale-codec", - "rand", - "sp-runtime", + "rand 0.8.5", + "sp-runtime 32.0.0", "sp-session", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7684,10 +8020,10 @@ dependencies = [ "parity-scale-codec", "rand_chacha 0.2.2", "scale-info", - "sp-arithmetic", - "sp-io", - "sp-runtime", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7707,11 +8043,11 @@ dependencies = [ "rand_chacha 0.2.2", "scale-info", "serde", - "sp-application-crypto", - "sp-io", - "sp-runtime", + "sp-application-crypto 31.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -7733,7 +8069,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "505d45e08bad052f55fb51f00a6b6244d23ee46ffdc8091f6cddf4e3a880319d" dependencies = [ "log", - "sp-arithmetic", + "sp-arithmetic 24.0.0", ] [[package]] @@ -7759,10 +8095,10 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7777,9 +8113,9 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7796,10 +8132,10 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-inherents", - "sp-io", - "sp-runtime", - "sp-std", - "sp-storage", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-storage 20.0.0", "sp-timestamp", ] @@ -7817,10 +8153,10 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7834,10 +8170,10 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7851,10 +8187,10 @@ dependencies = [ "parity-scale-codec", "sp-api", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-rpc", - "sp-runtime", - "sp-weights", + "sp-runtime 32.0.0", + "sp-weights 28.0.0", ] [[package]] @@ -7866,8 +8202,8 @@ dependencies = [ "pallet-transaction-payment", "parity-scale-codec", "sp-api", - "sp-runtime", - "sp-weights", + "sp-runtime 32.0.0", + "sp-weights 28.0.0", ] [[package]] @@ -7885,9 +8221,9 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7902,8 +8238,8 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7917,10 +8253,10 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7935,8 +8271,8 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7951,8 +8287,8 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -7970,10 +8306,10 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -7991,9 +8327,9 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-io", - "sp-runtime", - "sp-std", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -8012,9 +8348,9 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", ] @@ -8041,10 +8377,10 @@ dependencies = [ "polkadot-primitives", "scale-info", "sp-consensus-aura", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-parachain-info", "staging-xcm", "staging-xcm-executor", @@ -8071,11 +8407,11 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain-primitives", "sp-consensus-aura", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-tracing", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-tracing 16.0.0", "staging-parachain-info", "staging-xcm", "staging-xcm-executor", @@ -8103,7 +8439,7 @@ dependencies = [ "lz4", "memmap2 0.5.10", "parking_lot 0.12.1", - "rand", + "rand 0.8.5", "siphasher 0.3.11", "snap", "winapi", @@ -8168,7 +8504,7 @@ checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" dependencies = [ "proc-macro2", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] @@ -8252,6 +8588,15 @@ dependencies = [ "crypto-mac 0.11.0", ] +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "pbkdf2" version = "0.12.2" @@ -8425,7 +8770,7 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand", + "rand 0.8.5", "tracing-gum", ] @@ -8442,7 +8787,7 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand", + "rand 0.8.5", "tracing-gum", ] @@ -8462,10 +8807,10 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand", + "rand 0.8.5", "schnellru", - "sp-core", - "sp-keystore", + "sp-core 29.0.0", + "sp-keystore 0.35.0", "thiserror", "tracing-gum", ] @@ -8486,7 +8831,7 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand", + "rand 0.8.5", "sc-network", "schnellru", "thiserror", @@ -8514,8 +8859,8 @@ dependencies = [ "sc-storage-monitor", "sc-sysinfo", "sc-tracing", - "sp-core", - "sp-io", + "sp-core 29.0.0", + "sp-io 31.0.0", "sp-keyring", "sp-maybe-compressed-blob", "substrate-build-script-utils", @@ -8538,9 +8883,9 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "sp-core", - "sp-keystore", - "sp-runtime", + "sp-core 29.0.0", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "thiserror", "tokio-util", "tracing-gum", @@ -8554,9 +8899,9 @@ checksum = "b6a08e4e014c853b252ecbbe3ccd67b2d33d78e46988d309b8cccf4ac06e25ef" dependencies = [ "parity-scale-codec", "scale-info", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -8579,8 +8924,8 @@ dependencies = [ "polkadot-primitives", "sc-network", "schnellru", - "sp-application-crypto", - "sp-keystore", + "sp-application-crypto 31.0.0", + "sp-keystore 0.35.0", "thiserror", "tracing-gum", ] @@ -8595,8 +8940,8 @@ dependencies = [ "polkadot-node-primitives", "polkadot-primitives", "reed-solomon-novelpoly", - "sp-core", - "sp-trie", + "sp-core 29.0.0", + "sp-trie 30.0.0", "thiserror", ] @@ -8612,14 +8957,14 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "rand", + "rand 0.8.5", "rand_chacha 0.3.1", "sc-network", "sc-network-common", - "sp-application-crypto", - "sp-core", + "sp-application-crypto 31.0.0", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-keystore", + "sp-keystore 0.35.0", "tracing-gum", ] @@ -8660,7 +9005,7 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "sp-core", + "sp-core 29.0.0", "sp-maybe-compressed-blob", "thiserror", "tracing-gum", @@ -8678,7 +9023,7 @@ dependencies = [ "futures-timer", "itertools 0.10.5", "kvdb", - "merlin", + "merlin 3.0.0", "parity-scale-codec", "polkadot-node-jaeger", "polkadot-node-primitives", @@ -8686,16 +9031,16 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-overseer", "polkadot-primitives", - "rand", + "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", "sc-keystore", "schnellru", "schnorrkel 0.11.4", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-consensus", "sp-consensus-slots", - "sp-runtime", + "sp-runtime 32.0.0", "thiserror", "tracing-gum", ] @@ -8739,7 +9084,7 @@ dependencies = [ "polkadot-primitives", "polkadot-statement-table", "schnellru", - "sp-keystore", + "sp-keystore 0.35.0", "thiserror", "tracing-gum", ] @@ -8754,7 +9099,7 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "sp-keystore", + "sp-keystore 0.35.0", "thiserror", "tracing-gum", "wasm-timer", @@ -8912,11 +9257,11 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-parachain-primitives", "polkadot-primitives", - "rand", + "rand 0.8.5", "slotmap", - "sp-core", + "sp-core 29.0.0", "sp-maybe-compressed-blob", - "sp-wasm-interface", + "sp-wasm-interface 20.0.0", "tempfile", "thiserror", "tokio", @@ -8935,7 +9280,7 @@ dependencies = [ "polkadot-node-subsystem-util", "polkadot-overseer", "polkadot-primitives", - "sp-keystore", + "sp-keystore 0.35.0", "thiserror", "tracing-gum", ] @@ -8959,11 +9304,11 @@ dependencies = [ "sc-executor-common", "sc-executor-wasmtime", "seccompiler", - "sp-core", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-externalities", - "sp-io", - "sp-tracing", + "sp-externalities 0.26.0", + "sp-io 31.0.0", + "sp-tracing 16.0.0", "thiserror", "tracing-gum", ] @@ -8998,7 +9343,7 @@ dependencies = [ "polkadot-node-primitives", "polkadot-primitives", "sc-network", - "sp-core", + "sp-core 29.0.0", "thiserror", "tokio", ] @@ -9040,7 +9385,7 @@ dependencies = [ "polkadot-node-jaeger", "polkadot-node-primitives", "polkadot-primitives", - "rand", + "rand 0.8.5", "sc-authority-discovery", "sc-network", "strum 0.24.1", @@ -9062,12 +9407,12 @@ dependencies = [ "polkadot-primitives", "schnorrkel 0.11.4", "serde", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-consensus-babe", - "sp-core", - "sp-keystore", + "sp-core 29.0.0", + "sp-keystore 0.35.0", "sp-maybe-compressed-blob", - "sp-runtime", + "sp-runtime 32.0.0", "thiserror", "zstd 0.12.4", ] @@ -9107,7 +9452,7 @@ dependencies = [ "sp-authority-discovery", "sp-blockchain", "sp-consensus-babe", - "sp-runtime", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "thiserror", ] @@ -9138,12 +9483,12 @@ dependencies = [ "polkadot-overseer", "polkadot-primitives", "prioritized-metered-channel", - "rand", + "rand 0.8.5", "sc-client-api", "schnellru", - "sp-application-crypto", - "sp-core", - "sp-keystore", + "sp-application-crypto 31.0.0", + "sp-core 29.0.0", + "sp-keystore 0.35.0", "thiserror", "tracing-gum", ] @@ -9166,7 +9511,7 @@ dependencies = [ "polkadot-primitives", "sc-client-api", "sp-api", - "sp-core", + "sp-core 29.0.0", "tikv-jemalloc-ctl", "tracing-gum", ] @@ -9183,10 +9528,10 @@ dependencies = [ "polkadot-core-primitives", "scale-info", "serde", - "sp-core", - "sp-runtime", - "sp-std", - "sp-weights", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-weights 28.0.0", ] [[package]] @@ -9204,17 +9549,17 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-application-crypto", - "sp-arithmetic", + "sp-application-crypto 31.0.0", + "sp-arithmetic 24.0.0", "sp-authority-discovery", "sp-consensus-slots", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-io", - "sp-keystore", - "sp-runtime", + "sp-io 31.0.0", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -9245,8 +9590,8 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-babe", - "sp-keystore", - "sp-runtime", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "substrate-frame-rpc-system", "substrate-state-trie-migration-rpc", ] @@ -9289,14 +9634,14 @@ dependencies = [ "serde_derive", "slot-range-helper", "sp-api", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-io", + "sp-io 31.0.0", "sp-npos-elections", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", "sp-staking", - "sp-std", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -9313,8 +9658,8 @@ dependencies = [ "frame-benchmarking", "parity-scale-codec", "polkadot-primitives", - "sp-std", - "sp-tracing", + "sp-std 14.0.0", + "sp-tracing 16.0.0", ] [[package]] @@ -9346,22 +9691,22 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-metrics", - "rand", + "rand 0.8.5", "rand_chacha 0.3.1", "rustc-hex", "scale-info", "serde", "sp-api", - "sp-application-crypto", - "sp-arithmetic", - "sp-core", + "sp-application-crypto 31.0.0", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", "sp-inherents", - "sp-io", - "sp-keystore", - "sp-runtime", + "sp-io 31.0.0", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "sp-session", "sp-staking", - "sp-std", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-executor", "static_assertions", @@ -9464,21 +9809,21 @@ dependencies = [ "sp-consensus-babe", "sp-consensus-beefy", "sp-consensus-grandpa", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-io", + "sp-io 31.0.0", "sp-keyring", - "sp-keystore", + "sp-keystore 0.35.0", "sp-mmr-primitives", "sp-offchain", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", - "sp-state-machine", - "sp-storage", + "sp-state-machine 0.36.0", + "sp-storage 20.0.0", "sp-timestamp", "sp-transaction-pool", "sp-version", - "sp-weights", + "sp-weights 28.0.0", "substrate-prometheus-endpoint", "thiserror", "tracing-gum", @@ -9503,7 +9848,7 @@ dependencies = [ "polkadot-node-subsystem", "polkadot-node-subsystem-util", "polkadot-primitives", - "sp-keystore", + "sp-keystore 0.35.0", "sp-staking", "thiserror", "tracing-gum", @@ -9517,7 +9862,7 @@ checksum = "de5e010da3c6a65d8f263d0f825a04d995ffc8a37f886f674fcbbc73bf158d01" dependencies = [ "parity-scale-codec", "polkadot-primitives", - "sp-core", + "sp-core 29.0.0", "tracing-gum", ] @@ -9603,6 +9948,19 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "pop-api" +version = "0.0.0" +dependencies = [ + "enumflags2", + "ink", + "parity-scale-codec", + "pop-primitives", + "scale-info", + "sp-io 23.0.0", + "sp-runtime 24.0.0", +] + [[package]] name = "pop-node" version = "0.1.0-alpha" @@ -9653,11 +10011,11 @@ dependencies = [ "sp-block-builder", "sp-blockchain", "sp-consensus-aura", - "sp-core", - "sp-io", - "sp-keystore", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-keystore 0.35.0", "sp-offchain", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", "sp-timestamp", "sp-transaction-pool", @@ -9687,8 +10045,8 @@ dependencies = [ "parity-scale-codec", "polkadot-primitives", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -9740,6 +10098,7 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain-primitives", "polkadot-runtime-common", + "pop-api", "pop-primitives", "pop-runtime-common", "scale-info", @@ -9747,14 +10106,14 @@ dependencies = [ "sp-api", "sp-block-builder", "sp-consensus-aura", - "sp-core", + "sp-core 29.0.0", "sp-genesis-builder", "sp-inherents", - "sp-io", + "sp-io 31.0.0", "sp-offchain", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", - "sp-std", + "sp-std 14.0.0", "sp-transaction-pool", "sp-version", "staging-parachain-info", @@ -9820,14 +10179,14 @@ dependencies = [ "sp-api", "sp-block-builder", "sp-consensus-aura", - "sp-core", + "sp-core 29.0.0", "sp-genesis-builder", "sp-inherents", - "sp-io", + "sp-io 31.0.0", "sp-offchain", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", - "sp-std", + "sp-std 14.0.0", "sp-transaction-pool", "sp-version", "staging-parachain-info", @@ -10187,7 +10546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94b0b33c13a79f669c85defaf4c275dc86a0c0372807d0ca3d78e0bb87274863" dependencies = [ "bytes", - "rand", + "rand 0.8.5", "ring 0.16.20", "rustc-hash", "rustls 0.20.9", @@ -10215,7 +10574,20 @@ checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] name = "rand" -version = "0.8.5" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ @@ -10269,7 +10641,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" dependencies = [ "num-traits", - "rand", + "rand 0.8.5", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", ] [[package]] @@ -10495,6 +10876,12 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "rlibc" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" + [[package]] name = "rlp" version = "0.5.2" @@ -10587,22 +10974,22 @@ dependencies = [ "serde_derive", "smallvec", "sp-api", - "sp-arithmetic", + "sp-arithmetic 24.0.0", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", "sp-consensus-beefy", - "sp-core", + "sp-core 29.0.0", "sp-genesis-builder", "sp-inherents", - "sp-io", + "sp-io 31.0.0", "sp-mmr-primitives", "sp-offchain", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", "sp-staking", - "sp-std", - "sp-storage", + "sp-std 14.0.0", + "sp-storage 20.0.0", "sp-transaction-pool", "sp-version", "staging-xcm", @@ -10622,9 +11009,9 @@ dependencies = [ "polkadot-primitives", "polkadot-runtime-common", "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-weights 28.0.0", "staging-xcm", "staging-xcm-builder", ] @@ -10927,8 +11314,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357127c91373ed6d1ae582f6e3300ab5b13bcde43bbf270a891f44194ef48b70" dependencies = [ "log", - "sp-core", - "sp-wasm-interface", + "sp-core 29.0.0", + "sp-wasm-interface 20.0.0", "thiserror", ] @@ -10949,15 +11336,15 @@ dependencies = [ "parity-scale-codec", "prost 0.12.3", "prost-build", - "rand", + "rand 0.8.5", "sc-client-api", "sc-network", "sp-api", "sp-authority-discovery", "sp-blockchain", - "sp-core", - "sp-keystore", - "sp-runtime", + "sp-core 29.0.0", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "thiserror", ] @@ -10979,9 +11366,9 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-runtime", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", ] @@ -10995,10 +11382,10 @@ dependencies = [ "sp-api", "sp-block-builder", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-runtime", - "sp-trie", + "sp-runtime 32.0.0", + "sp-trie 30.0.0", ] [[package]] @@ -11020,12 +11407,12 @@ dependencies = [ "serde", "serde_json", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-crypto-hashing", "sp-genesis-builder", - "sp-io", - "sp-runtime", - "sp-state-machine", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", ] [[package]] @@ -11057,7 +11444,7 @@ dependencies = [ "log", "names", "parity-scale-codec", - "rand", + "rand 0.8.5", "regex", "rpassword", "sc-client-api", @@ -11072,11 +11459,11 @@ dependencies = [ "serde", "serde_json", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-keyring", - "sp-keystore", - "sp-panic-handler", - "sp-runtime", + "sp-keystore 0.35.0", + "sp-panic-handler 13.0.0", + "sp-runtime 32.0.0", "sp-version", "thiserror", "tokio", @@ -11099,14 +11486,14 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core", + "sp-core 29.0.0", "sp-database", - "sp-externalities", - "sp-runtime", - "sp-state-machine", + "sp-externalities 0.26.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", "sp-statement-store", - "sp-storage", - "sp-trie", + "sp-storage 20.0.0", + "sp-trie 30.0.0", "substrate-prometheus-endpoint", ] @@ -11128,13 +11515,13 @@ dependencies = [ "sc-client-api", "sc-state-db", "schnellru", - "sp-arithmetic", + "sp-arithmetic 24.0.0", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-database", - "sp-runtime", - "sp-state-machine", - "sp-trie", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-trie 30.0.0", ] [[package]] @@ -11156,9 +11543,9 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core", - "sp-runtime", - "sp-state-machine", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", "substrate-prometheus-endpoint", "thiserror", ] @@ -11179,16 +11566,16 @@ dependencies = [ "sc-consensus-slots", "sc-telemetry", "sp-api", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-block-builder", "sp-blockchain", "sp-consensus", "sp-consensus-aura", "sp-consensus-slots", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-keystore", - "sp-runtime", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "thiserror", ] @@ -11215,17 +11602,17 @@ dependencies = [ "sc-telemetry", "sc-transaction-pool-api", "sp-api", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-block-builder", "sp-blockchain", "sp-consensus", "sp-consensus-babe", "sp-consensus-slots", - "sp-core", + "sp-core 29.0.0", "sp-crypto-hashing", "sp-inherents", - "sp-keystore", - "sp-runtime", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "thiserror", ] @@ -11243,13 +11630,13 @@ dependencies = [ "sc-rpc-api", "serde", "sp-api", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-blockchain", "sp-consensus", "sp-consensus-babe", - "sp-core", - "sp-keystore", - "sp-runtime", + "sp-core 29.0.0", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "thiserror", ] @@ -11274,16 +11661,16 @@ dependencies = [ "sc-network-sync", "sc-utils", "sp-api", - "sp-application-crypto", - "sp-arithmetic", + "sp-application-crypto 31.0.0", + "sp-arithmetic 24.0.0", "sp-blockchain", "sp-consensus", "sp-consensus-beefy", - "sp-core", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-keystore", + "sp-keystore 0.35.0", "sp-mmr-primitives", - "sp-runtime", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "thiserror", "tokio", @@ -11305,8 +11692,8 @@ dependencies = [ "sc-rpc", "serde", "sp-consensus-beefy", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "thiserror", ] @@ -11321,7 +11708,7 @@ dependencies = [ "sc-client-api", "sc-consensus", "sp-blockchain", - "sp-runtime", + "sp-runtime 32.0.0", ] [[package]] @@ -11341,7 +11728,7 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot 0.12.1", - "rand", + "rand 0.8.5", "sc-block-builder", "sc-chain-spec", "sc-client-api", @@ -11355,15 +11742,15 @@ dependencies = [ "sc-utils", "serde_json", "sp-api", - "sp-application-crypto", - "sp-arithmetic", + "sp-application-crypto 31.0.0", + "sp-arithmetic 24.0.0", "sp-blockchain", "sp-consensus", "sp-consensus-grandpa", - "sp-core", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-keystore", - "sp-runtime", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "thiserror", ] @@ -11384,8 +11771,8 @@ dependencies = [ "sc-rpc", "serde", "sp-blockchain", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "thiserror", ] @@ -11403,14 +11790,14 @@ dependencies = [ "sc-client-api", "sc-consensus", "sc-telemetry", - "sp-arithmetic", + "sp-arithmetic 24.0.0", "sp-blockchain", "sp-consensus", "sp-consensus-slots", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-runtime", - "sp-state-machine", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", ] [[package]] @@ -11425,14 +11812,14 @@ dependencies = [ "sc-executor-wasmtime", "schnellru", "sp-api", - "sp-core", - "sp-externalities", - "sp-io", - "sp-panic-handler", - "sp-runtime-interface", - "sp-trie", + "sp-core 29.0.0", + "sp-externalities 0.26.0", + "sp-io 31.0.0", + "sp-panic-handler 13.0.0", + "sp-runtime-interface 25.0.0", + "sp-trie 30.0.0", "sp-version", - "sp-wasm-interface", + "sp-wasm-interface 20.0.0", "tracing", ] @@ -11444,7 +11831,7 @@ checksum = "07498138dee3ddf2c71299ca372d8449880bb3a8a8a299a483094e9c26b0823e" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", - "sp-wasm-interface", + "sp-wasm-interface 20.0.0", "thiserror", "wasm-instrument", ] @@ -11463,8 +11850,8 @@ dependencies = [ "rustix 0.36.17", "sc-allocator", "sc-executor-common", - "sp-runtime-interface", - "sp-wasm-interface", + "sp-runtime-interface 25.0.0", + "sp-wasm-interface 20.0.0", "wasmtime", ] @@ -11483,7 +11870,7 @@ dependencies = [ "sc-network-common", "sc-network-sync", "sp-blockchain", - "sp-runtime", + "sp-runtime 32.0.0", ] [[package]] @@ -11495,9 +11882,9 @@ dependencies = [ "array-bytes 6.2.2", "parking_lot 0.12.1", "serde_json", - "sp-application-crypto", - "sp-core", - "sp-keystore", + "sp-application-crypto 31.0.0", + "sp-core 29.0.0", + "sp-keystore 0.35.0", "thiserror", ] @@ -11524,10 +11911,10 @@ dependencies = [ "sc-transaction-pool-api", "sp-api", "sp-consensus", - "sp-core", - "sp-keystore", + "sp-core 29.0.0", + "sp-keystore 0.35.0", "sp-mixnet", - "sp-runtime", + "sp-runtime 32.0.0", "thiserror", ] @@ -11555,17 +11942,17 @@ dependencies = [ "parking_lot 0.12.1", "partial_sort", "pin-project", - "rand", + "rand 0.8.5", "sc-client-api", "sc-network-common", "sc-utils", "serde", "serde_json", "smallvec", - "sp-arithmetic", + "sp-arithmetic 24.0.0", "sp-blockchain", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "thiserror", "tokio", @@ -11591,7 +11978,7 @@ dependencies = [ "sc-client-api", "sc-network", "sp-blockchain", - "sp-runtime", + "sp-runtime 32.0.0", "thiserror", "unsigned-varint", ] @@ -11611,7 +11998,7 @@ dependencies = [ "sc-consensus", "sp-consensus", "sp-consensus-grandpa", - "sp-runtime", + "sp-runtime 32.0.0", ] [[package]] @@ -11629,7 +12016,7 @@ dependencies = [ "sc-network-common", "sc-network-sync", "schnellru", - "sp-runtime", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "tracing", ] @@ -11651,8 +12038,8 @@ dependencies = [ "sc-client-api", "sc-network", "sp-blockchain", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "thiserror", ] @@ -11681,12 +12068,12 @@ dependencies = [ "sc-utils", "schnellru", "smallvec", - "sp-arithmetic", + "sp-arithmetic 24.0.0", "sp-blockchain", "sp-consensus", "sp-consensus-grandpa", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", "thiserror", "tokio", @@ -11709,7 +12096,7 @@ dependencies = [ "sc-network-sync", "sc-utils", "sp-consensus", - "sp-runtime", + "sp-runtime 32.0.0", "substrate-prometheus-endpoint", ] @@ -11732,18 +12119,18 @@ dependencies = [ "once_cell", "parity-scale-codec", "parking_lot 0.12.1", - "rand", + "rand 0.8.5", "sc-client-api", "sc-network", "sc-network-common", "sc-transaction-pool-api", "sc-utils", "sp-api", - "sp-core", - "sp-externalities", - "sp-keystore", + "sp-core 29.0.0", + "sp-externalities 0.26.0", + "sp-keystore 0.35.0", "sp-offchain", - "sp-runtime", + "sp-runtime 32.0.0", "threadpool", "tracing", ] @@ -11780,11 +12167,11 @@ dependencies = [ "serde_json", "sp-api", "sp-blockchain", - "sp-core", - "sp-keystore", + "sp-core 29.0.0", + "sp-keystore 0.35.0", "sp-offchain", "sp-rpc", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", "sp-statement-store", "sp-version", @@ -11805,9 +12192,9 @@ dependencies = [ "scale-info", "serde", "serde_json", - "sp-core", + "sp-core 29.0.0", "sp-rpc", - "sp-runtime", + "sp-runtime 32.0.0", "sp-version", "thiserror", ] @@ -11850,9 +12237,9 @@ dependencies = [ "serde", "sp-api", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-rpc", - "sp-runtime", + "sp-runtime 32.0.0", "sp-version", "thiserror", "tokio", @@ -11875,7 +12262,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "pin-project", - "rand", + "rand 0.8.5", "sc-chain-spec", "sc-client-api", "sc-client-db", @@ -11903,16 +12290,16 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-consensus", - "sp-core", - "sp-externalities", - "sp-keystore", - "sp-runtime", + "sp-core 29.0.0", + "sp-externalities 0.26.0", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "sp-session", - "sp-state-machine", - "sp-storage", + "sp-state-machine 0.36.0", + "sp-storage 20.0.0", "sp-transaction-pool", "sp-transaction-storage-proof", - "sp-trie", + "sp-trie 30.0.0", "sp-version", "static_init", "substrate-prometheus-endpoint", @@ -11932,7 +12319,7 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot 0.12.1", - "sp-core", + "sp-core 29.0.0", ] [[package]] @@ -11944,7 +12331,7 @@ dependencies = [ "clap", "fs4", "log", - "sp-core", + "sp-core 29.0.0", "thiserror", "tokio", ] @@ -11965,7 +12352,7 @@ dependencies = [ "serde", "serde_json", "sp-blockchain", - "sp-runtime", + "sp-runtime 32.0.0", "thiserror", ] @@ -11979,16 +12366,16 @@ dependencies = [ "futures", "libc", "log", - "rand", + "rand 0.8.5", "rand_pcg", "regex", "sc-telemetry", "serde", "serde_json", - "sp-core", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-io", - "sp-std", + "sp-io 31.0.0", + "sp-std 14.0.0", ] [[package]] @@ -12003,7 +12390,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "pin-project", - "rand", + "rand 0.8.5", "sc-utils", "serde", "serde_json", @@ -12032,10 +12419,10 @@ dependencies = [ "serde", "sp-api", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-rpc", - "sp-runtime", - "sp-tracing", + "sp-runtime 32.0.0", + "sp-tracing 16.0.0", "thiserror", "tracing", "tracing-log 0.1.4", @@ -12073,10 +12460,10 @@ dependencies = [ "serde", "sp-api", "sp-blockchain", - "sp-core", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-runtime", - "sp-tracing", + "sp-runtime 32.0.0", + "sp-tracing 16.0.0", "sp-transaction-pool", "substrate-prometheus-endpoint", "thiserror", @@ -12094,8 +12481,8 @@ dependencies = [ "parity-scale-codec", "serde", "sp-blockchain", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "thiserror", ] @@ -12112,7 +12499,7 @@ dependencies = [ "log", "parking_lot 0.12.1", "prometheus", - "sp-arithmetic", + "sp-arithmetic 24.0.0", ] [[package]] @@ -12193,6 +12580,7 @@ dependencies = [ "derive_more", "parity-scale-codec", "scale-info-derive", + "schemars", "serde", ] @@ -12250,6 +12638,30 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.58", +] + [[package]] name = "schnellru" version = "0.2.1" @@ -12261,6 +12673,24 @@ dependencies = [ "hashbrown 0.13.2", ] +[[package]] +name = "schnorrkel" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "curve25519-dalek 2.1.3", + "getrandom 0.1.16", + "merlin 2.0.1", + "rand 0.7.3", + "rand_core 0.5.1", + "sha2 0.8.2", + "subtle 2.5.0", + "zeroize", +] + [[package]] name = "schnorrkel" version = "0.10.2" @@ -12270,7 +12700,7 @@ dependencies = [ "arrayref", "arrayvec 0.7.4", "curve25519-dalek-ng", - "merlin", + "merlin 3.0.0", "rand_core 0.6.4", "sha2 0.9.9", "subtle-ng", @@ -12288,7 +12718,7 @@ dependencies = [ "arrayvec 0.7.4", "curve25519-dalek 4.1.2", "getrandom_or_panic", - "merlin", + "merlin 3.0.0", "rand_core 0.6.4", "serde_bytes", "sha2 0.10.8", @@ -12341,13 +12771,31 @@ dependencies = [ "libc", ] +[[package]] +name = "secp256k1" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" +dependencies = [ + "secp256k1-sys 0.6.1", +] + [[package]] name = "secp256k1" version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ - "secp256k1-sys", + "secp256k1-sys 0.9.2", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", ] [[package]] @@ -12453,6 +12901,17 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "serde_json" version = "1.0.115" @@ -12497,6 +12956,18 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + [[package]] name = "sha2" version = "0.9.9" @@ -12555,6 +13026,12 @@ dependencies = [ "libc", ] +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" + [[package]] name = "signature" version = "2.2.0" @@ -12620,8 +13097,8 @@ dependencies = [ "enumn", "parity-scale-codec", "paste", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -12700,7 +13177,7 @@ dependencies = [ "hmac 0.12.1", "itertools 0.11.0", "libsecp256k1", - "merlin", + "merlin 3.0.0", "no-std-net", "nom", "num-bigint", @@ -12709,7 +13186,7 @@ dependencies = [ "pbkdf2 0.12.2", "pin-project", "poly1305", - "rand", + "rand 0.8.5", "rand_chacha 0.3.1", "ruzstd 0.4.0", "schnorrkel 0.10.2", @@ -12755,7 +13232,7 @@ dependencies = [ "itertools 0.12.1", "libm", "libsecp256k1", - "merlin", + "merlin 3.0.0", "no-std-net", "nom", "num-bigint", @@ -12764,7 +13241,7 @@ dependencies = [ "pbkdf2 0.12.2", "pin-project", "poly1305", - "rand", + "rand 0.8.5", "rand_chacha 0.3.1", "ruzstd 0.5.0", "schnorrkel 0.11.4", @@ -12807,7 +13284,7 @@ dependencies = [ "no-std-net", "parking_lot 0.12.1", "pin-project", - "rand", + "rand 0.8.5", "rand_chacha 0.3.1", "serde", "serde_json", @@ -12843,7 +13320,7 @@ dependencies = [ "no-std-net", "parking_lot 0.12.1", "pin-project", - "rand", + "rand 0.8.5", "rand_chacha 0.3.1", "serde", "serde_json", @@ -12903,10 +13380,10 @@ dependencies = [ "serde", "snowbridge-ethereum", "snowbridge-milagro-bls", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "ssz_rs", "ssz_rs_derive", "static_assertions", @@ -12927,11 +13404,11 @@ dependencies = [ "scale-info", "serde", "snowbridge-beacon-primitives", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", ] @@ -12953,10 +13430,10 @@ dependencies = [ "scale-info", "serde", "serde-big-array", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -12968,7 +13445,7 @@ dependencies = [ "hex", "lazy_static", "parity-scale-codec", - "rand", + "rand 0.8.5", "scale-info", "snowbridge-amcl", "zeroize", @@ -12989,10 +13466,10 @@ dependencies = [ "scale-info", "serde", "snowbridge-core", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -13031,7 +13508,7 @@ dependencies = [ "http", "httparse", "log", - "rand", + "rand 0.8.5", "sha-1", ] @@ -13046,13 +13523,13 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api-proc-macro", - "sp-core", - "sp-externalities", + "sp-core 29.0.0", + "sp-externalities 0.26.0", "sp-metadata-ir", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", "sp-version", "thiserror", ] @@ -13072,6 +13549,20 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "sp-application-crypto" +version = "23.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899492ea547816d5dfe9a5a2ecc32f65a7110805af6da3380aa4902371b31dc2" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core 21.0.0", + "sp-io 23.0.0", + "sp-std 8.0.0", +] + [[package]] name = "sp-application-crypto" version = "31.0.0" @@ -13081,9 +13572,24 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-io", - "sp-std", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-std 14.0.0", +] + +[[package]] +name = "sp-arithmetic" +version = "16.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6020576e544c6824a51d651bc8df8e6ab67cd59f1c9ac09868bb81a5199ded" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-std 8.0.0", + "static_assertions", ] [[package]] @@ -13097,7 +13603,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-std", + "sp-std 14.0.0", "static_assertions", ] @@ -13110,9 +13616,9 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-application-crypto", - "sp-runtime", - "sp-std", + "sp-application-crypto 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -13123,8 +13629,8 @@ checksum = "1b36ce171caa7eb2bbe682c089f755fdefa71d3702e4fb1ba30d10146aef99d5" dependencies = [ "sp-api", "sp-inherents", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -13141,8 +13647,8 @@ dependencies = [ "sp-api", "sp-consensus", "sp-database", - "sp-runtime", - "sp-state-machine", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", "thiserror", ] @@ -13155,10 +13661,10 @@ dependencies = [ "async-trait", "futures", "log", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-runtime", - "sp-state-machine", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", "thiserror", ] @@ -13172,11 +13678,11 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-consensus-slots", "sp-inherents", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "sp-timestamp", ] @@ -13191,12 +13697,12 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-application-crypto", + "sp-application-crypto 31.0.0", "sp-consensus-slots", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "sp-timestamp", ] @@ -13211,13 +13717,13 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-application-crypto", - "sp-core", + "sp-application-crypto 31.0.0", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-io", + "sp-io 31.0.0", "sp-mmr-primitives", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "strum 0.24.1", ] @@ -13233,11 +13739,11 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "sp-runtime", - "sp-std", + "sp-application-crypto 31.0.0", + "sp-core 29.0.0", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -13249,10 +13755,55 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-std", + "sp-std 14.0.0", "sp-timestamp", ] +[[package]] +name = "sp-core" +version = "21.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f18d9e2f67d8661f9729f35347069ac29d92758b59135176799db966947a7336" +dependencies = [ + "array-bytes 4.2.0", + "bitflags 1.3.2", + "blake2 0.10.6", + "bounded-collections 0.1.9", + "bs58 0.4.0", + "dyn-clonable", + "ed25519-zebra 3.1.0", + "futures", + "hash-db", + "hash256-std-hasher", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "merlin 2.0.1", + "parity-scale-codec", + "parking_lot 0.12.1", + "paste", + "primitive-types", + "rand 0.8.5", + "regex", + "scale-info", + "schnorrkel 0.9.1", + "secp256k1 0.24.3", + "secrecy", + "serde", + "sp-core-hashing 9.0.0", + "sp-debug-derive 8.0.0", + "sp-externalities 0.19.0", + "sp-runtime-interface 17.0.0", + "sp-std 8.0.0", + "sp-storage 13.0.0", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tiny-bip39", + "zeroize", +] + [[package]] name = "sp-core" version = "29.0.0" @@ -13274,23 +13825,23 @@ dependencies = [ "itertools 0.10.5", "libsecp256k1", "log", - "merlin", + "merlin 3.0.0", "parity-scale-codec", "parking_lot 0.12.1", "paste", "primitive-types", - "rand", + "rand 0.8.5", "scale-info", "schnorrkel 0.11.4", - "secp256k1", + "secp256k1 0.28.2", "secrecy", "serde", "sp-crypto-hashing", - "sp-debug-derive", - "sp-externalities", - "sp-runtime-interface", - "sp-std", - "sp-storage", + "sp-debug-derive 14.0.0", + "sp-externalities 0.26.0", + "sp-runtime-interface 25.0.0", + "sp-std 14.0.0", + "sp-storage 20.0.0", "ss58-registry", "substrate-bip39", "thiserror", @@ -13299,6 +13850,21 @@ dependencies = [ "zeroize", ] +[[package]] +name = "sp-core-hashing" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ee599a8399448e65197f9a6cee338ad192e9023e35e31f22382964c3c174c68" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest 0.10.7", + "sha2 0.10.8", + "sha3", + "sp-std 8.0.0", + "twox-hash", +] + [[package]] name = "sp-core-hashing" version = "15.0.0" @@ -13348,6 +13914,17 @@ dependencies = [ "parking_lot 0.12.1", ] +[[package]] +name = "sp-debug-derive" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f531814d2f16995144c74428830ccf7d94ff4a7749632b83ad8199b181140c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "sp-debug-derive" version = "14.0.0" @@ -13359,6 +13936,18 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "sp-externalities" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0f71c671e01a8ca60da925d43a1b351b69626e268b8837f8371e320cf1dd100" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-std 8.0.0", + "sp-storage 13.0.0", +] + [[package]] name = "sp-externalities" version = "0.26.0" @@ -13367,8 +13956,8 @@ checksum = "e7096ed024cec397804864898b093b51e14c7299f1d00c67dd5800330e02bb82" dependencies = [ "environmental", "parity-scale-codec", - "sp-std", - "sp-storage", + "sp-std 14.0.0", + "sp-storage 20.0.0", ] [[package]] @@ -13379,8 +13968,8 @@ checksum = "fd865540ec19479c7349b584ccd78cc34c3f3a628a2a69dbb6365ceec36295ee" dependencies = [ "serde_json", "sp-api", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -13393,11 +13982,38 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "thiserror", ] +[[package]] +name = "sp-io" +version = "23.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d597e35a9628fe7454b08965b2442e3ec0f264b0a90d41328e87422cec02e99" +dependencies = [ + "bytes", + "ed25519 1.5.3", + "ed25519-dalek 1.0.1", + "futures", + "libsecp256k1", + "log", + "parity-scale-codec", + "rustversion", + "secp256k1 0.24.3", + "sp-core 21.0.0", + "sp-externalities 0.19.0", + "sp-keystore 0.27.0", + "sp-runtime-interface 17.0.0", + "sp-state-machine 0.28.0", + "sp-std 8.0.0", + "sp-tracing 10.0.0", + "sp-trie 22.0.0", + "tracing", + "tracing-core", +] + [[package]] name = "sp-io" version = "31.0.0" @@ -13405,21 +14021,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec43aa073eab35fcb920d7592474d5427ea3be2bf938706a3ad955d7ba54fd8d" dependencies = [ "bytes", - "ed25519-dalek", + "ed25519-dalek 2.1.1", "libsecp256k1", "log", "parity-scale-codec", "rustversion", - "secp256k1", - "sp-core", + "secp256k1 0.28.2", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-externalities", - "sp-keystore", - "sp-runtime-interface", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-trie", + "sp-externalities 0.26.0", + "sp-keystore 0.35.0", + "sp-runtime-interface 25.0.0", + "sp-state-machine 0.36.0", + "sp-std 14.0.0", + "sp-tracing 16.0.0", + "sp-trie 30.0.0", "tracing", "tracing-core", ] @@ -13430,11 +14046,25 @@ version = "32.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cf0a2f881958466fc92bc9b39bbc2c0d815ded4a21f8f953372b0ac2e11b02" dependencies = [ - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", "strum 0.24.1", ] +[[package]] +name = "sp-keystore" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9be3cdd67cc1d9c1db17c5cbc4ec4924054a8437009d167f21f6590797e4aa45" +dependencies = [ + "futures", + "parity-scale-codec", + "parking_lot 0.12.1", + "sp-core 21.0.0", + "sp-externalities 0.19.0", + "thiserror", +] + [[package]] name = "sp-keystore" version = "0.35.0" @@ -13443,8 +14073,8 @@ checksum = "444f2d53968b1ce5e908882710ff1f3873fcf3e95f59d57432daf685bbacb959" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", - "sp-core", - "sp-externalities", + "sp-core 29.0.0", + "sp-externalities 0.26.0", "thiserror", ] @@ -13467,7 +14097,7 @@ dependencies = [ "frame-metadata 16.0.0", "parity-scale-codec", "scale-info", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -13479,8 +14109,8 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-application-crypto", - "sp-std", + "sp-application-crypto 31.0.0", + "sp-std 14.0.0", ] [[package]] @@ -13495,10 +14125,10 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-core", - "sp-debug-derive", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-debug-derive 14.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "thiserror", ] @@ -13511,10 +14141,10 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-arithmetic", - "sp-core", - "sp-runtime", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -13524,8 +14154,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d83b955dce0b6d143bec3f60571311168f362b1c16cf044da7037a407b66c19" dependencies = [ "sp-api", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", +] + +[[package]] +name = "sp-panic-handler" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd2de46003fa8212426838ca71cd42ee36a26480ba9ffea983506ce03131033" +dependencies = [ + "backtrace", + "lazy_static", + "regex", ] [[package]] @@ -13547,7 +14188,30 @@ checksum = "9af4b73fe7ddd88b1641cca90048c4e525e721763199e6fd29c4f590884f4d16" dependencies = [ "rustc-hash", "serde", - "sp-core", + "sp-core 29.0.0", +] + +[[package]] +name = "sp-runtime" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21c5bfc764a1a8259d7e8f7cfd22c84006275a512c958d3ff966c92151e134d5" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "paste", + "rand 0.8.5", + "scale-info", + "serde", + "sp-application-crypto 23.0.0", + "sp-arithmetic 16.0.0", + "sp-core 21.0.0", + "sp-io 23.0.0", + "sp-std 8.0.0", + "sp-weights 20.0.0", ] [[package]] @@ -13563,16 +14227,35 @@ dependencies = [ "log", "parity-scale-codec", "paste", - "rand", + "rand 0.8.5", "scale-info", "serde", "simple-mermaid", - "sp-application-crypto", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-std", - "sp-weights", + "sp-application-crypto 31.0.0", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-std 14.0.0", + "sp-weights 28.0.0", +] + +[[package]] +name = "sp-runtime-interface" +version = "17.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e676128182f90015e916f806cba635c8141e341e7abbc45d25525472e1bbce8" +dependencies = [ + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec", + "primitive-types", + "sp-externalities 0.19.0", + "sp-runtime-interface-proc-macro 11.0.0", + "sp-std 8.0.0", + "sp-storage 13.0.0", + "sp-tracing 10.0.0", + "sp-wasm-interface 14.0.0", + "static_assertions", ] [[package]] @@ -13585,15 +14268,28 @@ dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", "primitive-types", - "sp-externalities", - "sp-runtime-interface-proc-macro", - "sp-std", - "sp-storage", - "sp-tracing", - "sp-wasm-interface", + "sp-externalities 0.26.0", + "sp-runtime-interface-proc-macro 17.0.0", + "sp-std 14.0.0", + "sp-storage 20.0.0", + "sp-tracing 16.0.0", + "sp-wasm-interface 20.0.0", "static_assertions", ] +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "11.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d5bd5566fe5633ec48dfa35ab152fd29f8a577c21971e1c6db9f28afb9bbb9" +dependencies = [ + "Inflector", + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" @@ -13617,11 +14313,11 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-api", - "sp-core", - "sp-keystore", - "sp-runtime", + "sp-core 29.0.0", + "sp-keystore 0.35.0", + "sp-runtime 32.0.0", "sp-staking", - "sp-std", + "sp-std 14.0.0", ] [[package]] @@ -13634,9 +14330,30 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-core", - "sp-runtime", - "sp-std", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", +] + +[[package]] +name = "sp-state-machine" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef45d31f9e7ac648f8899a0cd038a3608f8499028bff55b6c799702592325b6" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "rand 0.8.5", + "smallvec", + "sp-core 21.0.0", + "sp-externalities 0.19.0", + "sp-panic-handler 8.0.0", + "sp-std 8.0.0", + "sp-trie 22.0.0", + "thiserror", + "tracing", ] [[package]] @@ -13649,16 +14366,16 @@ dependencies = [ "log", "parity-scale-codec", "parking_lot 0.12.1", - "rand", + "rand 0.8.5", "smallvec", - "sp-core", - "sp-externalities", - "sp-panic-handler", - "sp-std", - "sp-trie", + "sp-core 29.0.0", + "sp-externalities 0.26.0", + "sp-panic-handler 13.0.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", "thiserror", "tracing", - "trie-db", + "trie-db 0.28.0", ] [[package]] @@ -13669,30 +14386,50 @@ checksum = "309a9ae4e8134bbed8ffc510cf4d461a4a651f9250b556de782cedd876abe1ff" dependencies = [ "aes-gcm", "curve25519-dalek 4.1.2", - "ed25519-dalek", + "ed25519-dalek 2.1.1", "hkdf", "parity-scale-codec", - "rand", + "rand 0.8.5", "scale-info", "sha2 0.10.8", "sp-api", - "sp-application-crypto", - "sp-core", + "sp-application-crypto 31.0.0", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-externalities", - "sp-runtime", - "sp-runtime-interface", - "sp-std", + "sp-externalities 0.26.0", + "sp-runtime 32.0.0", + "sp-runtime-interface 25.0.0", + "sp-std 14.0.0", "thiserror", "x25519-dalek 2.0.1", ] +[[package]] +name = "sp-std" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53458e3c57df53698b3401ec0934bea8e8cfce034816873c0b0abbd83d7bac0d" + [[package]] name = "sp-std" version = "14.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8ee986414b0a9ad741776762f4083cd3a5128449b982a3919c4df36874834" +[[package]] +name = "sp-storage" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94294be83f11d4958cfea89ed5798f0b6605f5defc3a996948848458abbcc18e" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive 8.0.0", + "sp-std 8.0.0", +] + [[package]] name = "sp-storage" version = "20.0.0" @@ -13703,8 +14440,8 @@ dependencies = [ "parity-scale-codec", "ref-cast", "serde", - "sp-debug-derive", - "sp-std", + "sp-debug-derive 14.0.0", + "sp-std 14.0.0", ] [[package]] @@ -13716,11 +14453,24 @@ dependencies = [ "async-trait", "parity-scale-codec", "sp-inherents", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "thiserror", ] +[[package]] +name = "sp-tracing" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357f7591980dd58305956d32f8f6646d0a8ea9ea0e7e868e46f53b68ddf00cec" +dependencies = [ + "parity-scale-codec", + "sp-std 8.0.0", + "tracing", + "tracing-core", + "tracing-subscriber 0.2.25", +] + [[package]] name = "sp-tracing" version = "16.0.0" @@ -13728,7 +14478,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0351810b9d074df71c4514c5228ed05c250607cba131c1c9d1526760ab69c05c" dependencies = [ "parity-scale-codec", - "sp-std", + "sp-std 14.0.0", "tracing", "tracing-core", "tracing-subscriber 0.2.25", @@ -13741,7 +14491,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9742861c5330bdcb42856a6eed3d3745b58ee1c92ca4c9260032ff4e6c387165" dependencies = [ "sp-api", - "sp-runtime", + "sp-runtime 32.0.0", ] [[package]] @@ -13753,11 +14503,35 @@ dependencies = [ "async-trait", "parity-scale-codec", "scale-info", - "sp-core", + "sp-core 29.0.0", "sp-inherents", - "sp-runtime", - "sp-std", - "sp-trie", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-trie 30.0.0", +] + +[[package]] +name = "sp-trie" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4eeb7ef23f79eba8609db79ef9cef242f994f1f87a3c0387b4b5f177fda74" +dependencies = [ + "ahash 0.8.11", + "hash-db", + "hashbrown 0.13.2", + "lazy_static", + "memory-db", + "nohash-hasher", + "parity-scale-codec", + "parking_lot 0.12.1", + "scale-info", + "schnellru", + "sp-core 21.0.0", + "sp-std 8.0.0", + "thiserror", + "tracing", + "trie-db 0.27.1", + "trie-root", ] [[package]] @@ -13773,15 +14547,15 @@ dependencies = [ "nohash-hasher", "parity-scale-codec", "parking_lot 0.12.1", - "rand", + "rand 0.8.5", "scale-info", "schnellru", - "sp-core", - "sp-externalities", - "sp-std", + "sp-core 29.0.0", + "sp-externalities 0.26.0", + "sp-std 14.0.0", "thiserror", "tracing", - "trie-db", + "trie-db 0.28.0", "trie-root", ] @@ -13797,8 +14571,8 @@ dependencies = [ "scale-info", "serde", "sp-crypto-hashing-proc-macro", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", "sp-version-proc-macro", "thiserror", ] @@ -13815,6 +14589,20 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "sp-wasm-interface" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19c122609ca5d8246be6386888596320d03c7bc880959eaa2c36bcd5acd6846" +dependencies = [ + "anyhow", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-std 8.0.0", + "wasmtime", +] + [[package]] name = "sp-wasm-interface" version = "20.0.0" @@ -13825,10 +14613,26 @@ dependencies = [ "impl-trait-for-tuples", "log", "parity-scale-codec", - "sp-std", + "sp-std 14.0.0", "wasmtime", ] +[[package]] +name = "sp-weights" +version = "20.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45d084c735544f70625b821c3acdbc7a2fc1893ca98b85f1942631284692c75b" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic 16.0.0", + "sp-core 21.0.0", + "sp-debug-derive 8.0.0", + "sp-std 8.0.0", +] + [[package]] name = "sp-weights" version = "28.0.0" @@ -13840,9 +14644,9 @@ dependencies = [ "scale-info", "serde", "smallvec", - "sp-arithmetic", - "sp-debug-derive", - "sp-std", + "sp-arithmetic 24.0.0", + "sp-debug-derive 14.0.0", + "sp-std 14.0.0", ] [[package]] @@ -13933,8 +14737,8 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", - "sp-runtime", - "sp-std", + "sp-runtime 32.0.0", + "sp-std 14.0.0", ] [[package]] @@ -13952,7 +14756,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-weights", + "sp-weights 28.0.0", "xcm-procedural", ] @@ -13970,11 +14774,11 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain-primitives", "scale-info", - "sp-arithmetic", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", + "sp-arithmetic 24.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-weights 28.0.0", "staging-xcm", "staging-xcm-executor", ] @@ -13992,12 +14796,12 @@ dependencies = [ "log", "parity-scale-codec", "scale-info", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-weights 28.0.0", "staging-xcm", ] @@ -14136,8 +14940,8 @@ dependencies = [ "sp-api", "sp-block-builder", "sp-blockchain", - "sp-core", - "sp-runtime", + "sp-core 29.0.0", + "sp-runtime 32.0.0", ] [[package]] @@ -14164,7 +14968,7 @@ dependencies = [ "log", "sc-rpc-api", "serde", - "sp-runtime", + "sp-runtime 32.0.0", ] [[package]] @@ -14178,11 +14982,11 @@ dependencies = [ "sc-client-api", "sc-rpc-api", "serde", - "sp-core", - "sp-runtime", - "sp-state-machine", - "sp-trie", - "trie-db", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", + "sp-trie 30.0.0", + "trie-db 0.28.0", ] [[package]] @@ -14248,7 +15052,7 @@ dependencies = [ "scale-value", "serde", "serde_json", - "sp-core-hashing", + "sp-core-hashing 15.0.0", "subxt-lightclient", "subxt-macro", "subxt-metadata", @@ -14320,7 +15124,7 @@ dependencies = [ "frame-metadata 16.0.0", "parity-scale-codec", "scale-info", - "sp-core-hashing", + "sp-core-hashing 15.0.0", "thiserror", ] @@ -14337,10 +15141,10 @@ dependencies = [ "pbkdf2 0.12.2", "regex", "schnorrkel 0.11.4", - "secp256k1", + "secp256k1 0.28.2", "secrecy", "sha2 0.10.8", - "sp-core-hashing", + "sp-core-hashing 15.0.0", "subxt", "thiserror", "zeroize", @@ -14380,6 +15184,17 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -14460,7 +15275,7 @@ dependencies = [ "polkadot-core-primitives", "rococo-runtime-constants", "smallvec", - "sp-runtime", + "sp-runtime 32.0.0", "staging-xcm", "westend-runtime-constants", ] @@ -14595,6 +15410,25 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-bip39" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" +dependencies = [ + "anyhow", + "hmac 0.12.1", + "once_cell", + "pbkdf2 0.11.0", + "rand 0.8.5", + "rustc-hash", + "sha2 0.10.8", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -14656,7 +15490,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" dependencies = [ "pin-project", - "rand", + "rand 0.8.5", "tokio", ] @@ -14968,6 +15802,19 @@ dependencies = [ "tracing-log 0.2.0", ] +[[package]] +name = "trie-db" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" +dependencies = [ + "hash-db", + "hashbrown 0.13.2", + "log", + "rustc-hex", + "smallvec", +] + [[package]] name = "trie-db" version = "0.28.0" @@ -15006,7 +15853,7 @@ dependencies = [ "idna 0.2.3", "ipnet", "lazy_static", - "rand", + "rand 0.8.5", "smallvec", "socket2 0.4.10", "thiserror", @@ -15062,19 +15909,19 @@ dependencies = [ "sp-api", "sp-consensus-aura", "sp-consensus-babe", - "sp-core", - "sp-debug-derive", - "sp-externalities", + "sp-core 29.0.0", + "sp-debug-derive 14.0.0", + "sp-externalities 0.26.0", "sp-inherents", - "sp-io", - "sp-keystore", + "sp-io 31.0.0", + "sp-keystore 0.35.0", "sp-rpc", - "sp-runtime", - "sp-state-machine", + "sp-runtime 32.0.0", + "sp-state-machine 0.36.0", "sp-timestamp", "sp-transaction-storage-proof", "sp-version", - "sp-weights", + "sp-weights 28.0.0", "substrate-rpc-client", "zstd 0.12.4", ] @@ -15093,7 +15940,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand", + "rand 0.8.5", "static_assertions", ] @@ -15244,7 +16091,7 @@ dependencies = [ "arrayref", "constcat", "digest 0.10.7", - "rand", + "rand 0.8.5", "rand_chacha 0.3.1", "rand_core 0.6.4", "sha2 0.10.8", @@ -15654,7 +16501,7 @@ dependencies = [ "memfd", "memoffset", "paste", - "rand", + "rand 0.8.5", "rustix 0.36.17", "wasmtime-asm-macros", "wasmtime-environ", @@ -15783,24 +16630,24 @@ dependencies = [ "serde_derive", "smallvec", "sp-api", - "sp-application-crypto", - "sp-arithmetic", + "sp-application-crypto 31.0.0", + "sp-arithmetic 24.0.0", "sp-authority-discovery", "sp-block-builder", "sp-consensus-babe", "sp-consensus-beefy", - "sp-core", + "sp-core 29.0.0", "sp-genesis-builder", "sp-inherents", - "sp-io", + "sp-io 31.0.0", "sp-mmr-primitives", "sp-npos-elections", "sp-offchain", - "sp-runtime", + "sp-runtime 32.0.0", "sp-session", "sp-staking", - "sp-std", - "sp-storage", + "sp-std 14.0.0", + "sp-storage 20.0.0", "sp-transaction-pool", "sp-version", "staging-xcm", @@ -15820,9 +16667,9 @@ dependencies = [ "polkadot-primitives", "polkadot-runtime-common", "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", + "sp-core 29.0.0", + "sp-runtime 32.0.0", + "sp-weights 28.0.0", "staging-xcm", "staging-xcm-builder", ] @@ -16214,13 +17061,13 @@ dependencies = [ "polkadot-parachain-primitives", "polkadot-primitives", "polkadot-runtime-parachains", - "sp-arithmetic", - "sp-core", + "sp-arithmetic 24.0.0", + "sp-core 29.0.0", "sp-crypto-hashing", - "sp-io", - "sp-runtime", - "sp-std", - "sp-tracing", + "sp-io 31.0.0", + "sp-runtime 32.0.0", + "sp-std 14.0.0", + "sp-tracing 16.0.0", "staging-xcm", "staging-xcm-executor", ] @@ -16237,6 +17084,12 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "xxhash-rust" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927da81e25be1e1a2901d59b81b37dd2efd1fc9c9345a55007f09bf5a2d3ee03" + [[package]] name = "yamux" version = "0.10.2" @@ -16247,7 +17100,7 @@ dependencies = [ "log", "nohash-hasher", "parking_lot 0.12.1", - "rand", + "rand 0.8.5", "static_assertions", ] diff --git a/pop-api/examples/fungibles/expanded.rs b/pop-api/examples/fungibles/expanded.rs deleted file mode 100644 index c73cdeb7..00000000 --- a/pop-api/examples/fungibles/expanded.rs +++ /dev/null @@ -1,2766 +0,0 @@ -#![feature(prelude_import)] -#[prelude_import] -use std::prelude::rust_2021::*; -#[macro_use] -extern crate std; -use pop_api::{ - primitives::{AccountId as AccountId32, AssetId}, - assets::fungibles::*, -}; -pub enum FungiblesError { - /// Not enough balance to fulfill a request is available. - InsufficientBalance, - /// Not enough allowance to fulfill a request is available. - InsufficientAllowance, - /// The asset status is not the expected status. - IncorrectStatus, - /// The asset ID is already taken. - InUse, - /// Minimum balance should be non-zero. - MinBalanceZero, - /// The signing account has no permission to do the operation. - NoPermission, - /// The given asset ID is unknown. - Unknown, - /// Recipient's address is zero. - ZeroRecipientAddress, - /// Sender's address is zero. - ZeroSenderAddress, -} -#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] -const _: () = { - impl ::scale_info::TypeInfo for FungiblesError { - type Identity = Self; - fn type_info() -> ::scale_info::Type { - ::scale_info::Type::builder() - .path( - ::scale_info::Path::new_with_replace( - "FungiblesError", - "fungibles", - &[], - ), - ) - .type_params(::alloc::vec::Vec::new()) - .variant( - ::scale_info::build::Variants::new() - .variant( - "InsufficientBalance", - |v| { - v - .index(0usize as ::core::primitive::u8) - .docs( - &["Not enough balance to fulfill a request is available."], - ) - }, - ) - .variant( - "InsufficientAllowance", - |v| { - v - .index(1usize as ::core::primitive::u8) - .docs( - &["Not enough allowance to fulfill a request is available."], - ) - }, - ) - .variant( - "IncorrectStatus", - |v| { - v - .index(2usize as ::core::primitive::u8) - .docs(&["The asset status is not the expected status."]) - }, - ) - .variant( - "InUse", - |v| { - v - .index(3usize as ::core::primitive::u8) - .docs(&["The asset ID is already taken."]) - }, - ) - .variant( - "MinBalanceZero", - |v| { - v - .index(4usize as ::core::primitive::u8) - .docs(&["Minimum balance should be non-zero."]) - }, - ) - .variant( - "NoPermission", - |v| { - v - .index(5usize as ::core::primitive::u8) - .docs( - &[ - "The signing account has no permission to do the operation.", - ], - ) - }, - ) - .variant( - "Unknown", - |v| { - v - .index(6usize as ::core::primitive::u8) - .docs(&["The given asset ID is unknown."]) - }, - ) - .variant( - "ZeroRecipientAddress", - |v| { - v - .index(7usize as ::core::primitive::u8) - .docs(&["Recipient's address is zero."]) - }, - ) - .variant( - "ZeroSenderAddress", - |v| { - v - .index(8usize as ::core::primitive::u8) - .docs(&["Sender's address is zero."]) - }, - ), - ) - } - } -}; -#[automatically_derived] -impl ::core::fmt::Debug for FungiblesError { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::write_str( - f, - match self { - FungiblesError::InsufficientBalance => "InsufficientBalance", - FungiblesError::InsufficientAllowance => "InsufficientAllowance", - FungiblesError::IncorrectStatus => "IncorrectStatus", - FungiblesError::InUse => "InUse", - FungiblesError::MinBalanceZero => "MinBalanceZero", - FungiblesError::NoPermission => "NoPermission", - FungiblesError::Unknown => "Unknown", - FungiblesError::ZeroRecipientAddress => "ZeroRecipientAddress", - FungiblesError::ZeroSenderAddress => "ZeroSenderAddress", - }, - ) - } -} -#[automatically_derived] -impl ::core::marker::Copy for FungiblesError {} -#[automatically_derived] -impl ::core::clone::Clone for FungiblesError { - #[inline] - fn clone(&self) -> FungiblesError { - *self - } -} -#[automatically_derived] -impl ::core::marker::StructuralPartialEq for FungiblesError {} -#[automatically_derived] -impl ::core::cmp::PartialEq for FungiblesError { - #[inline] - fn eq(&self, other: &FungiblesError) -> bool { - let __self_tag = ::core::intrinsics::discriminant_value(self); - let __arg1_tag = ::core::intrinsics::discriminant_value(other); - __self_tag == __arg1_tag - } -} -#[automatically_derived] -impl ::core::cmp::Eq for FungiblesError { - #[inline] - #[doc(hidden)] - #[coverage(off)] - fn assert_receiver_is_total_eq(&self) -> () {} -} -#[allow(deprecated)] -const _: () = { - #[automatically_derived] - impl ::scale::Encode for FungiblesError { - fn size_hint(&self) -> usize { - 1_usize - + match *self { - FungiblesError::InsufficientBalance => 0_usize, - FungiblesError::InsufficientAllowance => 0_usize, - FungiblesError::IncorrectStatus => 0_usize, - FungiblesError::InUse => 0_usize, - FungiblesError::MinBalanceZero => 0_usize, - FungiblesError::NoPermission => 0_usize, - FungiblesError::Unknown => 0_usize, - FungiblesError::ZeroRecipientAddress => 0_usize, - FungiblesError::ZeroSenderAddress => 0_usize, - _ => 0_usize, - } - } - fn encode_to<__CodecOutputEdqy: ::scale::Output + ?::core::marker::Sized>( - &self, - __codec_dest_edqy: &mut __CodecOutputEdqy, - ) { - match *self { - FungiblesError::InsufficientBalance => { - #[allow(clippy::unnecessary_cast)] - __codec_dest_edqy.push_byte(0usize as ::core::primitive::u8); - } - FungiblesError::InsufficientAllowance => { - #[allow(clippy::unnecessary_cast)] - __codec_dest_edqy.push_byte(1usize as ::core::primitive::u8); - } - FungiblesError::IncorrectStatus => { - #[allow(clippy::unnecessary_cast)] - __codec_dest_edqy.push_byte(2usize as ::core::primitive::u8); - } - FungiblesError::InUse => { - #[allow(clippy::unnecessary_cast)] - __codec_dest_edqy.push_byte(3usize as ::core::primitive::u8); - } - FungiblesError::MinBalanceZero => { - #[allow(clippy::unnecessary_cast)] - __codec_dest_edqy.push_byte(4usize as ::core::primitive::u8); - } - FungiblesError::NoPermission => { - #[allow(clippy::unnecessary_cast)] - __codec_dest_edqy.push_byte(5usize as ::core::primitive::u8); - } - FungiblesError::Unknown => { - #[allow(clippy::unnecessary_cast)] - __codec_dest_edqy.push_byte(6usize as ::core::primitive::u8); - } - FungiblesError::ZeroRecipientAddress => { - #[allow(clippy::unnecessary_cast)] - __codec_dest_edqy.push_byte(7usize as ::core::primitive::u8); - } - FungiblesError::ZeroSenderAddress => { - #[allow(clippy::unnecessary_cast)] - __codec_dest_edqy.push_byte(8usize as ::core::primitive::u8); - } - _ => {} - } - } - } - #[automatically_derived] - impl ::scale::EncodeLike for FungiblesError {} -}; -#[allow(deprecated)] -const _: () = { - #[automatically_derived] - impl ::scale::Decode for FungiblesError { - fn decode<__CodecInputEdqy: ::scale::Input>( - __codec_input_edqy: &mut __CodecInputEdqy, - ) -> ::core::result::Result { - match __codec_input_edqy - .read_byte() - .map_err(|e| { - e - .chain( - "Could not decode `FungiblesError`, failed to read variant byte", - ) - })? - { - #[allow(clippy::unnecessary_cast)] - __codec_x_edqy if __codec_x_edqy == 0usize as ::core::primitive::u8 => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Ok(FungiblesError::InsufficientBalance) - })(); - } - #[allow(clippy::unnecessary_cast)] - __codec_x_edqy if __codec_x_edqy == 1usize as ::core::primitive::u8 => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Ok(FungiblesError::InsufficientAllowance) - })(); - } - #[allow(clippy::unnecessary_cast)] - __codec_x_edqy if __codec_x_edqy == 2usize as ::core::primitive::u8 => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Ok(FungiblesError::IncorrectStatus) - })(); - } - #[allow(clippy::unnecessary_cast)] - __codec_x_edqy if __codec_x_edqy == 3usize as ::core::primitive::u8 => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Ok(FungiblesError::InUse) - })(); - } - #[allow(clippy::unnecessary_cast)] - __codec_x_edqy if __codec_x_edqy == 4usize as ::core::primitive::u8 => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Ok(FungiblesError::MinBalanceZero) - })(); - } - #[allow(clippy::unnecessary_cast)] - __codec_x_edqy if __codec_x_edqy == 5usize as ::core::primitive::u8 => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Ok(FungiblesError::NoPermission) - })(); - } - #[allow(clippy::unnecessary_cast)] - __codec_x_edqy if __codec_x_edqy == 6usize as ::core::primitive::u8 => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Ok(FungiblesError::Unknown) - })(); - } - #[allow(clippy::unnecessary_cast)] - __codec_x_edqy if __codec_x_edqy == 7usize as ::core::primitive::u8 => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Ok(FungiblesError::ZeroRecipientAddress) - })(); - } - #[allow(clippy::unnecessary_cast)] - __codec_x_edqy if __codec_x_edqy == 8usize as ::core::primitive::u8 => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Ok(FungiblesError::ZeroSenderAddress) - })(); - } - _ => { - #[allow(clippy::redundant_closure_call)] - return (move || { - ::core::result::Result::Err( - <_ as ::core::convert::Into< - _, - >>::into( - "Could not decode `FungiblesError`, variant doesn't exist", - ), - ) - })(); - } - } - } - } -}; -impl From for FungiblesError { - fn from(error: Error) -> Self { - match error { - Error::InUse => FungiblesError::InUse, - Error::MinBalanceZero => FungiblesError::MinBalanceZero, - Error::Unknown => FungiblesError::Unknown, - _ => ::core::panicking::panic("not yet implemented"), - } - } -} -/// The fungibles result type. -pub type Result = core::result::Result; -mod fungibles { - impl ::ink::env::ContractEnv for Fungibles { - type Env = pop_api::Environment; - } - type Environment = ::Env; - type AccountId = <::Env as ::ink::env::Environment>::AccountId; - type Balance = <::Env as ::ink::env::Environment>::Balance; - type Hash = <::Env as ::ink::env::Environment>::Hash; - type Timestamp = <::Env as ::ink::env::Environment>::Timestamp; - type BlockNumber = <::Env as ::ink::env::Environment>::BlockNumber; - type ChainExtension = <::Env as ::ink::env::Environment>::ChainExtension; - const MAX_EVENT_TOPICS: usize = <::Env as ::ink::env::Environment>::MAX_EVENT_TOPICS; - const _: () = { - struct Check { - salt: (), - } - }; - #[scale_info(crate = ::ink::scale_info)] - #[cfg(not(feature = "__ink_dylint_Storage"))] - pub struct Fungibles {} - const _: () = { - impl< - __ink_generic_salt: ::ink::storage::traits::StorageKey, - > ::ink::storage::traits::StorableHint<__ink_generic_salt> for Fungibles { - type Type = Fungibles; - type PreferredKey = ::ink::storage::traits::AutoKey; - } - }; - const _: () = { - impl ::ink::storage::traits::StorageKey for Fungibles { - const KEY: ::ink::primitives::Key = <() as ::ink::storage::traits::StorageKey>::KEY; - } - }; - const _: () = { - impl ::ink::storage::traits::Storable for Fungibles { - #[inline(always)] - #[allow(non_camel_case_types)] - fn decode<__ink_I: ::ink::scale::Input>( - __input: &mut __ink_I, - ) -> ::core::result::Result { - ::core::result::Result::Ok(Fungibles {}) - } - #[inline(always)] - #[allow(non_camel_case_types)] - fn encode<__ink_O: ::ink::scale::Output + ?::core::marker::Sized>( - &self, - __dest: &mut __ink_O, - ) { - match self { - Fungibles {} => {} - } - } - #[inline(always)] - #[allow(non_camel_case_types)] - fn encoded_size(&self) -> ::core::primitive::usize { - match self { - Fungibles {} => ::core::primitive::usize::MIN, - } - } - } - }; - #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] - const _: () = { - impl ::ink::scale_info::TypeInfo for Fungibles { - type Identity = Self; - fn type_info() -> ::ink::scale_info::Type { - ::ink::scale_info::Type::builder() - .path( - ::ink::scale_info::Path::new_with_replace( - "Fungibles", - "fungibles::fungibles", - &[], - ), - ) - .type_params(::alloc::vec::Vec::new()) - .composite(::ink::scale_info::build::Fields::named()) - } - } - }; - const _: () = { - impl ::ink::storage::traits::StorageLayout for Fungibles { - fn layout( - __key: &::ink::primitives::Key, - ) -> ::ink::metadata::layout::Layout { - ::ink::metadata::layout::Layout::Struct( - ::ink::metadata::layout::StructLayout::new("Fungibles", []), - ) - } - } - }; - #[automatically_derived] - impl ::core::default::Default for Fungibles { - #[inline] - fn default() -> Fungibles { - Fungibles {} - } - } - const _: () = { - impl ::ink::reflect::ContractName for Fungibles { - const NAME: &'static str = "Fungibles"; - } - }; - const _: () = { - impl<'a> ::ink::codegen::Env for &'a Fungibles { - type EnvAccess = ::ink::EnvAccess< - 'a, - ::Env, - >; - fn env(self) -> Self::EnvAccess { - <::EnvAccess as ::core::default::Default>::default() - } - } - impl<'a> ::ink::codegen::StaticEnv for Fungibles { - type EnvAccess = ::ink::EnvAccess< - 'static, - ::Env, - >; - fn env() -> Self::EnvAccess { - <::EnvAccess as ::core::default::Default>::default() - } - } - }; - const _: () = { - #[allow(unused_imports)] - use ::ink::codegen::{Env as _, StaticEnv as _}; - }; - impl ::ink::reflect::DispatchableConstructorInfo<0x9BAE9D5E_u32> for Fungibles { - type Input = (); - type Output = Self; - type Storage = Fungibles; - type Error = <::ink::reflect::ConstructorOutputValue< - Self, - > as ::ink::reflect::ConstructorOutput>::Error; - const IS_RESULT: ::core::primitive::bool = <::ink::reflect::ConstructorOutputValue< - Self, - > as ::ink::reflect::ConstructorOutput>::IS_RESULT; - const CALLABLE: fn(Self::Input) -> Self::Output = |_| { Fungibles::new() }; - const PAYABLE: ::core::primitive::bool = true; - const SELECTOR: [::core::primitive::u8; 4usize] = [ - 0x9B_u8, - 0xAE_u8, - 0x9D_u8, - 0x5E_u8, - ]; - const LABEL: &'static ::core::primitive::str = "new"; - } - impl ::ink::reflect::DispatchableMessageInfo<0xDB6375A8_u32> for Fungibles { - type Input = AssetId; - type Output = Result; - type Storage = Fungibles; - const CALLABLE: fn(&mut Self::Storage, Self::Input) -> Self::Output = | - storage, - __ink_binding_0| - { Fungibles::total_supply(storage, __ink_binding_0) }; - const SELECTOR: [::core::primitive::u8; 4usize] = [ - 0xDB_u8, - 0x63_u8, - 0x75_u8, - 0xA8_u8, - ]; - const PAYABLE: ::core::primitive::bool = false; - const MUTATES: ::core::primitive::bool = false; - const LABEL: &'static ::core::primitive::str = "total_supply"; - } - impl ::ink::reflect::DispatchableMessageInfo<0x0F755A56_u32> for Fungibles { - type Input = (AssetId, AccountId32); - type Output = Result; - type Storage = Fungibles; - const CALLABLE: fn(&mut Self::Storage, Self::Input) -> Self::Output = | - storage, - (__ink_binding_0, __ink_binding_1)| - { Fungibles::balance_of(storage, __ink_binding_0, __ink_binding_1) }; - const SELECTOR: [::core::primitive::u8; 4usize] = [ - 0x0F_u8, - 0x75_u8, - 0x5A_u8, - 0x56_u8, - ]; - const PAYABLE: ::core::primitive::bool = false; - const MUTATES: ::core::primitive::bool = false; - const LABEL: &'static ::core::primitive::str = "balance_of"; - } - impl ::ink::reflect::DispatchableMessageInfo<0x6A00165E_u32> for Fungibles { - type Input = (AssetId, AccountId32, AccountId32); - type Output = Result; - type Storage = Fungibles; - const CALLABLE: fn(&mut Self::Storage, Self::Input) -> Self::Output = | - storage, - (__ink_binding_0, __ink_binding_1, __ink_binding_2)| - { - Fungibles::allowance( - storage, - __ink_binding_0, - __ink_binding_1, - __ink_binding_2, - ) - }; - const SELECTOR: [::core::primitive::u8; 4usize] = [ - 0x6A_u8, - 0x00_u8, - 0x16_u8, - 0x5E_u8, - ]; - const PAYABLE: ::core::primitive::bool = false; - const MUTATES: ::core::primitive::bool = false; - const LABEL: &'static ::core::primitive::str = "allowance"; - } - impl ::ink::reflect::DispatchableMessageInfo<0xAA6B65DB_u32> for Fungibles { - type Input = AssetId; - type Output = Result; - type Storage = Fungibles; - const CALLABLE: fn(&mut Self::Storage, Self::Input) -> Self::Output = | - storage, - __ink_binding_0| - { Fungibles::asset_exists(storage, __ink_binding_0) }; - const SELECTOR: [::core::primitive::u8; 4usize] = [ - 0xAA_u8, - 0x6B_u8, - 0x65_u8, - 0xDB_u8, - ]; - const PAYABLE: ::core::primitive::bool = false; - const MUTATES: ::core::primitive::bool = false; - const LABEL: &'static ::core::primitive::str = "asset_exists"; - } - impl ::ink::reflect::DispatchableMessageInfo<0x1F8E8E22_u32> for Fungibles { - type Input = (u32, AccountId32, Balance); - type Output = Result<()>; - type Storage = Fungibles; - const CALLABLE: fn(&mut Self::Storage, Self::Input) -> Self::Output = | - storage, - (__ink_binding_0, __ink_binding_1, __ink_binding_2)| - { - Fungibles::mint_asset( - storage, - __ink_binding_0, - __ink_binding_1, - __ink_binding_2, - ) - }; - const SELECTOR: [::core::primitive::u8; 4usize] = [ - 0x1F_u8, - 0x8E_u8, - 0x8E_u8, - 0x22_u8, - ]; - const PAYABLE: ::core::primitive::bool = false; - const MUTATES: ::core::primitive::bool = false; - const LABEL: &'static ::core::primitive::str = "mint_asset"; - } - const _: () = { - #[allow(non_camel_case_types)] - pub enum __ink_ConstructorDecoder { - Constructor0( - >::Input, - ), - } - impl ::ink::reflect::DecodeDispatch for __ink_ConstructorDecoder { - fn decode_dispatch( - input: &mut I, - ) -> ::core::result::Result - where - I: ::ink::scale::Input, - { - const CONSTRUCTOR_0: [::core::primitive::u8; 4usize] = >::SELECTOR; - match <[::core::primitive::u8; 4usize] as ::ink::scale::Decode>::decode( - input, - ) - .map_err(|_| ::ink::reflect::DispatchError::InvalidSelector)? - { - CONSTRUCTOR_0 => { - ::core::result::Result::Ok( - Self::Constructor0( - <>::Input as ::ink::scale::Decode>::decode(input) - .map_err(|_| { - ::ink::reflect::DispatchError::InvalidParameters - })?, - ), - ) - } - _invalid => { - ::core::result::Result::Err( - ::ink::reflect::DispatchError::UnknownSelector, - ) - } - } - } - } - impl ::ink::scale::Decode for __ink_ConstructorDecoder { - fn decode( - input: &mut I, - ) -> ::core::result::Result - where - I: ::ink::scale::Input, - { - ::decode_dispatch(input) - .map_err(::core::convert::Into::into) - } - } - impl ::ink::reflect::ExecuteDispatchable for __ink_ConstructorDecoder { - #[allow(clippy::nonminimal_bool)] - fn execute_dispatchable( - self, - ) -> ::core::result::Result<(), ::ink::reflect::DispatchError> { - match self { - Self::Constructor0(input) => { - if { - false - || { - let constructor_0 = false; - let constructor_0 = >::PAYABLE; - constructor_0 - } - } - && !>::PAYABLE - { - ::ink::codegen::deny_payment::< - ::Env, - >()?; - } - let result: >::Output = >::CALLABLE(input); - let output_value = ::ink::reflect::ConstructorOutputValue::new( - result, - ); - let output_result = <::ink::reflect::ConstructorOutputValue< - >::Output, - > as ::ink::reflect::ConstructorOutput< - Fungibles, - >>::as_result(&output_value); - if let ::core::result::Result::Ok(contract) = output_result - .as_ref() - { - ::ink::env::set_contract_storage::< - ::ink::primitives::Key, - Fungibles, - >( - &::KEY, - contract, - ); - } - let mut flag = ::ink::env::ReturnFlags::empty(); - if output_result.is_err() { - flag = ::ink::env::ReturnFlags::REVERT; - } - ::ink::env::return_value::< - ::ink::ConstructorResult< - ::core::result::Result< - (), - &<::ink::reflect::ConstructorOutputValue< - >::Output, - > as ::ink::reflect::ConstructorOutput>::Error, - >, - >, - >( - flag, - &::ink::ConstructorResult::Ok(output_result.map(|_| ())), - ); - } - } - } - } - impl ::ink::reflect::ContractConstructorDecoder for Fungibles { - type Type = __ink_ConstructorDecoder; - } - }; - const _: () = { - #[allow(non_camel_case_types)] - pub enum __ink_MessageDecoder { - Message0( - >::Input, - ), - Message1( - >::Input, - ), - Message2( - >::Input, - ), - Message3( - >::Input, - ), - Message4( - >::Input, - ), - } - impl ::ink::reflect::DecodeDispatch for __ink_MessageDecoder { - fn decode_dispatch( - input: &mut I, - ) -> ::core::result::Result - where - I: ::ink::scale::Input, - { - const MESSAGE_0: [::core::primitive::u8; 4usize] = >::SELECTOR; - const MESSAGE_1: [::core::primitive::u8; 4usize] = >::SELECTOR; - const MESSAGE_2: [::core::primitive::u8; 4usize] = >::SELECTOR; - const MESSAGE_3: [::core::primitive::u8; 4usize] = >::SELECTOR; - const MESSAGE_4: [::core::primitive::u8; 4usize] = >::SELECTOR; - match <[::core::primitive::u8; 4usize] as ::ink::scale::Decode>::decode( - input, - ) - .map_err(|_| ::ink::reflect::DispatchError::InvalidSelector)? - { - MESSAGE_0 => { - ::core::result::Result::Ok( - Self::Message0( - <>::Input as ::ink::scale::Decode>::decode(input) - .map_err(|_| { - ::ink::reflect::DispatchError::InvalidParameters - })?, - ), - ) - } - MESSAGE_1 => { - ::core::result::Result::Ok( - Self::Message1( - <>::Input as ::ink::scale::Decode>::decode(input) - .map_err(|_| { - ::ink::reflect::DispatchError::InvalidParameters - })?, - ), - ) - } - MESSAGE_2 => { - ::core::result::Result::Ok( - Self::Message2( - <>::Input as ::ink::scale::Decode>::decode(input) - .map_err(|_| { - ::ink::reflect::DispatchError::InvalidParameters - })?, - ), - ) - } - MESSAGE_3 => { - ::core::result::Result::Ok( - Self::Message3( - <>::Input as ::ink::scale::Decode>::decode(input) - .map_err(|_| { - ::ink::reflect::DispatchError::InvalidParameters - })?, - ), - ) - } - MESSAGE_4 => { - ::core::result::Result::Ok( - Self::Message4( - <>::Input as ::ink::scale::Decode>::decode(input) - .map_err(|_| { - ::ink::reflect::DispatchError::InvalidParameters - })?, - ), - ) - } - _invalid => { - ::core::result::Result::Err( - ::ink::reflect::DispatchError::UnknownSelector, - ) - } - } - } - } - impl ::ink::scale::Decode for __ink_MessageDecoder { - fn decode( - input: &mut I, - ) -> ::core::result::Result - where - I: ::ink::scale::Input, - { - ::decode_dispatch(input) - .map_err(::core::convert::Into::into) - } - } - fn push_contract(contract: ::core::mem::ManuallyDrop, mutates: bool) { - if mutates { - ::ink::env::set_contract_storage::< - ::ink::primitives::Key, - Fungibles, - >(&::KEY, &contract); - } - } - impl ::ink::reflect::ExecuteDispatchable for __ink_MessageDecoder { - #[allow(clippy::nonminimal_bool, clippy::let_unit_value)] - fn execute_dispatchable( - self, - ) -> ::core::result::Result<(), ::ink::reflect::DispatchError> { - let key = ::KEY; - let mut contract: ::core::mem::ManuallyDrop = ::core::mem::ManuallyDrop::new( - match ::ink::env::get_contract_storage(&key) { - ::core::result::Result::Ok( - ::core::option::Option::Some(value), - ) => value, - ::core::result::Result::Ok(::core::option::Option::None) => { - ::core::panicking::panic_fmt( - format_args!("storage entry was empty"), - ); - } - ::core::result::Result::Err(_) => { - ::core::panicking::panic_fmt( - format_args!("could not properly decode storage entry"), - ); - } - }, - ); - match self { - Self::Message0(input) => { - if { - false - || { - let message_0 = false; - let message_0 = >::PAYABLE; - message_0 - } - || { - let message_1 = false; - let message_1 = >::PAYABLE; - message_1 - } - || { - let message_2 = false; - let message_2 = >::PAYABLE; - message_2 - } - || { - let message_3 = false; - let message_3 = >::PAYABLE; - message_3 - } - || { - let message_4 = false; - let message_4 = >::PAYABLE; - message_4 - } - } - && !>::PAYABLE - { - ::ink::codegen::deny_payment::< - ::Env, - >()?; - } - let result: >::Output = >::CALLABLE(&mut contract, input); - let is_reverted = { - #[allow(unused_imports)] - use ::ink::result_info::IsResultTypeFallback as _; - ::ink::result_info::IsResultType::< - >::Output, - >::VALUE - } - && { - #[allow(unused_imports)] - use ::ink::result_info::IsResultErrFallback as _; - ::ink::result_info::IsResultErr(&result).value() - }; - let mut flag = ::ink::env::ReturnFlags::REVERT; - if !is_reverted { - flag = ::ink::env::ReturnFlags::empty(); - push_contract( - contract, - >::MUTATES, - ); - } - ::ink::env::return_value::< - ::ink::MessageResult< - >::Output, - >, - >(flag, &::ink::MessageResult::Ok(result)) - } - Self::Message1(input) => { - if { - false - || { - let message_0 = false; - let message_0 = >::PAYABLE; - message_0 - } - || { - let message_1 = false; - let message_1 = >::PAYABLE; - message_1 - } - || { - let message_2 = false; - let message_2 = >::PAYABLE; - message_2 - } - || { - let message_3 = false; - let message_3 = >::PAYABLE; - message_3 - } - || { - let message_4 = false; - let message_4 = >::PAYABLE; - message_4 - } - } - && !>::PAYABLE - { - ::ink::codegen::deny_payment::< - ::Env, - >()?; - } - let result: >::Output = >::CALLABLE(&mut contract, input); - let is_reverted = { - #[allow(unused_imports)] - use ::ink::result_info::IsResultTypeFallback as _; - ::ink::result_info::IsResultType::< - >::Output, - >::VALUE - } - && { - #[allow(unused_imports)] - use ::ink::result_info::IsResultErrFallback as _; - ::ink::result_info::IsResultErr(&result).value() - }; - let mut flag = ::ink::env::ReturnFlags::REVERT; - if !is_reverted { - flag = ::ink::env::ReturnFlags::empty(); - push_contract( - contract, - >::MUTATES, - ); - } - ::ink::env::return_value::< - ::ink::MessageResult< - >::Output, - >, - >(flag, &::ink::MessageResult::Ok(result)) - } - Self::Message2(input) => { - if { - false - || { - let message_0 = false; - let message_0 = >::PAYABLE; - message_0 - } - || { - let message_1 = false; - let message_1 = >::PAYABLE; - message_1 - } - || { - let message_2 = false; - let message_2 = >::PAYABLE; - message_2 - } - || { - let message_3 = false; - let message_3 = >::PAYABLE; - message_3 - } - || { - let message_4 = false; - let message_4 = >::PAYABLE; - message_4 - } - } - && !>::PAYABLE - { - ::ink::codegen::deny_payment::< - ::Env, - >()?; - } - let result: >::Output = >::CALLABLE(&mut contract, input); - let is_reverted = { - #[allow(unused_imports)] - use ::ink::result_info::IsResultTypeFallback as _; - ::ink::result_info::IsResultType::< - >::Output, - >::VALUE - } - && { - #[allow(unused_imports)] - use ::ink::result_info::IsResultErrFallback as _; - ::ink::result_info::IsResultErr(&result).value() - }; - let mut flag = ::ink::env::ReturnFlags::REVERT; - if !is_reverted { - flag = ::ink::env::ReturnFlags::empty(); - push_contract( - contract, - >::MUTATES, - ); - } - ::ink::env::return_value::< - ::ink::MessageResult< - >::Output, - >, - >(flag, &::ink::MessageResult::Ok(result)) - } - Self::Message3(input) => { - if { - false - || { - let message_0 = false; - let message_0 = >::PAYABLE; - message_0 - } - || { - let message_1 = false; - let message_1 = >::PAYABLE; - message_1 - } - || { - let message_2 = false; - let message_2 = >::PAYABLE; - message_2 - } - || { - let message_3 = false; - let message_3 = >::PAYABLE; - message_3 - } - || { - let message_4 = false; - let message_4 = >::PAYABLE; - message_4 - } - } - && !>::PAYABLE - { - ::ink::codegen::deny_payment::< - ::Env, - >()?; - } - let result: >::Output = >::CALLABLE(&mut contract, input); - let is_reverted = { - #[allow(unused_imports)] - use ::ink::result_info::IsResultTypeFallback as _; - ::ink::result_info::IsResultType::< - >::Output, - >::VALUE - } - && { - #[allow(unused_imports)] - use ::ink::result_info::IsResultErrFallback as _; - ::ink::result_info::IsResultErr(&result).value() - }; - let mut flag = ::ink::env::ReturnFlags::REVERT; - if !is_reverted { - flag = ::ink::env::ReturnFlags::empty(); - push_contract( - contract, - >::MUTATES, - ); - } - ::ink::env::return_value::< - ::ink::MessageResult< - >::Output, - >, - >(flag, &::ink::MessageResult::Ok(result)) - } - Self::Message4(input) => { - if { - false - || { - let message_0 = false; - let message_0 = >::PAYABLE; - message_0 - } - || { - let message_1 = false; - let message_1 = >::PAYABLE; - message_1 - } - || { - let message_2 = false; - let message_2 = >::PAYABLE; - message_2 - } - || { - let message_3 = false; - let message_3 = >::PAYABLE; - message_3 - } - || { - let message_4 = false; - let message_4 = >::PAYABLE; - message_4 - } - } - && !>::PAYABLE - { - ::ink::codegen::deny_payment::< - ::Env, - >()?; - } - let result: >::Output = >::CALLABLE(&mut contract, input); - let is_reverted = { - #[allow(unused_imports)] - use ::ink::result_info::IsResultTypeFallback as _; - ::ink::result_info::IsResultType::< - >::Output, - >::VALUE - } - && { - #[allow(unused_imports)] - use ::ink::result_info::IsResultErrFallback as _; - ::ink::result_info::IsResultErr(&result).value() - }; - let mut flag = ::ink::env::ReturnFlags::REVERT; - if !is_reverted { - flag = ::ink::env::ReturnFlags::empty(); - push_contract( - contract, - >::MUTATES, - ); - } - ::ink::env::return_value::< - ::ink::MessageResult< - >::Output, - >, - >(flag, &::ink::MessageResult::Ok(result)) - } - }; - } - } - impl ::ink::reflect::ContractMessageDecoder for Fungibles { - type Type = __ink_MessageDecoder; - } - }; - const _: () = { - use ::ink::codegen::{Env as _, StaticEnv as _}; - const _: ::ink::codegen::utils::IsSameType = ::ink::codegen::utils::IsSameType::< - Fungibles, - >::new(); - impl Fungibles { - #[cfg(not(feature = "__ink_dylint_Constructor"))] - pub fn new() -> Self { - ::ink_env::debug_message( - &{ - let res = ::alloc::fmt::format( - format_args!( - "{0}\n", - { - let res = ::alloc::fmt::format( - format_args!("PopApiAssetsExample::new"), - ); - res - }, - ), - ); - res - }, - ); - Default::default() - } - pub fn total_supply(&self, id: AssetId) -> Result { - total_supply(id).map_err(From::from) - } - pub fn balance_of( - &self, - id: AssetId, - owner: AccountId32, - ) -> Result { - balance_of(id, owner).map_err(From::from) - } - pub fn allowance( - &self, - id: AssetId, - owner: AccountId32, - spender: AccountId32, - ) -> Result { - allowance(id, owner, spender).map_err(From::from) - } - pub fn asset_exists(&self, id: AssetId) -> Result { - asset_exists(id).map_err(From::from) - } - pub fn mint_asset( - &self, - id: u32, - beneficiary: AccountId32, - amount: Balance, - ) -> Result<()> { - ::ink_env::debug_message( - &{ - let res = ::alloc::fmt::format( - format_args!( - "{0}\n", - { - let res = ::alloc::fmt::format( - format_args!( - "PopApiAssetsExample::mint_asset_through_runtime: id: {0:?} beneficiary: {1:?} amount: {2:?}", - id, - beneficiary, - amount, - ), - ); - res - }, - ), - ); - res - }, - ); - let result = mint(id, beneficiary, amount)?; - ::ink_env::debug_message( - &{ - let res = ::alloc::fmt::format( - format_args!( - "{0}\n", - { - let res = ::alloc::fmt::format( - format_args!("Result: {0:?}", result), - ); - res - }, - ), - ); - res - }, - ); - Ok(()) - } - } - const _: () = { - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchInput, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchOutput>, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchInput, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchInput, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchOutput>, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchInput, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchInput, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchInput, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchOutput>, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchInput, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchOutput>, - >(); - ::ink::codegen::utils::consume_type::<::ink::codegen::DispatchInput>(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchInput, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchInput, - >(); - ::ink::codegen::utils::consume_type::< - ::ink::codegen::DispatchOutput>, - >(); - }; - }; - const _: () = { - #[codec(crate = ::ink::scale)] - #[scale_info(crate = ::ink::scale_info)] - /// The ink! smart contract's call builder. - /// - /// Implements the underlying on-chain calling of the ink! smart contract - /// messages and trait implementations in a type safe way. - #[repr(transparent)] - pub struct CallBuilder { - account_id: AccountId, - } - #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] - const _: () = { - impl ::ink::scale_info::TypeInfo for CallBuilder { - type Identity = Self; - fn type_info() -> ::ink::scale_info::Type { - ::ink::scale_info::Type::builder() - .path( - ::ink::scale_info::Path::new_with_replace( - "CallBuilder", - "fungibles::fungibles", - &[], - ), - ) - .type_params(::alloc::vec::Vec::new()) - .docs( - &[ - "The ink! smart contract's call builder.", - "", - "Implements the underlying on-chain calling of the ink! smart contract", - "messages and trait implementations in a type safe way.", - ], - ) - .composite( - ::ink::scale_info::build::Fields::named() - .field(|f| { - f - .ty::() - .name("account_id") - .type_name("AccountId") - }), - ) - } - } - }; - #[allow(deprecated)] - const _: () = { - #[automatically_derived] - impl ::ink::scale::Decode for CallBuilder { - fn decode<__CodecInputEdqy: ::ink::scale::Input>( - __codec_input_edqy: &mut __CodecInputEdqy, - ) -> ::core::result::Result { - ::core::result::Result::Ok(CallBuilder { - account_id: { - let __codec_res_edqy = ::decode( - __codec_input_edqy, - ); - match __codec_res_edqy { - ::core::result::Result::Err(e) => { - return ::core::result::Result::Err( - e.chain("Could not decode `CallBuilder::account_id`"), - ); - } - ::core::result::Result::Ok(__codec_res_edqy) => { - __codec_res_edqy - } - } - }, - }) - } - fn decode_into<__CodecInputEdqy: ::ink::scale::Input>( - __codec_input_edqy: &mut __CodecInputEdqy, - dst_: &mut ::core::mem::MaybeUninit, - ) -> ::core::result::Result< - ::ink::scale::DecodeFinished, - ::ink::scale::Error, - > { - match ( - &::core::mem::size_of::(), - &::core::mem::size_of::(), - ) { - (left_val, right_val) => { - if !(*left_val == *right_val) { - let kind = ::core::panicking::AssertKind::Eq; - ::core::panicking::assert_failed( - kind, - &*left_val, - &*right_val, - ::core::option::Option::None, - ); - } - } - }; - if !(if ::core::mem::size_of::() > 0 { 1 } else { 0 } - <= 1) - { - ::core::panicking::panic( - "assertion failed: if ::core::mem::size_of::() > 0 { 1 } else { 0 } <= 1", - ) - } - { - let dst_: &mut ::core::mem::MaybeUninit = dst_; - let dst_: &mut ::core::mem::MaybeUninit = unsafe { - &mut *dst_ - .as_mut_ptr() - .cast::<::core::mem::MaybeUninit>() - }; - ::decode_into( - __codec_input_edqy, - dst_, - )?; - } - unsafe { - ::core::result::Result::Ok( - ::ink::scale::DecodeFinished::assert_decoding_finished(), - ) - } - } - } - }; - #[allow(deprecated)] - const _: () = { - #[automatically_derived] - impl ::ink::scale::Encode for CallBuilder { - fn size_hint(&self) -> usize { - ::ink::scale::Encode::size_hint(&&self.account_id) - } - fn encode_to< - __CodecOutputEdqy: ::ink::scale::Output + ?::core::marker::Sized, - >(&self, __codec_dest_edqy: &mut __CodecOutputEdqy) { - ::ink::scale::Encode::encode_to(&&self.account_id, __codec_dest_edqy) - } - fn encode( - &self, - ) -> ::ink::scale::alloc::vec::Vec<::core::primitive::u8> { - ::ink::scale::Encode::encode(&&self.account_id) - } - fn using_encoded< - __CodecOutputReturn, - __CodecUsingEncodedCallback: ::core::ops::FnOnce( - &[::core::primitive::u8], - ) -> __CodecOutputReturn, - >(&self, f: __CodecUsingEncodedCallback) -> __CodecOutputReturn { - ::ink::scale::Encode::using_encoded(&&self.account_id, f) - } - } - #[automatically_derived] - impl ::ink::scale::EncodeLike for CallBuilder {} - }; - #[automatically_derived] - impl ::core::fmt::Debug for CallBuilder { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::debug_struct_field1_finish( - f, - "CallBuilder", - "account_id", - &&self.account_id, - ) - } - } - #[automatically_derived] - impl ::core::hash::Hash for CallBuilder { - #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { - ::core::hash::Hash::hash(&self.account_id, state) - } - } - #[automatically_derived] - impl ::core::marker::StructuralPartialEq for CallBuilder {} - #[automatically_derived] - impl ::core::cmp::PartialEq for CallBuilder { - #[inline] - fn eq(&self, other: &CallBuilder) -> bool { - self.account_id == other.account_id - } - } - #[automatically_derived] - impl ::core::cmp::Eq for CallBuilder { - #[inline] - #[doc(hidden)] - #[coverage(off)] - fn assert_receiver_is_total_eq(&self) -> () { - let _: ::core::cmp::AssertParamIsEq; - } - } - #[automatically_derived] - impl ::core::clone::Clone for CallBuilder { - #[inline] - fn clone(&self) -> CallBuilder { - CallBuilder { - account_id: ::core::clone::Clone::clone(&self.account_id), - } - } - } - const _: () = { - impl ::ink::storage::traits::StorageLayout for CallBuilder { - fn layout( - __key: &::ink::primitives::Key, - ) -> ::ink::metadata::layout::Layout { - ::ink::metadata::layout::Layout::Struct( - ::ink::metadata::layout::StructLayout::new( - "CallBuilder", - [ - ::ink::metadata::layout::FieldLayout::new( - "account_id", - ::layout( - __key, - ), - ), - ], - ), - ) - } - } - }; - const _: () = { - impl ::ink::codegen::ContractCallBuilder for Fungibles { - type Type = CallBuilder; - } - impl ::ink::env::ContractEnv for CallBuilder { - type Env = ::Env; - } - }; - impl ::ink::env::call::FromAccountId for CallBuilder { - #[inline] - fn from_account_id(account_id: AccountId) -> Self { - Self { account_id } - } - } - impl ::ink::ToAccountId for CallBuilder { - #[inline] - fn to_account_id(&self) -> AccountId { - ::clone(&self.account_id) - } - } - impl ::core::convert::AsRef for CallBuilder { - fn as_ref(&self) -> &AccountId { - &self.account_id - } - } - impl ::core::convert::AsMut for CallBuilder { - fn as_mut(&mut self) -> &mut AccountId { - &mut self.account_id - } - } - impl CallBuilder { - #[allow(clippy::type_complexity)] - #[inline] - pub fn total_supply( - &self, - __ink_binding_0: AssetId, - ) -> ::ink::env::call::CallBuilder< - Environment, - ::ink::env::call::utils::Set<::ink::env::call::Call>, - ::ink::env::call::utils::Set< - ::ink::env::call::ExecutionInput< - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::EmptyArgumentList, - >, - >, - >, - ::ink::env::call::utils::Set< - ::ink::env::call::utils::ReturnType>, - >, - > { - ::ink::env::call::build_call::() - .call(::ink::ToAccountId::to_account_id(self)) - .exec_input( - ::ink::env::call::ExecutionInput::new( - ::ink::env::call::Selector::new([ - 0xDB_u8, - 0x63_u8, - 0x75_u8, - 0xA8_u8, - ]), - ) - .push_arg(__ink_binding_0), - ) - .returns::>() - } - #[allow(clippy::type_complexity)] - #[inline] - pub fn balance_of( - &self, - __ink_binding_0: AssetId, - __ink_binding_1: AccountId32, - ) -> ::ink::env::call::CallBuilder< - Environment, - ::ink::env::call::utils::Set<::ink::env::call::Call>, - ::ink::env::call::utils::Set< - ::ink::env::call::ExecutionInput< - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::EmptyArgumentList, - >, - >, - >, - >, - ::ink::env::call::utils::Set< - ::ink::env::call::utils::ReturnType>, - >, - > { - ::ink::env::call::build_call::() - .call(::ink::ToAccountId::to_account_id(self)) - .exec_input( - ::ink::env::call::ExecutionInput::new( - ::ink::env::call::Selector::new([ - 0x0F_u8, - 0x75_u8, - 0x5A_u8, - 0x56_u8, - ]), - ) - .push_arg(__ink_binding_0) - .push_arg(__ink_binding_1), - ) - .returns::>() - } - #[allow(clippy::type_complexity)] - #[inline] - pub fn allowance( - &self, - __ink_binding_0: AssetId, - __ink_binding_1: AccountId32, - __ink_binding_2: AccountId32, - ) -> ::ink::env::call::CallBuilder< - Environment, - ::ink::env::call::utils::Set<::ink::env::call::Call>, - ::ink::env::call::utils::Set< - ::ink::env::call::ExecutionInput< - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::EmptyArgumentList, - >, - >, - >, - >, - >, - ::ink::env::call::utils::Set< - ::ink::env::call::utils::ReturnType>, - >, - > { - ::ink::env::call::build_call::() - .call(::ink::ToAccountId::to_account_id(self)) - .exec_input( - ::ink::env::call::ExecutionInput::new( - ::ink::env::call::Selector::new([ - 0x6A_u8, - 0x00_u8, - 0x16_u8, - 0x5E_u8, - ]), - ) - .push_arg(__ink_binding_0) - .push_arg(__ink_binding_1) - .push_arg(__ink_binding_2), - ) - .returns::>() - } - #[allow(clippy::type_complexity)] - #[inline] - pub fn asset_exists( - &self, - __ink_binding_0: AssetId, - ) -> ::ink::env::call::CallBuilder< - Environment, - ::ink::env::call::utils::Set<::ink::env::call::Call>, - ::ink::env::call::utils::Set< - ::ink::env::call::ExecutionInput< - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::EmptyArgumentList, - >, - >, - >, - ::ink::env::call::utils::Set< - ::ink::env::call::utils::ReturnType>, - >, - > { - ::ink::env::call::build_call::() - .call(::ink::ToAccountId::to_account_id(self)) - .exec_input( - ::ink::env::call::ExecutionInput::new( - ::ink::env::call::Selector::new([ - 0xAA_u8, - 0x6B_u8, - 0x65_u8, - 0xDB_u8, - ]), - ) - .push_arg(__ink_binding_0), - ) - .returns::>() - } - #[allow(clippy::type_complexity)] - #[inline] - pub fn mint_asset( - &self, - __ink_binding_0: u32, - __ink_binding_1: AccountId32, - __ink_binding_2: Balance, - ) -> ::ink::env::call::CallBuilder< - Environment, - ::ink::env::call::utils::Set<::ink::env::call::Call>, - ::ink::env::call::utils::Set< - ::ink::env::call::ExecutionInput< - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::ArgumentList< - ::ink::env::call::utils::Argument, - ::ink::env::call::utils::EmptyArgumentList, - >, - >, - >, - >, - >, - ::ink::env::call::utils::Set< - ::ink::env::call::utils::ReturnType>, - >, - > { - ::ink::env::call::build_call::() - .call(::ink::ToAccountId::to_account_id(self)) - .exec_input( - ::ink::env::call::ExecutionInput::new( - ::ink::env::call::Selector::new([ - 0x1F_u8, - 0x8E_u8, - 0x8E_u8, - 0x22_u8, - ]), - ) - .push_arg(__ink_binding_0) - .push_arg(__ink_binding_1) - .push_arg(__ink_binding_2), - ) - .returns::>() - } - } - }; - #[codec(crate = ::ink::scale)] - #[scale_info(crate = ::ink::scale_info)] - pub struct FungiblesRef { - inner: ::Type, - } - #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)] - const _: () = { - impl ::ink::scale_info::TypeInfo for FungiblesRef { - type Identity = Self; - fn type_info() -> ::ink::scale_info::Type { - ::ink::scale_info::Type::builder() - .path( - ::ink::scale_info::Path::new_with_replace( - "FungiblesRef", - "fungibles::fungibles", - &[], - ), - ) - .type_params(::alloc::vec::Vec::new()) - .composite( - ::ink::scale_info::build::Fields::named() - .field(|f| { - f - .ty::< - ::Type, - >() - .name("inner") - .type_name( - "::Type", - ) - }), - ) - } - } - }; - #[allow(deprecated)] - const _: () = { - #[automatically_derived] - impl ::ink::scale::Decode for FungiblesRef { - fn decode<__CodecInputEdqy: ::ink::scale::Input>( - __codec_input_edqy: &mut __CodecInputEdqy, - ) -> ::core::result::Result { - ::core::result::Result::Ok(FungiblesRef { - inner: { - let __codec_res_edqy = <::Type as ::ink::scale::Decode>::decode( - __codec_input_edqy, - ); - match __codec_res_edqy { - ::core::result::Result::Err(e) => { - return ::core::result::Result::Err( - e.chain("Could not decode `FungiblesRef::inner`"), - ); - } - ::core::result::Result::Ok(__codec_res_edqy) => { - __codec_res_edqy - } - } - }, - }) - } - } - }; - #[allow(deprecated)] - const _: () = { - #[automatically_derived] - impl ::ink::scale::Encode for FungiblesRef { - fn size_hint(&self) -> usize { - ::ink::scale::Encode::size_hint(&&self.inner) - } - fn encode_to< - __CodecOutputEdqy: ::ink::scale::Output + ?::core::marker::Sized, - >(&self, __codec_dest_edqy: &mut __CodecOutputEdqy) { - ::ink::scale::Encode::encode_to(&&self.inner, __codec_dest_edqy) - } - fn encode(&self) -> ::ink::scale::alloc::vec::Vec<::core::primitive::u8> { - ::ink::scale::Encode::encode(&&self.inner) - } - fn using_encoded< - __CodecOutputReturn, - __CodecUsingEncodedCallback: ::core::ops::FnOnce( - &[::core::primitive::u8], - ) -> __CodecOutputReturn, - >(&self, f: __CodecUsingEncodedCallback) -> __CodecOutputReturn { - ::ink::scale::Encode::using_encoded(&&self.inner, f) - } - } - #[automatically_derived] - impl ::ink::scale::EncodeLike for FungiblesRef {} - }; - #[automatically_derived] - impl ::core::fmt::Debug for FungiblesRef { - #[inline] - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - ::core::fmt::Formatter::debug_struct_field1_finish( - f, - "FungiblesRef", - "inner", - &&self.inner, - ) - } - } - #[automatically_derived] - impl ::core::hash::Hash for FungiblesRef { - #[inline] - fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () { - ::core::hash::Hash::hash(&self.inner, state) - } - } - #[automatically_derived] - impl ::core::marker::StructuralPartialEq for FungiblesRef {} - #[automatically_derived] - impl ::core::cmp::PartialEq for FungiblesRef { - #[inline] - fn eq(&self, other: &FungiblesRef) -> bool { - self.inner == other.inner - } - } - #[automatically_derived] - impl ::core::cmp::Eq for FungiblesRef { - #[inline] - #[doc(hidden)] - #[coverage(off)] - fn assert_receiver_is_total_eq(&self) -> () { - let _: ::core::cmp::AssertParamIsEq< - ::Type, - >; - } - } - #[automatically_derived] - impl ::core::clone::Clone for FungiblesRef { - #[inline] - fn clone(&self) -> FungiblesRef { - FungiblesRef { - inner: ::core::clone::Clone::clone(&self.inner), - } - } - } - const _: () = { - impl ::ink::storage::traits::StorageLayout for FungiblesRef { - fn layout( - __key: &::ink::primitives::Key, - ) -> ::ink::metadata::layout::Layout { - ::ink::metadata::layout::Layout::Struct( - ::ink::metadata::layout::StructLayout::new( - "FungiblesRef", - [ - ::ink::metadata::layout::FieldLayout::new( - "inner", - <::Type as ::ink::storage::traits::StorageLayout>::layout( - __key, - ), - ), - ], - ), - ) - } - } - }; - const _: () = { - impl ::ink::env::ContractReference for Fungibles { - type Type = FungiblesRef; - } - impl ::ink::env::call::ConstructorReturnType for Fungibles { - type Output = FungiblesRef; - type Error = (); - fn ok(value: FungiblesRef) -> Self::Output { - value - } - } - impl ::ink::env::call::ConstructorReturnType - for ::core::result::Result - where - E: ::ink::scale::Decode, - { - const IS_RESULT: bool = true; - type Output = ::core::result::Result; - type Error = E; - fn ok(value: FungiblesRef) -> Self::Output { - ::core::result::Result::Ok(value) - } - fn err(err: Self::Error) -> ::core::option::Option { - ::core::option::Option::Some(::core::result::Result::Err(err)) - } - } - impl ::ink::env::ContractEnv for FungiblesRef { - type Env = ::Env; - } - }; - impl FungiblesRef { - #[inline] - #[allow(clippy::type_complexity)] - pub fn new() -> ::ink::env::call::CreateBuilder< - Environment, - Self, - ::ink::env::call::utils::Unset, - ::ink::env::call::utils::Set< - ::ink::env::call::LimitParamsV2< - ::Env, - >, - >, - ::ink::env::call::utils::Unset, - ::ink::env::call::utils::Set< - ::ink::env::call::ExecutionInput< - ::ink::env::call::utils::EmptyArgumentList, - >, - >, - ::ink::env::call::utils::Unset<::ink::env::call::state::Salt>, - ::ink::env::call::utils::Set<::ink::env::call::utils::ReturnType>, - > { - ::ink::env::call::build_create::() - .exec_input( - ::ink::env::call::ExecutionInput::new( - ::ink::env::call::Selector::new([ - 0x9B_u8, - 0xAE_u8, - 0x9D_u8, - 0x5E_u8, - ]), - ), - ) - .returns::() - } - #[inline] - pub fn total_supply(&self, id: AssetId) -> Result { - self.try_total_supply(id) - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "total_supply", - error, - ), - ); - }) - } - #[inline] - pub fn try_total_supply( - &self, - id: AssetId, - ) -> ::ink::MessageResult> { - ::call(self) - .total_supply(id) - .try_invoke() - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "total_supply", - error, - ), - ); - }) - } - #[inline] - pub fn balance_of(&self, id: AssetId, owner: AccountId32) -> Result { - self.try_balance_of(id, owner) - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "balance_of", - error, - ), - ); - }) - } - #[inline] - pub fn try_balance_of( - &self, - id: AssetId, - owner: AccountId32, - ) -> ::ink::MessageResult> { - ::call(self) - .balance_of(id, owner) - .try_invoke() - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "balance_of", - error, - ), - ); - }) - } - #[inline] - pub fn allowance( - &self, - id: AssetId, - owner: AccountId32, - spender: AccountId32, - ) -> Result { - self.try_allowance(id, owner, spender) - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "allowance", - error, - ), - ); - }) - } - #[inline] - pub fn try_allowance( - &self, - id: AssetId, - owner: AccountId32, - spender: AccountId32, - ) -> ::ink::MessageResult> { - ::call(self) - .allowance(id, owner, spender) - .try_invoke() - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "allowance", - error, - ), - ); - }) - } - #[inline] - pub fn asset_exists(&self, id: AssetId) -> Result { - self.try_asset_exists(id) - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "asset_exists", - error, - ), - ); - }) - } - #[inline] - pub fn try_asset_exists( - &self, - id: AssetId, - ) -> ::ink::MessageResult> { - ::call(self) - .asset_exists(id) - .try_invoke() - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "asset_exists", - error, - ), - ); - }) - } - #[inline] - pub fn mint_asset( - &self, - id: u32, - beneficiary: AccountId32, - amount: Balance, - ) -> Result<()> { - self.try_mint_asset(id, beneficiary, amount) - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "mint_asset", - error, - ), - ); - }) - } - #[inline] - pub fn try_mint_asset( - &self, - id: u32, - beneficiary: AccountId32, - amount: Balance, - ) -> ::ink::MessageResult> { - ::call(self) - .mint_asset(id, beneficiary, amount) - .try_invoke() - .unwrap_or_else(|error| { - ::core::panicking::panic_fmt( - format_args!( - "encountered error while calling {0}::{1}: {2:?}", - "Fungibles", - "mint_asset", - error, - ), - ); - }) - } - } - const _: () = { - impl ::ink::codegen::TraitCallBuilder for FungiblesRef { - type Builder = ::Type; - #[inline] - fn call(&self) -> &Self::Builder { - &self.inner - } - #[inline] - fn call_mut(&mut self) -> &mut Self::Builder { - &mut self.inner - } - } - }; - impl ::ink::env::call::FromAccountId for FungiblesRef { - #[inline] - fn from_account_id(account_id: AccountId) -> Self { - Self { - inner: <::Type as ::ink::env::call::FromAccountId< - Environment, - >>::from_account_id(account_id), - } - } - } - impl ::ink::ToAccountId for FungiblesRef { - #[inline] - fn to_account_id(&self) -> AccountId { - <::Type as ::ink::ToAccountId< - Environment, - >>::to_account_id(&self.inner) - } - } - impl ::core::convert::AsRef for FungiblesRef { - fn as_ref(&self) -> &AccountId { - <_ as ::core::convert::AsRef>::as_ref(&self.inner) - } - } - impl ::core::convert::AsMut for FungiblesRef { - fn as_mut(&mut self) -> &mut AccountId { - <_ as ::core::convert::AsMut>::as_mut(&mut self.inner) - } - } - #[cfg(feature = "std")] - #[cfg(not(feature = "ink-as-dependency"))] - const _: () = { - #[no_mangle] - pub fn __ink_generate_metadata() -> ::ink::metadata::InkProject { - let layout = ::ink::metadata::layout::Layout::Root( - ::ink::metadata::layout::RootLayout::new( - <::ink::metadata::layout::LayoutKey as ::core::convert::From< - ::ink::primitives::Key, - >>::from(::KEY), - ::layout( - &::KEY, - ), - ::ink::scale_info::meta_type::(), - ), - ); - ::ink::metadata::layout::ValidateLayout::validate(&layout) - .unwrap_or_else(|error| { - { - ::core::panicking::panic_fmt( - format_args!("metadata ink! generation failed: {0}", error), - ); - } - }); - ::ink::metadata::InkProject::new( - layout, - ::ink::metadata::ContractSpec::new() - .constructors([ - ::ink::metadata::ConstructorSpec::from_label("new") - .selector([0x9B_u8, 0xAE_u8, 0x9D_u8, 0x5E_u8]) - .args([]) - .payable(true) - .default(false) - .returns( - ::ink::metadata::ReturnTypeSpec::new( - if >::IS_RESULT { - ::ink::metadata::TypeSpec::with_name_str::< - ::ink::ConstructorResult< - ::core::result::Result< - (), - >::Error, - >, - >, - >("ink_primitives::ConstructorResult") - } else { - ::ink::metadata::TypeSpec::with_name_str::< - ::ink::ConstructorResult<()>, - >("ink_primitives::ConstructorResult") - }, - ), - ) - .docs([]) - .done(), - ]) - .messages([ - ::ink::metadata::MessageSpec::from_label("total_supply") - .selector([0xDB_u8, 0x63_u8, 0x75_u8, 0xA8_u8]) - .args([ - ::ink::metadata::MessageParamSpec::new("id") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - AssetId, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["AssetId"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ]) - .returns( - ::ink::metadata::ReturnTypeSpec::new( - ::ink::metadata::TypeSpec::with_name_segs::< - ::ink::MessageResult>, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter([ - "ink", - "MessageResult", - ]), - ::core::convert::AsRef::as_ref, - ), - ), - ), - ) - .mutates(false) - .payable(false) - .default(false) - .docs([]) - .done(), - ::ink::metadata::MessageSpec::from_label("balance_of") - .selector([0x0F_u8, 0x75_u8, 0x5A_u8, 0x56_u8]) - .args([ - ::ink::metadata::MessageParamSpec::new("id") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - AssetId, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["AssetId"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ::ink::metadata::MessageParamSpec::new("owner") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - AccountId32, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["AccountId32"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ]) - .returns( - ::ink::metadata::ReturnTypeSpec::new( - ::ink::metadata::TypeSpec::with_name_segs::< - ::ink::MessageResult>, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter([ - "ink", - "MessageResult", - ]), - ::core::convert::AsRef::as_ref, - ), - ), - ), - ) - .mutates(false) - .payable(false) - .default(false) - .docs([]) - .done(), - ::ink::metadata::MessageSpec::from_label("allowance") - .selector([0x6A_u8, 0x00_u8, 0x16_u8, 0x5E_u8]) - .args([ - ::ink::metadata::MessageParamSpec::new("id") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - AssetId, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["AssetId"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ::ink::metadata::MessageParamSpec::new("owner") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - AccountId32, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["AccountId32"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ::ink::metadata::MessageParamSpec::new("spender") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - AccountId32, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["AccountId32"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ]) - .returns( - ::ink::metadata::ReturnTypeSpec::new( - ::ink::metadata::TypeSpec::with_name_segs::< - ::ink::MessageResult>, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter([ - "ink", - "MessageResult", - ]), - ::core::convert::AsRef::as_ref, - ), - ), - ), - ) - .mutates(false) - .payable(false) - .default(false) - .docs([]) - .done(), - ::ink::metadata::MessageSpec::from_label("asset_exists") - .selector([0xAA_u8, 0x6B_u8, 0x65_u8, 0xDB_u8]) - .args([ - ::ink::metadata::MessageParamSpec::new("id") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - AssetId, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["AssetId"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ]) - .returns( - ::ink::metadata::ReturnTypeSpec::new( - ::ink::metadata::TypeSpec::with_name_segs::< - ::ink::MessageResult>, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter([ - "ink", - "MessageResult", - ]), - ::core::convert::AsRef::as_ref, - ), - ), - ), - ) - .mutates(false) - .payable(false) - .default(false) - .docs([]) - .done(), - ::ink::metadata::MessageSpec::from_label("mint_asset") - .selector([0x1F_u8, 0x8E_u8, 0x8E_u8, 0x22_u8]) - .args([ - ::ink::metadata::MessageParamSpec::new("id") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - u32, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["u32"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ::ink::metadata::MessageParamSpec::new("beneficiary") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - AccountId32, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["AccountId32"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ::ink::metadata::MessageParamSpec::new("amount") - .of_type( - ::ink::metadata::TypeSpec::with_name_segs::< - Balance, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["Balance"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .done(), - ]) - .returns( - ::ink::metadata::ReturnTypeSpec::new( - ::ink::metadata::TypeSpec::with_name_segs::< - ::ink::MessageResult>, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter([ - "ink", - "MessageResult", - ]), - ::core::convert::AsRef::as_ref, - ), - ), - ), - ) - .mutates(false) - .payable(false) - .default(false) - .docs([]) - .done(), - ]) - .collect_events() - .docs([]) - .lang_error( - ::ink::metadata::TypeSpec::with_name_segs::< - ::ink::LangError, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["ink", "LangError"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .environment( - ::ink::metadata::EnvironmentSpec::new() - .account_id( - ::ink::metadata::TypeSpec::with_name_segs::< - AccountId, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["AccountId"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .balance( - ::ink::metadata::TypeSpec::with_name_segs::< - Balance, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["Balance"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .hash( - ::ink::metadata::TypeSpec::with_name_segs::< - Hash, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["Hash"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .timestamp( - ::ink::metadata::TypeSpec::with_name_segs::< - Timestamp, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["Timestamp"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .block_number( - ::ink::metadata::TypeSpec::with_name_segs::< - BlockNumber, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["BlockNumber"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .chain_extension( - ::ink::metadata::TypeSpec::with_name_segs::< - ChainExtension, - _, - >( - ::core::iter::Iterator::map( - ::core::iter::IntoIterator::into_iter(["ChainExtension"]), - ::core::convert::AsRef::as_ref, - ), - ), - ) - .max_event_topics(MAX_EVENT_TOPICS) - .static_buffer_size(::ink::env::BUFFER_SIZE) - .done(), - ) - .done(), - ) - } - }; - use super::*; -} diff --git a/pop-api/examples/fungibles/lib.rs b/pop-api/examples/fungibles/lib.rs index 68e43865..59040590 100755 --- a/pop-api/examples/fungibles/lib.rs +++ b/pop-api/examples/fungibles/lib.rs @@ -7,61 +7,12 @@ /// use ink::prelude::vec::Vec; use pop_api::{ - assets::fungibles::*, + assets::use_cases::fungibles as api, + error::PopApiError, primitives::{AccountId as AccountId32, AssetId}, }; -#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] -#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] -pub enum ContractError { - /// The asset is not live; either frozen or being destroyed. - AssetNotLive, - /// The amount to mint is less than the existential deposit. - BelowMinimum, - /// Unspecified dispatch error, providing the index and its error index (if none `0`). - DispatchError { index: u8, error: u8 }, - /// Not enough allowance to fulfill a request is available. - InsufficientAllowance, - /// Not enough balance to fulfill a request is available. - InsufficientBalance, - /// The asset ID is already taken. - InUse, - /// Minimum balance should be non-zero. - MinBalanceZero, - /// Unspecified pallet error, providing pallet index and error index. - ModuleError { pallet: u8, error: u16 }, - /// The account to alter does not exist. - NoAccount, - /// The signing account has no permission to do the operation. - NoPermission, - /// The given asset ID is unknown. - Unknown, -} - -impl From for ContractError { - fn from(error: FungiblesError) -> Self { - match error { - FungiblesError::AssetNotLive => ContractError::AssetNotLive, - FungiblesError::BelowMinimum => ContractError::BelowMinimum, - FungiblesError::DispatchError { index, error } => { - ContractError::DispatchError { index, error } - }, - FungiblesError::InsufficientAllowance => ContractError::InsufficientAllowance, - FungiblesError::InsufficientBalance => ContractError::InsufficientBalance, - FungiblesError::InUse => ContractError::InUse, - FungiblesError::MinBalanceZero => ContractError::MinBalanceZero, - FungiblesError::ModuleError { pallet, error } => { - ContractError::ModuleError { pallet, error } - }, - FungiblesError::NoAccount => ContractError::NoAccount, - FungiblesError::NoPermission => ContractError::NoPermission, - FungiblesError::Unknown => ContractError::Unknown, - } - } -} - -/// The fungibles result type. -pub type Result = core::result::Result; +pub type Result = core::result::Result; #[ink::contract(env = pop_api::Environment)] mod fungibles { @@ -74,7 +25,7 @@ mod fungibles { impl Fungibles { #[ink(constructor, payable)] pub fn new() -> Self { - ink::env::debug_println!("PopApiAssetsExample::new"); + ink::env::debug_println!("PopApiFungiblesExample::new"); Default::default() } @@ -90,12 +41,12 @@ mod fungibles { #[ink(message)] pub fn total_supply(&self, id: AssetId) -> Result { - total_supply(id).map_err(From::from) + api::total_supply(id) } #[ink(message)] pub fn balance_of(&self, id: AssetId, owner: AccountId32) -> Result { - balance_of(id, owner).map_err(From::from) + api::balance_of(id, owner) } #[ink(message)] @@ -105,21 +56,21 @@ mod fungibles { owner: AccountId32, spender: AccountId32, ) -> Result { - allowance(id, owner, spender).map_err(From::from) + api::allowance(id, owner, spender) } #[ink(message)] pub fn transfer(&self, id: AssetId, to: AccountId32, value: Balance) -> Result<()> { ink::env::debug_println!( - "PopApiAssetsExample::transfer: id: {:?}, to: {:?} value: {:?}", + "PopApiFungiblesExample::transfer: id: {:?}, to: {:?} value: {:?}", id, to, value, ); - let result = transfer(id, to, value); + let result = api::transfer(id, to, value); ink::env::debug_println!("Result: {:?}", result); - result.map_err(From::from) + result } #[ink(message)] @@ -129,20 +80,21 @@ mod fungibles { from: Option, to: Option, value: Balance, - // Size needs to be known at compile time or ink's `Vec` + // In the standard a `[u8]`, but the size needs to be known at compile time ink's `Vec` + // has to be used. data: Vec, ) -> Result<()> { ink::env::debug_println!( - "PopApiAssetsExample::transfer_from: id: {:?}, from: {:?}, to: {:?} value: {:?}", + "PopApiFungiblesExample::transfer_from: id: {:?}, from: {:?}, to: {:?} value: {:?}", id, from, to, value, ); - let result = transfer_from(id, from, to, value, &data); + let result = api::transfer_from(id, from, to, value, &data); ink::env::debug_println!("Result: {:?}", result); - result.map_err(From::from) + result } /// 2. PSP-22 Metadata Interface: @@ -162,14 +114,14 @@ mod fungibles { #[ink(message)] pub fn create(&self, id: AssetId, admin: AccountId32, min_balance: Balance) -> Result<()> { ink::env::debug_println!( - "PopApiAssetsExample::create: id: {:?} admin: {:?} min_balance: {:?}", + "PopApiFungiblesExample::create: id: {:?} admin: {:?} min_balance: {:?}", id, admin, min_balance, ); - let result = create(id, admin, min_balance); + let result = api::create(id, admin, min_balance); ink::env::debug_println!("Result: {:?}", result); - result.map_err(From::from) + result } #[ink(message)] @@ -181,20 +133,20 @@ mod fungibles { decimals: u8, ) -> Result<()> { ink::env::debug_println!( - "PopApiAssetsExample::set_metadata: id: {:?} name: {:?} symbol: {:?}, decimals: {:?}", + "PopApiFungiblesExample::set_metadata: id: {:?} name: {:?} symbol: {:?}, decimals: {:?}", id, name, symbol, decimals, ); - let result = set_metadata(id, name, symbol, decimals); + let result = api::set_metadata(id, name, symbol, decimals); ink::env::debug_println!("Result: {:?}", result); - result.map_err(From::from) + result } #[ink(message)] pub fn asset_exists(&self, id: AssetId) -> Result { - asset_exists(id).map_err(From::from) + api::asset_exists(id) } } @@ -204,7 +156,7 @@ mod fungibles { #[ink::test] fn default_works() { - PopApiAssetsExample::new(); + PopApiFungiblesExample::new(); } } } diff --git a/pop-api/src/error.rs b/pop-api/src/error.rs new file mode 100644 index 00000000..92da4045 --- /dev/null +++ b/pop-api/src/error.rs @@ -0,0 +1,255 @@ +use crate::assets::use_cases::fungibles::{convert_to_fungibles_error, FungiblesError}; +use ink::env::chain_extension::FromStatusCode; +use scale::{Decode, Encode}; +use PopApiError::*; + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encode, Decode)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +#[repr(u8)] +pub enum PopApiError { + /// Some unknown error occurred. Go to the Pop API docs section `Pop API error`. + Other { + // Index within the `DispatchError` + dispatch_error_index: u8, + // Index within the `DispatchError` variant. + error_index: u8, + // Index for further nesting, e.g. pallet error. + error: u8, + } = 0, + /// Failed to lookup some data. + CannotLookup = 1, + /// A bad origin. + BadOrigin = 2, + /// A custom error in a module. + Module { + index: u8, + error: u8, + } = 3, + /// At least one consumer is remaining so the account cannot be destroyed. + ConsumerRemaining = 4, + /// There are no providers so the account cannot be created. + NoProviders = 5, + /// There are too many consumers so the account cannot be created. + TooManyConsumers = 6, + /// An error to do with tokens. + Token(TokenError) = 7, + /// An arithmetic error. + Arithmetic(ArithmeticError) = 8, + /// The number of transactional layers has been reached, or we are not in a transactional + /// layer. + Transactional(TransactionalError) = 9, + /// Resources exhausted, e.g. attempt to read/write data which is too large to manipulate. + Exhausted = 10, + /// The state is corrupt; this is generally not going to fix itself. + Corruption = 11, + /// Some resource (e.g. a preimage) is unavailable right now. This might fix itself later. + Unavailable = 12, + /// Root origin is not allowed. + RootNotAllowed = 13, + // TODO: make generic and add docs. + UseCaseError(FungiblesError) = 254, + DecodingFailed = 255, +} + +impl FromStatusCode for PopApiError { + fn from_status_code(status_code: u32) -> core::result::Result<(), Self> { + match status_code { + 0 => Ok(()), + _ => Err(convert_to_pop_api_error(status_code)), + } + } +} + +// `pub` because it is used in `runtime/devnet/src/extensions/tests/mod.rs`'s test: +// `dispatch_error_to_status_code_to_pop_api_error_works` +// +// This function converts a given `status_code` (u32) into a `PopApiError`. First it encodes the +// status code into a 4-byte array and checks for unknown nested errors. If decoding into +// `PopApiError` fails (e.g. a breaking change in the `DispatchError`), it handles the error by +// converting it to the `Other` variant by shifting each byte one position forward (the last byte is +// not used for anything)and setting the first byte to 0. If decoding succeeds, it checks if the +// error is of the `Module` variant and performs any necessary conversion based on the use case. +pub fn convert_to_pop_api_error(status_code: u32) -> PopApiError { + let mut encoded: [u8; 4] = + status_code.encode().try_into().expect("qid u32 always encodes to 4 bytes"); + encoded = check_for_unknown_nesting(encoded); + let error = match PopApiError::decode(&mut &encoded[..]) { + Err(_) => { + encoded[3] = encoded[2]; + encoded[2] = encoded[1]; + encoded[1] = encoded[0]; + encoded[0] = 0; + PopApiError::decode(&mut &encoded[..]).unwrap().into() + }, + Ok(error) => { + if let crate::PopApiError::Module { index, error } = error { + // TODO: make generic. + convert_to_fungibles_error(index, error) + } else { + error + } + }, + }; + ink::env::debug_println!("PopApiError: {:?}", error); + error +} + +// If a unknown nested variant of the `DispatchError` is detected meaning any of the subsequent +// bytes are non-zero (e.g. breaking change in the DispatchError), the error needs to be converted +// into `PopApiError::Other`'s encoded value. This conversion is done by shifting the bytes one +// position forward (the last byte is discarded as it is not being used) and replacing the first +// byte with the `Other` encoded value (0u8). This ensures that the error is correctly categorized +// as an `Other` variant. +fn check_for_unknown_nesting(encoded_error: [u8; 4]) -> [u8; 4] { + if non_nested_pop_api_errors().contains(&encoded_error[0]) + && encoded_error[1..].iter().any(|x| *x != 0u8) + { + [0u8, encoded_error[0], encoded_error[1], encoded_error[2]] + } else if singular_nested_pop_api_errors().contains(&encoded_error[0]) + && encoded_error[2..].iter().any(|x| *x != 0u8) + { + [0u8, encoded_error[0], encoded_error[1], encoded_error[2]] + } else { + encoded_error + } +} + +impl From for PopApiError { + fn from(_: scale::Error) -> Self { + DecodingFailed + } +} +#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +pub enum TokenError { + /// Funds are unavailable. + FundsUnavailable, + /// Some part of the balance gives the only provider reference to the account and thus cannot + /// be (re)moved. + OnlyProvider, + /// Account cannot exist with the funds that would be given. + BelowMinimum, + /// Account cannot be created. + CannotCreate, + /// The asset in question is unknown. + UnknownAsset, + /// Funds exist but are frozen. + Frozen, + /// Operation is not supported by the asset. + Unsupported, + /// Account cannot be created for a held balance. + CannotCreateHold, + /// Withdrawal would cause unwanted loss of account. + NotExpendable, + /// Account cannot receive the assets. + Blocked, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +pub enum ArithmeticError { + /// Underflow. + Underflow, + /// Overflow. + Overflow, + /// Division by zero. + DivisionByZero, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +pub enum TransactionalError { + /// Too many transactional layers have been spawned. + LimitReached, + /// A transactional layer was expected, but does not exist. + NoLayer, +} + +fn singular_nested_pop_api_errors() -> [u8; 3] { + const TOKEN_ERROR: u8 = 7; + const ARITHMETIC_ERROR: u8 = 8; + const TRANSACTION_ERROR: u8 = 9; + [TOKEN_ERROR, ARITHMETIC_ERROR, TRANSACTION_ERROR] +} + +fn non_nested_pop_api_errors() -> [u8; 9] { + const CANNOT_LOOKUP: u8 = 1; + const BAD_ORIGIN: u8 = 2; + const CONSUMER_REMAINING: u8 = 4; + const NO_PROVIDERS: u8 = 5; + const TOO_MANY_CONSUMERS: u8 = 6; + const EXHAUSTED: u8 = 10; + const CORRUPTION: u8 = 11; + const UNAVAILABLE: u8 = 12; + const ROOT_NOT_ALLOWED: u8 = 13; + [ + CANNOT_LOOKUP, + BAD_ORIGIN, + CONSUMER_REMAINING, + NO_PROVIDERS, + TOO_MANY_CONSUMERS, + EXHAUSTED, + CORRUPTION, + UNAVAILABLE, + ROOT_NOT_ALLOWED, + ] +} + +#[test] +fn u32_always_encodes_to_4_bytes() { + assert_eq!(0u32.encode().len(), 4); + assert_eq!(u32::MAX.encode().len(), 4); +} + +// If decoding failed the encoded value is converted to the `PopApiError::Other`. This handles +// unknown errors coming from the runtime. This could happen if a contract is not upgraded to the +// latest Pop API version. +#[test] +fn test_non_existing_pop_api_errors() { + let encoded_error = [7u8, 100u8, 0u8, 0u8]; + let status_code = u32::decode(&mut &encoded_error[..]).unwrap(); + let pop_api_error = ::from_status_code(status_code); + assert_eq!(Err(Other { dispatch_error_index: 7, error_index: 100, error: 0 }), pop_api_error); +} + +// If the encoded value indicates a nested PopApiError which is not handled by the Pop API version, +// the encoded value is converted into `PopApiError::Other`. +#[test] +fn check_for_unknown_nested_pop_api_errors_works() { + for &error_code in &non_nested_pop_api_errors() { + let encoded_error = [error_code, 1, 2, 3]; + let result = check_for_unknown_nesting(encoded_error); + let decoded = PopApiError::decode(&mut &result[..]).unwrap(); + + assert_eq!( + decoded, + Other { dispatch_error_index: error_code, error_index: 1, error: 2 }, + "Failed for error code: {}", + error_code + ); + } + for &error_code in &singular_nested_pop_api_errors() { + let encoded_error = [error_code, 1, 2, 3]; + let result = check_for_unknown_nesting(encoded_error); + let decoded = PopApiError::decode(&mut &result[..]).unwrap(); + + assert_eq!( + decoded, + Other { dispatch_error_index: error_code, error_index: 1, error: 2 }, + "Failed for error code: {}", + error_code + ); + } +} + +// This test ensures that a non-zero value for unused bytes does not interfere with the correct +// decoding of the error. It verifies that even with an additional byte, the errors are correctly +// decoded and represented in its correct variant. +#[test] +fn extra_byte_does_not_mess_up_decoding() { + // Module error + let encoded_error = [3u8, 4u8, 5u8, 6u8]; + let status_code = u32::decode(&mut &encoded_error[..]).unwrap(); + let pop_api_error = ::from_status_code(status_code); + assert_eq!(Err(Module { index: 4, error: 5 }), pop_api_error); +} diff --git a/pop-api/src/lib.rs b/pop-api/src/lib.rs index be448890..a785aebe 100644 --- a/pop-api/src/lib.rs +++ b/pop-api/src/lib.rs @@ -1,19 +1,19 @@ #![cfg_attr(not(feature = "std"), no_std, no_main)] -use core::convert::TryInto; +use crate::error::PopApiError; use ink::{prelude::vec::Vec, ChainExtensionInstance}; use primitives::{cross_chain::*, storage_keys::*, AccountId as AccountId32}; +use scale::Encode; pub use sp_runtime::{BoundedVec, MultiAddress, MultiSignature}; use v0::RuntimeCall; -pub use v0::{ - assets, balances, contracts, cross_chain, dispatch_error, nfts, relay_chain_block_number, state, -}; +pub use v0::{assets, balances, cross_chain, nfts, relay_chain_block_number, state}; +pub mod error; pub mod primitives; pub mod v0; -// type AccountId = ::AccountId; type AccountId = AccountId32; +// TODO: do the same as above and check expanded code. type Balance = ::Balance; type BlockNumber = ::BlockNumber; type StringLimit = u32; @@ -21,54 +21,6 @@ type MaxTips = u32; pub type Result = core::result::Result; -#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] -#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] -pub enum PopApiError { - Assets(assets::fungibles::AssetsError), - Balances(balances::BalancesError), - Contracts(contracts::Error), - DecodingFailed, - Nfts(nfts::Error), - SystemCallFiltered, - TokenError(dispatch_error::TokenError), - UnknownModuleStatusCode(u32), - UnknownDispatchStatusCode(u32), - Xcm(cross_chain::Error), -} - -impl ink::env::chain_extension::FromStatusCode for PopApiError { - fn from_status_code(status_code: u32) -> core::result::Result<(), Self> { - use crate::PopApiError::{ - Assets, Balances, Contracts, Nfts, TokenError, UnknownDispatchStatusCode, - UnknownModuleStatusCode, - }; - - match status_code { - 0 => Ok(()), - 3_000_000..=3_999_999 => { - let status_code = status_code - 3_000_000; - match status_code { - // CallFiltered originates from `frame_system` with pallet-index 0. The CallFiltered error is at index 5 - 5 => Err(PopApiError::SystemCallFiltered), - 10_000..=10_999 => Err(Balances((status_code - 10_000).try_into()?)), - 40_000..=40_999 => Err(Contracts((status_code - 40_000).try_into()?)), - 50_000..=50_999 => Err(Nfts((status_code - 50_000).try_into()?)), - 52_000..=52_999 => Err(Assets((status_code - 52_000).try_into()?)), - _ => Err(UnknownModuleStatusCode(status_code)), - } - }, - 7_000_000..=7_999_999 => Err(TokenError((status_code - 7_000_000).try_into()?)), - _ => Err(UnknownDispatchStatusCode(status_code)), - } - } -} - -impl From for PopApiError { - fn from(_: scale::Error) -> Self { - panic!("encountered unexpected invalid SCALE encoding") - } -} - #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub enum Environment {} diff --git a/pop-api/src/v0/assets/fungibles.rs b/pop-api/src/v0/assets/fungibles.rs deleted file mode 100644 index df9033c7..00000000 --- a/pop-api/src/v0/assets/fungibles.rs +++ /dev/null @@ -1,610 +0,0 @@ -use crate::{ - balances::BalancesError, AccountId, Balance, PopApiError::UnknownModuleStatusCode, RuntimeCall, - *, -}; -use ink::prelude::vec::Vec; -use primitives::AssetId; -use scale::{Compact, Encode}; - -type Result = core::result::Result; - -/// Local Fungibles: -/// 1. PSP-22 Interface -/// 2. PSP-22 Metadata Interface -/// 3. Asset Management - -/// 1. PSP-22 Interface: -/// - total_supply -/// - balance_of -/// - allowance -/// - transfer -/// - transfer_from -/// - approve -/// - increase_allowance -/// - decrease_allowance - -/// Returns the total token supply for a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// The total supply of the token, or an error if the operation fails. -pub fn total_supply(id: AssetId) -> Result { - Ok(state::read(RuntimeStateKeys::Assets(AssetsKeys::TotalSupply(id)))?) -} - -/// Returns the account balance for the specified `owner` for a given asset ID. Returns `0` if -/// the account is non-existent. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// * `owner` - The account whose balance is being queried. -/// -/// # Returns -/// The balance of the specified account, or an error if the operation fails. -pub fn balance_of(id: AssetId, owner: AccountId) -> Result { - Ok(state::read(RuntimeStateKeys::Assets(AssetsKeys::BalanceOf(id, owner)))?) -} - -/// Returns the amount which `spender` is still allowed to withdraw from `owner` for a given -/// asset ID. Returns `0` if no allowance has been set. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// * `owner` - The account that owns the tokens. -/// * `spender` - The account that is allowed to spend the tokens. -/// -/// # Returns -/// The remaining allowance, or an error if the operation fails. -pub fn allowance(id: AssetId, owner: AccountId, spender: AccountId) -> Result { - Ok(state::read(RuntimeStateKeys::Assets(AssetsKeys::Allowance(id, owner, spender)))?) -} - -/// Transfers `value` amount of tokens from the caller's account to account `to`, with additional -/// `data` in unspecified format. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// * `to` - The recipient account. -/// * `value` - The number of tokens to transfer. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the transfer fails. -pub fn transfer( - id: AssetId, - to: impl Into>, - value: Balance, -) -> Result<()> { - // TODO: transfer or transfer_keep_alive - // Ok(dispatch(RuntimeCall::Assets(AssetsCall::Transfer { - // id: id.into(), - // target: target.into(), - // amount: Compact(amount), - // }))?) - Ok(dispatch(RuntimeCall::Assets(AssetsCall::TransferKeepAlive { - id: id.into(), - target: to.into(), - amount: Compact(value), - }))?) -} - -/// Transfers `value` tokens on behalf of `from` to account `to` with additional `data` -/// in unspecified format. If `from` is equal to `None`, tokens will be minted to account `to`. If -/// `to` is equal to `None`, tokens will be burned from account `from`. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// * `from` - The account from which the tokens are transferred. -/// * `to` - The recipient account. -/// * `value` - The number of tokens to transfer. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the transfer fails. -pub fn transfer_from( - id: AssetId, - from: Option>>, - to: Option>>, - value: Balance, - _data: &[u8], -) -> Result<()> { - match (from, to) { - (None, Some(to)) => mint(id, to, value), - // (Some(from), None) => burn(id, from, value), - (Some(from), Some(to)) => { - Ok(dispatch(RuntimeCall::Assets(AssetsCall::TransferApproved { - id: id.into(), - owner: from.into(), - destination: to.into(), - amount: Compact(value), - }))?) - }, - _ => Ok(()), - } -} - -/// Approves an account to spend a specified number of tokens on behalf of the caller. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// * `spender` - The account that is allowed to spend the tokens. -/// * `value` - The number of tokens to approve. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the approval fails. -// #[allow(unused_variables)] -// fn approve(id: AssetId, spender: AccountId, value: Balance) -> Result<()> { -// todo!() -// // TODO: read allowance and increase or decrease. -// // Ok(dispatch(RuntimeCall::Assets(AssetsCall::ApproveTransfer { -// // id: id.into(), -// // delegate: spender.into(), -// // amount: Compact(value), -// // }))?) -// } - -/// Increases the allowance of a spender. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// * `spender` - The account that is allowed to spend the tokens. -/// * `value` - The number of tokens to increase the allowance by. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the operation fails. -// fn increase_allowance(id: AssetId, spender: AccountId, value: Balance) -> Result<()> { -// Ok(dispatch(RuntimeCall::Assets(AssetsCall::ApproveTransfer { -// id: id.into(), -// delegate: spender.into(), -// amount: Compact(value), -// }))?) -// } - -/// Decreases the allowance of a spender. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// * `spender` - The account that is allowed to spend the tokens. -/// * `value` - The number of tokens to decrease the allowance by. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the operation fails. -// #[allow(unused_variables)] -// fn decrease_allowance(id: AssetId, spender: AccountId, value: Balance) -> Result<()> { -// todo!() -// // TODO: cancel_approval + approve_transfer -// // Ok(dispatch(RuntimeCall::Assets(AssetsCall::CancelApproval { -// // id: id.into(), -// // delegate: delegate.into(), -// // }))?) -// // Ok(dispatch(RuntimeCall::Assets(AssetsCall::ApproveTransfer { -// // id: id.into(), -// // delegate: spender.into(), -// // amount: Compact(value), -// // }))?) -// } - -/// 2. PSP-22 Metadata Interface: -/// - token_name -/// - token_symbol -/// - token_decimals - -/// Returns the token name for a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// The name of the token as a byte vector, or an error if the operation fails. -// #[allow(unused_variables)] -// pub fn token_name(id: AssetId) -> Result>> { -// todo!() -// // Ok(state::read(RuntimeStateKeys::Assets(AssetsKeys::TokenName(id)))?) -// } - -/// Returns the token symbol for a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// The symbol of the token as a byte vector, or an error if the operation fails. -// #[allow(unused_variables)] -// fn token_symbol(id: AssetId) -> Result>> { -// todo!() -// } - -/// Returns the token decimals for a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// The number of decimals of the token as a byte vector, or an error if the operation fails. -// #[allow(unused_variables)] -// fn token_decimals(id: AssetId) -> Result>> { -// todo!() -// } - -/// 3. Asset Management: -/// - create -/// - start_destroy -/// - destroy_accounts -/// - destroy_approvals -/// - finish_destroy -/// - set_metadata -/// - clear_metadata - -/// Create a new token with a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// * `admin` - The account that will administer the asset. -/// * `min_balance` - The minimum balance required for accounts holding this asset. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the creation fails. -pub fn create( - id: AssetId, - admin: impl Into>, - min_balance: Balance, -) -> Result<()> { - Ok(dispatch(RuntimeCall::Assets(AssetsCall::Create { - id: id.into(), - admin: admin.into(), - min_balance, - }))?) -} - -/// Start the process of destroying a token with a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the operation fails. -// fn start_destroy(id: AssetId) -> Result<()> { -// Ok(dispatch(RuntimeCall::Assets(AssetsCall::StartDestroy { -// id: id.into(), -// }))?) -// } - -/// Destroy all accounts associated with a token with a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the operation fails. -// fn destroy_accounts(id: AssetId) -> Result<()> { -// Ok(dispatch(RuntimeCall::Assets(AssetsCall::DestroyAccounts { -// id: id.into(), -// }))?) -// } - -/// Destroy all approvals associated with a token with a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the operation fails. -// fn destroy_approvals(id: AssetId) -> Result<()> { -// Ok(dispatch(RuntimeCall::Assets(AssetsCall::DestroyApprovals { -// id: id.into(), -// }))?) -// } - -/// Complete the process of destroying a token with a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the operation fails. -// fn finish_destroy(id: AssetId) -> Result<()> { -// Ok(dispatch(RuntimeCall::Assets(AssetsCall::FinishDestroy { -// id: id.into(), -// }))?) -// } - -/// Set the metadata for a token with a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the operation fails. -pub fn set_metadata(id: AssetId, name: Vec, symbol: Vec, decimals: u8) -> Result<()> { - Ok(dispatch(RuntimeCall::Assets(AssetsCall::SetMetadata { - id: id.into(), - name, - symbol, - decimals, - }))?) -} - -/// Clear the metadata for a token with a given asset ID. -/// -/// # Arguments -/// * `id` - The ID of the asset. -/// -/// # Returns -/// Returns `Ok(())` if successful, or an error if the operation fails. -// fn clear_metadata(id: AssetId) -> Result<()> { -// Ok(dispatch(RuntimeCall::Assets(AssetsCall::ClearMetadata { -// id: id.into(), -// }))?) -// } - -pub fn asset_exists(id: AssetId) -> Result { - Ok(state::read(RuntimeStateKeys::Assets(AssetsKeys::AssetExists(id)))?) -} - -/// Mint assets of a particular class. -fn mint( - id: AssetId, - beneficiary: impl Into>, - amount: Balance, -) -> Result<()> { - Ok(dispatch(RuntimeCall::Assets(AssetsCall::Mint { - id: id.into(), - beneficiary: beneficiary.into(), - amount: Compact(amount), - }))?) -} - -// Parameters to extrinsics representing an asset id (`AssetIdParameter`) and a balance amount -// (`Balance`) are expected to be compact encoded. The pop api handles that for the developer. -// https://substrate.stackexchange.com/questions/1873/what-is-the-meaning-of-palletcompact-in-pallet-development -// -// Asset id that is compact encoded. -type AssetIdParameter = Compact; -// Balance amount that is compact encoded. -type BalanceParameter = Compact; - -#[allow(warnings, unused)] -#[derive(Encode)] -pub(crate) enum AssetsCall { - #[codec(index = 0)] - Create { id: AssetIdParameter, admin: MultiAddress, min_balance: Balance }, - #[codec(index = 2)] - StartDestroy { id: AssetIdParameter }, - #[codec(index = 3)] - DestroyAccounts { id: AssetIdParameter }, - #[codec(index = 4)] - DestroyApprovals { id: AssetIdParameter }, - #[codec(index = 5)] - FinishDestroy { id: AssetIdParameter }, - #[codec(index = 6)] - Mint { - id: AssetIdParameter, - beneficiary: MultiAddress, - amount: BalanceParameter, - }, - #[codec(index = 7)] - Burn { id: AssetIdParameter, who: MultiAddress, amount: BalanceParameter }, - // TODO: ED or not - // #[codec(index = 8)] - // Transfer { id: AssetIdParameter, target: MultiAddress, amount: BalanceParameter }, - #[codec(index = 9)] - TransferKeepAlive { - id: AssetIdParameter, - target: MultiAddress, - amount: BalanceParameter, - }, - #[codec(index = 17)] - SetMetadata { id: AssetIdParameter, name: Vec, symbol: Vec, decimals: u8 }, - #[codec(index = 18)] - ClearMetadata { id: AssetIdParameter }, - #[codec(index = 22)] - ApproveTransfer { - id: AssetIdParameter, - delegate: MultiAddress, - amount: BalanceParameter, - }, - #[codec(index = 23)] - CancelApproval { id: AssetIdParameter, delegate: MultiAddress }, - #[codec(index = 25)] - TransferApproved { - id: AssetIdParameter, - owner: MultiAddress, - destination: MultiAddress, - amount: BalanceParameter, - }, -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encode, scale::Decode)] -#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] -pub(crate) enum AssetsError { - /// Account balance must be greater than or equal to the transfer amount. - BalanceLow, - /// The account to alter does not exist. - NoAccount, - /// The signing account has no permission to do the operation. - NoPermission, - /// The given asset ID is unknown. - Unknown, - /// The origin account is frozen. - Frozen, - /// The asset ID is already taken. - InUse, - /// Invalid witness data given. - BadWitness, - /// Minimum balance should be non-zero. - MinBalanceZero, - /// Unable to increment the consumer reference counters on the account. Either no provider - /// reference exists to allow a non-zero balance of a non-self-sufficient asset, or one - /// fewer then the maximum number of consumers has been reached. - UnavailableConsumer, - /// Invalid metadata given. - BadMetadata, - /// No approval exists that would allow the transfer. - Unapproved, - /// The source account would not survive the transfer and it needs to stay alive. - WouldDie, - /// The asset-account already exists. - AlreadyExists, - /// The asset-account doesn't have an associated deposit. - NoDeposit, - /// The operation would result in funds being burned. - WouldBurn, - /// The asset is a live asset and is actively being used. Usually emit for operations such - /// as `start_destroy` which require the asset to be in a destroying state. - LiveAsset, - /// The asset is not live, and likely being destroyed. - AssetNotLive, - /// The asset status is not the expected status. - IncorrectStatus, - /// The asset should be frozen before the given operation. - NotFrozen, - /// Callback action resulted in error - CallbackFailed, -} - -impl From for AssetsError { - fn from(error: PopApiError) -> Self { - match error { - PopApiError::Assets(e) => e, - _ => panic!("Expected AssetsError"), - } - } -} - -impl TryFrom for AssetsError { - type Error = PopApiError; - - fn try_from(status_code: u32) -> core::result::Result { - use AssetsError::*; - match status_code { - 0 => Ok(BalanceLow), - 1 => Ok(NoAccount), - 2 => Ok(NoPermission), - 3 => Ok(Unknown), - 4 => Ok(Frozen), - 5 => Ok(InUse), - 6 => Ok(BadWitness), - 7 => Ok(MinBalanceZero), - 8 => Ok(UnavailableConsumer), - 9 => Ok(BadMetadata), - 10 => Ok(Unapproved), - 11 => Ok(WouldDie), - 12 => Ok(AlreadyExists), - 13 => Ok(NoDeposit), - 14 => Ok(WouldBurn), - 15 => Ok(LiveAsset), - 16 => Ok(AssetNotLive), - 17 => Ok(IncorrectStatus), - 18 => Ok(NotFrozen), - _ => Err(UnknownModuleStatusCode(status_code)), - } - } -} - -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encode, scale::Decode)] -#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] -pub enum FungiblesError { - /// The asset is not live; either frozen or being destroyed. - AssetNotLive, - /// The amount to mint is less than the existential deposit. - BelowMinimum, - /// Unspecified dispatch error, providing the index and its error index (if none `0`). - DispatchError { index: u8, error: u8 }, - /// Not enough allowance to fulfill a request is available. - InsufficientAllowance, - /// Not enough balance to fulfill a request is available. - InsufficientBalance, - /// The asset ID is already taken. - InUse, - /// Minimum balance should be non-zero. - MinBalanceZero, - /// Unspecified pallet error, providing pallet index and error index. - ModuleError { pallet: u8, error: u16 }, - /// The account to alter does not exist. - NoAccount, - /// The signing account has no permission to do the operation. - NoPermission, - /// The given asset ID is unknown. - Unknown, -} - -impl From for FungiblesError { - fn from(error: BalancesError) -> Self { - match error { - // TODO: this insufficient balance is different than the assets variant. This one is - // for a deposit of creating an asset, the latter is for transfer tokens. - BalancesError::InsufficientBalance => FungiblesError::InsufficientBalance, - _ => FungiblesError::ModuleError { pallet: 40, error: error as u16 }, - } - } -} - -impl From for FungiblesError { - fn from(error: dispatch_error::TokenError) -> Self { - match error { - dispatch_error::TokenError::BelowMinimum => FungiblesError::BelowMinimum, - // ED is not respected. - dispatch_error::TokenError::OnlyProvider => FungiblesError::InsufficientBalance, - dispatch_error::TokenError::UnknownAsset => FungiblesError::Unknown, - _ => FungiblesError::DispatchError { index: 7, error: error as u8 }, - } - } -} - -impl From for FungiblesError { - fn from(error: AssetsError) -> Self { - match error { - AssetsError::AssetNotLive => FungiblesError::AssetNotLive, - AssetsError::BalanceLow => FungiblesError::InsufficientBalance, - AssetsError::Unapproved => FungiblesError::InsufficientAllowance, - AssetsError::InUse => FungiblesError::InUse, - AssetsError::MinBalanceZero => FungiblesError::MinBalanceZero, - AssetsError::NoPermission => FungiblesError::NoPermission, - AssetsError::NoAccount => FungiblesError::NoAccount, - AssetsError::Unknown => FungiblesError::Unknown, - _ => FungiblesError::ModuleError { pallet: 52, error: error as u16 }, - } - } -} - -impl From for FungiblesError { - fn from(error: PopApiError) -> Self { - match error { - PopApiError::Assets(e) => e.into(), - PopApiError::Balances(e) => e.into(), - PopApiError::TokenError(e) => e.into(), - PopApiError::UnknownModuleStatusCode(e) => { - let pallet = (e / 1_000) as u8; - let error = (e % 1_000) as u16; - FungiblesError::ModuleError { pallet, error } - }, - PopApiError::UnknownDispatchStatusCode(e) => { - let index = (e / 1_000_000) as u8; - let error = (3 % 1_000_000) as u8; - FungiblesError::DispatchError { index, error } - }, - _ => todo!(), - } - } -} - -// macro_rules! impl_error_conversion { -// ($pallet_index:, $pallet_error:ty, $interface_error:ty, $($variant:ident),*) => { -// impl From<$pallet_error> for $interface_error { -// fn from(error: $pallet_error) -> Self { -// match error { -// $( -// <$pallet_error>::$variant => <$interface_error>::$variant, -// )* -// _ => <$interface_error>::ModuleError { pallet: 0, error: [255, 0, 0, 0] }, // Default case -// } -// } -// } -// -// impl FromPalletError<$pallet_error> for $interface_error { -// fn from_pallet_error(error: $pallet_error) -> Self { -// Self::from(error) -// } -// } -// }; -// } diff --git a/pop-api/src/v0/assets/mod.rs b/pop-api/src/v0/assets/mod.rs index d6b0261c..736ccc0e 100644 --- a/pop-api/src/v0/assets/mod.rs +++ b/pop-api/src/v0/assets/mod.rs @@ -1 +1,2 @@ -pub mod fungibles; \ No newline at end of file +pub(crate) mod pallets; +pub mod use_cases; diff --git a/pop-api/src/v0/assets/pallets/assets.rs b/pop-api/src/v0/assets/pallets/assets.rs new file mode 100644 index 00000000..7a575e08 --- /dev/null +++ b/pop-api/src/v0/assets/pallets/assets.rs @@ -0,0 +1,491 @@ +// TODO: what to put in this file? +#![allow(dead_code)] + +use crate::{Balance, RuntimeCall, *}; +use ink::prelude::vec::Vec; +use primitives::{AssetId, MultiAddress}; +use scale::{Compact, Encode}; + +type Result = core::result::Result; + +/// [Pallet Assets](https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/assets/src/lib.rs): +/// 1. Dispatchables +/// 2. Read state functions +/// +/// 1. Dispatchables within pallet assets (TrustBackedAssets instance) that can be used via the pop api on Pop Network: +/// - create +/// - start_destroy +/// - destroy_accounts +/// - destroy_approvals +/// - finish_destroy +/// - mint +/// - burn +/// - transfer +/// - transfer_keep_alive +/// - force_transfer +/// - freeze +/// - thaw +/// - freeze_asset +/// - thaw_asset +/// - transfer_ownership +/// - set_team +/// - set_metadata +/// - clear_metadata +/// - approve_transfer +/// - cancel_approval +/// - force_cancel_approval +/// - transfer_approved +/// - touch +/// - refund +/// - set_min_balance +/// - touch_other +/// - refund_other +/// - block + +/// Issue a new class of fungible assets from a public origin. +pub(crate) fn create( + id: AssetId, + admin: impl Into>, + min_balance: Balance, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::Create { + id: id.into(), + admin: admin.into(), + min_balance, + })) +} + +/// Start the process of destroying a fungible asset class. +pub(crate) fn start_destroy(id: AssetId) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::StartDestroy { id: id.into() })) +} + +/// Destroy all accounts associated with a given asset. +pub(crate) fn destroy_accounts(id: AssetId) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::DestroyAccounts { id: id.into() })) +} + +/// Destroy all approvals associated with a given asset up to the max (see runtime configuration Assets `RemoveItemsLimit`). +pub(crate) fn destroy_approvals(id: AssetId) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::DestroyApprovals { id: id.into() })) +} + +/// Complete destroying asset and unreserve currency. +pub(crate) fn finish_destroy(id: AssetId) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::FinishDestroy { id: id.into() })) +} + +/// Mint assets of a particular class. +pub(crate) fn mint( + id: AssetId, + beneficiary: impl Into>, + amount: Balance, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::Mint { + id: id.into(), + beneficiary: beneficiary.into(), + amount: Compact(amount), + })) +} + +/// Reduce the balance of `who` by as much as possible up to `amount` assets of `id`. +pub(crate) fn burn( + id: AssetId, + who: impl Into>, + amount: Balance, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::Burn { + id: id.into(), + who: who.into(), + amount: Compact(amount), + })) +} + +/// Move some assets from the sender account to another. +pub(crate) fn transfer( + id: AssetId, + target: impl Into>, + amount: Balance, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::TransferKeepAlive { + id: id.into(), + target: target.into(), + amount: Compact(amount), + })) +} + +/// Move some assets from the sender account to another, keeping the sender account alive. +pub(crate) fn transfer_keep_alive( + id: AssetId, + target: impl Into>, + amount: Balance, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::TransferKeepAlive { + id: id.into(), + target: target.into(), + amount: Compact(amount), + })) +} + +/// Move some assets from one account to another. Sender should be the Admin of the asset `id`. +pub(crate) fn force_transfer( + id: AssetId, + source: impl Into>, + dest: impl Into>, + amount: Balance, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::ForceTransfer { + id: id.into(), + source: source.into(), + dest: dest.into(), + amount: Compact(amount), + })) +} + +/// Disallow further unprivileged transfers of an asset `id` from an account `who`. `who` +/// must already exist as an entry in `Account`s of the asset. If you want to freeze an +/// account that does not have an entry, use `touch_other` first. +pub(crate) fn freeze(id: AssetId, who: impl Into>) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::Freeze { id: id.into(), who: who.into() })) +} + +/// Allow unprivileged transfers to and from an account again. +pub(crate) fn thaw(id: AssetId, who: impl Into>) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::Thaw { id: id.into(), who: who.into() })) +} + +/// Disallow further unprivileged transfers for the asset class. +pub(crate) fn freeze_asset(id: AssetId) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::FreezeAsset { id: id.into() })) +} + +/// Allow unprivileged transfers for the asset again. +pub(crate) fn thaw_asset(id: AssetId) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::ThawAsset { id: id.into() })) +} + +/// Change the Owner of an asset. +pub(crate) fn transfer_ownership( + id: AssetId, + owner: impl Into>, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::TransferOwnership { + id: id.into(), + owner: owner.into(), + })) +} + +/// Change the Issuer, Admin and Freezer of an asset. +pub(crate) fn set_team( + id: AssetId, + issuer: impl Into>, + admin: impl Into>, + freezer: impl Into>, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::SetTeam { + id: id.into(), + issuer: issuer.into(), + admin: admin.into(), + freezer: freezer.into(), + })) +} + +/// Set the metadata for an asset. +pub(crate) fn set_metadata( + id: AssetId, + name: Vec, + symbol: Vec, + decimals: u8, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::SetMetadata { id: id.into(), name, symbol, decimals })) +} + +/// Clear the metadata for an asset. +pub(crate) fn clear_metadata(id: AssetId) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::ClearMetadata { id: id.into() })) +} + +/// Approve an amount of asset for transfer by a delegated third-party account. +pub(crate) fn approve_transfer( + id: AssetId, + delegate: impl Into>, + amount: Balance, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::ApproveTransfer { + id: id.into(), + delegate: delegate.into(), + amount: Compact(amount), + })) +} + +/// Cancel all of some asset approved for delegated transfer by a third-party account. +pub(crate) fn cancel_approval( + id: AssetId, + delegate: impl Into>, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::CancelApproval { + id: id.into(), + delegate: delegate.into(), + })) +} + +/// Cancel all of some asset approved for delegated transfer by a third-party account. +pub(crate) fn force_cancel_approval( + id: AssetId, + owner: impl Into>, + delegate: impl Into>, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::ForceCancelApproval { + id: id.into(), + owner: owner.into(), + delegate: delegate.into(), + })) +} + +/// Transfer some asset balance from a previously delegated account to some third-party +/// account. +pub(crate) fn transfer_approved( + id: AssetId, + owner: impl Into>, + destination: impl Into>, + amount: Balance, +) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::TransferApproved { + id: id.into(), + owner: owner.into(), + destination: destination.into(), + amount: Compact(amount), + })) +} + +/// Create an asset account for non-provider assets. +pub(crate) fn touch(id: AssetId) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::Touch { id: id.into() })) +} + +/// Return the deposit (if any) of an asset account or a consumer reference (if any) of an +/// account. +pub(crate) fn refund(id: AssetId, allow_burn: bool) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::Refund { id: id.into(), allow_burn })) +} + +/// Sets the minimum balance of an asset. +pub(crate) fn set_min_balance(id: AssetId, min_balance: Balance) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::SetMinBalance { + id: id.into(), + min_balance: Compact(min_balance), + })) +} + +/// Create an asset account for `who`. +pub(crate) fn touch_other(id: AssetId, who: impl Into>) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::TouchOther { id: id.into(), who: who.into() })) +} + +/// Return the deposit (if any) of a target asset account. Useful if you are the depositor. +pub(crate) fn refund_other(id: AssetId, who: impl Into>) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::RefundOther { id: id.into(), who: who.into() })) +} + +/// Disallow further unprivileged transfers of an asset `id` to and from an account `who`. +pub(crate) fn block(id: AssetId, who: impl Into>) -> Result<()> { + dispatch(RuntimeCall::Assets(AssetsCall::Block { id: id.into(), who: who.into() })) +} + +/// 2. Read state functions +/// - total_supply +/// - + +pub(crate) fn total_supply(id: AssetId) -> Result { + state::read(RuntimeStateKeys::Assets(AssetsKeys::TotalSupply(id))).into() +} + +pub(crate) fn balance_of(id: AssetId, owner: AccountId) -> Result { + state::read(RuntimeStateKeys::Assets(AssetsKeys::BalanceOf(id, owner))).into() +} + +pub(crate) fn allowance(id: AssetId, owner: AccountId, spender: AccountId) -> Result { + state::read(RuntimeStateKeys::Assets(AssetsKeys::Allowance(id, owner, spender))).into() +} +pub(crate) fn asset_exists(id: AssetId) -> Result { + state::read(RuntimeStateKeys::Assets(AssetsKeys::AssetExists(id))).into() +} + +// Parameters to extrinsics representing an asset id (`AssetIdParameter`) and a balance amount (`Balance`) are expected +// to be compact encoded. The pop api handles that for the developer. +// +// reference: https://substrate.stackexchange.com/questions/1873/what-is-the-meaning-of-palletcompact-in-pallet-development +// +// Asset id that is compact encoded. +type AssetIdParameter = Compact; +// Balance amount that is compact encoded. +type BalanceParameter = Compact; + +#[derive(Encode)] +pub(crate) enum AssetsCall { + #[codec(index = 0)] + Create { id: AssetIdParameter, admin: MultiAddress, min_balance: Balance }, + #[codec(index = 2)] + StartDestroy { id: AssetIdParameter }, + #[codec(index = 3)] + DestroyAccounts { id: AssetIdParameter }, + #[codec(index = 4)] + DestroyApprovals { id: AssetIdParameter }, + #[codec(index = 5)] + FinishDestroy { id: AssetIdParameter }, + #[codec(index = 6)] + Mint { + id: AssetIdParameter, + beneficiary: MultiAddress, + amount: BalanceParameter, + }, + #[codec(index = 7)] + Burn { id: AssetIdParameter, who: MultiAddress, amount: BalanceParameter }, + #[codec(index = 8)] + Transfer { id: AssetIdParameter, target: MultiAddress, amount: BalanceParameter }, + #[codec(index = 9)] + TransferKeepAlive { + id: AssetIdParameter, + target: MultiAddress, + amount: BalanceParameter, + }, + #[codec(index = 10)] + ForceTransfer { + id: AssetIdParameter, + source: MultiAddress, + dest: MultiAddress, + amount: BalanceParameter, + }, + #[codec(index = 11)] + Freeze { id: AssetIdParameter, who: MultiAddress }, + #[codec(index = 12)] + Thaw { id: AssetIdParameter, who: MultiAddress }, + #[codec(index = 13)] + FreezeAsset { id: AssetIdParameter }, + #[codec(index = 14)] + ThawAsset { id: AssetIdParameter }, + #[codec(index = 15)] + TransferOwnership { id: AssetIdParameter, owner: MultiAddress }, + #[codec(index = 16)] + SetTeam { + id: AssetIdParameter, + issuer: MultiAddress, + admin: MultiAddress, + freezer: MultiAddress, + }, + #[codec(index = 17)] + SetMetadata { id: AssetIdParameter, name: Vec, symbol: Vec, decimals: u8 }, + #[codec(index = 18)] + ClearMetadata { id: AssetIdParameter }, + #[codec(index = 22)] + ApproveTransfer { + id: AssetIdParameter, + delegate: MultiAddress, + amount: BalanceParameter, + }, + #[codec(index = 23)] + CancelApproval { id: AssetIdParameter, delegate: MultiAddress }, + #[codec(index = 24)] + ForceCancelApproval { + id: AssetIdParameter, + owner: MultiAddress, + delegate: MultiAddress, + }, + #[codec(index = 25)] + TransferApproved { + id: AssetIdParameter, + owner: MultiAddress, + destination: MultiAddress, + amount: BalanceParameter, + }, + #[codec(index = 26)] + Touch { id: AssetIdParameter }, + #[codec(index = 27)] + Refund { id: AssetIdParameter, allow_burn: bool }, + #[codec(index = 28)] + SetMinBalance { id: AssetIdParameter, min_balance: BalanceParameter }, + #[codec(index = 29)] + TouchOther { id: AssetIdParameter, who: MultiAddress }, + #[codec(index = 30)] + RefundOther { id: AssetIdParameter, who: MultiAddress }, + #[codec(index = 31)] + Block { id: AssetIdParameter, who: MultiAddress }, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encode, scale::Decode)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +pub enum AssetsError { + /// Account balance must be greater than or equal to the transfer amount. + BalanceLow, + /// The account to alter does not exist. + NoAccount, + /// The signing account has no permission to do the operation. + NoPermission, + /// The given asset ID is unknown. + Unknown, + /// The origin account is frozen. + Frozen, + /// The asset ID is already taken. + InUse, + /// Invalid witness data given. + BadWitness, + /// Minimum balance should be non-zero. + MinBalanceZero, + /// Unable to increment the consumer reference counters on the account. Either no provider + /// reference exists to allow a non-zero balance of a non-self-sufficient asset, or one + /// fewer then the maximum number of consumers has been reached. + UnavailableConsumer, + /// Invalid metadata given. + BadMetadata, + /// No approval exists that would allow the transfer. + Unapproved, + /// The source account would not survive the transfer and it needs to stay alive. + WouldDie, + /// The asset-account already exists. + AlreadyExists, + /// The asset-account doesn't have an associated deposit. + NoDeposit, + /// The operation would result in funds being burned. + WouldBurn, + /// The asset is a live asset and is actively being used. Usually emit for operations such + /// as `start_destroy` which require the asset to be in a destroying state. + LiveAsset, + /// The asset is not live, and likely being destroyed. + AssetNotLive, + /// The asset status is not the expected status. + IncorrectStatus, + /// The asset should be frozen before the given operation. + NotFrozen, + /// Callback action resulted in error. + CallbackFailed, +} + +impl TryFrom for AssetsError { + type Error = PopApiError; + + fn try_from(status_code: u32) -> core::result::Result { + use AssetsError::*; + match status_code { + 0 => Ok(BalanceLow), + 1 => Ok(NoAccount), + 2 => Ok(NoPermission), + 3 => Ok(Unknown), + 4 => Ok(Frozen), + 5 => Ok(InUse), + 6 => Ok(BadWitness), + 7 => Ok(MinBalanceZero), + 8 => Ok(UnavailableConsumer), + 9 => Ok(BadMetadata), + 10 => Ok(Unapproved), + 11 => Ok(WouldDie), + 12 => Ok(AlreadyExists), + 13 => Ok(NoDeposit), + 14 => Ok(WouldBurn), + 15 => Ok(LiveAsset), + 16 => Ok(AssetNotLive), + 17 => Ok(IncorrectStatus), + 18 => Ok(NotFrozen), + _ => todo!(), + } + } +} diff --git a/pop-api/src/v0/assets/pallets/mod.rs b/pop-api/src/v0/assets/pallets/mod.rs new file mode 100644 index 00000000..0b8a53a0 --- /dev/null +++ b/pop-api/src/v0/assets/pallets/mod.rs @@ -0,0 +1 @@ +pub(crate) mod assets; diff --git a/pop-api/src/v0/assets/use_cases/fungibles.rs b/pop-api/src/v0/assets/use_cases/fungibles.rs new file mode 100644 index 00000000..4af5d97e --- /dev/null +++ b/pop-api/src/v0/assets/use_cases/fungibles.rs @@ -0,0 +1,372 @@ +use crate::{ + assets::pallets, + error::PopApiError::{self, *}, + AccountId, Balance, *, +}; +use ink::prelude::vec::Vec; +use primitives::AssetId; + +type Result = core::result::Result; + +/// Local Fungibles: +/// 1. PSP-22 Interface +/// 2. PSP-22 Metadata Interface +/// 3. Asset Management + +/// 1. PSP-22 Interface: +/// - total_supply +/// - balance_of +/// - allowance +/// - transfer +/// - transfer_from +/// - approve +/// - increase_allowance +/// - decrease_allowance + +/// Returns the total token supply for a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// The total supply of the token, or an error if the operation fails. +pub fn total_supply(id: AssetId) -> Result { + pallets::assets::total_supply(id) +} + +/// Returns the account balance for the specified `owner` for a given asset ID. Returns `0` if +/// the account is non-existent. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// * `owner` - The account whose balance is being queried. +/// +/// # Returns +/// The balance of the specified account, or an error if the operation fails. +pub fn balance_of(id: AssetId, owner: AccountId) -> Result { + pallets::assets::balance_of(id, owner) +} + +/// Returns the amount which `spender` is still allowed to withdraw from `owner` for a given +/// asset ID. Returns `0` if no allowance has been set. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// * `owner` - The account that owns the tokens. +/// * `spender` - The account that is allowed to spend the tokens. +/// +/// # Returns +/// The remaining allowance, or an error if the operation fails. +pub fn allowance(id: AssetId, owner: AccountId, spender: AccountId) -> Result { + pallets::assets::allowance(id, owner, spender) +} + +/// Transfers `value` amount of tokens from the caller's account to account `to`, with additional +/// `data` in unspecified format. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// * `to` - The recipient account. +/// * `value` - The number of tokens to transfer. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the transfer fails. +pub fn transfer( + id: AssetId, + to: impl Into>, + value: Balance, +) -> Result<()> { + pallets::assets::transfer(id, to, value) +} + +/// Transfers `value` tokens on behalf of `from` to account `to` with additional `data` +/// in unspecified format. If `from` is equal to `None`, tokens will be minted to account `to`. If +/// `to` is equal to `None`, tokens will be burned from account `from`. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// * `from` - The account from which the tokens are transferred. +/// * `to` - The recipient account. +/// * `value` - The number of tokens to transfer. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the transfer fails. +pub fn transfer_from( + id: AssetId, + from: Option>>, + to: Option>>, + value: Balance, + _data: &[u8], +) -> Result<()> { + match (from, to) { + (None, Some(to)) => pallets::assets::mint(id, to, value), + (Some(from), None) => pallets::assets::burn(id, from, value), + (Some(from), Some(to)) => pallets::assets::transfer_approved(id, from, to, value), + _ => Ok(()), + } +} + +/// Approves an account to spend a specified number of tokens on behalf of the caller. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// * `spender` - The account that is allowed to spend the tokens. +/// * `value` - The number of tokens to approve. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the approval fails. +// #[allow(unused_variables)] +// fn approve(id: AssetId, spender: AccountId, value: Balance) -> Result<()> { +// todo!() +// // TODO: read allowance and increase or decrease. +// // Ok(dispatch(RuntimeCall::Assets(AssetsCall::ApproveTransfer { +// // id: id.into(), +// // delegate: spender.into(), +// // amount: Compact(value), +// // }))?) +// } + +/// Increases the allowance of a spender. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// * `spender` - The account that is allowed to spend the tokens. +/// * `value` - The number of tokens to increase the allowance by. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the operation fails. +// fn increase_allowance(id: AssetId, spender: AccountId, value: Balance) -> Result<()> { +// Ok(dispatch(RuntimeCall::Assets(AssetsCall::ApproveTransfer { +// id: id.into(), +// delegate: spender.into(), +// amount: Compact(value), +// }))?) +// } + +/// Decreases the allowance of a spender. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// * `spender` - The account that is allowed to spend the tokens. +/// * `value` - The number of tokens to decrease the allowance by. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the operation fails. +// #[allow(unused_variables)] +// fn decrease_allowance(id: AssetId, spender: AccountId, value: Balance) -> Result<()> { +// todo!() +// // TODO: cancel_approval + approve_transfer +// // Ok(dispatch(RuntimeCall::Assets(AssetsCall::CancelApproval { +// // id: id.into(), +// // delegate: delegate.into(), +// // }))?) +// // Ok(dispatch(RuntimeCall::Assets(AssetsCall::ApproveTransfer { +// // id: id.into(), +// // delegate: spender.into(), +// // amount: Compact(value), +// // }))?) +// } + +/// 2. PSP-22 Metadata Interface: +/// - token_name +/// - token_symbol +/// - token_decimals + +/// Returns the token name for a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// The name of the token as a byte vector, or an error if the operation fails. +// #[allow(unused_variables)] +// pub fn token_name(id: AssetId) -> Result>> { +// todo!() +// // Ok(state::read(RuntimeStateKeys::Assets(AssetsKeys::TokenName(id)))?) +// } + +/// Returns the token symbol for a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// The symbol of the token as a byte vector, or an error if the operation fails. +// #[allow(unused_variables)] +// fn token_symbol(id: AssetId) -> Result>> { +// todo!() +// } + +/// Returns the token decimals for a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// The number of decimals of the token as a byte vector, or an error if the operation fails. +// #[allow(unused_variables)] +// fn token_decimals(id: AssetId) -> Result>> { +// todo!() +// } + +/// 3. Asset Management: +/// - create +/// - start_destroy +/// - destroy_accounts +/// - destroy_approvals +/// - finish_destroy +/// - set_metadata +/// - clear_metadata + +/// Create a new token with a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// * `admin` - The account that will administer the asset. +/// * `min_balance` - The minimum balance required for accounts holding this asset. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the creation fails. +pub fn create( + id: AssetId, + admin: impl Into>, + min_balance: Balance, +) -> Result<()> { + pallets::assets::create(id, admin, min_balance) +} + +/// Start the process of destroying a token with a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the operation fails. +// fn start_destroy(id: AssetId) -> Result<()> { +// Ok(dispatch(RuntimeCall::Assets(AssetsCall::StartDestroy { +// id: id.into(), +// }))?) +// } + +/// Destroy all accounts associated with a token with a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the operation fails. +// fn destroy_accounts(id: AssetId) -> Result<()> { +// Ok(dispatch(RuntimeCall::Assets(AssetsCall::DestroyAccounts { +// id: id.into(), +// }))?) +// } + +/// Destroy all approvals associated with a token with a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the operation fails. +// fn destroy_approvals(id: AssetId) -> Result<()> { +// Ok(dispatch(RuntimeCall::Assets(AssetsCall::DestroyApprovals { +// id: id.into(), +// }))?) +// } + +/// Complete the process of destroying a token with a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the operation fails. +// fn finish_destroy(id: AssetId) -> Result<()> { +// Ok(dispatch(RuntimeCall::Assets(AssetsCall::FinishDestroy { +// id: id.into(), +// }))?) +// } + +/// Set the metadata for a token with a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the operation fails. +pub fn set_metadata(id: AssetId, name: Vec, symbol: Vec, decimals: u8) -> Result<()> { + pallets::assets::set_metadata(id, name, symbol, decimals) +} + +/// Clear the metadata for a token with a given asset ID. +/// +/// # Arguments +/// * `id` - The ID of the asset. +/// +/// # Returns +/// Returns `Ok(())` if successful, or an error if the operation fails. +// fn clear_metadata(id: AssetId) -> Result<()> { +// Ok(dispatch(RuntimeCall::Assets(AssetsCall::ClearMetadata { +// id: id.into(), +// }))?) +// } + +pub fn asset_exists(id: AssetId) -> Result { + pallets::assets::asset_exists(id) +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encode, scale::Decode)] +#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] +pub enum FungiblesError { + /// The asset is not live; either frozen or being destroyed. + AssetNotLive, + /// Not enough allowance to fulfill a request is available. + InsufficientAllowance, + /// Not enough balance to fulfill a request is available. + InsufficientBalance, + /// The asset ID is already taken. + InUse, + /// Minimum balance should be non-zero. + MinBalanceZero, + /// The account to alter does not exist. + NoAccount, + /// The signing account has no permission to do the operation. + NoPermission, + /// The given asset ID is unknown. + Unknown, + // // TODO: + // // - Originally `InsufficientBalance` for the deposit but this would result in the same error + // // as the error when there is insufficient balance for transferring an asset. + /// No balance for creation of assets or fees. + NoBalance, +} + +// TODO: make generic. +pub(crate) fn convert_to_fungibles_error(index: u8, error: u8) -> PopApiError { + match index { + 10 => balance_into(error), + 52 => assets_into(error), + _ => Module { index, error }, + } +} + +fn balance_into(error: u8) -> PopApiError { + match error { + 2 => UseCaseError(FungiblesError::NoBalance), + _ => Module { index: 10, error }, + } +} + +fn assets_into(error: u8) -> PopApiError { + match error { + 0 => UseCaseError(FungiblesError::InsufficientBalance), + 1 => UseCaseError(FungiblesError::NoAccount), + 2 => UseCaseError(FungiblesError::NoPermission), + 3 => UseCaseError(FungiblesError::Unknown), + 5 => UseCaseError(FungiblesError::InUse), + 7 => UseCaseError(FungiblesError::MinBalanceZero), + 10 => UseCaseError(FungiblesError::InsufficientAllowance), + 16 => UseCaseError(FungiblesError::AssetNotLive), + _ => Module { index: 52, error }, + } +} diff --git a/pop-api/src/v0/assets/use_cases/mod.rs b/pop-api/src/v0/assets/use_cases/mod.rs new file mode 100644 index 00000000..182590df --- /dev/null +++ b/pop-api/src/v0/assets/use_cases/mod.rs @@ -0,0 +1 @@ +pub mod fungibles; diff --git a/pop-api/src/v0/balances.rs b/pop-api/src/v0/balances.rs index 08db0a75..5d38d851 100644 --- a/pop-api/src/v0/balances.rs +++ b/pop-api/src/v0/balances.rs @@ -1,9 +1,7 @@ -use crate::{ - dispatch, primitives::MultiAddress, v0::RuntimeCall, AccountId, PopApiError, - PopApiError::UnknownModuleStatusCode, -}; +// TODO: what to put in this file? +use crate::{dispatch, error::PopApiError, primitives::MultiAddress, v0::RuntimeCall, AccountId}; -type Result = core::result::Result; +type Result = core::result::Result; pub fn transfer_keep_alive( dest: impl Into>, @@ -17,7 +15,7 @@ pub fn transfer_keep_alive( #[derive(scale::Encode)] #[allow(dead_code)] -pub(crate) enum BalancesCall { +pub enum BalancesCall { #[codec(index = 3)] TransferKeepAlive { dest: MultiAddress, @@ -28,7 +26,7 @@ pub(crate) enum BalancesCall { #[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] -pub(crate) enum BalancesError { +pub enum BalancesError { /// Vesting balance too high to send value. VestingBalance, /// Account liquidity restrictions prevent withdrawal. @@ -73,15 +71,6 @@ impl TryFrom for BalancesError { 9 => Ok(TooManyFreezes), 10 => Ok(IssuanceDeactivated), 11 => Ok(DeltaZero), - _ => Err(UnknownModuleStatusCode(status_code)), - } - } -} - -impl From for BalancesError { - fn from(error: PopApiError) -> Self { - match error { - PopApiError::Balances(e) => e, _ => todo!(), } } diff --git a/pop-api/src/v0/contracts.rs b/pop-api/src/v0/contracts.rs deleted file mode 100644 index 5d4a3692..00000000 --- a/pop-api/src/v0/contracts.rs +++ /dev/null @@ -1,152 +0,0 @@ -use crate::{PopApiError, PopApiError::UnknownModuleStatusCode}; - -#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] -#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] -pub enum Error { - /// Invalid schedule supplied, e.g. with zero weight of a basic operation. - InvalidSchedule, - /// Invalid combination of flags supplied to `seal_call` or `seal_delegate_call`. - InvalidCallFlags, - /// The executed contract exhausted its gas limit. - OutOfGas, - /// The output buffer supplied to a contract API call was too small. - OutputBufferTooSmall, - /// Performing the requested transfer failed. Probably because there isn't enough - /// free balance in the sender's account. - TransferFailed, - /// Performing a call was denied because the calling depth reached the limit - /// of what is specified in the schedule. - MaxCallDepthReached, - /// No contract was found at the specified address. - ContractNotFound, - /// The code supplied to `instantiate_with_code` exceeds the limit specified in the - /// current schedule. - CodeTooLarge, - /// No code could be found at the supplied code hash. - CodeNotFound, - /// No code info could be found at the supplied code hash. - CodeInfoNotFound, - /// A buffer outside of sandbox memory was passed to a contract API function. - OutOfBounds, - /// Input passed to a contract API function failed to decode as expected type. - DecodingFailed, - /// Contract trapped during execution. - ContractTrapped, - /// The size defined in `T::MaxValueSize` was exceeded. - ValueTooLarge, - /// Termination of a contract is not allowed while the contract is already - /// on the call stack. Can be triggered by `seal_terminate`. - TerminatedWhileReentrant, - /// `seal_call` forwarded this contracts input. It therefore is no longer available. - InputForwarded, - /// The subject passed to `seal_random` exceeds the limit. - RandomSubjectTooLong, - /// The amount of topics passed to `seal_deposit_events` exceeds the limit. - TooManyTopics, - /// The chain does not provide a chain extension. Calling the chain extension results - /// in this error. Note that this usually shouldn't happen as deploying such contracts - /// is rejected. - NoChainExtension, - /// Failed to decode the XCM program. - XCMDecodeFailed, - /// A contract with the same AccountId already exists. - DuplicateContract, - /// A contract self destructed in its constructor. - /// - /// This can be triggered by a call to `seal_terminate`. - TerminatedInConstructor, - /// A call tried to invoke a contract that is flagged as non-reentrant. - /// The only other cause is that a call from a contract into the runtime tried to call back - /// into `pallet-contracts`. This would make the whole pallet reentrant with regard to - /// contract code execution which is not supported. - ReentranceDenied, - /// Origin doesn't have enough balance to pay the required storage deposits. - StorageDepositNotEnoughFunds, - /// More storage was created than allowed by the storage deposit limit. - StorageDepositLimitExhausted, - /// Code removal was denied because the code is still in use by at least one contract. - CodeInUse, - /// The contract ran to completion but decided to revert its storage changes. - /// Please note that this error is only returned from extrinsics. When called directly - /// or via RPC an `Ok` will be returned. In this case the caller needs to inspect the flags - /// to determine whether a reversion has taken place. - ContractReverted, - /// The contract's code was found to be invalid during validation. - /// - /// The most likely cause of this is that an API was used which is not supported by the - /// node. This happens if an older node is used with a new version of ink!. Try updating - /// your node to the newest available version. - /// - /// A more detailed error can be found on the node console if debug messages are enabled - /// by supplying `-lruntime::contracts=debug`. - CodeRejected, - /// An indeterministic code was used in a context where this is not permitted. - Indeterministic, - /// A pending migration needs to complete before the extrinsic can be called. - MigrationInProgress, - /// Migrate dispatch call was attempted but no migration was performed. - NoMigrationPerformed, - /// The contract has reached its maximum number of delegate dependencies. - MaxDelegateDependenciesReached, - /// The dependency was not found in the contract's delegate dependencies. - DelegateDependencyNotFound, - /// The contract already depends on the given delegate dependency. - DelegateDependencyAlreadyExists, - /// Can not add a delegate dependency to the code hash of the contract itself. - CannotAddSelfAsDelegateDependency, -} - -impl TryFrom for Error { - type Error = PopApiError; - - fn try_from(status_code: u32) -> core::result::Result { - use Error::*; - match status_code { - 0 => Ok(InvalidSchedule), - 1 => Ok(InvalidCallFlags), - 2 => Ok(OutOfGas), - 3 => Ok(OutputBufferTooSmall), - 4 => Ok(TransferFailed), - 5 => Ok(MaxCallDepthReached), - 6 => Ok(ContractNotFound), - 7 => Ok(CodeTooLarge), - 8 => Ok(CodeNotFound), - 9 => Ok(CodeInfoNotFound), - 10 => Ok(OutOfBounds), - 11 => Ok(DecodingFailed), - 12 => Ok(ContractTrapped), - 13 => Ok(ValueTooLarge), - 14 => Ok(TerminatedWhileReentrant), - 15 => Ok(InputForwarded), - 16 => Ok(RandomSubjectTooLong), - 17 => Ok(TooManyTopics), - 18 => Ok(NoChainExtension), - 19 => Ok(XCMDecodeFailed), - 20 => Ok(DuplicateContract), - 21 => Ok(TerminatedInConstructor), - 22 => Ok(ReentranceDenied), - 23 => Ok(StorageDepositNotEnoughFunds), - 24 => Ok(StorageDepositLimitExhausted), - 25 => Ok(CodeInUse), - 26 => Ok(ContractReverted), - 27 => Ok(CodeRejected), - 28 => Ok(Indeterministic), - 29 => Ok(MigrationInProgress), - 30 => Ok(NoMigrationPerformed), - 31 => Ok(MaxDelegateDependenciesReached), - 32 => Ok(DelegateDependencyNotFound), - 33 => Ok(DelegateDependencyAlreadyExists), - 34 => Ok(CannotAddSelfAsDelegateDependency), - _ => Err(UnknownModuleStatusCode(status_code)), - } - } -} - -impl From for Error { - fn from(error: PopApiError) -> Self { - match error { - PopApiError::Contracts(e) => e, - _ => panic!("expected balances error"), - } - } -} diff --git a/pop-api/src/v0/cross_chain/mod.rs b/pop-api/src/v0/cross_chain/mod.rs index 1e5afbf5..1d3c5b7d 100644 --- a/pop-api/src/v0/cross_chain/mod.rs +++ b/pop-api/src/v0/cross_chain/mod.rs @@ -1,8 +1,8 @@ pub mod coretime; -use crate::{PopApiError::UnknownModuleStatusCode, *}; +use crate::error::PopApiError; -type Result = core::result::Result; +type Result = core::result::Result; #[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] @@ -92,16 +92,7 @@ impl TryFrom for Error { 21 => Ok(InvalidAssetUnknownReserve), 22 => Ok(InvalidAssetUnsupportedReserve), 23 => Ok(TooManyReserves), - _ => Err(UnknownModuleStatusCode(status_code)), - } - } -} - -impl From for Error { - fn from(error: PopApiError) -> Self { - match error { - PopApiError::Xcm(e) => e, - _ => panic!("expected xcm error"), + _ => todo!(), } } } diff --git a/pop-api/src/v0/dispatch_error.rs b/pop-api/src/v0/dispatch_error.rs deleted file mode 100644 index 6ed40ce5..00000000 --- a/pop-api/src/v0/dispatch_error.rs +++ /dev/null @@ -1,57 +0,0 @@ -use super::*; - -#[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)] -#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] -pub(crate) enum TokenError { - /// Funds are unavailable. - FundsUnavailable, - /// Some part of the balance gives the only provider reference to the account and thus cannot - /// be (re)moved. - OnlyProvider, - /// Account cannot exist with the funds that would be given. - BelowMinimum, - /// Account cannot be created. - CannotCreate, - /// The asset in question is unknown. - UnknownAsset, - /// Funds exist but are frozen. - Frozen, - /// Operation is not supported by the asset. - Unsupported, - /// Account cannot be created for a held balance. - CannotCreateHold, - /// Withdrawal would cause unwanted loss of account. - NotExpendable, - /// Account cannot receive the assets. - Blocked, -} - -impl TryFrom for TokenError { - type Error = crate::PopApiError; - - fn try_from(status_code: u32) -> core::result::Result { - use TokenError::*; - match status_code { - 0 => Ok(FundsUnavailable), - 1 => Ok(OnlyProvider), - 2 => Ok(BelowMinimum), - 3 => Ok(CannotCreate), - 4 => Ok(UnknownAsset), - 5 => Ok(Frozen), - 6 => Ok(Unsupported), - 7 => Ok(CannotCreateHold), - 8 => Ok(NotExpendable), - 9 => Ok(Blocked), - _ => todo!(), - } - } -} - -impl From for TokenError { - fn from(error: PopApiError) -> Self { - match error { - PopApiError::TokenError(e) => e, - _ => todo!(), - } - } -} diff --git a/pop-api/src/v0/mod.rs b/pop-api/src/v0/mod.rs index 02169c22..75bcb878 100644 --- a/pop-api/src/v0/mod.rs +++ b/pop-api/src/v0/mod.rs @@ -5,9 +5,7 @@ use crate::{ pub mod assets; pub mod balances; -pub mod contracts; pub mod cross_chain; -pub mod dispatch_error; pub mod nfts; pub mod state; @@ -22,5 +20,5 @@ pub(crate) enum RuntimeCall { #[codec(index = 50)] Nfts(nfts::NftCalls), #[codec(index = 52)] - Assets(assets::fungibles::AssetsCall), + Assets(assets::pallets::assets::AssetsCall), } diff --git a/pop-api/src/v0/nfts.rs b/pop-api/src/v0/nfts.rs index 946a3eca..2de306a9 100644 --- a/pop-api/src/v0/nfts.rs +++ b/pop-api/src/v0/nfts.rs @@ -1,12 +1,12 @@ use super::RuntimeCall; -use crate::{PopApiError::UnknownModuleStatusCode, *}; +use crate::{PopApiError, *}; use ink::prelude::vec::Vec; use primitives::{ApprovalsLimit, BoundedBTreeMap, KeyLimit, MultiAddress}; pub use primitives::{CollectionId, ItemId}; use scale::Encode; pub use types::*; -type Result = core::result::Result; +type Result = core::result::Result; /// Issue a new collection of non-fungible items pub fn create( @@ -660,16 +660,7 @@ impl TryFrom for Error { 42 => Ok(WrongNamespace), 43 => Ok(CollectionNotEmpty), 44 => Ok(WitnessRequired), - _ => Err(UnknownModuleStatusCode(status_code)), - } - } -} - -impl From for Error { - fn from(error: PopApiError) -> Self { - match error { - PopApiError::Nfts(e) => e, - _ => panic!("unexpected pallet nfts error. This error is unknown to pallet nfts"), + _ => todo!(), } } } diff --git a/primitives/src/storage_keys.rs b/primitives/src/storage_keys.rs index 67448842..fc7234aa 100644 --- a/primitives/src/storage_keys.rs +++ b/primitives/src/storage_keys.rs @@ -1,5 +1,4 @@ use super::*; -// use scale::{Decode, Encode, MaxEncodedLen}; #[derive(Encode, Decode, Debug, MaxEncodedLen)] pub enum RuntimeStateKeys { @@ -28,8 +27,6 @@ pub enum NftsKeys { Owner(CollectionId, ItemId), /// Get the attribute value of `item` of `collection` corresponding to `key`. Attribute(CollectionId, ItemId, BoundedVec), - // /// Get the custom attribute value of `item` of `collection` corresponding to `key`. - // CustomAttribute(AccountId, CollectionId, ItemId, BoundedVec), /// Get the system attribute value of `item` of `collection` corresponding to `key` SystemAttribute(CollectionId, Option, BoundedVec), /// Get the attribute value of `item` of `collection` corresponding to `key`. diff --git a/runtime/devnet/Cargo.toml b/runtime/devnet/Cargo.toml index d4fe2923..46208d8f 100644 --- a/runtime/devnet/Cargo.toml +++ b/runtime/devnet/Cargo.toml @@ -91,6 +91,7 @@ parachain-info.workspace = true env_logger = "0.11.2" hex = "0.4.3" enumflags2 = "0.7.9" +pop-api = { path = "../../pop-api", default-features = false } [features] default = ["std"] @@ -138,6 +139,7 @@ std = [ "polkadot-parachain-primitives/std", "polkadot-runtime-common/std", "pop-primitives/std", + "pop-api/std", "scale-info/std", "sp-api/std", "sp-io/std", diff --git a/runtime/devnet/src/extensions/mod.rs b/runtime/devnet/src/extensions.rs similarity index 97% rename from runtime/devnet/src/extensions/mod.rs rename to runtime/devnet/src/extensions.rs index d2129c4f..014893f9 100644 --- a/runtime/devnet/src/extensions/mod.rs +++ b/runtime/devnet/src/extensions.rs @@ -17,10 +17,7 @@ use pop_primitives::{ AssetId, CollectionId, ItemId, }; use sp_core::crypto::UncheckedFrom; -use sp_runtime::{ - traits::{BlockNumberProvider, Dispatchable}, - DispatchError, -}; +use sp_runtime::traits::{BlockNumberProvider, Dispatchable}; use sp_std::{boxed::Box, vec::Vec}; use xcm::{ latest::{prelude::*, OriginKind::SovereignAccount}, @@ -32,9 +29,6 @@ use crate::{ RuntimeOrigin, UNIT, }; -#[cfg(test)] -mod tests; - const LOG_TARGET: &str = "pop-api::extension"; type ContractSchedule = ::Schedule; @@ -42,6 +36,7 @@ type ContractSchedule = ::Schedule; #[derive(Default)] pub struct PopApiExtension; +// TODO: check removal or simplification of trait bounds. impl ChainExtension for PopApiExtension where T: pallet_contracts::Config @@ -59,31 +54,12 @@ where fn call(&mut self, env: Environment) -> Result where E: Ext, - // T::AccountId: UncheckedFrom + AsRef<[u8]>, { log::debug!(target:LOG_TARGET, " extension called "); match v0::FuncId::try_from(env.func_id())? { - v0::FuncId::Dispatch => { - match dispatch::(env) { - Ok(()) => Ok(RetVal::Converging(0)), - Err(DispatchError::Module(error)) => { - // encode status code = pallet index in runtime + error index, allowing for - // 999 errors - let first = (3u32 * 1_000_000u32) - + (error.index as u32 * 1_000u32) - + u32::from_le_bytes(error.error); - Ok(RetVal::Converging( - // (3u32 * 1_000_000u32) - // + (error.index as u32 * 1_000u32) - // + u32::from_le_bytes(error.error), - first, - )) - }, - Err(DispatchError::Token(error)) => { - Ok(RetVal::Converging((7u32 * 1_000_000u32) + error as u32)) - }, - Err(e) => Err(e), - } + v0::FuncId::Dispatch => match dispatch::(env) { + Ok(()) => Ok(RetVal::Converging(0)), + Err(e) => Ok(RetVal::Converging(convert_to_status_code(e))), }, v0::FuncId::ReadState => { read_state::(env)?; @@ -97,6 +73,17 @@ where } } +pub(crate) fn convert_to_status_code(error: DispatchError) -> u32 { + match error { + _ => { + let mut encoded_error = error.encode(); + // Resize the encoded value to 4 bytes in order to decode the value in a u32 (4 bytes). + encoded_error.resize(4, 0); + u32::decode(&mut &encoded_error[..]).unwrap() + }, + } +} + pub mod v0 { #[derive(Debug)] pub enum FuncId { diff --git a/runtime/devnet/src/extensions/tests/mod.rs b/runtime/devnet/src/extensions/tests/mod.rs deleted file mode 100644 index cbd13d62..00000000 --- a/runtime/devnet/src/extensions/tests/mod.rs +++ /dev/null @@ -1,89 +0,0 @@ -#![cfg(test)] -use super::*; -use crate::{Assets, Balances, Contracts, Runtime, System}; -use pallet_contracts::{Code, CollectEvents, Determinism, ExecReturnValue}; -use sp_runtime::{traits::Hash, AccountId32, BuildStorage}; - -mod local_fungibles; - -type Balance = u128; -type AssetId = u32; -const DEBUG_OUTPUT: pallet_contracts::DebugInfo = pallet_contracts::DebugInfo::UnsafeDebug; - -const ALICE: AccountId32 = AccountId32::new([1_u8; 32]); -const BOB: AccountId32 = AccountId32::new([2_u8; 32]); -const INIT_AMOUNT: Balance = 100_000_000 * UNIT; -const INIT_VALUE: Balance = 100 * UNIT; -const GAS_LIMIT: Weight = Weight::from_parts(100_000_000_000, 3 * 1024 * 1024); - -fn new_test_ext() -> sp_io::TestExternalities { - let mut t = frame_system::GenesisConfig::::default() - .build_storage() - .expect("Frame system builds valid default genesis config"); - - pallet_balances::GenesisConfig:: { - balances: vec![(ALICE, INIT_AMOUNT), (BOB, INIT_AMOUNT)], - } - .assimilate_storage(&mut t) - .expect("Pallet balances storage can be assimilated"); - - let mut ext = sp_io::TestExternalities::new(t); - ext.execute_with(|| System::set_block_number(1)); - ext -} - -fn load_wasm_module(path: &str) -> std::io::Result<(Vec, ::Output)> -where - T: frame_system::Config, -{ - let wasm_binary = std::fs::read(path)?; - let code_hash = T::Hashing::hash(&wasm_binary); - Ok((wasm_binary, code_hash)) -} - -fn function_selector(name: &str) -> Vec { - let hash = sp_io::hashing::blake2_256(name.as_bytes()); - [hash[0..4].to_vec()].concat() -} - -fn do_bare_call( - addr: AccountId32, - input: Vec, - value: u128, -) -> Result { - let result = Contracts::bare_call( - ALICE, - addr.into(), - value.into(), - GAS_LIMIT, - None, - input, - DEBUG_OUTPUT, - CollectEvents::Skip, - Determinism::Enforced, - ); - log::debug!("Contract debug buffer - {:?}", String::from_utf8(result.debug_message.clone())); - log::debug!("result: {:?}", result); - result.result -} - -// Deploy, instantiate and return contract address. -fn instantiate(contract: &str, init_value: u128, salt: Vec) -> AccountId32 { - let (wasm_binary, _) = - load_wasm_module::(contract).expect("could not read .wasm file"); - let result = Contracts::bare_instantiate( - ALICE, - init_value, - GAS_LIMIT, - None, - Code::Upload(wasm_binary), - function_selector("new"), - salt, - DEBUG_OUTPUT, - CollectEvents::Skip, - ) - .result - .unwrap(); - assert!(!result.result.did_revert(), "deploying contract reverted {:?}", result); - result.account_id -} diff --git a/runtime/devnet/src/lib.rs b/runtime/devnet/src/lib.rs index a82be804..416a3298 100644 --- a/runtime/devnet/src/lib.rs +++ b/runtime/devnet/src/lib.rs @@ -10,6 +10,8 @@ mod extensions; mod weights; // Public due to integration tests crate. pub mod config; +#[cfg(test)] +mod tests; use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases; use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; diff --git a/runtime/devnet/src/extensions/tests/local_fungibles.rs b/runtime/devnet/src/tests/local_fungibles.rs similarity index 70% rename from runtime/devnet/src/extensions/tests/local_fungibles.rs rename to runtime/devnet/src/tests/local_fungibles.rs index 5de162c9..bc13fbde 100644 --- a/runtime/devnet/src/extensions/tests/local_fungibles.rs +++ b/runtime/devnet/src/tests/local_fungibles.rs @@ -2,31 +2,10 @@ use super::*; -#[derive(Decode, Encode, Debug, Eq, PartialEq)] -enum FungiblesError { - /// The asset is not live; either frozen or being destroyed. - AssetNotLive, - /// The amount to mint is less than the existential deposit. - BelowMinimum, - /// Unspecified dispatch error, providing the index and optionally its error index. - DispatchError { index: u8, error: Option }, - /// Not enough allowance to fulfill a request is available. - InsufficientAllowance, - /// Not enough balance to fulfill a request is available. - InsufficientBalance, - /// The asset ID is already taken. - InUse, - /// Minimum balance should be non-zero. - MinBalanceZero, - /// Unspecified pallet error, providing pallet index and error index. - ModuleError { pallet: u8, error: u16 }, - /// The account to alter does not exist. - NoAccount, - /// The signing account has no permission to do the operation. - NoPermission, - /// The given asset ID is unknown. - Unknown, -} +use pop_api::{ + error::{ArithmeticError::*, PopApiError::*, TokenError::*}, + v0::assets::use_cases::fungibles::FungiblesError::*, +}; const ASSET_ID: AssetId = 1; @@ -119,8 +98,7 @@ fn transfer_from( do_bare_call(addr, params, 0).expect("should work") } -// Create an asset and mint to owner. -fn create_asset(asset_id: AssetId, owner: AccountId32, min_balance: Balance) -> AssetId { +fn create_asset(owner: AccountId32, asset_id: AssetId, min_balance: Balance) -> AssetId { assert_eq!( Assets::create( RuntimeOrigin::signed(owner.clone()), @@ -133,31 +111,34 @@ fn create_asset(asset_id: AssetId, owner: AccountId32, min_balance: Balance) -> asset_id } -// Create an asset and mint to owner. +fn mint_asset(owner: AccountId32, asset_id: AssetId, to: AccountId32, value: Balance) -> AssetId { + assert_eq!( + Assets::mint(RuntimeOrigin::signed(owner.clone()), asset_id.into(), to.into(), value), + Ok(()) + ); + asset_id +} + fn create_asset_and_mint_to( - asset_id: AssetId, owner: AccountId32, + asset_id: AssetId, to: AccountId32, value: Balance, ) -> AssetId { - create_asset(asset_id, owner.clone(), 1); - assert_eq!( - Assets::mint(RuntimeOrigin::signed(owner.into()), asset_id.into(), to.into(), value,), - Ok(()) - ); - asset_id + create_asset(owner.clone(), asset_id, 1); + mint_asset(owner, asset_id, to, value) } // Create an asset, mints to, and approves spender. fn create_asset_mint_and_approve( - asset_id: AssetId, owner: AccountId32, + asset_id: AssetId, to: AccountId32, mint: Balance, spender: AccountId32, approve: Balance, ) { - create_asset_and_mint_to(asset_id, owner.clone(), to.clone(), mint); + create_asset_and_mint_to(owner.clone(), asset_id, to.clone(), mint); assert_eq!( Assets::approve_transfer( RuntimeOrigin::signed(to.into()), @@ -199,7 +180,7 @@ fn total_supply_works() { assert_eq!(Assets::total_supply(ASSET_ID), total_supply(addr.clone(), ASSET_ID)); // Tokens in circulation. - create_asset_and_mint_to(ASSET_ID, addr.clone(), BOB, 100); + create_asset_and_mint_to(addr.clone(), ASSET_ID, BOB, 100); assert_eq!(Assets::total_supply(ASSET_ID), total_supply(addr, ASSET_ID)); }); } @@ -219,7 +200,7 @@ fn balance_of_works() { assert_eq!(Assets::balance(ASSET_ID, BOB), balance_of(addr.clone(), ASSET_ID, BOB)); // Tokens in circulation. - create_asset_and_mint_to(ASSET_ID, addr.clone(), BOB, 100); + create_asset_and_mint_to(addr.clone(), ASSET_ID, BOB, 100); assert_eq!(Assets::balance(ASSET_ID, BOB), balance_of(addr, ASSET_ID, BOB)); }); } @@ -242,7 +223,7 @@ fn allowance_works() { ); // Tokens in circulation. - create_asset_mint_and_approve(ASSET_ID, addr.clone(), BOB, 100, ALICE, 50); + create_asset_mint_and_approve(addr.clone(), ASSET_ID, BOB, 100, ALICE, 50); assert_eq!( Assets::allowance(ASSET_ID, &BOB, &ALICE), allowance(addr, ASSET_ID, BOB, ALICE) @@ -265,7 +246,7 @@ fn asset_exists_works() { assert_eq!(Assets::asset_exists(ASSET_ID), asset_exists(addr.clone(), ASSET_ID)); // Tokens in circulation. - create_asset(ASSET_ID, addr.clone(), 1); + create_asset(addr.clone(), ASSET_ID, 1); assert_eq!(Assets::asset_exists(ASSET_ID), asset_exists(addr, ASSET_ID)); }); } @@ -276,34 +257,52 @@ fn asset_exists_works() { // - reserve(): Overflow, LiquidityRestrictions; frozen // - Callback // - StorageDepositLimitExhausted +// todo: errors: +// - TokenErrors +// - Arithmetic +// - https://github.com/paritytech/polkadot-sdk/blob/3977f389cce4a00fd7100f95262e0563622b9aa4/substrate/frame/assets/src/functions.rs#L125 #[test] #[ignore] fn create_works() { new_test_ext().execute_with(|| { let _ = env_logger::try_init(); let new_asset = 2; + // Instantiate a contract without balance (relay token). let addr = instantiate("../../pop-api/examples/fungibles/target/ink/fungibles.wasm", 0, vec![0]); - + // No balance to pay for fees. assert_eq!( - decoded::(create(addr.clone(), ASSET_ID, addr.clone(), 1)), - FungiblesError::InsufficientBalance + decoded::(create(addr.clone(), ASSET_ID, addr.clone(), 1)), + UseCaseError(NoBalance) ); + // Instantiate a contract without balance (relay token). + let addr = + instantiate("../../pop-api/examples/fungibles/target/ink/fungibles.wasm", 100, vec![2]); + // TODO: make sure it has enough for the fees but not for the deposit. + // No balance to pay fe deposit. + assert_eq!( + decoded::(create(addr.clone(), ASSET_ID, addr.clone(), 1)), + UseCaseError(NoBalance) + ); + // Instantiate a contract with balance. let addr = instantiate( "../../pop-api/examples/fungibles/target/ink/fungibles.wasm", INIT_VALUE, vec![1], ); - create_asset(ASSET_ID, ALICE, 1); + create_asset(ALICE, ASSET_ID, 1); + // Asset ID is already taken. assert_eq!( - decoded::(create(addr.clone(), ASSET_ID, BOB, 1)), - FungiblesError::InUse + decoded::(create(addr.clone(), ASSET_ID, BOB, 1)), + UseCaseError(InUse) ); + // The minimal balance for an asset must be non zero. assert_eq!( - decoded::(create(addr.clone(), new_asset, BOB, 0)), - FungiblesError::MinBalanceZero + decoded::(create(addr.clone(), new_asset, BOB, 0)), + UseCaseError(MinBalanceZero) ); - assert!(!create(addr.clone(), new_asset, BOB, 1).did_revert(), "Contract reverted!"); + let result = create(addr.clone(), new_asset, BOB, 1); + assert!(!result.did_revert(), "Contract reverted!"); }); } @@ -318,17 +317,12 @@ fn set_metadata_works() { vec![], ); - create_asset(ASSET_ID, addr.clone(), 1); - + create_asset(addr.clone(), ASSET_ID, 1); let result = set_metadata(addr.clone(), ASSET_ID, vec![12], vec![12], 12); assert!(!result.did_revert(), "Contract reverted!"); }); } -// todo: errors: -// - TokenErrors -// - Arithmetic -// - https://github.com/paritytech/polkadot-sdk/blob/3977f389cce4a00fd7100f95262e0563622b9aa4/substrate/frame/assets/src/functions.rs#L125 #[test] #[ignore] fn transfer_from_mint_works() { @@ -341,20 +335,15 @@ fn transfer_from_mint_works() { ); let amount: Balance = 100 * UNIT; + // Asset does not exist. assert_eq!( - decoded::(transfer_from( - addr.clone(), - 1, - None, - Some(BOB), - amount, - &[0u8] - )), - FungiblesError::Unknown + decoded::(transfer_from(addr.clone(), 1, None, Some(BOB), amount, &[0u8])), + Token(UnknownAsset) ); - let asset = create_asset(1, ALICE, 2); + let asset = create_asset(ALICE, 1, 2); + // Minting can only be done by the owner. assert_eq!( - decoded::(transfer_from( + decoded::(transfer_from( addr.clone(), asset, None, @@ -362,23 +351,18 @@ fn transfer_from_mint_works() { amount, &[0u8] )), - FungiblesError::NoPermission + UseCaseError(NoPermission) ); + // Minimum balance of an asset can not be zero. assert_eq!( - decoded::(transfer_from( - addr.clone(), - asset, - None, - Some(BOB), - 1, - &[0u8] - )), - FungiblesError::BelowMinimum + decoded::(transfer_from(addr.clone(), asset, None, Some(BOB), 1, &[0u8])), + Token(BelowMinimum) ); - let asset = create_asset(2, addr.clone(), 2); + let asset = create_asset(addr.clone(), 2, 2); + // Asset is not live, i.e. frozen or being destroyed. freeze_asset(asset, addr.clone()); assert_eq!( - decoded::(transfer_from( + decoded::(transfer_from( addr.clone(), asset, None, @@ -386,17 +370,31 @@ fn transfer_from_mint_works() { amount, &[0u8] )), - FungiblesError::AssetNotLive + UseCaseError(AssetNotLive) ); thaw_asset(asset, addr.clone()); + // Successful mint. let bob_balance_before_mint = Assets::balance(asset, &BOB); let result = transfer_from(addr.clone(), asset, None, Some(BOB), amount, &[0u8]); assert!(!result.did_revert(), "Contract reverted!"); let bob_balance_after_mint = Assets::balance(asset, &BOB); assert_eq!(bob_balance_after_mint, bob_balance_before_mint + amount); + // Can not mint more tokens than Balance::MAX. + assert_eq!( + decoded::(transfer_from( + addr.clone(), + asset, + None, + Some(BOB), + Balance::MAX, + &[0u8] + )), + Arithmetic(Overflow) + ); + // Asset is not live, i.e. frozen or being destroyed. start_destroy_asset(asset, addr.clone()); assert_eq!( - decoded::(transfer_from( + decoded::(transfer_from( addr.clone(), asset, None, @@ -404,17 +402,15 @@ fn transfer_from_mint_works() { amount, &[0u8] )), - FungiblesError::AssetNotLive + UseCaseError(AssetNotLive) ); }); } // Todo: error: -// - Frozen: account is frozen, who do you freeze an account? // - https://github.com/paritytech/polkadot-sdk/blob/2460cddf57660a88844d201f769eb17a7accce5a/substrate/frame/assets/src/functions.rs#L161 // - ArithmeticError: Underflow, Overflow // - https://github.com/paritytech/polkadot-sdk/blob/master/substrate/frame/assets/src/functions.rs#L125 -// - #[test] #[ignore] fn transfer_works() { @@ -427,35 +423,46 @@ fn transfer_works() { ); let amount: Balance = 100 * UNIT; + // Asset does not exist. assert_eq!( - decoded::(transfer(addr.clone(), 1, BOB, amount,)), - FungiblesError::Unknown + decoded::(transfer(addr.clone(), 1, BOB, amount,)), + UseCaseError(Unknown) ); - let asset = create_asset_and_mint_to(1, ALICE, addr.clone(), amount); + // Create asset with Alice as owner and mint `amount` to contract address. + let asset = create_asset_and_mint_to(ALICE, 1, addr.clone(), amount); + // Asset is not live, i.e. frozen or being destroyed. freeze_asset(asset, ALICE); assert_eq!( - decoded::(transfer(addr.clone(), asset, BOB, amount,)), - FungiblesError::AssetNotLive + decoded::(transfer(addr.clone(), asset, BOB, amount,)), + UseCaseError(AssetNotLive) ); thaw_asset(asset, ALICE); + // Not enough balance. assert_eq!( - decoded::(transfer(addr.clone(), asset, BOB, amount + 1 * UNIT)), - FungiblesError::InsufficientBalance + decoded::(transfer(addr.clone(), asset, BOB, amount + 1 * UNIT)), + UseCaseError(InsufficientBalance) ); - // Errors due to ED. Could be Belowminimum + // Not enough balance due to ED. assert_eq!( - decoded::(transfer(addr.clone(), asset, BOB, amount)), - FungiblesError::InsufficientBalance + decoded::(transfer(addr.clone(), asset, BOB, amount)), + UseCaseError(InsufficientBalance) ); + // Successful transfer. let bob_balance_before_mint = Assets::balance(asset, &BOB); let result = transfer(addr.clone(), asset, BOB, amount / 2); assert!(!result.did_revert(), "Contract reverted!"); let bob_balance_after_mint = Assets::balance(asset, &BOB); assert_eq!(bob_balance_after_mint, bob_balance_before_mint + amount / 2); + // Transfer asset to account that does not exist. + assert_eq!( + decoded::(transfer(addr.clone(), asset, FERDIE, amount / 4)), + Token(CannotCreate) + ); + // Asset is not live, i.e. frozen or being destroyed. start_destroy_asset(asset, ALICE); assert_eq!( - decoded::(transfer(addr.clone(), asset, BOB, amount / 4)), - FungiblesError::AssetNotLive + decoded::(transfer(addr.clone(), asset, BOB, amount / 4)), + UseCaseError(AssetNotLive) ); }); } diff --git a/runtime/devnet/src/tests/mod.rs b/runtime/devnet/src/tests/mod.rs new file mode 100644 index 00000000..c13030a3 --- /dev/null +++ b/runtime/devnet/src/tests/mod.rs @@ -0,0 +1,262 @@ +#![cfg(test)] + +use crate::{ + config::assets::TrustBackedAssetsInstance, Assets, Contracts, Runtime, RuntimeOrigin, System, + Weight, UNIT, +}; +use codec::{Decode, Encode}; +use frame_support::traits::fungibles::{approvals::Inspect as ApprovalInspect, Inspect}; +use frame_system::Config; +use pallet_contracts::{Code, CollectEvents, Determinism, ExecReturnValue}; +use pop_api::error::{ArithmeticError, PopApiError, TokenError, TransactionalError}; +use sp_runtime::{traits::Hash, AccountId32, BuildStorage, DispatchError}; + +mod local_fungibles; + +type Balance = u128; +type AssetId = u32; +const DEBUG_OUTPUT: pallet_contracts::DebugInfo = pallet_contracts::DebugInfo::UnsafeDebug; + +const ALICE: AccountId32 = AccountId32::new([1_u8; 32]); +const BOB: AccountId32 = AccountId32::new([2_u8; 32]); +// FERDIE has no initial balance. +const FERDIE: AccountId32 = AccountId32::new([3_u8; 32]); +const INIT_AMOUNT: Balance = 100_000_000 * UNIT; +const INIT_VALUE: Balance = 100 * UNIT; +const GAS_LIMIT: Weight = Weight::from_parts(100_000_000_000, 3 * 1024 * 1024); + +fn new_test_ext() -> sp_io::TestExternalities { + let mut t = frame_system::GenesisConfig::::default() + .build_storage() + .expect("Frame system builds valid default genesis config"); + + pallet_balances::GenesisConfig:: { + balances: vec![(ALICE, INIT_AMOUNT), (BOB, INIT_AMOUNT)], + } + .assimilate_storage(&mut t) + .expect("Pallet balances storage can be assimilated"); + + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| System::set_block_number(1)); + ext +} + +fn load_wasm_module(path: &str) -> std::io::Result<(Vec, ::Output)> +where + T: frame_system::Config, +{ + let wasm_binary = std::fs::read(path)?; + let code_hash = T::Hashing::hash(&wasm_binary); + Ok((wasm_binary, code_hash)) +} + +fn function_selector(name: &str) -> Vec { + let hash = sp_io::hashing::blake2_256(name.as_bytes()); + [hash[0..4].to_vec()].concat() +} + +fn do_bare_call( + addr: AccountId32, + input: Vec, + value: u128, +) -> Result { + let result = Contracts::bare_call( + ALICE, + addr.into(), + value.into(), + GAS_LIMIT, + None, + input, + DEBUG_OUTPUT, + CollectEvents::Skip, + Determinism::Enforced, + ); + log::debug!("Contract debug buffer - {:?}", String::from_utf8(result.debug_message.clone())); + log::debug!("result: {:?}", result); + result.result +} + +// Deploy, instantiate and return contract address. +fn instantiate(contract: &str, init_value: u128, salt: Vec) -> AccountId32 { + let (wasm_binary, _) = + load_wasm_module::(contract).expect("could not read .wasm file"); + let result = Contracts::bare_instantiate( + ALICE, + init_value, + GAS_LIMIT, + None, + Code::Upload(wasm_binary), + function_selector("new"), + salt, + DEBUG_OUTPUT, + CollectEvents::Skip, + ) + .result + .unwrap(); + assert!(!result.result.did_revert(), "deploying contract reverted {:?}", result); + result.account_id +} + +pub fn get_pallet_index() -> u8 { + // Get the index of the pallet (module) + <::PalletInfo as frame_support::traits::PalletInfo>::index::() + .expect("Every active module has an index in the runtime; qed") as u8 +} + +#[test] +fn encoding_decoding_dispatch_error() { + use codec::{Decode, Encode}; + use sp_runtime::{ArithmeticError, DispatchError, ModuleError, TokenError}; + + new_test_ext().execute_with(|| { + let error = DispatchError::Module(ModuleError { + index: 255, + error: [2, 0, 0, 0], + message: Some("error message"), + }); + let encoded = error.encode(); + let decoded = DispatchError::decode(&mut &encoded[..]).unwrap(); + assert_eq!(encoded, vec![3, 255, 2, 0, 0, 0]); + assert_eq!( + decoded, + // `message` is skipped for encoding. + DispatchError::Module(ModuleError { index: 255, error: [2, 0, 0, 0], message: None }) + ); + println!("Encoded Module Error: {:?}", encoded); + + // Example pallet assets Error into ModuleError + let index = get_pallet_index::(); + let mut error = + pallet_assets::Error::NotFrozen::.encode(); + error.resize(sp_runtime::MAX_MODULE_ERROR_ENCODED_SIZE, 0); + let message = None; + let error = DispatchError::Module(ModuleError { + index, + error: TryInto::try_into(error).expect("should work"), + message, + }); + let encoded = error.encode(); + let decoded = DispatchError::decode(&mut &encoded[..]).unwrap(); + assert_eq!(encoded, vec![3, 52, 18, 0, 0, 0]); + assert_eq!( + decoded, + DispatchError::Module(ModuleError { index: 52, error: [18, 0, 0, 0], message: None }) + ); + println!("Encoded Module Error: {:?}", encoded); + + // Example DispatchError::Token + let error = DispatchError::Token(TokenError::UnknownAsset); + let encoded = error.encode(); + assert_eq!(encoded, vec![7, 4]); + println!("Encoded Token Error: {:?}", encoded); + + // Example DispatchError::Arithmetic + let error = DispatchError::Arithmetic(ArithmeticError::Overflow); + let encoded = error.encode(); + assert_eq!(encoded, vec![8, 1]); + println!("Encoded Arithmetic Error: {:?}", encoded); + }); +} + +#[test] +fn encoding_of_enum() { + use codec::{Decode, Encode}; + + // Comprehensive enum with all different type of variants. + #[derive(Debug, PartialEq, Encode, Decode)] + enum ComprehensiveEnum { + SimpleVariant, + DataVariant(u8), + NamedFields { w: u8 }, + NestedEnum(InnerEnum), + OptionVariant(Option), + VecVariant(Vec), + TupleVariant(u8, u8), + NestedStructVariant(NestedStruct), + NestedEnumStructVariant(NestedEnumStruct), + } + + #[derive(Debug, PartialEq, Encode, Decode)] + enum InnerEnum { + A, + B { inner_data: u8 }, + C(u8), + } + + #[derive(Debug, PartialEq, Encode, Decode)] + struct NestedStruct { + x: u8, + y: u8, + } + + #[derive(Debug, PartialEq, Encode, Decode)] + struct NestedEnumStruct { + inner_enum: InnerEnum, + } + + // Creating each possible variant for an enum. + let enum_simple = ComprehensiveEnum::SimpleVariant; + let enum_data = ComprehensiveEnum::DataVariant(42); + let enum_named = ComprehensiveEnum::NamedFields { w: 42 }; + let enum_nested = ComprehensiveEnum::NestedEnum(InnerEnum::B { inner_data: 42 }); + let enum_option = ComprehensiveEnum::OptionVariant(Some(42)); + let enum_vec = ComprehensiveEnum::VecVariant(vec![1, 2, 3, 4, 5]); + let enum_tuple = ComprehensiveEnum::TupleVariant(42, 42); + let enum_nested_struct = ComprehensiveEnum::NestedStructVariant(NestedStruct { x: 42, y: 42 }); + let enum_nested_enum_struct = ComprehensiveEnum::NestedEnumStructVariant(NestedEnumStruct { + inner_enum: InnerEnum::C(42), + }); + + // Encode and print each variant individually to see their encoded values. + println!("{:?} -> {:?}", enum_simple, enum_simple.encode()); + println!("{:?} -> {:?}", enum_data, enum_data.encode()); + println!("{:?} -> {:?}", enum_named, enum_named.encode()); + println!("{:?} -> {:?}", enum_nested, enum_nested.encode()); + println!("{:?} -> {:?}", enum_option, enum_option.encode()); + println!("{:?} -> {:?}", enum_vec, enum_vec.encode()); + println!("{:?} -> {:?}", enum_tuple, enum_tuple.encode()); + println!("{:?} -> {:?}", enum_nested_struct, enum_nested_struct.encode()); + println!("{:?} -> {:?}", enum_nested_enum_struct, enum_nested_enum_struct.encode()); +} + +#[test] +fn dispatch_error_to_status_code_to_pop_api_error_works() { + // Create all the different `DispatchError` variants with its respective `PopApiError`. + let test_cases = vec![ + (DispatchError::CannotLookup, PopApiError::CannotLookup), + (DispatchError::BadOrigin, PopApiError::BadOrigin), + ( + DispatchError::Module(sp_runtime::ModuleError { + index: 1, + error: [2, 0, 0, 0], + message: Some("hallo"), + }), + PopApiError::Module { index: 1, error: 2 }, + ), + (DispatchError::ConsumerRemaining, PopApiError::ConsumerRemaining), + (DispatchError::NoProviders, PopApiError::NoProviders), + (DispatchError::TooManyConsumers, PopApiError::TooManyConsumers), + ( + DispatchError::Token(sp_runtime::TokenError::FundsUnavailable), + PopApiError::Token(TokenError::FundsUnavailable), + ), + ( + DispatchError::Arithmetic(sp_runtime::ArithmeticError::Overflow), + PopApiError::Arithmetic(ArithmeticError::Overflow), + ), + ( + DispatchError::Transactional(sp_runtime::TransactionalError::LimitReached), + PopApiError::Transactional(TransactionalError::LimitReached), + ), + (DispatchError::Exhausted, PopApiError::Exhausted), + (DispatchError::Corruption, PopApiError::Corruption), + (DispatchError::Unavailable, PopApiError::Unavailable), + (DispatchError::RootNotAllowed, PopApiError::RootNotAllowed), + ]; + for (error, pop_api_error) in test_cases { + // Show that the encoding and decoding of the PopApiError <> u32 (status code) works. + let status_code = crate::extensions::convert_to_status_code(error); + let error = pop_api::error::convert_to_pop_api_error(status_code); + assert_eq!(pop_api_error, error,); + } +}