From 5c04026829e87a0f66bfc621e3ccf48e2706db80 Mon Sep 17 00:00:00 2001 From: nathan gd Date: Tue, 14 Jun 2022 14:54:12 +0200 Subject: [PATCH 1/9] first build ideas --- Cargo.lock | 2733 ++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 40 + src/lib.rs | 192 ++++ src/types.rs | 29 + 4 files changed, 2994 insertions(+) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/lib.rs create mode 100644 src/types.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..a0d95bc --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2733 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.7", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" + +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "async-trait" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base58" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitvec" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1489fcb93a5bb47da0462ca93ad252ad6af2145cce58d10d46a83931ba9f016b" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" +dependencies = [ + "digest 0.10.3", +] + +[[package]] +name = "blake2-rfc" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +dependencies = [ + "arrayvec 0.4.12", + "constant_time_eq", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.5", +] + +[[package]] +name = "block-buffer" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +dependencies = [ + "generic-array 0.14.5", +] + +[[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 = "bumpalo" +version = "3.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" + +[[package]] +name = "byte-slice-cast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "winapi", +] + +[[package]] +name = "const-oid" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +dependencies = [ + "generic-array 0.14.5", + "rand_core 0.6.3", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +dependencies = [ + "generic-array 0.14.5", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.5", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array 0.14.5", + "subtle", +] + +[[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", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "der" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +dependencies = [ + "const-oid", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.5", +] + +[[package]] +name = "digest" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +dependencies = [ + "block-buffer 0.10.2", + "crypto-common", + "subtle", +] + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[package]] +name = "dyn-clonable" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" +dependencies = [ + "dyn-clonable-impl", + "dyn-clone", +] + +[[package]] +name = "dyn-clonable-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dyn-clone" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" + +[[package]] +name = "ecdsa" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + +[[package]] +name = "ed25519" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +dependencies = [ + "signature", +] + +[[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", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "elliptic-curve" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "ff", + "generic-array 0.14.5", + "group", + "rand_core 0.6.3", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "environmental" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797" + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "ff" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" +dependencies = [ + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "fixed-hash" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "frame-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "frame-support", + "frame-system", + "linregress", + "log", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-io", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "sp-storage", +] + +[[package]] +name = "frame-metadata" +version = "15.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df6bb8542ef006ef0de09a5c4420787d79823c0ed7924225822362fd2bf2ff2d" +dependencies = [ + "cfg-if", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "frame-support" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "bitflags", + "frame-metadata", + "frame-support-procedural", + "impl-trait-for-tuples", + "k256", + "log", + "once_cell", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-core", + "sp-core-hashing-proc-macro", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-state-machine", + "sp-std", + "sp-tracing", + "tt-call", +] + +[[package]] +name = "frame-support-procedural" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "Inflector", + "frame-support-procedural-tools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-support-procedural-tools" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "frame-support-procedural-tools-derive", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "frame-system" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "frame-support", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-version", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" + +[[package]] +name = "futures-executor" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" + +[[package]] +name = "futures-macro" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" + +[[package]] +name = "futures-task" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" + +[[package]] +name = "futures-util" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" + +[[package]] +name = "group" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +dependencies = [ + "ff", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "hash-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" +dependencies = [ + "ahash", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.5", + "hmac 0.8.1", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "itoa" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" + +[[package]] +name = "js-sys" +version = "0.3.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sec1", +] + +[[package]] +name = "keccak" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + +[[package]] +name = "libm" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db" + +[[package]] +name = "libsecp256k1" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0452aac8bab02242429380e9b2f94ea20cea2b37e2c1777a1358799bbe97f37" +dependencies = [ + "arrayref", + "base64", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "linregress" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6c601a85f5ecd1aba625247bca0031585fb1c446461b142878a16f8245ddeb8" +dependencies = [ + "nalgebra", + "statrs", +] + +[[package]] +name = "lock_api" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "matrixmultiply" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +dependencies = [ + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memory-db" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6566c70c1016f525ced45d7b7f97730a2bafb037c788211d0c186ef5b2189f0a" +dependencies = [ + "hash-db", + "hashbrown", + "parity-util-mem", +] + +[[package]] +name = "memory_units" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" + +[[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 = "miniz_oxide" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +dependencies = [ + "adler", +] + +[[package]] +name = "nalgebra" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "462fffe4002f4f2e1f6a9dcf12cc1a6fc0e15989014efc02a941d3e0f5dc2120" +dependencies = [ + "approx", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational 0.4.0", + "num-traits", + "rand 0.8.5", + "rand_distr", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fbc387afefefd5e9e39493299f3069e14a140dd34dc19b4c1c1a8fddb6a790" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" +dependencies = [ + "arrayvec 0.4.12", + "itoa 0.4.8", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.28.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "pallet-template" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", +] + +[[package]] +name = "parity-scale-codec" +version = "3.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" +dependencies = [ + "arrayvec 0.7.2", + "bitvec", + "byte-slice-cast", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "parity-util-mem" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c32561d248d352148124f036cac253a644685a21dc9fea383eb4907d7bd35a8f" +dependencies = [ + "cfg-if", + "hashbrown", + "impl-trait-for-tuples", + "parity-util-mem-derive", + "parking_lot", + "primitive-types", + "winapi", +] + +[[package]] +name = "parity-util-mem-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" +dependencies = [ + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "parity-wasm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + +[[package]] +name = "paste" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" + +[[package]] +name = "pbkdf2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +dependencies = [ + "crypto-mac 0.8.0", +] + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "primitive-types" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "scale-info", + "uint", +] + +[[package]] +name = "proc-macro-crate" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +dependencies = [ + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +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", + "rand_pcg", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.7", +] + +[[package]] +name = "rand_distr" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +dependencies = [ + "num-traits", + "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]] +name = "rand_pcg" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "redox_syscall" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ref-cast" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "685d58625b6c2b83e4cc88a27c4bf65adb7b6b16dbdc413e515c9405b47432ab" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a043824e29c94169374ac5183ac0ed43f5724dc4556b19568007486bd840fa1f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "regex" +version = "1.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" + +[[package]] +name = "rfc6979" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +dependencies = [ + "crypto-bigint", + "hmac 0.11.0", + "zeroize", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "ryu" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" + +[[package]] +name = "scale-info" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c46be926081c9f4dd5dd9b6f1d3e3229f2360bc6502dd8836f84a93b7c75e99a" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e334bb10a245e28e5fd755cabcafd96cfcd167c99ae63a46924ca8d8703a3c" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[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", + "rand 0.7.3", + "rand_core 0.5.1", + "sha2 0.8.2", + "subtle", + "zeroize", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der", + "generic-array 0.14.5", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c42e6f1735c5f00f51e43e28d6634141f2bcad10931b2609ddd74a86d751260" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957da2573cde917463ece3570eab4a0b3f19de6f1646cde62e6fd3868f566036" +dependencies = [ + "cc", +] + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "serde" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +dependencies = [ + "itoa 1.0.2", + "ryu", + "serde", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.3", +] + +[[package]] +name = "sha3" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" +dependencies = [ + "digest 0.10.3", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signature" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +dependencies = [ + "digest 0.9.0", + "rand_core 0.6.3", +] + +[[package]] +name = "simba" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e82063457853d00243beda9952e910b82593e4b07ae9f721b9278a99a0d3d5c" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", +] + +[[package]] +name = "slab" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + +[[package]] +name = "sp-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "sp-api-proc-macro", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-version", + "thiserror", +] + +[[package]] +name = "sp-api-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "blake2", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-application-crypto" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-arithmetic" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-debug-derive", + "sp-std", + "static_assertions", +] + +[[package]] +name = "sp-core" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "base58", + "bitflags", + "blake2-rfc", + "byteorder", + "dyn-clonable", + "ed25519-dalek", + "futures", + "hash-db", + "hash256-std-hasher", + "hex", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "merlin", + "num-traits", + "parity-scale-codec", + "parity-util-mem", + "parking_lot", + "primitive-types", + "rand 0.7.3", + "regex", + "scale-info", + "schnorrkel", + "secp256k1", + "secrecy", + "serde", + "sp-core-hashing", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tiny-bip39", + "wasmi", + "zeroize", +] + +[[package]] +name = "sp-core-hashing" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "blake2", + "byteorder", + "digest 0.10.3", + "sha2 0.10.2", + "sha3", + "sp-std", + "twox-hash", +] + +[[package]] +name = "sp-core-hashing-proc-macro" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "proc-macro2", + "quote", + "sp-core-hashing", + "syn", +] + +[[package]] +name = "sp-debug-derive" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-externalities" +version = "0.12.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-std", + "sp-storage", +] + +[[package]] +name = "sp-inherents" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "async-trait", + "impl-trait-for-tuples", + "parity-scale-codec", + "sp-core", + "sp-runtime", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-io" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "futures", + "hash-db", + "libsecp256k1", + "log", + "parity-scale-codec", + "parking_lot", + "secp256k1", + "sp-core", + "sp-externalities", + "sp-keystore", + "sp-runtime-interface", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-trie", + "sp-wasm-interface", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-keystore" +version = "0.12.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "async-trait", + "futures", + "merlin", + "parity-scale-codec", + "parking_lot", + "schnorrkel", + "sp-core", + "sp-externalities", + "thiserror", +] + +[[package]] +name = "sp-panic-handler" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "backtrace", + "lazy_static", + "regex", +] + +[[package]] +name = "sp-runtime" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "parity-util-mem", + "paste", + "rand 0.7.3", + "scale-info", + "serde", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-runtime-interface" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +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", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "Inflector", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-staking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-state-machine" +version = "0.12.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "hash-db", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot", + "rand 0.7.3", + "smallvec", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-std", + "sp-trie", + "thiserror", + "tracing", + "trie-root", +] + +[[package]] +name = "sp-std" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" + +[[package]] +name = "sp-storage" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "sp-tracing" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "parity-scale-codec", + "sp-std", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "sp-trie" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "hash-db", + "memory-db", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-std", + "thiserror", + "trie-db", + "trie-root", +] + +[[package]] +name = "sp-version" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "scale-info", + "serde", + "sp-core-hashing-proc-macro", + "sp-runtime", + "sp-std", + "sp-version-proc-macro", + "thiserror", +] + +[[package]] +name = "sp-version-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "parity-scale-codec", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sp-wasm-interface" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-std", + "wasmi", +] + +[[package]] +name = "ss58-registry" +version = "1.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d804c8d48aeab838be31570866fce1130d275b563d49af08b4927a0bd561e7c" +dependencies = [ + "Inflector", + "num-format", + "proc-macro2", + "quote", + "serde", + "serde_json", + "unicode-xid", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "statrs" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05bdbb8e4e78216a85785a85d3ec3183144f98d0097b9281802c019bb07a6f05" +dependencies = [ + "approx", + "lazy_static", + "nalgebra", + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "substrate-bip39" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +dependencies = [ + "hmac 0.11.0", + "pbkdf2 0.8.0", + "schnorrkel", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "thiserror" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tiny-bip39" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +dependencies = [ + "anyhow", + "hmac 0.8.1", + "once_cell", + "pbkdf2 0.4.0", + "rand 0.7.3", + "rustc-hash", + "sha2 0.9.9", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc6b8ad3567499f98a1db7a752b07a7c8c7c7c34c332ec00effb2b0027974b7c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7709595b8878a4965ce5e87ebf880a7d39c9afc6837721b21a5a816a8117d921" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "trie-db" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83" +dependencies = [ + "hash-db", + "hashbrown", + "log", + "rustc-hex", + "smallvec", +] + +[[package]] +name = "trie-root" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a36c5ca3911ed3c9a5416ee6c679042064b93fc637ded67e25f92e68d783891" +dependencies = [ + "hash-db", +] + +[[package]] +name = "tt-call" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "digest 0.10.3", + "rand 0.8.5", + "static_assertions", +] + +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "uint" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-ident" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" + +[[package]] +name = "wasmi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca00c5147c319a8ec91ec1a0edbec31e566ce2c9cc93b3f9bb86a9efd0eb795d" +dependencies = [ + "downcast-rs", + "libc", + "memory_units", + "num-rational 0.2.4", + "num-traits", + "parity-wasm", + "wasmi-validation", +] + +[[package]] +name = "wasmi-validation" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "165343ecd6c018fc09ebcae280752702c9a2ef3e6f8d02f1cfcbdb53ef6d7937" +dependencies = [ + "parity-wasm", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "wyz" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +dependencies = [ + "tap", +] + +[[package]] +name = "zeroize" +version = "1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94693807d016b2f2d2e14420eb3bfcca689311ff775dcf113d74ea624b7cdf07" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b1d657c --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "pallet-template" +version = "4.0.0-dev" +description = "FRAME pallet template for defining custom runtime logic." +authors = ["Substrate DevHub "] +homepage = "https://substrate.io/" +edition = "2021" +license = "Unlicense" +publish = false +repository = "https://github.com/substrate-developer-hub/substrate-node-template/" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [ + "derive", +] } +scale-info = { version = "2.0.1", default-features = false, features = ["derive"] } +frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23"} +frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23" } +frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23", optional = true } + +[dev-dependencies] +sp-core = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23" } +sp-io = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23" } +sp-runtime = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23" } + +[features] +default = ["std"] +std = [ + "codec/std", + "scale-info/std", + "frame-support/std", + "frame-system/std", + "frame-benchmarking/std", +] + +runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] +try-runtime = ["frame-support/try-runtime"] diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..3c338d3 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,192 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +pub use pallet::*; + +pub mod types; +pub use types::*; + +pub use frame_support::traits::tokens::currency::{Currency, ReservableCurrency}; + +// #[cfg(test)] +// mod mock; +// +// #[cfg(test)] +// mod tests; +// +// #[cfg(feature = "runtime-benchmarks")] +// mod benchmarking; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config { + /// Because this pallet emits events, it depends on the runtime's definition of an event. + type Event: From> + IsType<::Event>; + /// The trait to manage funds + type Currency: Currency + ReservableCurrency; + /// The maximum amount of metadata + #[pallet::constant] + type MaxMetadataLength: Get; + } + + #[pallet::pallet] + #[pallet::generate_store(pub(super) trait Store)] + pub struct Pallet(_); + + #[pallet::storage] + #[pallet::getter(fn subscription_plans)] + pub type SubscriptionPlans = + StorageMap<_, Blake2_256, Nonce, SubscriptionPlan, OptionQuery>; + + #[pallet::storage] + #[pallet::getter(fn plan_nonce)] + pub type PlanNonce = StorageValue<_, Nonce, ValueQuery>; + + // actually the best solution rn because we dont need that much key ? idk + #[pallet::storage] + #[pallet::getter(fn subscriptions)] + pub type Subscriptions = + StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; + + + //// OPTION WITH A LOT OF STORAGE + /// way better for the execution, but some constraints + /// + /// - check if a subscription is running = 4 reads, not cool // oooor maybe 2 read, get the + /// recurence in the plans, and get in the right storage ? + /// - we can have ONLY 4 types of recurence (or we need another storage for each recurence) + + // pub type DailySubscriptions = + // StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; + // pub type WeeklySubscriptions = + // StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; + // pub type MonthlySubscriptions = + // StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; + // pub type AnnualySubscriptions = + // StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; + // + + // might be a good way too but more complicated idk + // first solution simpler atm + // + // #[pallet::storage] + // #[pallet::getter(fn subscriptions)] + // pub type Subscriptions = + // StorageDoubleMap< + // _, + // Blake2_256, + // AccountId, + // Blake2_256, + // Nonce, + // Subscription, + // OptionQuery, + // >; + // + // easier for execution ? + // + // pub type Subscriptions = + // StorageDoubleMap< + // _, + // Blake2_256, + // AccountId, + // Blake2_256, + // Nonce, + // Recurence, // or block_number or idk + // OptionQuery, + // >; + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + SomethingStored(u32, T::AccountId), + } + + #[pallet::error] + pub enum Error { + NoneValue, + } + + // this example comes from treasury + // + // #[pallet::hooks] + // impl, I: 'static> Hooks> for Pallet { + // /// # + // /// - Complexity: `O(A)` where `A` is the number of approvals + // /// - Db reads and writes: `Approvals`, `pot account data` + // /// - Db reads and writes per approval: `Proposals`, `proposer account data`, `beneficiary + // /// account data` + // /// - The weight is overestimated if some approvals got missed. + // /// # + // fn on_initialize(n: T::BlockNumber) -> Weight { + // // Check to see if we should spend some funds! + // if (n % T::SpendPeriod::get()).is_zero() { + // Self::spend_funds() + // } else { + // 0 + // } + // } + // } + // + // this is OUR hook + // #[pallet::hooks] + // impl Hooks> for Pallet { + // fn on_initialize(n: T::BlockNumber) -> Weight { + // //// prop 1: + // - loop over all subscriptions (.iter_values()) + // - check if the subscription shoud be taken + // - take it + // + // //// prop 2: (2nd key: ) + // + // } + // } + + #[pallet::call] + impl Pallet { + #[pallet::weight(1)] + pub fn create_subsciption_plan(origin: OriginFor, plan: SubscriptionPlan) -> DispatchResult { + // maybe make a new function for Subscription, so `plan` is already valid 100% + // + // + // todo: + // push the plan to the storage + Ok(()) + } + + #[pallet::weight(1)] + pub fn another_create_subsciption_plan(origin: OriginFor, /* data of the struct so we can verify */) -> DispatchResult { + // better ? 5 parameters but we can check, better option if no plan.new() function + // + // + // todo: + // push the plan to the storage + Ok(()) + } + + #[pallet::weight(1)] + pub fn delete_subsciption_plan(origin: OriginFor, plan_id: Nonce) -> DispatchResult { + // better ? 5 parameters but we can check, better option if no plan.new() function + // + // + // todo: + // push the plan to the storage + Ok(()) + } + + #[pallet::weight(1)] + pub fn subscribe(origin: OriginFor, plan_id: Nonce) -> DispatchResult { + // todo: + // check if plan exist + // if yes, push the nonce to the subscription storage + } + + #[pallet::weight(1)] + pub fn unsubscribe(origin: OriginFor, plan_id: Nonce) -> DispatchResult { + //kinda obv + } + } +} diff --git a/src/types.rs b/src/types.rs new file mode 100644 index 0000000..4d3946e --- /dev/null +++ b/src/types.rs @@ -0,0 +1,29 @@ +use crate::*; +use scale_info::TypeInfo; +use codec::{Decode, Encode}; +use frame_support::{ + storage::bounded_vec::BoundedVec, + pallet_prelude::MaxEncodedLen, +}; + +pub type BalanceOf = + <::Currency as Currency<::AccountId>>::Balance; + +pub type Nonce = u64; + +#[derive(Clone, Encode, Decode, TypeInfo, Debug, MaxEncodedLen)] +pub enum Frequency { + Daily, + Weekly, + Monthly, + Annualy, +} + +#[derive(Clone, Encode, Decode, TypeInfo, Debug, MaxEncodedLen)] +#[codec(mel_bound())] +pub struct SubscriptionPlan { + pub frequency: Frequency, + pub amount: BalanceOf, + pub beneficiary: T::AccountId, + pub metadata: BoundedVec +} From 1f5ac65e37801450a99f000f813a43291275c059 Mon Sep 17 00:00:00 2001 From: nathan gd Date: Tue, 14 Jun 2022 16:41:02 +0200 Subject: [PATCH 2/9] updated with what we'll show --- src/lib.rs | 183 +++++++++++++++++++-------------------------------- src/types.rs | 36 +++++----- 2 files changed, 87 insertions(+), 132 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3c338d3..384a2e6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,76 +28,31 @@ pub mod pallet { type Event: From> + IsType<::Event>; /// The trait to manage funds type Currency: Currency + ReservableCurrency; - /// The maximum amount of metadata - #[pallet::constant] - type MaxMetadataLength: Get; + /// The maximum amount of metadata + #[pallet::constant] + type MaxMetadataLength: Get; } #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] pub struct Pallet(_); + #[pallet::storage] + #[pallet::getter(fn plan_nonce)] + pub type PlanNonce = StorageValue<_, PlanId, ValueQuery>; + #[pallet::storage] #[pallet::getter(fn subscription_plans)] - pub type SubscriptionPlans = - StorageMap<_, Blake2_256, Nonce, SubscriptionPlan, OptionQuery>; + pub type Plans = StorageMap<_, Blake2_256, PlanId, Subscription, OptionQuery>; #[pallet::storage] - #[pallet::getter(fn plan_nonce)] - pub type PlanNonce = StorageValue<_, Nonce, ValueQuery>; + #[pallet::getter(fn subscription_nonce)] + pub type SubscriptionNonce = StorageValue<_, SubscriptionId, ValueQuery>; - // actually the best solution rn because we dont need that much key ? idk #[pallet::storage] #[pallet::getter(fn subscriptions)] - pub type Subscriptions = - StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; - - - //// OPTION WITH A LOT OF STORAGE - /// way better for the execution, but some constraints - /// - /// - check if a subscription is running = 4 reads, not cool // oooor maybe 2 read, get the - /// recurence in the plans, and get in the right storage ? - /// - we can have ONLY 4 types of recurence (or we need another storage for each recurence) - - // pub type DailySubscriptions = - // StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; - // pub type WeeklySubscriptions = - // StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; - // pub type MonthlySubscriptions = - // StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; - // pub type AnnualySubscriptions = - // StorageMap<_, Blake2_256, Nonce, Subscription, OptionQuery>; - // - - // might be a good way too but more complicated idk - // first solution simpler atm - // - // #[pallet::storage] - // #[pallet::getter(fn subscriptions)] - // pub type Subscriptions = - // StorageDoubleMap< - // _, - // Blake2_256, - // AccountId, - // Blake2_256, - // Nonce, - // Subscription, - // OptionQuery, - // >; - // - // easier for execution ? - // - // pub type Subscriptions = - // StorageDoubleMap< - // _, - // Blake2_256, - // AccountId, - // Blake2_256, - // Nonce, - // Recurence, // or block_number or idk - // OptionQuery, - // >; + pub type Subscriptions = + StorageMap<_, Blake2_256, SubscriptionId, Subscription, OptionQuery>; #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] @@ -110,83 +65,79 @@ pub mod pallet { NoneValue, } - // this example comes from treasury - // - // #[pallet::hooks] - // impl, I: 'static> Hooks> for Pallet { - // /// # - // /// - Complexity: `O(A)` where `A` is the number of approvals - // /// - Db reads and writes: `Approvals`, `pot account data` - // /// - Db reads and writes per approval: `Proposals`, `proposer account data`, `beneficiary - // /// account data` - // /// - The weight is overestimated if some approvals got missed. - // /// # - // fn on_initialize(n: T::BlockNumber) -> Weight { - // // Check to see if we should spend some funds! - // if (n % T::SpendPeriod::get()).is_zero() { - // Self::spend_funds() - // } else { - // 0 - // } - // } - // } - // - // this is OUR hook - // #[pallet::hooks] - // impl Hooks> for Pallet { - // fn on_initialize(n: T::BlockNumber) -> Weight { - // //// prop 1: - // - loop over all subscriptions (.iter_values()) - // - check if the subscription shoud be taken - // - take it - // - // //// prop 2: (2nd key: ) - // - // } - // } + #[pallet::hooks] + impl Hooks> for Pallet { + fn on_initialize(n: T::BlockNumber) -> Weight { + //// prop 1: + // - loop over all subscriptions (.iter_values()) + // - check if the subscription shoud be taken + // - take it + + //// prop 2: (2nd key: ) + 0 + } + } #[pallet::call] impl Pallet { #[pallet::weight(1)] - pub fn create_subsciption_plan(origin: OriginFor, plan: SubscriptionPlan) -> DispatchResult { - // maybe make a new function for Subscription, so `plan` is already valid 100% + pub fn create_subsciption_plan( + origin: OriginFor, + plan: Subscription, + ) -> DispatchResult { + // maybe make a new function for Subscription, so `plan` is already valid 100% + // + // + // todo: + // signed ? + // valid plan ? // - // - // todo: - // push the plan to the storage + // -> push the plan to the storage Ok(()) } #[pallet::weight(1)] - pub fn another_create_subsciption_plan(origin: OriginFor, /* data of the struct so we can verify */) -> DispatchResult { - // better ? 5 parameters but we can check, better option if no plan.new() function - // + pub fn delete_subsciption_plan(origin: OriginFor, plan_id: Nonce) -> DispatchResult { + // better ? 5 parameters but we can check, better option if no plan.new() function + // + // + // todo: + // signed ? + // plan exist ? // - // todo: - // push the plan to the storage + // -> remove the plan to the storage Ok(()) } #[pallet::weight(1)] - pub fn delete_subsciption_plan(origin: OriginFor, plan_id: Nonce) -> DispatchResult { - // better ? 5 parameters but we can check, better option if no plan.new() function + pub fn subscribe_to_plan(origin: OriginFor, plan_id: Nonce) -> DispatchResult { + // todo: + // signed ? + // plan exist ? // + // -> create entry in storage + Ok(()) + } + + #[pallet::weight(1)] + pub fn subscribe(origin: OriginFor, plan: Subscription) -> DispatchResult { + // todo: + // signed ? + // valid subscription ? // - // todo: - // push the plan to the storage + // -> create entry in storage Ok(()) } - #[pallet::weight(1)] - pub fn subscribe(origin: OriginFor, plan_id: Nonce) -> DispatchResult { - // todo: - // check if plan exist - // if yes, push the nonce to the subscription storage - } - - #[pallet::weight(1)] - pub fn unsubscribe(origin: OriginFor, plan_id: Nonce) -> DispatchResult { - //kinda obv - } + #[pallet::weight(1)] + pub fn unsubscribe(origin: OriginFor, other: T::AccountId) -> DispatchResult { + // signed by the subscriber ? + // yes -> subscriber is subscribed to other ? + // delete from storage + // no -> signed by beneficiary ? + // other is subscribed to beneficiary ? + // delete from storage + Ok(()) + } } } diff --git a/src/types.rs b/src/types.rs index 4d3946e..8f87f8a 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,29 +1,33 @@ use crate::*; use scale_info::TypeInfo; use codec::{Decode, Encode}; -use frame_support::{ - storage::bounded_vec::BoundedVec, - pallet_prelude::MaxEncodedLen, -}; +// use frame_support::{ +// // storage::bounded_vec::BoundedVec, +// pallet_prelude::MaxEncodedLen, +// }; pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; pub type Nonce = u64; +pub type PlanId = u64; +pub type SubscriptionId = u64; -#[derive(Clone, Encode, Decode, TypeInfo, Debug, MaxEncodedLen)] -pub enum Frequency { - Daily, - Weekly, - Monthly, - Annualy, -} +// #[derive(Clone, Encode, Decode, TypeInfo, Debug, MaxEncodedLen)] +// pub enum Frequency { +// Daily, +// Weekly, +// Monthly, +// Annualy, +// } -#[derive(Clone, Encode, Decode, TypeInfo, Debug, MaxEncodedLen)] -#[codec(mel_bound())] -pub struct SubscriptionPlan { - pub frequency: Frequency, +#[derive(Clone, Encode, Decode, TypeInfo, Debug)] +// #[codec(mel_bound())] +pub struct Subscription { + pub frequency: u32, // block number pub amount: BalanceOf, + pub remaining_payments: Option, pub beneficiary: T::AccountId, - pub metadata: BoundedVec + // for later + // pub metadata: BoundedVec } From 80d09bc814110f94e6944e4c746bf713c5798622 Mon Sep 17 00:00:00 2001 From: nathan gd Date: Thu, 16 Jun 2022 18:30:23 +0200 Subject: [PATCH 3/9] added the hook --- Cargo.toml | 2 + src/lib.rs | 139 +++++++++++++++++++++++++++----------- src/tests/hook.rs | 45 +++++++++++++ src/tests/mock.rs | 168 ++++++++++++++++++++++++++++++++++++++++++++++ src/tests/mod.rs | 3 + src/types.rs | 38 +++++------ 6 files changed, 333 insertions(+), 62 deletions(-) create mode 100644 src/tests/hook.rs create mode 100644 src/tests/mock.rs create mode 100644 src/tests/mod.rs diff --git a/Cargo.toml b/Cargo.toml index b1d657c..4b180bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,11 +25,13 @@ frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "h sp-core = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23" } sp-io = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23" } sp-runtime = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23" } +pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.23" } [features] default = ["std"] std = [ "codec/std", + "pallet-balances/std", "scale-info/std", "frame-support/std", "frame-system/std", diff --git a/src/lib.rs b/src/lib.rs index 384a2e6..5b2581e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,18 +1,24 @@ #![cfg_attr(not(feature = "std"), no_std)] +#![feature(drain_filter)] +#![allow(clippy::type_complexity)] pub use pallet::*; pub mod types; pub use types::*; -pub use frame_support::traits::tokens::currency::{Currency, ReservableCurrency}; +pub use frame_support::{ + storage::IterableStorageMap, + traits::tokens::{ + currency::{Currency, ReservableCurrency}, + ExistenceRequirement, + }, + ReversibleStorageHasher, +}; + +#[cfg(test)] +mod tests; -// #[cfg(test)] -// mod mock; -// -// #[cfg(test)] -// mod tests; -// // #[cfg(feature = "runtime-benchmarks")] // mod benchmarking; @@ -39,23 +45,39 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn plan_nonce)] - pub type PlanNonce = StorageValue<_, PlanId, ValueQuery>; + pub type PlanNonce = StorageValue<_, PlanId, ValueQuery>; #[pallet::storage] #[pallet::getter(fn subscription_plans)] - pub type Plans = StorageMap<_, Blake2_256, PlanId, Subscription, OptionQuery>; + pub type Plans = StorageMap< + _, + Blake2_256, + PlanId, + Subscription, T::AccountId>, + OptionQuery, + >; #[pallet::storage] #[pallet::getter(fn subscription_nonce)] - pub type SubscriptionNonce = StorageValue<_, SubscriptionId, ValueQuery>; + pub type SubscriptionNonce = StorageValue<_, SubscriptionId, ValueQuery>; + // the vector should ALWAYS be sorted from biggest to smallest block_number #[pallet::storage] + #[pallet::unbounded] #[pallet::getter(fn subscriptions)] - pub type Subscriptions = - StorageMap<_, Blake2_256, SubscriptionId, Subscription, OptionQuery>; + pub type Subscriptions = StorageValue< + _, + Vec<( + T::BlockNumber, + ( + Subscription, T::AccountId>, + T::AccountId, + ), + )>, + >; #[pallet::event] - #[pallet::generate_deposit(pub(super) fn deposit_event)] + // #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { SomethingStored(u32, T::AccountId), } @@ -68,13 +90,45 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(n: T::BlockNumber) -> Weight { - //// prop 1: - // - loop over all subscriptions (.iter_values()) - // - check if the subscription shoud be taken - // - take it - - //// prop 2: (2nd key: ) - 0 + let _weight = 0; + + let mut subs = unwrap_or_return!(Subscriptions::::get(), 0); // 1 read + let tmp = subs.clone(); + let (exec_block, (_, _)) = unwrap_or_return!(tmp.last(), 0); // 1 unwrap + if n != *exec_block { + return 0 + } + loop { + if let Some((b, (mut sub, account))) = subs.pop() { + if b == *exec_block { + if let Some(val) = sub.remaining_payments { + if val == 0 { + subs.pop(); + continue + } + } + if T::Currency::transfer( + &account, + &sub.beneficiary, + sub.amount, + ExistenceRequirement::AllowDeath, + ) + .is_err() + { + continue + } + sub.remaining_payments = sub.remaining_payments.map(|amount| amount - 1); + let new_block = n + sub.frequency; + let new_index = + subs.binary_search_by(|(b, _)| b.cmp(&new_block)).unwrap_or_else(|e| e); + subs.insert(new_index, (new_block, (sub.clone(), account.clone()))); + } + } + if (unwrap_or_return!(subs.last(), 0)).0 == *exec_block { + Subscriptions::::set(Some(subs)); + return 0 // WEIGHT + } + } } } @@ -82,61 +136,64 @@ pub mod pallet { impl Pallet { #[pallet::weight(1)] pub fn create_subsciption_plan( - origin: OriginFor, - plan: Subscription, + _origin: OriginFor, + _plan: Subscription, T::AccountId>, ) -> DispatchResult { // maybe make a new function for Subscription, so `plan` is already valid 100% // // // todo: - // signed ? - // valid plan ? - // + // signed ? + // valid plan ? + // // -> push the plan to the storage Ok(()) } #[pallet::weight(1)] - pub fn delete_subsciption_plan(origin: OriginFor, plan_id: Nonce) -> DispatchResult { + pub fn delete_subsciption_plan(_origin: OriginFor, _plan_id: Nonce) -> DispatchResult { // better ? 5 parameters but we can check, better option if no plan.new() function // // // todo: - // signed ? - // plan exist ? - // + // signed ? + // plan exist ? + // // -> remove the plan to the storage Ok(()) } #[pallet::weight(1)] - pub fn subscribe_to_plan(origin: OriginFor, plan_id: Nonce) -> DispatchResult { + pub fn subscribe_to_plan(_origin: OriginFor, _plan_id: Nonce) -> DispatchResult { // todo: // signed ? - // plan exist ? - // + // plan exist ? + // // -> create entry in storage Ok(()) } #[pallet::weight(1)] - pub fn subscribe(origin: OriginFor, plan: Subscription) -> DispatchResult { + pub fn subscribe( + _origin: OriginFor, + _plan: Subscription, T::AccountId>, + ) -> DispatchResult { // todo: // signed ? - // valid subscription ? - // + // valid subscription ? + // // -> create entry in storage Ok(()) } #[pallet::weight(1)] - pub fn unsubscribe(origin: OriginFor, other: T::AccountId) -> DispatchResult { + pub fn unsubscribe(_origin: OriginFor, _other: T::AccountId) -> DispatchResult { // signed by the subscriber ? - // yes -> subscriber is subscribed to other ? - // delete from storage - // no -> signed by beneficiary ? - // other is subscribed to beneficiary ? - // delete from storage + // yes -> subscriber is subscribed to other ? + // delete from storage + // no -> signed by beneficiary ? + // other is subscribed to beneficiary ? + // delete from storage Ok(()) } } diff --git a/src/tests/hook.rs b/src/tests/hook.rs new file mode 100644 index 0000000..5b23efc --- /dev/null +++ b/src/tests/hook.rs @@ -0,0 +1,45 @@ +use super::mock::*; +use frame_support::traits::OnInitialize; + +#[test] +fn working_subscription() { + ExtBuilder::default().balances(vec![]).build().execute_with(|| { + let _x = 10; + let _bob_balance = Balances::free_balance(BOB()); + let _alice_balance = Balances::free_balance(ALICE()); + + //TODO: make a subscription of x amount, that recur every 1 block, from ALICE() to BOB() + + >::on_initialize(1); + + //assert_eq!(Balances::free_balance(BOB()), bob_balance + _x); + //assert_eq!(Balances::free_balance(ALICE()), alice_balance - _x); + //TODO: check if the subscription is still running (should be OK) + }) +} + +#[test] +fn sub_last_occurence() { + ExtBuilder::default().balances(vec![]).build().execute_with(|| { + let _x = 10; + let _bob_balance = Balances::free_balance(BOB()); + let _alice_balance = Balances::free_balance(ALICE()); + + //TODO: make a subscription of x amount, that recur every 1 block, from ALICE() to BOB(). + // with remaining_payments = 1, this should only be executed once. + + >::on_initialize(1); + + //assert_eq!(Balances::free_balance(BOB()), bob_balance + _x); + //assert_eq!(Balances::free_balance(ALICE()), alice_balance - _x); + + //TODO: check if the subscription is still running (should be OK) + + >::on_initialize(2); + + //assert_eq!(Balances::free_balance(BOB()), bob_balance + _x); + //assert_eq!(Balances::free_balance(ALICE()), alice_balance - _x); + + //TODO: check if the subscription is still running (should be KO) + }) +} diff --git a/src/tests/mock.rs b/src/tests/mock.rs new file mode 100644 index 0000000..29fb504 --- /dev/null +++ b/src/tests/mock.rs @@ -0,0 +1,168 @@ +use crate as pallet_subscription; +use frame_support::{parameter_types, traits::Everything}; +use frame_system as system; +use sp_core::{sr25519, Pair, Public, H256}; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, + MultiSignature, +}; + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; +type AccountId = <::Signer as IdentifyAccount>::AccountId; + +frame_support::construct_runtime!( + pub enum Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + Subscription: pallet_subscription::{Pallet, Call, Storage, Event}, + + Balances: pallet_balances, + } +); + +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const SS58Prefix: u8 = 42; +} + +impl system::Config for Test { + type AccountData = pallet_balances::AccountData; + type AccountId = AccountId; + type BaseCallFilter = Everything; + type BlockHashCount = BlockHashCount; + type BlockLength = (); + type BlockNumber = u64; + type BlockWeights = (); + type Call = Call; + type DbWeight = (); + type Event = Event; + type Hash = H256; + type Hashing = BlakeTwo256; + type Header = Header; + type Index = u64; + type Lookup = IdentityLookup; + type MaxConsumers = frame_support::traits::ConstU32<16>; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = (); + type Origin = Origin; + type PalletInfo = PalletInfo; + type SS58Prefix = SS58Prefix; + type SystemWeightInfo = (); + type Version = (); +} + +pub type Balance = u64; + +parameter_types! { + pub const ExistentialDeposit: Balance = 1_000; + pub const MaxLocks: u32 = 50; + pub const MaxReserves: u32 = 50; +} + +impl pallet_balances::Config for Test { + type AccountStore = System; + type Balance = Balance; + type DustRemoval = (); + type Event = Event; + type ExistentialDeposit = ExistentialDeposit; + type MaxLocks = MaxLocks; + type MaxReserves = MaxReserves; + type ReserveIdentifier = [u8; 8]; + type WeightInfo = (); +} + +parameter_types! { + pub const MaxMetadataLength: u32 = 64; +} + +impl pallet_subscription::Config for Test { + type Currency = Balances; + type Event = Event; + type MaxMetadataLength = MaxMetadataLength; +} + +type AccountPublic = ::Signer; + +/// Helper function to generate a crypto pair from seeds +pub fn get_from_seed(seed: &str) -> ::Public { + TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public() +} + +/// Helper function to generate an account ID from seed +pub fn get_account_id_from_seed(seed: &str) -> AccountId +where + AccountPublic: From<::Public>, +{ + AccountPublic::from(get_from_seed::(seed)).into_account() +} + +/// Mock users AccountId +#[allow(non_snake_case)] +pub fn ALICE() -> AccountId { + get_account_id_from_seed::("Alice") +} +#[allow(non_snake_case)] +pub fn BOB() -> AccountId { + get_account_id_from_seed::("Bob") +} +#[allow(non_snake_case)] +pub fn CHARLIE() -> AccountId { + get_account_id_from_seed::("Charlie") +} +#[allow(non_snake_case)] +pub fn PAUL() -> AccountId { + get_account_id_from_seed::("Paul") +} +#[allow(non_snake_case)] +pub fn DONALD() -> AccountId { + get_account_id_from_seed::("Donald") +} + +pub struct ExtBuilder { + caps_endowed_accounts: Vec<(AccountId, u64)>, +} + +impl Default for ExtBuilder { + fn default() -> Self { + ExtBuilder { + caps_endowed_accounts: vec![ + (ALICE(), 1_000_000), + (BOB(), 100_000), + (CHARLIE(), 101_000), + (PAUL(), 100_000), + (DONALD(), 100_000), + ], + } + } +} + +impl ExtBuilder { + pub fn balances(mut self, accounts: Vec<(AccountId, u64)>) -> Self { + for account in accounts { + self.caps_endowed_accounts.push(account); + } + self + } + + pub fn build(self) -> sp_io::TestExternalities { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + + pallet_balances::GenesisConfig:: { + balances: self.caps_endowed_accounts, + } + .assimilate_storage(&mut t) + .unwrap(); + + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| System::set_block_number(1)); + ext + } +} diff --git a/src/tests/mod.rs b/src/tests/mod.rs new file mode 100644 index 0000000..15268b4 --- /dev/null +++ b/src/tests/mod.rs @@ -0,0 +1,3 @@ +mod hook; + +pub mod mock; diff --git a/src/types.rs b/src/types.rs index 8f87f8a..ed540f9 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,10 +1,7 @@ use crate::*; -use scale_info::TypeInfo; use codec::{Decode, Encode}; -// use frame_support::{ -// // storage::bounded_vec::BoundedVec, -// pallet_prelude::MaxEncodedLen, -// }; +use frame_support::pallet_prelude::MaxEncodedLen; +use scale_info::TypeInfo; pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -13,21 +10,20 @@ pub type Nonce = u64; pub type PlanId = u64; pub type SubscriptionId = u64; -// #[derive(Clone, Encode, Decode, TypeInfo, Debug, MaxEncodedLen)] -// pub enum Frequency { -// Daily, -// Weekly, -// Monthly, -// Annualy, -// } +#[derive(Clone, Encode, Decode, TypeInfo, PartialEq, Eq, Debug, MaxEncodedLen)] +pub struct Subscription { + pub frequency: BlockNumber, + pub amount: Balance, + pub remaining_payments: Option, + pub beneficiary: AccountId, +} -#[derive(Clone, Encode, Decode, TypeInfo, Debug)] -// #[codec(mel_bound())] -pub struct Subscription { - pub frequency: u32, // block number - pub amount: BalanceOf, - pub remaining_payments: Option, - pub beneficiary: T::AccountId, - // for later - // pub metadata: BoundedVec +#[macro_export] +macro_rules! unwrap_or_return { + ( $e:expr, $f:expr ) => { + match $e { + Some(x) => x, + None => return $f, + } + }; } From 94343492e4c28f319489e3aca6dae570595f7bfb Mon Sep 17 00:00:00 2001 From: nathan gd Date: Thu, 16 Jun 2022 18:31:05 +0200 Subject: [PATCH 4/9] add cargo.lock --- Cargo.lock | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index a0d95bc..df4e3df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1262,6 +1262,21 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "pallet-balances" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.23#76522d7937ba94ff1becef4e4e3ca78e3e1de341" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-template" version = "4.0.0-dev" @@ -1269,6 +1284,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "pallet-balances", "parity-scale-codec", "scale-info", "sp-core", From 4b351c1b09b5281bc14ff075608a6ffa089216a8 Mon Sep 17 00:00:00 2001 From: nathan gd Date: Fri, 17 Jun 2022 09:26:00 +0200 Subject: [PATCH 5/9] removing drain_filter instable feature --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5b2581e..e012b80 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(not(feature = "std"), no_std)] -#![feature(drain_filter)] #![allow(clippy::type_complexity)] pub use pallet::*; From 8982ad41c4bf236e90802aece0a0030716111022 Mon Sep 17 00:00:00 2001 From: nathan gd Date: Fri, 17 Jun 2022 15:11:16 +0200 Subject: [PATCH 6/9] solving code review --- src/lib.rs | 85 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e012b80..7d3e088 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,7 @@ pub mod pallet { /// Because this pallet emits events, it depends on the runtime's definition of an event. type Event: From> + IsType<::Event>; /// The trait to manage funds - type Currency: Currency + ReservableCurrency; + type Currency: Currency; /// The maximum amount of metadata #[pallet::constant] type MaxMetadataLength: Get; @@ -89,46 +89,8 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(n: T::BlockNumber) -> Weight { - let _weight = 0; - - let mut subs = unwrap_or_return!(Subscriptions::::get(), 0); // 1 read - let tmp = subs.clone(); - let (exec_block, (_, _)) = unwrap_or_return!(tmp.last(), 0); // 1 unwrap - if n != *exec_block { - return 0 - } - loop { - if let Some((b, (mut sub, account))) = subs.pop() { - if b == *exec_block { - if let Some(val) = sub.remaining_payments { - if val == 0 { - subs.pop(); - continue - } - } - if T::Currency::transfer( - &account, - &sub.beneficiary, - sub.amount, - ExistenceRequirement::AllowDeath, - ) - .is_err() - { - continue - } - sub.remaining_payments = sub.remaining_payments.map(|amount| amount - 1); - let new_block = n + sub.frequency; - let new_index = - subs.binary_search_by(|(b, _)| b.cmp(&new_block)).unwrap_or_else(|e| e); - subs.insert(new_index, (new_block, (sub.clone(), account.clone()))); - } - } - if (unwrap_or_return!(subs.last(), 0)).0 == *exec_block { - Subscriptions::::set(Some(subs)); - return 0 // WEIGHT - } - } - } + Self::do_execute_subscriptions(n) + } } #[pallet::call] @@ -196,4 +158,45 @@ pub mod pallet { Ok(()) } } + + impl Pallet { + pub fn do_execute_subscriptions(n: T::BlockNumber) -> Weight { + let mut subs = unwrap_or_return!(Subscriptions::::get(), 0); // 1 read + let tmp = subs.clone(); + let (exec_block, (_, _)) = unwrap_or_return!(tmp.last(), 0); // 1 unwrap + if n != *exec_block { + return 0 + } + loop { + if let Some((b, (mut sub, account))) = subs.pop() { + if b == *exec_block { + if let Some(val) = sub.remaining_payments { + if val == 0 { + continue + } + } + if T::Currency::transfer( + &account, + &sub.beneficiary, + sub.amount, + ExistenceRequirement::AllowDeath, + ) + .is_err() + { + continue + } + sub.remaining_payments = sub.remaining_payments.map(|amount| amount - 1); + let new_block = n + sub.frequency; + let new_index = + subs.binary_search_by(|(b, _)| b.cmp(&new_block)).unwrap_or_else(|e| e); + subs.insert(new_index, (new_block, (sub.clone(), account.clone()))); + } + } + if (unwrap_or_return!(subs.last(), 0)).0 == *exec_block { + Subscriptions::::set(Some(subs)); + return 0 + } + } + } + } } From e13a3b925be9c11f8fe8df1242cd6e8c3cfa58f1 Mon Sep 17 00:00:00 2001 From: nathan gd Date: Fri, 17 Jun 2022 16:19:32 +0200 Subject: [PATCH 7/9] added weight structure for hook --- Cargo.lock | 1 + Cargo.toml | 2 ++ src/lib.rs | 29 ++++++++++++++++++----------- src/weights.rs | 21 +++++++++++++++++++++ 4 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 src/weights.rs diff --git a/Cargo.lock b/Cargo.lock index df4e3df..5a28ea4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1290,6 +1290,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-std", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 4b180bd..cd31202 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ scale-info = { version = "2.0.1", default-features = false, features = ["derive" frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23"} frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23" } frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23", optional = true } +sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.23" } [dev-dependencies] sp-core = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.23" } @@ -32,6 +33,7 @@ default = ["std"] std = [ "codec/std", "pallet-balances/std", + "sp-std/std", "scale-info/std", "frame-support/std", "frame-system/std", diff --git a/src/lib.rs b/src/lib.rs index 7d3e088..36e2d98 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,9 @@ pub use pallet::*; pub mod types; pub use types::*; +pub mod weights; +pub use weights::*; + pub use frame_support::{ storage::IterableStorageMap, traits::tokens::{ @@ -33,9 +36,9 @@ pub mod pallet { type Event: From> + IsType<::Event>; /// The trait to manage funds type Currency: Currency; - /// The maximum amount of metadata - #[pallet::constant] - type MaxMetadataLength: Get; + + /// Weigths module + type WeightInfo: WeightInfo; } #[pallet::pallet] @@ -161,20 +164,23 @@ pub mod pallet { impl Pallet { pub fn do_execute_subscriptions(n: T::BlockNumber) -> Weight { - let mut subs = unwrap_or_return!(Subscriptions::::get(), 0); // 1 read + let mut itterations = 0; + + let mut subs = unwrap_or_return!(Subscriptions::::get(), 0); let tmp = subs.clone(); - let (exec_block, (_, _)) = unwrap_or_return!(tmp.last(), 0); // 1 unwrap - if n != *exec_block { + let (exec_block, (_, _)) = unwrap_or_return!(tmp.last(), 0); + if n > *exec_block { return 0 } loop { - if let Some((b, (mut sub, account))) = subs.pop() { - if b == *exec_block { + if let Some((block, (mut sub, account))) = subs.pop() { + if block <= *exec_block { if let Some(val) = sub.remaining_payments { if val == 0 { continue } } + itterations += 1; if T::Currency::transfer( &account, &sub.beneficiary, @@ -186,17 +192,18 @@ pub mod pallet { continue } sub.remaining_payments = sub.remaining_payments.map(|amount| amount - 1); - let new_block = n + sub.frequency; + let new_block = n + sub.frequency - (*exec_block - n); let new_index = - subs.binary_search_by(|(b, _)| b.cmp(&new_block)).unwrap_or_else(|e| e); + subs.binary_search_by(|(block, _)| block.cmp(&new_block)).unwrap_or_else(|e| e); subs.insert(new_index, (new_block, (sub.clone(), account.clone()))); } } if (unwrap_or_return!(subs.last(), 0)).0 == *exec_block { Subscriptions::::set(Some(subs)); - return 0 + break; } } + T::WeightInfo::do_execute_subscriptions(itterations) } } } diff --git a/src/weights.rs b/src/weights.rs new file mode 100644 index 0000000..9fea7db --- /dev/null +++ b/src/weights.rs @@ -0,0 +1,21 @@ +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +pub trait WeightInfo { + fn do_execute_subscriptions(itts: u32) -> Weight; +} + +/// Weight functions for `pallet_supersig`. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + fn do_execute_subscriptions(itts: u32) -> Weight { + (0u64) + .saturating_add(T::DbWeight::get().reads(1u64)) + .saturating_add(T::DbWeight::get().writes(1u64)) + .saturating_add((0u64).saturating_mul(itts as Weight)) + } +} From 60eb5cc843e9a164a9305558c610e1dce0d2b7da Mon Sep 17 00:00:00 2001 From: nathan gd Date: Fri, 17 Jun 2022 16:33:51 +0200 Subject: [PATCH 8/9] clippy --- src/lib.rs | 91 ++++++++++++++++++++++++----------------------- src/tests/mock.rs | 2 +- src/weights.rs | 6 ++++ 3 files changed, 53 insertions(+), 46 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 36e2d98..e6b103a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,8 +92,8 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(n: T::BlockNumber) -> Weight { - Self::do_execute_subscriptions(n) - } + Self::do_execute_subscriptions(n) + } } #[pallet::call] @@ -163,47 +163,48 @@ pub mod pallet { } impl Pallet { - pub fn do_execute_subscriptions(n: T::BlockNumber) -> Weight { - let mut itterations = 0; - - let mut subs = unwrap_or_return!(Subscriptions::::get(), 0); - let tmp = subs.clone(); - let (exec_block, (_, _)) = unwrap_or_return!(tmp.last(), 0); - if n > *exec_block { - return 0 - } - loop { - if let Some((block, (mut sub, account))) = subs.pop() { - if block <= *exec_block { - if let Some(val) = sub.remaining_payments { - if val == 0 { - continue - } - } - itterations += 1; - if T::Currency::transfer( - &account, - &sub.beneficiary, - sub.amount, - ExistenceRequirement::AllowDeath, - ) - .is_err() - { - continue - } - sub.remaining_payments = sub.remaining_payments.map(|amount| amount - 1); - let new_block = n + sub.frequency - (*exec_block - n); - let new_index = - subs.binary_search_by(|(block, _)| block.cmp(&new_block)).unwrap_or_else(|e| e); - subs.insert(new_index, (new_block, (sub.clone(), account.clone()))); - } - } - if (unwrap_or_return!(subs.last(), 0)).0 == *exec_block { - Subscriptions::::set(Some(subs)); - break; - } - } - T::WeightInfo::do_execute_subscriptions(itterations) - } - } + pub fn do_execute_subscriptions(n: T::BlockNumber) -> Weight { + let mut itterations = 0; + + let mut subs = unwrap_or_return!(Subscriptions::::get(), 0); + let tmp = subs.clone(); + let (exec_block, (_, _)) = unwrap_or_return!(tmp.last(), 0); + if n > *exec_block { + return 0 + } + loop { + if let Some((block, (mut sub, account))) = subs.pop() { + if block <= *exec_block { + if let Some(val) = sub.remaining_payments { + if val == 0 { + continue + } + } + itterations += 1; + if T::Currency::transfer( + &account, + &sub.beneficiary, + sub.amount, + ExistenceRequirement::AllowDeath, + ) + .is_err() + { + continue + } + sub.remaining_payments = sub.remaining_payments.map(|amount| amount - 1); + let new_block = n + sub.frequency - (*exec_block - n); + let new_index = subs + .binary_search_by(|(block, _)| block.cmp(&new_block)) + .unwrap_or_else(|e| e); + subs.insert(new_index, (new_block, (sub.clone(), account.clone()))); + } + } + if (unwrap_or_return!(subs.last(), 0)).0 == *exec_block { + Subscriptions::::set(Some(subs)); + break + } + } + T::WeightInfo::do_execute_subscriptions(itterations) + } + } } diff --git a/src/tests/mock.rs b/src/tests/mock.rs index 29fb504..d9c4fe8 100644 --- a/src/tests/mock.rs +++ b/src/tests/mock.rs @@ -84,7 +84,7 @@ parameter_types! { impl pallet_subscription::Config for Test { type Currency = Balances; type Event = Event; - type MaxMetadataLength = MaxMetadataLength; + type WeightInfo = (); } type AccountPublic = ::Signer; diff --git a/src/weights.rs b/src/weights.rs index 9fea7db..f573344 100644 --- a/src/weights.rs +++ b/src/weights.rs @@ -9,6 +9,12 @@ pub trait WeightInfo { fn do_execute_subscriptions(itts: u32) -> Weight; } +impl WeightInfo for () { + fn do_execute_subscriptions(itts: u32) -> Weight { + (itts as Weight) + } +} + /// Weight functions for `pallet_supersig`. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { From 8a4a12a9254e806c0e7e89f6a3faaaea21f1aa3f Mon Sep 17 00:00:00 2001 From: nathan gd Date: Fri, 24 Jun 2022 15:16:52 +0200 Subject: [PATCH 9/9] updated hook to new storage --- src/lib.rs | 69 +++++++++++++++++++---------------------------- src/tests/hook.rs | 12 +++++++++ 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e6b103a..a415d6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,19 +63,18 @@ pub mod pallet { #[pallet::getter(fn subscription_nonce)] pub type SubscriptionNonce = StorageValue<_, SubscriptionId, ValueQuery>; - // the vector should ALWAYS be sorted from biggest to smallest block_number #[pallet::storage] #[pallet::unbounded] #[pallet::getter(fn subscriptions)] - pub type Subscriptions = StorageValue< + pub type Subscriptions = StorageMap< _, + Blake2_256, + T::BlockNumber, Vec<( - T::BlockNumber, - ( - Subscription, T::AccountId>, - T::AccountId, - ), + Subscription, T::AccountId>, + T::AccountId, )>, + OptionQuery, >; #[pallet::event] @@ -166,43 +165,31 @@ pub mod pallet { pub fn do_execute_subscriptions(n: T::BlockNumber) -> Weight { let mut itterations = 0; - let mut subs = unwrap_or_return!(Subscriptions::::get(), 0); - let tmp = subs.clone(); - let (exec_block, (_, _)) = unwrap_or_return!(tmp.last(), 0); - if n > *exec_block { - return 0 - } - loop { - if let Some((block, (mut sub, account))) = subs.pop() { - if block <= *exec_block { - if let Some(val) = sub.remaining_payments { - if val == 0 { - continue - } - } - itterations += 1; - if T::Currency::transfer( - &account, - &sub.beneficiary, - sub.amount, - ExistenceRequirement::AllowDeath, - ) - .is_err() - { - continue - } - sub.remaining_payments = sub.remaining_payments.map(|amount| amount - 1); - let new_block = n + sub.frequency - (*exec_block - n); - let new_index = subs - .binary_search_by(|(block, _)| block.cmp(&new_block)) - .unwrap_or_else(|e| e); - subs.insert(new_index, (new_block, (sub.clone(), account.clone()))); + let subs = unwrap_or_return!(Subscriptions::::get(n), 0); + for (mut sub, account) in subs { + if let Some(val) = sub.remaining_payments { + if val == 0 { + continue } } - if (unwrap_or_return!(subs.last(), 0)).0 == *exec_block { - Subscriptions::::set(Some(subs)); - break + itterations += 1; + if T::Currency::transfer( + &account, + &sub.beneficiary, + sub.amount, + ExistenceRequirement::AllowDeath, + ) + .is_err() + { + continue } + sub.remaining_payments = sub.remaining_payments.map(|amount| amount - 1); + let new_block = n + sub.frequency; + let new_subs = Subscriptions::::take(new_block).map(|mut subs| { + subs.push((sub.clone(), account.clone())); + subs + }).unwrap_or_else(|| vec!((sub, account))); + Subscriptions::::insert(new_block, new_subs); } T::WeightInfo::do_execute_subscriptions(itterations) } diff --git a/src/tests/hook.rs b/src/tests/hook.rs index 5b23efc..feb3de3 100644 --- a/src/tests/hook.rs +++ b/src/tests/hook.rs @@ -9,9 +9,13 @@ fn working_subscription() { let _alice_balance = Balances::free_balance(ALICE()); //TODO: make a subscription of x amount, that recur every 1 block, from ALICE() to BOB() + //check subscription is stored in key BlockNumber 1 >::on_initialize(1); + //check subscription is not stored in key BlockNumber 1 + //check subscription is stored in key BlockNumber 2 + //assert_eq!(Balances::free_balance(BOB()), bob_balance + _x); //assert_eq!(Balances::free_balance(ALICE()), alice_balance - _x); //TODO: check if the subscription is still running (should be OK) @@ -28,8 +32,13 @@ fn sub_last_occurence() { //TODO: make a subscription of x amount, that recur every 1 block, from ALICE() to BOB(). // with remaining_payments = 1, this should only be executed once. + //check subscription is not stored in key BlockNumber 1 + //check subscription is stored in key BlockNumber 2 >::on_initialize(1); + //check subscription is not stored in key BlockNumber 1 + //check subscription is stored in key BlockNumber 2 + //assert_eq!(Balances::free_balance(BOB()), bob_balance + _x); //assert_eq!(Balances::free_balance(ALICE()), alice_balance - _x); @@ -37,6 +46,9 @@ fn sub_last_occurence() { >::on_initialize(2); + //check subscription is not stored in key BlockNumber 2 + //check subscription is not stored in key BlockNumber 3 + //assert_eq!(Balances::free_balance(BOB()), bob_balance + _x); //assert_eq!(Balances::free_balance(ALICE()), alice_balance - _x);