From 5e4ab1e38dcb2a47d148ca15a30753ce20757991 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 13 Jul 2022 22:20:48 +0300 Subject: [PATCH 01/41] rpc pending rewards --- Cargo.lock | 365 ++++++++++++------ Cargo.toml | 2 + bin/node/runtime/Cargo.toml | 2 + bin/node/runtime/src/lib.rs | 9 + frame/nomination-pools/rpc/Cargo.toml | 26 ++ .../rpc/runtime-api/Cargo.toml | 28 ++ .../rpc/runtime-api/src/lib.rs | 58 +++ frame/nomination-pools/rpc/src/README.md | 3 + frame/nomination-pools/rpc/src/lib.rs | 64 +++ frame/nomination-pools/src/lib.rs | 6 +- 10 files changed, 451 insertions(+), 112 deletions(-) create mode 100644 frame/nomination-pools/rpc/Cargo.toml create mode 100644 frame/nomination-pools/rpc/runtime-api/Cargo.toml create mode 100644 frame/nomination-pools/rpc/runtime-api/src/lib.rs create mode 100644 frame/nomination-pools/rpc/src/README.md create mode 100644 frame/nomination-pools/rpc/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 3b7c315be4390..860d0923c0ed6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,7 +448,7 @@ version = "4.0.0-dev" dependencies = [ "beefy-primitives", "fnv", - "futures", + "futures 0.3.21", "futures-timer", "hex", "log", @@ -491,7 +491,7 @@ version = "4.0.0-dev" dependencies = [ "beefy-gadget", "beefy-primitives", - "futures", + "futures 0.3.21", "jsonrpsee", "log", "parity-scale-codec", @@ -1071,6 +1071,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "core-foundation" version = "0.9.3" @@ -1306,7 +1312,7 @@ dependencies = [ "clap 2.34.0", "criterion-plot", "csv", - "futures", + "futures 0.3.21", "itertools", "lazy_static", "num-traits", @@ -1592,8 +1598,10 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ + "convert_case", "proc-macro2", "quote", + "rustc_version 0.4.0", "syn", ] @@ -1963,7 +1971,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures", + "futures 0.3.21", ] [[package]] @@ -2035,7 +2043,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b22349c6a11563a202d95772a68e0fcf56119e74ea8a2a19cf2301460fcd0df5" dependencies = [ "either", - "futures", + "futures 0.3.21", "futures-timer", "log", "num-traits", @@ -2096,7 +2104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ "matches", - "percent-encoding", + "percent-encoding 2.1.0", ] [[package]] @@ -2179,7 +2187,7 @@ dependencies = [ "frame-election-provider-support", "frame-support", "parity-scale-codec", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "scale-info", @@ -2305,7 +2313,7 @@ name = "frame-support-procedural-tools" version = "4.0.0-dev" dependencies = [ "frame-support-procedural-tools-derive", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -2457,6 +2465,12 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "futures" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" + [[package]] name = "futures" version = "0.3.21" @@ -2567,6 +2581,7 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ + "futures 0.1.31", "futures-channel", "futures-core", "futures-io", @@ -2703,7 +2718,7 @@ dependencies = [ "libc", "libgit2-sys", "log", - "url", + "url 2.2.1", ] [[package]] @@ -3010,6 +3025,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "idna" version = "0.2.3" @@ -3040,7 +3066,7 @@ dependencies = [ "async-io", "core-foundation", "fnv", - "futures", + "futures 0.3.21", "if-addrs", "ipnet", "log", @@ -3182,6 +3208,74 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonrpc-client-transports" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b99d4207e2a04fb4581746903c2bb7eb376f88de9c699d0f3e10feeac0cd3a" +dependencies = [ + "derive_more", + "futures 0.3.21", + "jsonrpc-core", + "jsonrpc-pubsub", + "log", + "serde", + "serde_json", + "url 1.7.2", +] + +[[package]] +name = "jsonrpc-core" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" +dependencies = [ + "futures 0.3.21", + "futures-executor", + "futures-util", + "log", + "serde", + "serde_derive", + "serde_json", +] + +[[package]] +name = "jsonrpc-core-client" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b51da17abecbdab3e3d4f26b01c5ec075e88d3abe3ab3b05dc9aa69392764ec0" +dependencies = [ + "futures 0.3.21", + "jsonrpc-client-transports", +] + +[[package]] +name = "jsonrpc-derive" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b939a78fa820cdfcb7ee7484466746a7377760970f6f9c6fe19f9edcc8a38d2" +dependencies = [ + "proc-macro-crate 0.1.5", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "jsonrpc-pubsub" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240f87695e6c6f62fb37f05c02c04953cf68d6408b8c1c89de85c7a0125b1011" +dependencies = [ + "futures 0.3.21", + "jsonrpc-core", + "lazy_static", + "log", + "parking_lot 0.11.2", + "rand 0.7.3", + "serde", +] + [[package]] name = "jsonrpsee" version = "0.14.0" @@ -3271,7 +3365,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "874cf3f6a027cebf36cae767feca9aa2e8a8f799880e49eb5540819fcbd8eada" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -3466,7 +3560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81327106887e42d004fbdab1fef93675be2e2e07c1b95fce45e2cc813485611d" dependencies = [ "bytes", - "futures", + "futures 0.3.21", "futures-timer", "getrandom 0.2.3", "instant", @@ -3510,7 +3604,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4decc51f3573653a9f4ecacb31b1b922dd20c25a6322bb15318ec04287ec46f9" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "futures-timer", "instant", "libp2p-core", @@ -3533,7 +3627,7 @@ dependencies = [ "ed25519-dalek", "either", "fnv", - "futures", + "futures 0.3.21", "futures-timer", "instant", "lazy_static", @@ -3564,7 +3658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0183dc2a3da1fbbf85e5b6cf51217f55b14f5daea0c455a9536eef646bfec71" dependencies = [ "flate2", - "futures", + "futures 0.3.21", "libp2p-core", ] @@ -3575,7 +3669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6cbf54723250fa5d521383be789bf60efdabe6bacfb443f87da261019a49b4b5" dependencies = [ "async-std-resolver", - "futures", + "futures 0.3.21", "libp2p-core", "log", "parking_lot 0.12.0", @@ -3591,7 +3685,7 @@ checksum = "98a4b6ffd53e355775d24b76f583fdda54b3284806f678499b57913adb94f231" dependencies = [ "cuckoofilter", "fnv", - "futures", + "futures 0.3.21", "libp2p-core", "libp2p-swarm", "log", @@ -3612,7 +3706,7 @@ dependencies = [ "byteorder", "bytes", "fnv", - "futures", + "futures 0.3.21", "hex_fmt", "instant", "libp2p-core", @@ -3636,7 +3730,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c50b585518f8efd06f93ac2f976bd672e17cdac794644b3117edd078e96bda06" dependencies = [ "asynchronous-codec", - "futures", + "futures 0.3.21", "futures-timer", "libp2p-core", "libp2p-swarm", @@ -3661,7 +3755,7 @@ dependencies = [ "bytes", "either", "fnv", - "futures", + "futures 0.3.21", "futures-timer", "instant", "libp2p-core", @@ -3687,7 +3781,7 @@ dependencies = [ "async-io", "data-encoding", "dns-parser", - "futures", + "futures 0.3.21", "if-watch", "lazy_static", "libp2p-core", @@ -3723,7 +3817,7 @@ checksum = "61fd1b20638ec209c5075dfb2e8ce6a7ea4ec3cd3ad7b77f7a477c06d53322e2" dependencies = [ "asynchronous-codec", "bytes", - "futures", + "futures 0.3.21", "libp2p-core", "log", "nohash-hasher", @@ -3741,7 +3835,7 @@ checksum = "762408cb5d84b49a600422d7f9a42c18012d8da6ebcd570f9a4a4290ba41fb6f" dependencies = [ "bytes", "curve25519-dalek 3.0.2", - "futures", + "futures 0.3.21", "lazy_static", "libp2p-core", "log", @@ -3761,7 +3855,7 @@ version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "100a6934ae1dbf8a693a4e7dd1d730fd60b774dafc45688ed63b554497c6c925" dependencies = [ - "futures", + "futures 0.3.21", "futures-timer", "instant", "libp2p-core", @@ -3779,7 +3873,7 @@ checksum = "be27bf0820a6238a4e06365b096d428271cce85a129cf16f2fe9eb1610c4df86" dependencies = [ "asynchronous-codec", "bytes", - "futures", + "futures 0.3.21", "libp2p-core", "log", "prost", @@ -3794,7 +3888,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f1a458bbda880107b5b36fcb9b5a1ef0c329685da0e203ed692a8ebe64cc92c" dependencies = [ - "futures", + "futures 0.3.21", "log", "pin-project", "rand 0.7.3", @@ -3811,7 +3905,7 @@ dependencies = [ "asynchronous-codec", "bytes", "either", - "futures", + "futures 0.3.21", "futures-timer", "instant", "libp2p-core", @@ -3836,7 +3930,7 @@ checksum = "9511c9672ba33284838e349623319c8cad2d18cfad243ae46c6b7e8a2982ea4e" dependencies = [ "asynchronous-codec", "bimap", - "futures", + "futures 0.3.21", "futures-timer", "instant", "libp2p-core", @@ -3859,7 +3953,7 @@ checksum = "508a189e2795d892c8f5c1fa1e9e0b1845d32d7b0b249dbf7b05b18811361843" dependencies = [ "async-trait", "bytes", - "futures", + "futures 0.3.21", "instant", "libp2p-core", "libp2p-swarm", @@ -3877,7 +3971,7 @@ checksum = "95ac5be6c2de2d1ff3f7693fda6faf8a827b1f3e808202277783fea9f527d114" dependencies = [ "either", "fnv", - "futures", + "futures 0.3.21", "futures-timer", "instant", "libp2p-core", @@ -3906,7 +4000,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a6771dc19aa3c65d6af9a8c65222bfc8fcd446630ddca487acd161fa6096f3b" dependencies = [ "async-io", - "futures", + "futures 0.3.21", "futures-timer", "if-watch", "ipnet", @@ -3923,7 +4017,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d125e3e5f0d58f3c6ac21815b20cf4b6a88b8db9dc26368ea821838f4161fd4d" dependencies = [ "async-std", - "futures", + "futures 0.3.21", "libp2p-core", "log", ] @@ -3934,7 +4028,7 @@ version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec894790eec3c1608f8d1a8a0bdf0dbeb79ed4de2dce964222011c2896dfa05a" dependencies = [ - "futures", + "futures 0.3.21", "js-sys", "libp2p-core", "parity-send-wrapper", @@ -3949,7 +4043,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9808e57e81be76ff841c106b4c5974fb4d41a233a7bdd2afbf1687ac6def3818" dependencies = [ "either", - "futures", + "futures 0.3.21", "futures-rustls", "libp2p-core", "log", @@ -3957,7 +4051,7 @@ dependencies = [ "quicksink", "rw-stream-sink", "soketto", - "url", + "url 2.2.1", "webpki-roots", ] @@ -3967,7 +4061,7 @@ version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6dea686217a06072033dc025631932810e2f6ad784e4fafa42e27d311c7a81c" dependencies = [ - "futures", + "futures 0.3.21", "libp2p-core", "parking_lot 0.12.0", "thiserror", @@ -4364,11 +4458,11 @@ dependencies = [ "byteorder", "data-encoding", "multihash", - "percent-encoding", + "percent-encoding 2.1.0", "serde", "static_assertions", "unsigned-varint", - "url", + "url 2.2.1", ] [[package]] @@ -4405,7 +4499,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro-error", "proc-macro2", "quote", @@ -4426,7 +4520,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "363a84be6453a70e63513660f4894ef815daf88e3356bffcda9ca27d810ce83b" dependencies = [ "bytes", - "futures", + "futures 0.3.21", "log", "pin-project", "smallvec", @@ -4516,7 +4610,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef8785b8141e8432aa45fceb922a7e876d7da3fad37fa7e7ec702ace3aa0826b" dependencies = [ "bytes", - "futures", + "futures 0.3.21", "log", "netlink-packet-core", "netlink-sys", @@ -4531,7 +4625,7 @@ checksum = "3e4c9f9547a08241bee7b6558b9b98e1f290d187de8b7cfca2bbb4937bcaa8f8" dependencies = [ "async-io", "bytes", - "futures", + "futures 0.3.21", "libc", "log", ] @@ -4569,7 +4663,7 @@ dependencies = [ "clap 3.1.18", "derive_more", "fs_extra", - "futures", + "futures 0.3.21", "hash-db", "hex", "kvdb", @@ -4611,7 +4705,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-system", "frame-system-rpc-runtime-api", - "futures", + "futures 0.3.21", "hex-literal", "jsonrpsee", "log", @@ -4691,7 +4785,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "futures", + "futures 0.3.21", "node-primitives", "node-runtime", "node-testing", @@ -4822,6 +4916,7 @@ dependencies = [ "pallet-multisig", "pallet-nomination-pools", "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-rpc-runtime-api", "pallet-offences", "pallet-offences-benchmarking", "pallet-preimage", @@ -4964,7 +5059,7 @@ version = "3.0.0-dev" dependencies = [ "frame-system", "fs_extra", - "futures", + "futures 0.3.21", "log", "node-executor", "node-primitives", @@ -5981,6 +6076,32 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-nomination-pools-rpc" +version = "1.0.0-dev" +dependencies = [ + "jsonrpc-core", + "jsonrpc-core-client", + "jsonrpc-derive", + "pallet-nomination-pools-rpc-runtime-api", + "parity-scale-codec", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-rpc", + "sp-runtime", +] + +[[package]] +name = "pallet-nomination-pools-rpc-runtime-api" +version = "1.0.0-dev" +dependencies = [ + "pallet-nomination-pools", + "parity-scale-codec", + "sp-api", + "sp-std", +] + [[package]] name = "pallet-nomination-pools-test-staking" version = "1.0.0" @@ -6294,7 +6415,7 @@ dependencies = [ name = "pallet-staking-reward-curve" version = "4.0.0-dev" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "sp-runtime", @@ -6587,7 +6708,7 @@ version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -6744,6 +6865,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +[[package]] +name = "percent-encoding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" + [[package]] name = "percent-encoding" version = "2.1.0" @@ -6975,6 +7102,15 @@ dependencies = [ "uint", ] +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + [[package]] name = "proc-macro-crate" version = "1.1.3" @@ -7705,7 +7841,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f54290e54521dac3de4149d83ddf9f62a359b3cc93bcb494a794a41e6f4744b" dependencies = [ "async-global-executor", - "futures", + "futures 0.3.21", "log", "netlink-packet-route", "netlink-proto", @@ -7822,7 +7958,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" dependencies = [ - "futures", + "futures 0.3.21", "pin-project", "static_assertions", ] @@ -7875,7 +8011,7 @@ name = "sc-authority-discovery" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "futures-timer", "ip_network", "libp2p", @@ -7903,7 +8039,7 @@ dependencies = [ name = "sc-basic-authorship" version = "0.10.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "futures-timer", "log", "parity-scale-codec", @@ -7960,7 +8096,7 @@ dependencies = [ name = "sc-chain-spec-derive" version = "4.0.0-dev" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -7973,7 +8109,7 @@ dependencies = [ "chrono", "clap 3.1.18", "fdlimit", - "futures", + "futures 0.3.21", "hex", "libp2p", "log", @@ -8010,7 +8146,7 @@ name = "sc-client-api" version = "4.0.0-dev" dependencies = [ "fnv", - "futures", + "futures 0.3.21", "hash-db", "log", "parity-scale-codec", @@ -8068,7 +8204,7 @@ name = "sc-consensus" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "futures-timer", "libp2p", "log", @@ -8092,7 +8228,7 @@ name = "sc-consensus-aura" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -8130,7 +8266,7 @@ version = "0.10.0-dev" dependencies = [ "async-trait", "fork-tree", - "futures", + "futures 0.3.21", "log", "merlin", "num-bigint", @@ -8178,7 +8314,7 @@ dependencies = [ name = "sc-consensus-babe-rpc" version = "0.10.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "jsonrpsee", "sc-consensus", "sc-consensus-babe", @@ -8220,7 +8356,7 @@ version = "0.10.0-dev" dependencies = [ "assert_matches", "async-trait", - "futures", + "futures 0.3.21", "jsonrpsee", "log", "parity-scale-codec", @@ -8256,7 +8392,7 @@ name = "sc-consensus-pow" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "futures-timer", "log", "parity-scale-codec", @@ -8280,7 +8416,7 @@ name = "sc-consensus-slots" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "futures-timer", "log", "parity-scale-codec", @@ -8416,7 +8552,7 @@ dependencies = [ "dyn-clone", "finality-grandpa", "fork-tree", - "futures", + "futures 0.3.21", "futures-timer", "hex", "log", @@ -8459,7 +8595,7 @@ name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" dependencies = [ "finality-grandpa", - "futures", + "futures 0.3.21", "jsonrpsee", "log", "parity-scale-codec", @@ -8484,7 +8620,7 @@ name = "sc-informant" version = "0.10.0-dev" dependencies = [ "ansi_term", - "futures", + "futures 0.3.21", "futures-timer", "log", "parity-util-mem", @@ -8524,7 +8660,7 @@ dependencies = [ "either", "fnv", "fork-tree", - "futures", + "futures 0.3.21", "futures-timer", "hex", "ip_network", @@ -8572,7 +8708,7 @@ name = "sc-network-common" version = "0.10.0-dev" dependencies = [ "bitflags", - "futures", + "futures 0.3.21", "libp2p", "parity-scale-codec", "prost-build", @@ -8590,7 +8726,7 @@ version = "0.10.0-dev" dependencies = [ "ahash", "async-std", - "futures", + "futures 0.3.21", "futures-timer", "libp2p", "log", @@ -8607,7 +8743,7 @@ dependencies = [ name = "sc-network-light" version = "0.10.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "libp2p", "log", "parity-scale-codec", @@ -8627,7 +8763,7 @@ name = "sc-network-sync" version = "0.10.0-dev" dependencies = [ "fork-tree", - "futures", + "futures 0.3.21", "libp2p", "log", "lru", @@ -8659,7 +8795,7 @@ version = "0.8.0" dependencies = [ "async-std", "async-trait", - "futures", + "futures 0.3.21", "futures-timer", "libp2p", "log", @@ -8689,7 +8825,7 @@ version = "4.0.0-dev" dependencies = [ "bytes", "fnv", - "futures", + "futures 0.3.21", "futures-timer", "hex", "hyper", @@ -8723,7 +8859,7 @@ dependencies = [ name = "sc-peerset" version = "4.0.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "libp2p", "log", "rand 0.7.3", @@ -8746,7 +8882,7 @@ version = "4.0.0-dev" dependencies = [ "assert_matches", "env_logger 0.9.0", - "futures", + "futures 0.3.21", "hash-db", "jsonrpsee", "lazy_static", @@ -8782,7 +8918,7 @@ dependencies = [ name = "sc-rpc-api" version = "0.10.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "jsonrpsee", "log", "parity-scale-codec", @@ -8804,7 +8940,7 @@ dependencies = [ name = "sc-rpc-server" version = "4.0.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "jsonrpsee", "log", "serde_json", @@ -8834,7 +8970,7 @@ dependencies = [ "async-trait", "directories", "exit-future", - "futures", + "futures 0.3.21", "futures-timer", "hash-db", "jsonrpsee", @@ -8900,7 +9036,7 @@ name = "sc-service-test" version = "2.0.0" dependencies = [ "fdlimit", - "futures", + "futures 0.3.21", "hex", "hex-literal", "log", @@ -8966,7 +9102,7 @@ dependencies = [ name = "sc-sysinfo" version = "6.0.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "libc", "log", "rand 0.7.3", @@ -8985,7 +9121,7 @@ name = "sc-telemetry" version = "4.0.0-dev" dependencies = [ "chrono", - "futures", + "futures 0.3.21", "libp2p", "log", "parking_lot 0.12.0", @@ -9032,7 +9168,7 @@ dependencies = [ name = "sc-tracing-proc-macro" version = "4.0.0-dev" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -9044,7 +9180,7 @@ version = "4.0.0-dev" dependencies = [ "assert_matches", "criterion", - "futures", + "futures 0.3.21", "futures-timer", "hex", "linked-hash-map", @@ -9076,7 +9212,7 @@ dependencies = [ name = "sc-transaction-pool-api" version = "4.0.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "log", "serde", "sp-blockchain", @@ -9088,7 +9224,7 @@ dependencies = [ name = "sc-utils" version = "4.0.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "futures-timer", "lazy_static", "log", @@ -9117,7 +9253,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4260c630e8a8a33429d1688eff2f163f24c65a4e1b1578ef6b565061336e4b6f" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -9538,7 +9674,7 @@ dependencies = [ "base64", "bytes", "flate2", - "futures", + "futures 0.3.21", "httparse", "log", "rand 0.8.4", @@ -9567,7 +9703,7 @@ name = "sp-api-proc-macro" version = "4.0.0-dev" dependencies = [ "blake2", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -9578,7 +9714,7 @@ name = "sp-api-test" version = "2.0.1" dependencies = [ "criterion", - "futures", + "futures 0.3.21", "log", "parity-scale-codec", "rustversion", @@ -9684,7 +9820,7 @@ dependencies = [ name = "sp-blockchain" version = "4.0.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "log", "lru", "parity-scale-codec", @@ -9702,7 +9838,7 @@ name = "sp-consensus" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "futures-timer", "log", "parity-scale-codec", @@ -9802,7 +9938,7 @@ dependencies = [ "criterion", "dyn-clonable", "ed25519-dalek", - "futures", + "futures 0.3.21", "hash-db", "hash256-std-hasher", "hex", @@ -9913,7 +10049,7 @@ name = "sp-inherents" version = "4.0.0-dev" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "impl-trait-for-tuples", "parity-scale-codec", "sp-core", @@ -9926,7 +10062,7 @@ dependencies = [ name = "sp-io" version = "6.0.0" dependencies = [ - "futures", + "futures 0.3.21", "hash-db", "libsecp256k1", "log", @@ -9961,7 +10097,7 @@ name = "sp-keystore" version = "0.12.0" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "merlin", "parity-scale-codec", "parking_lot 0.12.0", @@ -10107,7 +10243,7 @@ name = "sp-runtime-interface-proc-macro" version = "5.0.0" dependencies = [ "Inflector", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -10491,7 +10627,7 @@ version = "3.0.0" dependencies = [ "frame-support", "frame-system", - "futures", + "futures 0.3.21", "jsonrpsee", "parity-scale-codec", "sc-rpc-api", @@ -10507,7 +10643,7 @@ version = "4.0.0-dev" dependencies = [ "assert_matches", "frame-system-rpc-runtime-api", - "futures", + "futures 0.3.21", "jsonrpsee", "log", "parity-scale-codec", @@ -10564,7 +10700,7 @@ name = "substrate-test-client" version = "2.0.1" dependencies = [ "async-trait", - "futures", + "futures 0.3.21", "hex", "parity-scale-codec", "sc-client-api", @@ -10594,7 +10730,7 @@ dependencies = [ "frame-support", "frame-system", "frame-system-rpc-runtime-api", - "futures", + "futures 0.3.21", "log", "memory-db", "pallet-babe", @@ -10636,7 +10772,7 @@ dependencies = [ name = "substrate-test-runtime-client" version = "2.0.0" dependencies = [ - "futures", + "futures 0.3.21", "parity-scale-codec", "sc-block-builder", "sc-client-api", @@ -10654,7 +10790,7 @@ dependencies = [ name = "substrate-test-runtime-transaction-pool" version = "2.0.0" dependencies = [ - "futures", + "futures 0.3.21", "parity-scale-codec", "parking_lot 0.12.0", "sc-transaction-pool", @@ -10669,7 +10805,7 @@ dependencies = [ name = "substrate-test-utils" version = "4.0.0-dev" dependencies = [ - "futures", + "futures 0.3.21", "sc-service", "substrate-test-utils-derive", "tokio", @@ -10680,7 +10816,7 @@ dependencies = [ name = "substrate-test-utils-derive" version = "0.10.0-dev" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn", @@ -11196,7 +11332,7 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna", + "idna 0.2.3", "ipnet", "lazy_static", "log", @@ -11204,7 +11340,7 @@ dependencies = [ "smallvec", "thiserror", "tinyvec", - "url", + "url 2.2.1", ] [[package]] @@ -11393,6 +11529,17 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "url" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +dependencies = [ + "idna 0.1.5", + "matches", + "percent-encoding 1.0.1", +] + [[package]] name = "url" version = "2.2.1" @@ -11400,9 +11547,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" dependencies = [ "form_urlencoded", - "idna", + "idna 0.2.3", "matches", - "percent-encoding", + "percent-encoding 2.1.0", ] [[package]] @@ -11585,7 +11732,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures", + "futures 0.3.21", "js-sys", "parking_lot 0.11.2", "pin-utils", @@ -12283,7 +12430,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c0608f53c1dc0bad505d03a34bbd49fbf2ad7b51eb036123e896365532745a1" dependencies = [ - "futures", + "futures 0.3.21", "log", "nohash-hasher", "parking_lot 0.12.0", diff --git a/Cargo.toml b/Cargo.toml index 9909e6f893877..c4686c017075c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,6 +116,8 @@ members = [ "frame/nomination-pools", "frame/nomination-pools/benchmarking", "frame/nomination-pools/test-staking", + "frame/nomination-pools/rpc", + "frame/nomination-pools/rpc/runtime-api", "frame/randomness-collective-flip", "frame/ranked-collective", "frame/recovery", diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index ca971f29e93c9..15d984e3de3c9 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -79,6 +79,7 @@ pallet-mmr = { version = "4.0.0-dev", default-features = false, path = "../../.. pallet-multisig = { version = "4.0.0-dev", default-features = false, path = "../../../frame/multisig" } pallet-nomination-pools = { version = "1.0.0", default-features = false, path = "../../../frame/nomination-pools"} pallet-nomination-pools-benchmarking = { version = "1.0.0", default-features = false, optional = true, path = "../../../frame/nomination-pools/benchmarking" } +pallet-nomination-pools-rpc-runtime-api = { version = "1.0.0-dev", default-features = false, path = "../../../frame/nomination-pools/rpc/runtime-api"} pallet-offences = { version = "4.0.0-dev", default-features = false, path = "../../../frame/offences" } pallet-offences-benchmarking = { version = "4.0.0-dev", path = "../../../frame/offences/benchmarking", default-features = false, optional = true } pallet-preimage = { version = "4.0.0-dev", default-features = false, path = "../../../frame/preimage" } @@ -145,6 +146,7 @@ std = [ "pallet-mmr/std", "pallet-multisig/std", "pallet-nomination-pools/std", + "pallet-nomination-pools-rpc-runtime-api/std", "pallet-identity/std", "pallet-scheduler/std", "node-primitives/std", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index b2efcb196787d..60758846f1b1e 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1835,6 +1835,15 @@ impl_runtime_apis! { } } + impl pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi for Runtime { + fn pending_rewards(member_account: AccountId) -> Balance { + let member = pallet_nomination_pools::PoolMembers::::get(member_account).unwrap(); + let reward_pool = pallet_nomination_pools::RewardPools::::get(member.pool_id).unwrap(); + + member.pending_rewards(reward_pool.last_recorded_reward_counter).unwrap() + } + } + impl sp_consensus_babe::BabeApi for Runtime { fn configuration() -> sp_consensus_babe::BabeGenesisConfiguration { // The choice of `c` parameter (where `1 - c` represents the diff --git a/frame/nomination-pools/rpc/Cargo.toml b/frame/nomination-pools/rpc/Cargo.toml new file mode 100644 index 0000000000000..53c482229c810 --- /dev/null +++ b/frame/nomination-pools/rpc/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "pallet-nomination-pools-rpc" +version = "1.0.0-dev" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "RPC interface for the nomination-pools pallet." +readme = "README.md" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0" } +jsonrpc-core = "18.0.0" +jsonrpc-core-client = "18.0.0" +jsonrpc-derive = "18.0.0" + +sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } +sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } +sp-core = { version = "6.0.0", path = "../../../primitives/core" } +sp-rpc = { version = "6.0.0", path = "../../../primitives/rpc" } +sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" } +pallet-nomination-pools-rpc-runtime-api = { path = "./runtime-api" } \ No newline at end of file diff --git a/frame/nomination-pools/rpc/runtime-api/Cargo.toml b/frame/nomination-pools/rpc/runtime-api/Cargo.toml new file mode 100644 index 0000000000000..0eedffbd69cf1 --- /dev/null +++ b/frame/nomination-pools/rpc/runtime-api/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "pallet-nomination-pools-rpc-runtime-api" +version = "1.0.0-dev" +authors = ["Parity Technologies "] +edition = "2021" +license = "Apache-2.0" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +description = "RPC runtime API for nomination-pools FRAME pallet" +readme = "README.md" + +[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"] } +sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/api" } +sp-std = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/std" } +pallet-nomination-pools = { default-features = false, path = "../../" } + +[features] +default = ["std"] +std = [ + "codec/std", + "sp-api/std", + "sp-std/std", + "pallet-nomination-pools/std", +] \ No newline at end of file diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs new file mode 100644 index 0000000000000..96ba2910eda50 --- /dev/null +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -0,0 +1,58 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Runtime API definition for transaction payment pallet. + +#![cfg_attr(not(feature = "std"), no_std)] + +use codec::{Codec, Decode, Encode}; +pub use pallet_nomination_pools::PoolId; +use sp_std::prelude::*; + +/// Some points and balance bundled together. +#[derive(Encode, Decode, PartialEq, Eq)] +pub struct PointsAndBalance { + pub points: B, + pub balance: B, +} + +/// Stats of a member in a pool. +#[derive(Encode, Decode, PartialEq, Eq)] +pub struct MemberStatus { + /// Active stake, both in points and balance. + /// + /// The balance value is evaluated on the fly and can change based on external factors, such as + /// slash. + pub active: PointsAndBalance, + /// Unbonding stake, per era, both in points and balance. + /// + /// The balance value is evaluated on the fly and can change based on external factors, such as + /// slash. + pub unbonding: Vec<(u32, PointsAndBalance)>, + /// The pending rewards of this member in their existing pool. + pub pending_rewards: B, + /// The pool to which this member belongs. + pub pool_id: PoolId, +} + +sp_api::decl_runtime_apis! { + pub trait NominationPoolsApi where AccountId: Codec, Balance: Codec + { + /// Returns the pending rewards for the given member. + fn pending_rewards(member: AccountId) -> Balance; + } +} diff --git a/frame/nomination-pools/rpc/src/README.md b/frame/nomination-pools/rpc/src/README.md new file mode 100644 index 0000000000000..7bf98d92a711d --- /dev/null +++ b/frame/nomination-pools/rpc/src/README.md @@ -0,0 +1,3 @@ +RPC interface. + +License: Apache-2.0 \ No newline at end of file diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs new file mode 100644 index 0000000000000..4137c6c7f7b4c --- /dev/null +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -0,0 +1,64 @@ +// This file is part of Substrate. + +// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! RPC interface for the transaction payment pallet. + +pub use self::gen_client::Client as NominationPoolsClient; +use codec::Codec; +use jsonrpc_derive::rpc; +use pallet_nomination_pools_rpc_runtime_api::MemberStatus; +pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::HeaderBackend; +use sp_runtime::{generic::BlockId, traits::Block as BlockT}; +use std::sync::Arc; + +#[rpc] +pub trait NominationPoolsRpc { + #[rpc(name = "nompools_pending_rewards")] + fn pending_rewards(&self, member: AccountId, at: Option) + -> Result; +} + +pub struct NominationPoolsRpcType { + client: Arc, + _marker: std::marker::PhantomData

, +} + +impl NominationPoolsRpcType { + pub fn new(client: Arc) -> Self { + Self { client, _marker: Default::default() } + } +} + +impl + NominationPoolsRpc<::Hash, AccountId, MemberStatus> + for NominationPoolsRpcType +where + Block: BlockT, + C: 'static + ProvideRuntimeApi + HeaderBackend, + C::Api: NominationPoolsRuntimeApi, + AccountId: Codec, + Balance: Codec, +{ + fn pending_rewards(&self, member: AccountId, at: Option) -> Result { + let api = self.client.runtime_api(); + let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); + + api.pending_rewards(&at, member).map_err(|_| ()) + } +} diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 53e1c48a5e39e..b1a3e1620f8f6 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -378,7 +378,7 @@ pub struct PoolMember { impl PoolMember { /// The pending rewards of this member. - fn pending_rewards( + pub fn pending_rewards( &self, current_reward_counter: T::RewardCounter, ) -> Result, Error> { @@ -922,7 +922,7 @@ pub struct RewardPool { /// /// This is updated ONLY when the points in the bonded pool change, which means `join`, /// `bond_extra` and `unbond`, all of which is done through `update_recorded`. - last_recorded_reward_counter: T::RewardCounter, + pub last_recorded_reward_counter: T::RewardCounter, /// The last recorded total payouts of the reward pool. /// /// Payouts is essentially income of the pool. @@ -935,7 +935,7 @@ pub struct RewardPool { impl RewardPool { /// Getter for [`RewardPool::last_recorded_reward_counter`]. - fn last_recorded_reward_counter(&self) -> T::RewardCounter { + pub fn last_recorded_reward_counter(&self) -> T::RewardCounter { self.last_recorded_reward_counter } From f548a89103102dcb9d45cc8ef94c0712be23da87 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 13 Jul 2022 22:23:18 +0300 Subject: [PATCH 02/41] commit --- .../rpc/runtime-api/src/lib.rs | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index 96ba2910eda50..73f6d8dd36817 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -23,32 +23,6 @@ use codec::{Codec, Decode, Encode}; pub use pallet_nomination_pools::PoolId; use sp_std::prelude::*; -/// Some points and balance bundled together. -#[derive(Encode, Decode, PartialEq, Eq)] -pub struct PointsAndBalance { - pub points: B, - pub balance: B, -} - -/// Stats of a member in a pool. -#[derive(Encode, Decode, PartialEq, Eq)] -pub struct MemberStatus { - /// Active stake, both in points and balance. - /// - /// The balance value is evaluated on the fly and can change based on external factors, such as - /// slash. - pub active: PointsAndBalance, - /// Unbonding stake, per era, both in points and balance. - /// - /// The balance value is evaluated on the fly and can change based on external factors, such as - /// slash. - pub unbonding: Vec<(u32, PointsAndBalance)>, - /// The pending rewards of this member in their existing pool. - pub pending_rewards: B, - /// The pool to which this member belongs. - pub pool_id: PoolId, -} - sp_api::decl_runtime_apis! { pub trait NominationPoolsApi where AccountId: Codec, Balance: Codec { From 26004a399f553fabf2e202684e7c52c5083959bf Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 13 Jul 2022 22:27:41 +0300 Subject: [PATCH 03/41] remove unused imports --- frame/nomination-pools/rpc/runtime-api/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index 73f6d8dd36817..ef89d314f64dc 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -19,9 +19,8 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Codec, Decode, Encode}; +use codec::Codec; pub use pallet_nomination_pools::PoolId; -use sp_std::prelude::*; sp_api::decl_runtime_apis! { pub trait NominationPoolsApi where AccountId: Codec, Balance: Codec From 08bcda55299fbe9e8a8dfc9b4ca886450fe54227 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 13 Jul 2022 22:33:13 +0300 Subject: [PATCH 04/41] fix --- frame/nomination-pools/rpc/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 4137c6c7f7b4c..89519d91009c4 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -20,7 +20,6 @@ pub use self::gen_client::Client as NominationPoolsClient; use codec::Codec; use jsonrpc_derive::rpc; -use pallet_nomination_pools_rpc_runtime_api::MemberStatus; pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; From 9b5cf9e275364578f96c4db63955a9cc9b2c7ad5 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 13 Jul 2022 22:36:47 +0300 Subject: [PATCH 05/41] fix --- frame/nomination-pools/rpc/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 89519d91009c4..1670ac2dd98f6 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -45,7 +45,7 @@ impl NominationPoolsRpcType { } impl - NominationPoolsRpc<::Hash, AccountId, MemberStatus> + NominationPoolsRpc<::Hash, AccountId, Balance> for NominationPoolsRpcType where Block: BlockT, From 180f7ef7229b450e223571689d411635f52c17e9 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 13 Jul 2022 22:38:35 +0300 Subject: [PATCH 06/41] fmt --- frame/nomination-pools/rpc/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 1670ac2dd98f6..a06f6db66024b 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -44,8 +44,7 @@ impl NominationPoolsRpcType { } } -impl - NominationPoolsRpc<::Hash, AccountId, Balance> +impl NominationPoolsRpc<::Hash, AccountId, Balance> for NominationPoolsRpcType where Block: BlockT, From 0d50df7f4ecb36da8a4080c12dd130506c68b7d9 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 08:07:12 +0300 Subject: [PATCH 07/41] fix --- frame/nomination-pools/rpc/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index a06f6db66024b..377076aae2ac9 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -20,6 +20,7 @@ pub use self::gen_client::Client as NominationPoolsClient; use codec::Codec; use jsonrpc_derive::rpc; +use jsonrpc_core::Error; pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; @@ -30,7 +31,7 @@ use std::sync::Arc; pub trait NominationPoolsRpc { #[rpc(name = "nompools_pending_rewards")] fn pending_rewards(&self, member: AccountId, at: Option) - -> Result; + -> Result; } pub struct NominationPoolsRpcType { @@ -53,10 +54,14 @@ where AccountId: Codec, Balance: Codec, { - fn pending_rewards(&self, member: AccountId, at: Option) -> Result { + fn pending_rewards(&self, member: AccountId, at: Option) -> Result { let api = self.client.runtime_api(); let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); - api.pending_rewards(&at, member).map_err(|_| ()) + api.pending_rewards(&at, member).map_err(|e| Error{ + code: jsonrpc_core::ErrorCode::ServerError(1), + message: format!("{:?}", e), + data: None + }) } } From c95d1551ebd12dd1c59476913b2b99eb3979fd0b Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 08:08:10 +0300 Subject: [PATCH 08/41] fmt --- frame/nomination-pools/rpc/src/lib.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 377076aae2ac9..22c33fc1df814 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -19,8 +19,8 @@ pub use self::gen_client::Client as NominationPoolsClient; use codec::Codec; -use jsonrpc_derive::rpc; use jsonrpc_core::Error; +use jsonrpc_derive::rpc; pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; @@ -30,8 +30,11 @@ use std::sync::Arc; #[rpc] pub trait NominationPoolsRpc { #[rpc(name = "nompools_pending_rewards")] - fn pending_rewards(&self, member: AccountId, at: Option) - -> Result; + fn pending_rewards( + &self, + member: AccountId, + at: Option, + ) -> Result; } pub struct NominationPoolsRpcType { @@ -54,14 +57,18 @@ where AccountId: Codec, Balance: Codec, { - fn pending_rewards(&self, member: AccountId, at: Option) -> Result { + fn pending_rewards( + &self, + member: AccountId, + at: Option, + ) -> Result { let api = self.client.runtime_api(); let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); - api.pending_rewards(&at, member).map_err(|e| Error{ + api.pending_rewards(&at, member).map_err(|e| Error { code: jsonrpc_core::ErrorCode::ServerError(1), message: format!("{:?}", e), - data: None + data: None, }) } } From 611d410bebc296de3005cc375097cdd0af3905c0 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 08:17:15 +0300 Subject: [PATCH 09/41] fix --- bin/node/runtime/src/lib.rs | 3 +-- frame/nomination-pools/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 60758846f1b1e..ab9e43f4c1b13 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1838,9 +1838,8 @@ impl_runtime_apis! { impl pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi for Runtime { fn pending_rewards(member_account: AccountId) -> Balance { let member = pallet_nomination_pools::PoolMembers::::get(member_account).unwrap(); - let reward_pool = pallet_nomination_pools::RewardPools::::get(member.pool_id).unwrap(); - member.pending_rewards(reward_pool.last_recorded_reward_counter).unwrap() + member.pending_rewards(member.last_recorded_reward_counter).unwrap() } } diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index b1a3e1620f8f6..92381d3018fd4 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -922,7 +922,7 @@ pub struct RewardPool { /// /// This is updated ONLY when the points in the bonded pool change, which means `join`, /// `bond_extra` and `unbond`, all of which is done through `update_recorded`. - pub last_recorded_reward_counter: T::RewardCounter, + last_recorded_reward_counter: T::RewardCounter, /// The last recorded total payouts of the reward pool. /// /// Payouts is essentially income of the pool. @@ -935,7 +935,7 @@ pub struct RewardPool { impl RewardPool { /// Getter for [`RewardPool::last_recorded_reward_counter`]. - pub fn last_recorded_reward_counter(&self) -> T::RewardCounter { + fn last_recorded_reward_counter(&self) -> T::RewardCounter { self.last_recorded_reward_counter } From 6419f43000bbd1659c86532075459e7feb2fad6e Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 08:36:51 +0300 Subject: [PATCH 10/41] docs --- frame/nomination-pools/rpc/runtime-api/README.md | 3 +++ frame/nomination-pools/rpc/runtime-api/src/lib.rs | 2 +- frame/nomination-pools/rpc/src/README.md | 2 +- frame/nomination-pools/rpc/src/lib.rs | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 frame/nomination-pools/rpc/runtime-api/README.md diff --git a/frame/nomination-pools/rpc/runtime-api/README.md b/frame/nomination-pools/rpc/runtime-api/README.md new file mode 100644 index 0000000000000..af90b31733b0b --- /dev/null +++ b/frame/nomination-pools/rpc/runtime-api/README.md @@ -0,0 +1,3 @@ +Runtime API definition for nomination-pools pallet. + +License: Apache-2.0 \ No newline at end of file diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index ef89d314f64dc..02b2316aea582 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Runtime API definition for transaction payment pallet. +//! Runtime API definition for nomination-pools pallet. #![cfg_attr(not(feature = "std"), no_std)] diff --git a/frame/nomination-pools/rpc/src/README.md b/frame/nomination-pools/rpc/src/README.md index 7bf98d92a711d..259e056014bb4 100644 --- a/frame/nomination-pools/rpc/src/README.md +++ b/frame/nomination-pools/rpc/src/README.md @@ -1,3 +1,3 @@ -RPC interface. +RPC interface for the nomination-pools pallet. License: Apache-2.0 \ No newline at end of file diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 22c33fc1df814..4f8fde6aadbab 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! RPC interface for the transaction payment pallet. +//! RPC interface for the nomination-pools pallet. pub use self::gen_client::Client as NominationPoolsClient; use codec::Codec; From a9582a088dc106e8ab2e45f6e254ac90a5d21822 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 11:10:52 +0300 Subject: [PATCH 11/41] docs & formatting --- bin/node/runtime/src/lib.rs | 2 +- frame/nomination-pools/rpc/Cargo.toml | 2 +- frame/nomination-pools/rpc/runtime-api/Cargo.toml | 2 +- frame/nomination-pools/rpc/runtime-api/src/lib.rs | 2 +- frame/nomination-pools/rpc/src/lib.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index ab9e43f4c1b13..d2efe797c43b3 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2018-2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2022 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify diff --git a/frame/nomination-pools/rpc/Cargo.toml b/frame/nomination-pools/rpc/Cargo.toml index 53c482229c810..326ec557ea28f 100644 --- a/frame/nomination-pools/rpc/Cargo.toml +++ b/frame/nomination-pools/rpc/Cargo.toml @@ -23,4 +23,4 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" sp-core = { version = "6.0.0", path = "../../../primitives/core" } sp-rpc = { version = "6.0.0", path = "../../../primitives/rpc" } sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" } -pallet-nomination-pools-rpc-runtime-api = { path = "./runtime-api" } \ No newline at end of file +pallet-nomination-pools-rpc-runtime-api = { path = "./runtime-api" } diff --git a/frame/nomination-pools/rpc/runtime-api/Cargo.toml b/frame/nomination-pools/rpc/runtime-api/Cargo.toml index 0eedffbd69cf1..4674c83fab7b5 100644 --- a/frame/nomination-pools/rpc/runtime-api/Cargo.toml +++ b/frame/nomination-pools/rpc/runtime-api/Cargo.toml @@ -25,4 +25,4 @@ std = [ "sp-api/std", "sp-std/std", "pallet-nomination-pools/std", -] \ No newline at end of file +] diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index 02b2316aea582..22e962981f785 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2022 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 4f8fde6aadbab..3b16e2a762ff8 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2019-2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2022 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); From 830ae637c60da5fc1db8dd416253d923217dc978 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 12:51:25 +0300 Subject: [PATCH 12/41] better formatting --- bin/node/runtime/src/lib.rs | 2 +- frame/nomination-pools/rpc/runtime-api/src/lib.rs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d2efe797c43b3..d1a3aa6892d11 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1836,7 +1836,7 @@ impl_runtime_apis! { } impl pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi for Runtime { - fn pending_rewards(member_account: AccountId) -> Balance { + fn pending_rewards(member_account: AccountId) -> Result { let member = pallet_nomination_pools::PoolMembers::::get(member_account).unwrap(); member.pending_rewards(member.last_recorded_reward_counter).unwrap() diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index 22e962981f785..5bb9afa8a78da 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -23,9 +23,10 @@ use codec::Codec; pub use pallet_nomination_pools::PoolId; sp_api::decl_runtime_apis! { - pub trait NominationPoolsApi where AccountId: Codec, Balance: Codec + pub trait NominationPoolsApi + where AccountId: Codec, Balance: Codec { /// Returns the pending rewards for the given member. - fn pending_rewards(member: AccountId) -> Balance; + fn pending_rewards(member: AccountId) -> Result; } } From e9b183bb0d6d6f1f3d4dd6088b3bb24a5ce9d38c Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 12:57:57 +0300 Subject: [PATCH 13/41] temporary fix --- bin/node/runtime/src/lib.rs | 2 +- frame/nomination-pools/rpc/runtime-api/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d1a3aa6892d11..d2efe797c43b3 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1836,7 +1836,7 @@ impl_runtime_apis! { } impl pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi for Runtime { - fn pending_rewards(member_account: AccountId) -> Result { + fn pending_rewards(member_account: AccountId) -> Balance { let member = pallet_nomination_pools::PoolMembers::::get(member_account).unwrap(); member.pending_rewards(member.last_recorded_reward_counter).unwrap() diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index 5bb9afa8a78da..44d019350cd62 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -27,6 +27,6 @@ sp_api::decl_runtime_apis! { where AccountId: Codec, Balance: Codec { /// Returns the pending rewards for the given member. - fn pending_rewards(member: AccountId) -> Result; + fn pending_rewards(member: AccountId) -> Balance; } } From b3b3e18bb816bc6bc9c7b6cb034ee90301856c3e Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 15:38:37 +0300 Subject: [PATCH 14/41] error handling --- bin/node/runtime/src/lib.rs | 10 ++++++---- .../rpc/runtime-api/src/lib.rs | 13 +++++++++++-- frame/nomination-pools/rpc/src/lib.rs | 18 ++++++++++++++---- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d2efe797c43b3..cb764f7bdea84 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -52,6 +52,7 @@ use pallet_grandpa::{ fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, }; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; +use pallet_nomination_pools_rpc_runtime_api::NpApiError; use pallet_session::historical::{self as pallet_session_historical}; pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; @@ -1836,10 +1837,11 @@ impl_runtime_apis! { } impl pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi for Runtime { - fn pending_rewards(member_account: AccountId) -> Balance { - let member = pallet_nomination_pools::PoolMembers::::get(member_account).unwrap(); - - member.pending_rewards(member.last_recorded_reward_counter).unwrap() + fn pending_rewards(member_account: AccountId) -> Result { + if let Some(member) = pallet_nomination_pools::PoolMembers::::get(member_account) { + return member.pending_rewards(member.last_recorded_reward_counter).map_err(|_| NpApiError::OverflowInPendingRewards); + } + Err(NpApiError::MemberNotFound) } } diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index 44d019350cd62..e29871165db4c 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -19,14 +19,23 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::Codec; +use codec::{Codec, Decode, Encode}; pub use pallet_nomination_pools::PoolId; +/// The possible errors that may occur when getting the pending rewards. +#[derive(Decode, Encode, Eq, PartialEq)] +pub enum NpApiError { + /// The member was not found. + MemberNotFound, + /// An overflow occured when calculating the pending rewards. + OverflowInPendingRewards, +} + sp_api::decl_runtime_apis! { pub trait NominationPoolsApi where AccountId: Codec, Balance: Codec { /// Returns the pending rewards for the given member. - fn pending_rewards(member: AccountId) -> Balance; + fn pending_rewards(member: AccountId) -> Result; } } diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 3b16e2a762ff8..231abd6891797 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -22,6 +22,7 @@ use codec::Codec; use jsonrpc_core::Error; use jsonrpc_derive::rpc; pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; +use pallet_nomination_pools_rpc_runtime_api::NpApiError; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::{generic::BlockId, traits::Block as BlockT}; @@ -65,10 +66,19 @@ where let api = self.client.runtime_api(); let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); - api.pending_rewards(&at, member).map_err(|e| Error { - code: jsonrpc_core::ErrorCode::ServerError(1), - message: format!("{:?}", e), - data: None, + api.pending_rewards(&at, member).map_err(|e| -> Error { + match e { + NpApiError::MemberNotFound => Error { + code: jsonrpc_core::ErrorCode::ServerError(1), + message: format!("Member with the given account was not found."), + data: None, + }, + NpApiError::OverflowInPendingRewards => Error { + code: jsonrpc_core::ErrorCode::ServerError(2), + message: format!("An overflow occured when calculating the pending rewards."), + data: None, + }, + } }) } } From cf983493e780e1c42aecc7ea83f50127e2aade32 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 19:09:24 +0300 Subject: [PATCH 15/41] fix? --- frame/nomination-pools/rpc/src/lib.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 231abd6891797..edfcb2572bbcd 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -22,7 +22,6 @@ use codec::Codec; use jsonrpc_core::Error; use jsonrpc_derive::rpc; pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; -use pallet_nomination_pools_rpc_runtime_api::NpApiError; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::{generic::BlockId, traits::Block as BlockT}; @@ -66,19 +65,20 @@ where let api = self.client.runtime_api(); let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); - api.pending_rewards(&at, member).map_err(|e| -> Error { - match e { - NpApiError::MemberNotFound => Error { - code: jsonrpc_core::ErrorCode::ServerError(1), - message: format!("Member with the given account was not found."), - data: None, - }, - NpApiError::OverflowInPendingRewards => Error { + match api.pending_rewards(&at, member) { + Ok(rewards) => match rewards { + Ok(r) => Ok(r), + Err(_) => Err(Error { code: jsonrpc_core::ErrorCode::ServerError(2), message: format!("An overflow occured when calculating the pending rewards."), data: None, - }, - } - }) + }) + }, + Err(_) => Err(Error { + code: jsonrpc_core::ErrorCode::ServerError(1), + message: format!("Member with the given account was not found."), + data: None, + }) + } } } From 397802341663a81a8a970bccfb5050e192f9f477 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 19:10:05 +0300 Subject: [PATCH 16/41] fmt --- frame/nomination-pools/rpc/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index edfcb2572bbcd..2dc50da32f0bc 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -72,13 +72,13 @@ where code: jsonrpc_core::ErrorCode::ServerError(2), message: format!("An overflow occured when calculating the pending rewards."), data: None, - }) + }), }, Err(_) => Err(Error { code: jsonrpc_core::ErrorCode::ServerError(1), message: format!("Member with the given account was not found."), data: None, - }) + }), } } } From c8273c2518803fd7d67547f32cf5a43bb1a3dc9f Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 19:26:51 +0300 Subject: [PATCH 17/41] use to_string --- frame/nomination-pools/rpc/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 2dc50da32f0bc..27ac06c1d57ef 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -70,13 +70,13 @@ where Ok(r) => Ok(r), Err(_) => Err(Error { code: jsonrpc_core::ErrorCode::ServerError(2), - message: format!("An overflow occured when calculating the pending rewards."), + message: "An overflow occured when calculating the pending rewards.".to_string(), data: None, }), }, Err(_) => Err(Error { code: jsonrpc_core::ErrorCode::ServerError(1), - message: format!("Member with the given account was not found."), + message: "Member with the given account was not found.".to_string(), data: None, }), } From 3a866ffe8403ac6f4e38cc7ff0990865d7fcce4d Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 14 Jul 2022 21:06:23 +0300 Subject: [PATCH 18/41] fmt --- frame/nomination-pools/rpc/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 27ac06c1d57ef..5771d87921ea3 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -70,7 +70,8 @@ where Ok(r) => Ok(r), Err(_) => Err(Error { code: jsonrpc_core::ErrorCode::ServerError(2), - message: "An overflow occured when calculating the pending rewards.".to_string(), + message: "An overflow occured when calculating the pending rewards." + .to_string(), data: None, }), }, From 3266173d8a28bb1c286eda1eeb132d503a4da0cd Mon Sep 17 00:00:00 2001 From: Szegoo Date: Fri, 15 Jul 2022 12:32:04 +0300 Subject: [PATCH 19/41] fixed error handling --- frame/nomination-pools/rpc/src/lib.rs | 36 +++++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 5771d87921ea3..a99dfe8bf7f2c 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -22,11 +22,33 @@ use codec::Codec; use jsonrpc_core::Error; use jsonrpc_derive::rpc; pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; +use pallet_nomination_pools_rpc_runtime_api::NpApiError; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::{generic::BlockId, traits::Block as BlockT}; use std::sync::Arc; +trait ToError { + fn to_error(&self) -> Error; +} + +impl ToError for NpApiError { + fn to_error(&self) -> Error { + match self { + NpApiError::MemberNotFound => Error { + code: jsonrpc_core::ErrorCode::ServerError(2), + message: "Member with the given account was not found.".to_string(), + data: None, + }, + NpApiError::OverflowInPendingRewards => Error { + code: jsonrpc_core::ErrorCode::ServerError(3), + message: "An overflow occured when calculating the pending rewards.".to_string(), + data: None, + }, + } + } +} + #[rpc] pub trait NominationPoolsRpc { #[rpc(name = "nompools_pending_rewards")] @@ -66,18 +88,10 @@ where let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); match api.pending_rewards(&at, member) { - Ok(rewards) => match rewards { - Ok(r) => Ok(r), - Err(_) => Err(Error { - code: jsonrpc_core::ErrorCode::ServerError(2), - message: "An overflow occured when calculating the pending rewards." - .to_string(), - data: None, - }), - }, - Err(_) => Err(Error { + Ok(rewards) => rewards.map_err(|e| e.to_error()), + Err(e) => Err(Error { code: jsonrpc_core::ErrorCode::ServerError(1), - message: "Member with the given account was not found.".to_string(), + message: format!("{:?}", e), data: None, }), } From 34857e5b038090c71136b15814b14fa7d35a03b8 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Fri, 15 Jul 2022 15:45:16 +0300 Subject: [PATCH 20/41] fix --- bin/node/runtime/src/lib.rs | 7 ++-- .../rpc/runtime-api/src/lib.rs | 13 ++----- frame/nomination-pools/rpc/src/lib.rs | 35 ++----------------- 3 files changed, 8 insertions(+), 47 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index cb764f7bdea84..461b0c60908aa 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -52,7 +52,6 @@ use pallet_grandpa::{ fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList, }; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; -use pallet_nomination_pools_rpc_runtime_api::NpApiError; use pallet_session::historical::{self as pallet_session_historical}; pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment}; use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; @@ -1837,11 +1836,11 @@ impl_runtime_apis! { } impl pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi for Runtime { - fn pending_rewards(member_account: AccountId) -> Result { + fn pending_rewards(member_account: AccountId) -> Balance { if let Some(member) = pallet_nomination_pools::PoolMembers::::get(member_account) { - return member.pending_rewards(member.last_recorded_reward_counter).map_err(|_| NpApiError::OverflowInPendingRewards); + return member.pending_rewards(member.last_recorded_reward_counter).unwrap_or_default(); } - Err(NpApiError::MemberNotFound) + Balance::default() } } diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index e29871165db4c..44d019350cd62 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -19,23 +19,14 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Codec, Decode, Encode}; +use codec::Codec; pub use pallet_nomination_pools::PoolId; -/// The possible errors that may occur when getting the pending rewards. -#[derive(Decode, Encode, Eq, PartialEq)] -pub enum NpApiError { - /// The member was not found. - MemberNotFound, - /// An overflow occured when calculating the pending rewards. - OverflowInPendingRewards, -} - sp_api::decl_runtime_apis! { pub trait NominationPoolsApi where AccountId: Codec, Balance: Codec { /// Returns the pending rewards for the given member. - fn pending_rewards(member: AccountId) -> Result; + fn pending_rewards(member: AccountId) -> Balance; } } diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index a99dfe8bf7f2c..b9dc66ef80656 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -22,36 +22,14 @@ use codec::Codec; use jsonrpc_core::Error; use jsonrpc_derive::rpc; pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; -use pallet_nomination_pools_rpc_runtime_api::NpApiError; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::{generic::BlockId, traits::Block as BlockT}; use std::sync::Arc; -trait ToError { - fn to_error(&self) -> Error; -} - -impl ToError for NpApiError { - fn to_error(&self) -> Error { - match self { - NpApiError::MemberNotFound => Error { - code: jsonrpc_core::ErrorCode::ServerError(2), - message: "Member with the given account was not found.".to_string(), - data: None, - }, - NpApiError::OverflowInPendingRewards => Error { - code: jsonrpc_core::ErrorCode::ServerError(3), - message: "An overflow occured when calculating the pending rewards.".to_string(), - data: None, - }, - } - } -} - #[rpc] pub trait NominationPoolsRpc { - #[rpc(name = "nompools_pending_rewards")] + #[rpc(name = "nominationPools_pending_rewards")] fn pending_rewards( &self, member: AccountId, @@ -77,7 +55,7 @@ where C: 'static + ProvideRuntimeApi + HeaderBackend, C::Api: NominationPoolsRuntimeApi, AccountId: Codec, - Balance: Codec, + Balance: Codec + Default, { fn pending_rewards( &self, @@ -87,13 +65,6 @@ where let api = self.client.runtime_api(); let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); - match api.pending_rewards(&at, member) { - Ok(rewards) => rewards.map_err(|e| e.to_error()), - Err(e) => Err(Error { - code: jsonrpc_core::ErrorCode::ServerError(1), - message: format!("{:?}", e), - data: None, - }), - } + Ok(api.pending_rewards(&at, member).unwrap_or_default()) } } From ff745f12e75a260d32977192dbe15972fec0a4fc Mon Sep 17 00:00:00 2001 From: Szegoo Date: Fri, 15 Jul 2022 16:28:29 +0300 Subject: [PATCH 21/41] rpc added to client --- Cargo.lock | 343 +++++++++----------------- bin/node/rpc/Cargo.toml | 1 + bin/node/rpc/src/lib.rs | 3 + frame/nomination-pools/rpc/Cargo.toml | 4 +- frame/nomination-pools/rpc/src/lib.rs | 27 +- 5 files changed, 127 insertions(+), 251 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 860d0923c0ed6..ca0ec0ef4014c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,7 +448,7 @@ version = "4.0.0-dev" dependencies = [ "beefy-primitives", "fnv", - "futures 0.3.21", + "futures", "futures-timer", "hex", "log", @@ -491,7 +491,7 @@ version = "4.0.0-dev" dependencies = [ "beefy-gadget", "beefy-primitives", - "futures 0.3.21", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -1071,12 +1071,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "core-foundation" version = "0.9.3" @@ -1312,7 +1306,7 @@ dependencies = [ "clap 2.34.0", "criterion-plot", "csv", - "futures 0.3.21", + "futures", "itertools", "lazy_static", "num-traits", @@ -1598,10 +1592,8 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ - "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", "syn", ] @@ -1971,7 +1963,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures 0.3.21", + "futures", ] [[package]] @@ -2043,7 +2035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b22349c6a11563a202d95772a68e0fcf56119e74ea8a2a19cf2301460fcd0df5" dependencies = [ "either", - "futures 0.3.21", + "futures", "futures-timer", "log", "num-traits", @@ -2104,7 +2096,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ "matches", - "percent-encoding 2.1.0", + "percent-encoding", ] [[package]] @@ -2187,7 +2179,7 @@ dependencies = [ "frame-election-provider-support", "frame-support", "parity-scale-codec", - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "scale-info", @@ -2313,7 +2305,7 @@ name = "frame-support-procedural-tools" version = "4.0.0-dev" dependencies = [ "frame-support-procedural-tools-derive", - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn", @@ -2465,12 +2457,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - [[package]] name = "futures" version = "0.3.21" @@ -2581,7 +2567,6 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ - "futures 0.1.31", "futures-channel", "futures-core", "futures-io", @@ -2718,7 +2703,7 @@ dependencies = [ "libc", "libgit2-sys", "log", - "url 2.2.1", + "url", ] [[package]] @@ -3025,17 +3010,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "0.2.3" @@ -3066,7 +3040,7 @@ dependencies = [ "async-io", "core-foundation", "fnv", - "futures 0.3.21", + "futures", "if-addrs", "ipnet", "log", @@ -3208,74 +3182,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "jsonrpc-client-transports" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b99d4207e2a04fb4581746903c2bb7eb376f88de9c699d0f3e10feeac0cd3a" -dependencies = [ - "derive_more", - "futures 0.3.21", - "jsonrpc-core", - "jsonrpc-pubsub", - "log", - "serde", - "serde_json", - "url 1.7.2", -] - -[[package]] -name = "jsonrpc-core" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" -dependencies = [ - "futures 0.3.21", - "futures-executor", - "futures-util", - "log", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "jsonrpc-core-client" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b51da17abecbdab3e3d4f26b01c5ec075e88d3abe3ab3b05dc9aa69392764ec0" -dependencies = [ - "futures 0.3.21", - "jsonrpc-client-transports", -] - -[[package]] -name = "jsonrpc-derive" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b939a78fa820cdfcb7ee7484466746a7377760970f6f9c6fe19f9edcc8a38d2" -dependencies = [ - "proc-macro-crate 0.1.5", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "jsonrpc-pubsub" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240f87695e6c6f62fb37f05c02c04953cf68d6408b8c1c89de85c7a0125b1011" -dependencies = [ - "futures 0.3.21", - "jsonrpc-core", - "lazy_static", - "log", - "parking_lot 0.11.2", - "rand 0.7.3", - "serde", -] - [[package]] name = "jsonrpsee" version = "0.14.0" @@ -3365,7 +3271,7 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "874cf3f6a027cebf36cae767feca9aa2e8a8f799880e49eb5540819fcbd8eada" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn", @@ -3560,7 +3466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81327106887e42d004fbdab1fef93675be2e2e07c1b95fce45e2cc813485611d" dependencies = [ "bytes", - "futures 0.3.21", + "futures", "futures-timer", "getrandom 0.2.3", "instant", @@ -3604,7 +3510,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4decc51f3573653a9f4ecacb31b1b922dd20c25a6322bb15318ec04287ec46f9" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "futures-timer", "instant", "libp2p-core", @@ -3627,7 +3533,7 @@ dependencies = [ "ed25519-dalek", "either", "fnv", - "futures 0.3.21", + "futures", "futures-timer", "instant", "lazy_static", @@ -3658,7 +3564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0183dc2a3da1fbbf85e5b6cf51217f55b14f5daea0c455a9536eef646bfec71" dependencies = [ "flate2", - "futures 0.3.21", + "futures", "libp2p-core", ] @@ -3669,7 +3575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6cbf54723250fa5d521383be789bf60efdabe6bacfb443f87da261019a49b4b5" dependencies = [ "async-std-resolver", - "futures 0.3.21", + "futures", "libp2p-core", "log", "parking_lot 0.12.0", @@ -3685,7 +3591,7 @@ checksum = "98a4b6ffd53e355775d24b76f583fdda54b3284806f678499b57913adb94f231" dependencies = [ "cuckoofilter", "fnv", - "futures 0.3.21", + "futures", "libp2p-core", "libp2p-swarm", "log", @@ -3706,7 +3612,7 @@ dependencies = [ "byteorder", "bytes", "fnv", - "futures 0.3.21", + "futures", "hex_fmt", "instant", "libp2p-core", @@ -3730,7 +3636,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c50b585518f8efd06f93ac2f976bd672e17cdac794644b3117edd078e96bda06" dependencies = [ "asynchronous-codec", - "futures 0.3.21", + "futures", "futures-timer", "libp2p-core", "libp2p-swarm", @@ -3755,7 +3661,7 @@ dependencies = [ "bytes", "either", "fnv", - "futures 0.3.21", + "futures", "futures-timer", "instant", "libp2p-core", @@ -3781,7 +3687,7 @@ dependencies = [ "async-io", "data-encoding", "dns-parser", - "futures 0.3.21", + "futures", "if-watch", "lazy_static", "libp2p-core", @@ -3817,7 +3723,7 @@ checksum = "61fd1b20638ec209c5075dfb2e8ce6a7ea4ec3cd3ad7b77f7a477c06d53322e2" dependencies = [ "asynchronous-codec", "bytes", - "futures 0.3.21", + "futures", "libp2p-core", "log", "nohash-hasher", @@ -3835,7 +3741,7 @@ checksum = "762408cb5d84b49a600422d7f9a42c18012d8da6ebcd570f9a4a4290ba41fb6f" dependencies = [ "bytes", "curve25519-dalek 3.0.2", - "futures 0.3.21", + "futures", "lazy_static", "libp2p-core", "log", @@ -3855,7 +3761,7 @@ version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "100a6934ae1dbf8a693a4e7dd1d730fd60b774dafc45688ed63b554497c6c925" dependencies = [ - "futures 0.3.21", + "futures", "futures-timer", "instant", "libp2p-core", @@ -3873,7 +3779,7 @@ checksum = "be27bf0820a6238a4e06365b096d428271cce85a129cf16f2fe9eb1610c4df86" dependencies = [ "asynchronous-codec", "bytes", - "futures 0.3.21", + "futures", "libp2p-core", "log", "prost", @@ -3888,7 +3794,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f1a458bbda880107b5b36fcb9b5a1ef0c329685da0e203ed692a8ebe64cc92c" dependencies = [ - "futures 0.3.21", + "futures", "log", "pin-project", "rand 0.7.3", @@ -3905,7 +3811,7 @@ dependencies = [ "asynchronous-codec", "bytes", "either", - "futures 0.3.21", + "futures", "futures-timer", "instant", "libp2p-core", @@ -3930,7 +3836,7 @@ checksum = "9511c9672ba33284838e349623319c8cad2d18cfad243ae46c6b7e8a2982ea4e" dependencies = [ "asynchronous-codec", "bimap", - "futures 0.3.21", + "futures", "futures-timer", "instant", "libp2p-core", @@ -3953,7 +3859,7 @@ checksum = "508a189e2795d892c8f5c1fa1e9e0b1845d32d7b0b249dbf7b05b18811361843" dependencies = [ "async-trait", "bytes", - "futures 0.3.21", + "futures", "instant", "libp2p-core", "libp2p-swarm", @@ -3971,7 +3877,7 @@ checksum = "95ac5be6c2de2d1ff3f7693fda6faf8a827b1f3e808202277783fea9f527d114" dependencies = [ "either", "fnv", - "futures 0.3.21", + "futures", "futures-timer", "instant", "libp2p-core", @@ -4000,7 +3906,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a6771dc19aa3c65d6af9a8c65222bfc8fcd446630ddca487acd161fa6096f3b" dependencies = [ "async-io", - "futures 0.3.21", + "futures", "futures-timer", "if-watch", "ipnet", @@ -4017,7 +3923,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d125e3e5f0d58f3c6ac21815b20cf4b6a88b8db9dc26368ea821838f4161fd4d" dependencies = [ "async-std", - "futures 0.3.21", + "futures", "libp2p-core", "log", ] @@ -4028,7 +3934,7 @@ version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec894790eec3c1608f8d1a8a0bdf0dbeb79ed4de2dce964222011c2896dfa05a" dependencies = [ - "futures 0.3.21", + "futures", "js-sys", "libp2p-core", "parity-send-wrapper", @@ -4043,7 +3949,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9808e57e81be76ff841c106b4c5974fb4d41a233a7bdd2afbf1687ac6def3818" dependencies = [ "either", - "futures 0.3.21", + "futures", "futures-rustls", "libp2p-core", "log", @@ -4051,7 +3957,7 @@ dependencies = [ "quicksink", "rw-stream-sink", "soketto", - "url 2.2.1", + "url", "webpki-roots", ] @@ -4061,7 +3967,7 @@ version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6dea686217a06072033dc025631932810e2f6ad784e4fafa42e27d311c7a81c" dependencies = [ - "futures 0.3.21", + "futures", "libp2p-core", "parking_lot 0.12.0", "thiserror", @@ -4458,11 +4364,11 @@ dependencies = [ "byteorder", "data-encoding", "multihash", - "percent-encoding 2.1.0", + "percent-encoding", "serde", "static_assertions", "unsigned-varint", - "url 2.2.1", + "url", ] [[package]] @@ -4499,7 +4405,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro-error", "proc-macro2", "quote", @@ -4520,7 +4426,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "363a84be6453a70e63513660f4894ef815daf88e3356bffcda9ca27d810ce83b" dependencies = [ "bytes", - "futures 0.3.21", + "futures", "log", "pin-project", "smallvec", @@ -4610,7 +4516,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef8785b8141e8432aa45fceb922a7e876d7da3fad37fa7e7ec702ace3aa0826b" dependencies = [ "bytes", - "futures 0.3.21", + "futures", "log", "netlink-packet-core", "netlink-sys", @@ -4625,7 +4531,7 @@ checksum = "3e4c9f9547a08241bee7b6558b9b98e1f290d187de8b7cfca2bbb4937bcaa8f8" dependencies = [ "async-io", "bytes", - "futures 0.3.21", + "futures", "libc", "log", ] @@ -4663,7 +4569,7 @@ dependencies = [ "clap 3.1.18", "derive_more", "fs_extra", - "futures 0.3.21", + "futures", "hash-db", "hex", "kvdb", @@ -4705,7 +4611,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-system", "frame-system-rpc-runtime-api", - "futures 0.3.21", + "futures", "hex-literal", "jsonrpsee", "log", @@ -4785,7 +4691,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "futures 0.3.21", + "futures", "node-primitives", "node-runtime", "node-testing", @@ -4848,6 +4754,7 @@ dependencies = [ "node-primitives", "pallet-contracts-rpc", "pallet-mmr-rpc", + "pallet-nomination-pools-rpc", "pallet-transaction-payment-rpc", "sc-chain-spec", "sc-client-api", @@ -5059,7 +4966,7 @@ version = "3.0.0-dev" dependencies = [ "frame-system", "fs_extra", - "futures 0.3.21", + "futures", "log", "node-executor", "node-primitives", @@ -6080,9 +5987,7 @@ dependencies = [ name = "pallet-nomination-pools-rpc" version = "1.0.0-dev" dependencies = [ - "jsonrpc-core", - "jsonrpc-core-client", - "jsonrpc-derive", + "jsonrpsee", "pallet-nomination-pools-rpc-runtime-api", "parity-scale-codec", "sp-api", @@ -6415,7 +6320,7 @@ dependencies = [ name = "pallet-staking-reward-curve" version = "4.0.0-dev" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "sp-runtime", @@ -6708,7 +6613,7 @@ version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn", @@ -6865,12 +6770,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "percent-encoding" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" - [[package]] name = "percent-encoding" version = "2.1.0" @@ -7102,15 +7001,6 @@ dependencies = [ "uint", ] -[[package]] -name = "proc-macro-crate" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" -dependencies = [ - "toml", -] - [[package]] name = "proc-macro-crate" version = "1.1.3" @@ -7841,7 +7731,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f54290e54521dac3de4149d83ddf9f62a359b3cc93bcb494a794a41e6f4744b" dependencies = [ "async-global-executor", - "futures 0.3.21", + "futures", "log", "netlink-packet-route", "netlink-proto", @@ -7958,7 +7848,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" dependencies = [ - "futures 0.3.21", + "futures", "pin-project", "static_assertions", ] @@ -8011,7 +7901,7 @@ name = "sc-authority-discovery" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "futures-timer", "ip_network", "libp2p", @@ -8039,7 +7929,7 @@ dependencies = [ name = "sc-basic-authorship" version = "0.10.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -8096,7 +7986,7 @@ dependencies = [ name = "sc-chain-spec-derive" version = "4.0.0-dev" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn", @@ -8109,7 +7999,7 @@ dependencies = [ "chrono", "clap 3.1.18", "fdlimit", - "futures 0.3.21", + "futures", "hex", "libp2p", "log", @@ -8146,7 +8036,7 @@ name = "sc-client-api" version = "4.0.0-dev" dependencies = [ "fnv", - "futures 0.3.21", + "futures", "hash-db", "log", "parity-scale-codec", @@ -8204,7 +8094,7 @@ name = "sc-consensus" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "futures-timer", "libp2p", "log", @@ -8228,7 +8118,7 @@ name = "sc-consensus-aura" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -8266,7 +8156,7 @@ version = "0.10.0-dev" dependencies = [ "async-trait", "fork-tree", - "futures 0.3.21", + "futures", "log", "merlin", "num-bigint", @@ -8314,7 +8204,7 @@ dependencies = [ name = "sc-consensus-babe-rpc" version = "0.10.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "jsonrpsee", "sc-consensus", "sc-consensus-babe", @@ -8356,7 +8246,7 @@ version = "0.10.0-dev" dependencies = [ "assert_matches", "async-trait", - "futures 0.3.21", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -8392,7 +8282,7 @@ name = "sc-consensus-pow" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -8416,7 +8306,7 @@ name = "sc-consensus-slots" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -8552,7 +8442,7 @@ dependencies = [ "dyn-clone", "finality-grandpa", "fork-tree", - "futures 0.3.21", + "futures", "futures-timer", "hex", "log", @@ -8595,7 +8485,7 @@ name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" dependencies = [ "finality-grandpa", - "futures 0.3.21", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -8620,7 +8510,7 @@ name = "sc-informant" version = "0.10.0-dev" dependencies = [ "ansi_term", - "futures 0.3.21", + "futures", "futures-timer", "log", "parity-util-mem", @@ -8660,7 +8550,7 @@ dependencies = [ "either", "fnv", "fork-tree", - "futures 0.3.21", + "futures", "futures-timer", "hex", "ip_network", @@ -8708,7 +8598,7 @@ name = "sc-network-common" version = "0.10.0-dev" dependencies = [ "bitflags", - "futures 0.3.21", + "futures", "libp2p", "parity-scale-codec", "prost-build", @@ -8726,7 +8616,7 @@ version = "0.10.0-dev" dependencies = [ "ahash", "async-std", - "futures 0.3.21", + "futures", "futures-timer", "libp2p", "log", @@ -8743,7 +8633,7 @@ dependencies = [ name = "sc-network-light" version = "0.10.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "libp2p", "log", "parity-scale-codec", @@ -8763,7 +8653,7 @@ name = "sc-network-sync" version = "0.10.0-dev" dependencies = [ "fork-tree", - "futures 0.3.21", + "futures", "libp2p", "log", "lru", @@ -8795,7 +8685,7 @@ version = "0.8.0" dependencies = [ "async-std", "async-trait", - "futures 0.3.21", + "futures", "futures-timer", "libp2p", "log", @@ -8825,7 +8715,7 @@ version = "4.0.0-dev" dependencies = [ "bytes", "fnv", - "futures 0.3.21", + "futures", "futures-timer", "hex", "hyper", @@ -8859,7 +8749,7 @@ dependencies = [ name = "sc-peerset" version = "4.0.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "libp2p", "log", "rand 0.7.3", @@ -8882,7 +8772,7 @@ version = "4.0.0-dev" dependencies = [ "assert_matches", "env_logger 0.9.0", - "futures 0.3.21", + "futures", "hash-db", "jsonrpsee", "lazy_static", @@ -8918,7 +8808,7 @@ dependencies = [ name = "sc-rpc-api" version = "0.10.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -8940,7 +8830,7 @@ dependencies = [ name = "sc-rpc-server" version = "4.0.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "jsonrpsee", "log", "serde_json", @@ -8970,7 +8860,7 @@ dependencies = [ "async-trait", "directories", "exit-future", - "futures 0.3.21", + "futures", "futures-timer", "hash-db", "jsonrpsee", @@ -9036,7 +8926,7 @@ name = "sc-service-test" version = "2.0.0" dependencies = [ "fdlimit", - "futures 0.3.21", + "futures", "hex", "hex-literal", "log", @@ -9102,7 +8992,7 @@ dependencies = [ name = "sc-sysinfo" version = "6.0.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "libc", "log", "rand 0.7.3", @@ -9121,7 +9011,7 @@ name = "sc-telemetry" version = "4.0.0-dev" dependencies = [ "chrono", - "futures 0.3.21", + "futures", "libp2p", "log", "parking_lot 0.12.0", @@ -9168,7 +9058,7 @@ dependencies = [ name = "sc-tracing-proc-macro" version = "4.0.0-dev" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn", @@ -9180,7 +9070,7 @@ version = "4.0.0-dev" dependencies = [ "assert_matches", "criterion", - "futures 0.3.21", + "futures", "futures-timer", "hex", "linked-hash-map", @@ -9212,7 +9102,7 @@ dependencies = [ name = "sc-transaction-pool-api" version = "4.0.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "log", "serde", "sp-blockchain", @@ -9224,7 +9114,7 @@ dependencies = [ name = "sc-utils" version = "4.0.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "futures-timer", "lazy_static", "log", @@ -9253,7 +9143,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4260c630e8a8a33429d1688eff2f163f24c65a4e1b1578ef6b565061336e4b6f" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn", @@ -9674,7 +9564,7 @@ dependencies = [ "base64", "bytes", "flate2", - "futures 0.3.21", + "futures", "httparse", "log", "rand 0.8.4", @@ -9703,7 +9593,7 @@ name = "sp-api-proc-macro" version = "4.0.0-dev" dependencies = [ "blake2", - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn", @@ -9714,7 +9604,7 @@ name = "sp-api-test" version = "2.0.1" dependencies = [ "criterion", - "futures 0.3.21", + "futures", "log", "parity-scale-codec", "rustversion", @@ -9820,7 +9710,7 @@ dependencies = [ name = "sp-blockchain" version = "4.0.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "log", "lru", "parity-scale-codec", @@ -9838,7 +9728,7 @@ name = "sp-consensus" version = "0.10.0-dev" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "futures-timer", "log", "parity-scale-codec", @@ -9938,7 +9828,7 @@ dependencies = [ "criterion", "dyn-clonable", "ed25519-dalek", - "futures 0.3.21", + "futures", "hash-db", "hash256-std-hasher", "hex", @@ -10049,7 +9939,7 @@ name = "sp-inherents" version = "4.0.0-dev" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "impl-trait-for-tuples", "parity-scale-codec", "sp-core", @@ -10062,7 +9952,7 @@ dependencies = [ name = "sp-io" version = "6.0.0" dependencies = [ - "futures 0.3.21", + "futures", "hash-db", "libsecp256k1", "log", @@ -10097,7 +9987,7 @@ name = "sp-keystore" version = "0.12.0" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "merlin", "parity-scale-codec", "parking_lot 0.12.0", @@ -10243,7 +10133,7 @@ name = "sp-runtime-interface-proc-macro" version = "5.0.0" dependencies = [ "Inflector", - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn", @@ -10627,7 +10517,7 @@ version = "3.0.0" dependencies = [ "frame-support", "frame-system", - "futures 0.3.21", + "futures", "jsonrpsee", "parity-scale-codec", "sc-rpc-api", @@ -10643,7 +10533,7 @@ version = "4.0.0-dev" dependencies = [ "assert_matches", "frame-system-rpc-runtime-api", - "futures 0.3.21", + "futures", "jsonrpsee", "log", "parity-scale-codec", @@ -10700,7 +10590,7 @@ name = "substrate-test-client" version = "2.0.1" dependencies = [ "async-trait", - "futures 0.3.21", + "futures", "hex", "parity-scale-codec", "sc-client-api", @@ -10730,7 +10620,7 @@ dependencies = [ "frame-support", "frame-system", "frame-system-rpc-runtime-api", - "futures 0.3.21", + "futures", "log", "memory-db", "pallet-babe", @@ -10772,7 +10662,7 @@ dependencies = [ name = "substrate-test-runtime-client" version = "2.0.0" dependencies = [ - "futures 0.3.21", + "futures", "parity-scale-codec", "sc-block-builder", "sc-client-api", @@ -10790,7 +10680,7 @@ dependencies = [ name = "substrate-test-runtime-transaction-pool" version = "2.0.0" dependencies = [ - "futures 0.3.21", + "futures", "parity-scale-codec", "parking_lot 0.12.0", "sc-transaction-pool", @@ -10805,7 +10695,7 @@ dependencies = [ name = "substrate-test-utils" version = "4.0.0-dev" dependencies = [ - "futures 0.3.21", + "futures", "sc-service", "substrate-test-utils-derive", "tokio", @@ -10816,7 +10706,7 @@ dependencies = [ name = "substrate-test-utils-derive" version = "0.10.0-dev" dependencies = [ - "proc-macro-crate 1.1.3", + "proc-macro-crate", "proc-macro2", "quote", "syn", @@ -11332,7 +11222,7 @@ dependencies = [ "futures-channel", "futures-io", "futures-util", - "idna 0.2.3", + "idna", "ipnet", "lazy_static", "log", @@ -11340,7 +11230,7 @@ dependencies = [ "smallvec", "thiserror", "tinyvec", - "url 2.2.1", + "url", ] [[package]] @@ -11529,17 +11419,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna 0.1.5", - "matches", - "percent-encoding 1.0.1", -] - [[package]] name = "url" version = "2.2.1" @@ -11547,9 +11426,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" dependencies = [ "form_urlencoded", - "idna 0.2.3", + "idna", "matches", - "percent-encoding 2.1.0", + "percent-encoding", ] [[package]] @@ -11732,7 +11611,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures 0.3.21", + "futures", "js-sys", "parking_lot 0.11.2", "pin-utils", @@ -12430,7 +12309,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c0608f53c1dc0bad505d03a34bbd49fbf2ad7b51eb036123e896365532745a1" dependencies = [ - "futures 0.3.21", + "futures", "log", "nohash-hasher", "parking_lot 0.12.0", diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index 547d0df7a8372..8b6e4bbdf9a9c 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -16,6 +16,7 @@ node-primitives = { version = "2.0.0", path = "../primitives" } pallet-contracts-rpc = { version = "4.0.0-dev", path = "../../../frame/contracts/rpc/" } pallet-mmr-rpc = { version = "3.0.0", path = "../../../frame/merkle-mountain-range/rpc/" } pallet-transaction-payment-rpc = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/rpc/" } +pallet-nomination-pools-rpc = { version = "1.0.0-dev", path = "../../../frame/nomination-pools/rpc/"} sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" } sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" } diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index e5b666195e1bc..48a2c5db364ce 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -111,6 +111,7 @@ where C::Api: pallet_contracts_rpc::ContractsRuntimeApi, C::Api: pallet_mmr_rpc::MmrRuntimeApi::Hash>, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, + C::Api: pallet_nomination_pools_rpc::NominationPoolsRuntimeApi, C::Api: BabeApi, C::Api: BlockBuilder, P: TransactionPool + 'static, @@ -120,6 +121,7 @@ where { use pallet_contracts_rpc::{Contracts, ContractsApiServer}; use pallet_mmr_rpc::{Mmr, MmrApiServer}; + use pallet_nomination_pools_rpc::{NominationPoolsRpcServer, NominationPoolsRpcType}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_consensus_babe_rpc::{Babe, BabeApiServer}; use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer}; @@ -147,6 +149,7 @@ where io.merge(Contracts::new(client.clone()).into_rpc())?; io.merge(Mmr::new(client.clone()).into_rpc())?; io.merge(TransactionPayment::new(client.clone()).into_rpc())?; + io.merge(NominationPoolsRpcType::new(client.clone()).into_rpc())?; io.merge( Babe::new( client.clone(), diff --git a/frame/nomination-pools/rpc/Cargo.toml b/frame/nomination-pools/rpc/Cargo.toml index 326ec557ea28f..53b1cf818d47c 100644 --- a/frame/nomination-pools/rpc/Cargo.toml +++ b/frame/nomination-pools/rpc/Cargo.toml @@ -14,9 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0" } -jsonrpc-core = "18.0.0" -jsonrpc-core-client = "18.0.0" -jsonrpc-derive = "18.0.0" +jsonrpsee = { version = "0.14.0", features = ["server", "macros"] } sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index b9dc66ef80656..88ea8ece1e288 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -17,24 +17,21 @@ //! RPC interface for the nomination-pools pallet. -pub use self::gen_client::Client as NominationPoolsClient; use codec::Codec; -use jsonrpc_core::Error; -use jsonrpc_derive::rpc; +use jsonrpsee::{ + core::{async_trait, RpcResult}, + proc_macros::rpc, +}; pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_runtime::{generic::BlockId, traits::Block as BlockT}; use std::sync::Arc; -#[rpc] +#[rpc(client, server)] pub trait NominationPoolsRpc { - #[rpc(name = "nominationPools_pending_rewards")] - fn pending_rewards( - &self, - member: AccountId, - at: Option, - ) -> Result; + #[method(name = "nominationPools_pending_rewards")] + fn pending_rewards(&self, member: AccountId, at: Option) -> RpcResult; } pub struct NominationPoolsRpcType { @@ -48,7 +45,9 @@ impl NominationPoolsRpcType { } } -impl NominationPoolsRpc<::Hash, AccountId, Balance> +#[async_trait] +impl + NominationPoolsRpcServer<::Hash, AccountId, Balance> for NominationPoolsRpcType where Block: BlockT, @@ -57,11 +56,7 @@ where AccountId: Codec, Balance: Codec + Default, { - fn pending_rewards( - &self, - member: AccountId, - at: Option, - ) -> Result { + fn pending_rewards(&self, member: AccountId, at: Option) -> RpcResult { let api = self.client.runtime_api(); let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); From 83a1b3f5dcbaba98c030ee37a02ceb644c183f75 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Sun, 17 Jul 2022 15:12:27 +0300 Subject: [PATCH 22/41] Update Cargo.toml --- bin/node/rpc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index 8b6e4bbdf9a9c..598e8997c6d2e 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -16,7 +16,7 @@ node-primitives = { version = "2.0.0", path = "../primitives" } pallet-contracts-rpc = { version = "4.0.0-dev", path = "../../../frame/contracts/rpc/" } pallet-mmr-rpc = { version = "3.0.0", path = "../../../frame/merkle-mountain-range/rpc/" } pallet-transaction-payment-rpc = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/rpc/" } -pallet-nomination-pools-rpc = { version = "1.0.0-dev", path = "../../../frame/nomination-pools/rpc/"} +pallet-nomination-pools-rpc = { version = "1.0.0-dev", path = "../../../frame/nomination-pools/rpc/" } sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" } sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" } From 3eeb3e662c198477db4f17d2e14fc6d6dfea3af1 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Sun, 17 Jul 2022 15:38:50 +0300 Subject: [PATCH 23/41] Update Cargo.toml --- bin/node/runtime/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 15d984e3de3c9..7478c64d50bb3 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -79,7 +79,7 @@ pallet-mmr = { version = "4.0.0-dev", default-features = false, path = "../../.. pallet-multisig = { version = "4.0.0-dev", default-features = false, path = "../../../frame/multisig" } pallet-nomination-pools = { version = "1.0.0", default-features = false, path = "../../../frame/nomination-pools"} pallet-nomination-pools-benchmarking = { version = "1.0.0", default-features = false, optional = true, path = "../../../frame/nomination-pools/benchmarking" } -pallet-nomination-pools-rpc-runtime-api = { version = "1.0.0-dev", default-features = false, path = "../../../frame/nomination-pools/rpc/runtime-api"} +pallet-nomination-pools-rpc-runtime-api = { version = "1.0.0-dev", default-features = false, path = "../../../frame/nomination-pools/rpc/runtime-api" } pallet-offences = { version = "4.0.0-dev", default-features = false, path = "../../../frame/offences" } pallet-offences-benchmarking = { version = "4.0.0-dev", path = "../../../frame/offences/benchmarking", default-features = false, optional = true } pallet-preimage = { version = "4.0.0-dev", default-features = false, path = "../../../frame/preimage" } From 24c12304d0accd2b88877e04e9ac82fe04cb4071 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Sun, 17 Jul 2022 18:58:19 +0300 Subject: [PATCH 24/41] fix wrong reward counter --- bin/node/runtime/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 461b0c60908aa..fbc2228060c5e 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2018-2022 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify @@ -1838,7 +1838,9 @@ impl_runtime_apis! { impl pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi for Runtime { fn pending_rewards(member_account: AccountId) -> Balance { if let Some(member) = pallet_nomination_pools::PoolMembers::::get(member_account) { - return member.pending_rewards(member.last_recorded_reward_counter).unwrap_or_default(); + if let Some(pool) = pallet_nomination_pools::RewardPools::::get(member.pool_id) { + return member.pending_rewards(pool.last_recorded_reward_counter()).unwrap_or_default(); + } } Balance::default() } From 685a1168d43a5da45fa662f89a0d3a40d7fc08e5 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Sun, 17 Jul 2022 19:00:53 +0300 Subject: [PATCH 25/41] expose function --- frame/nomination-pools/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 40a149d0f33a8..a078b4930a79c 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -939,7 +939,7 @@ pub struct RewardPool { impl RewardPool { /// Getter for [`RewardPool::last_recorded_reward_counter`]. - fn last_recorded_reward_counter(&self) -> T::RewardCounter { + pub fn last_recorded_reward_counter(&self) -> T::RewardCounter { self.last_recorded_reward_counter } From 756f1b05a767032108f46095226f2d31da95ddf4 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 17 Jul 2022 21:06:13 +0300 Subject: [PATCH 26/41] move implementation --- bin/node/runtime/src/lib.rs | 7 +------ frame/nomination-pools/src/lib.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index fbc2228060c5e..c6da6298be6d6 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1837,12 +1837,7 @@ impl_runtime_apis! { impl pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi for Runtime { fn pending_rewards(member_account: AccountId) -> Balance { - if let Some(member) = pallet_nomination_pools::PoolMembers::::get(member_account) { - if let Some(pool) = pallet_nomination_pools::RewardPools::::get(member.pool_id) { - return member.pending_rewards(pool.last_recorded_reward_counter()).unwrap_or_default(); - } - } - Balance::default() + NominationPools::pending_rewards(member_account) } } diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index a078b4930a79c..069a2e46aac2e 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -2145,6 +2145,20 @@ pub mod pallet { } impl Pallet { + /// Returns the pending rewards for the specified member. + /// + /// In case of some error returns balance of 0. + pub fn pending_rewards(member_account: T::AccountId) -> BalanceOf { + if let Some(member) = PoolMembers::::get(member_account) { + if let Some(pool) = RewardPools::::get(member.pool_id) { + return member + .pending_rewards(pool.last_recorded_reward_counter()) + .unwrap_or_default() + } + } + BalanceOf::::default() + } + /// The amount of bond that MUST REMAIN IN BONDED in ALL POOLS. /// /// It is the responsibility of the depositor to put these funds into the pool initially. Upon From 36dfaf39793f3dc74ca7556a94999732c9bb6ace Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Sun, 17 Jul 2022 21:31:28 +0300 Subject: [PATCH 27/41] docs --- frame/nomination-pools/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 069a2e46aac2e..df79b5f3b6c90 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -2145,7 +2145,7 @@ pub mod pallet { } impl Pallet { - /// Returns the pending rewards for the specified member. + /// Returns the pending rewards for the specified `member_account`. /// /// In case of some error returns balance of 0. pub fn pending_rewards(member_account: T::AccountId) -> BalanceOf { From 6b8968a552c0ad0d9992f5954a6bf1622bc7ea3d Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Mon, 18 Jul 2022 08:31:25 +0300 Subject: [PATCH 28/41] docs --- frame/nomination-pools/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index df79b5f3b6c90..b88c011844d10 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -2147,7 +2147,7 @@ pub mod pallet { impl Pallet { /// Returns the pending rewards for the specified `member_account`. /// - /// In case of some error returns balance of 0. + /// In the case of error the function returns balance of 0. pub fn pending_rewards(member_account: T::AccountId) -> BalanceOf { if let Some(member) = PoolMembers::::get(member_account) { if let Some(pool) = RewardPools::::get(member.pool_id) { From 6d976b3185bddbb9e692768243e378bdd6804f70 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Mon, 18 Jul 2022 08:53:46 +0300 Subject: [PATCH 29/41] docs --- frame/nomination-pools/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index b88c011844d10..396c74c9947ae 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -2147,7 +2147,7 @@ pub mod pallet { impl Pallet { /// Returns the pending rewards for the specified `member_account`. /// - /// In the case of error the function returns balance of 0. + /// In the case of error the function returns balance of zero. pub fn pending_rewards(member_account: T::AccountId) -> BalanceOf { if let Some(member) = PoolMembers::::get(member_account) { if let Some(pool) = RewardPools::::get(member.pool_id) { From 5650a9ace3798bb6ebfc1eb4ceba67a9de1d3d72 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Mon, 18 Jul 2022 09:17:05 +0300 Subject: [PATCH 30/41] Update lib.rs --- frame/nomination-pools/rpc/runtime-api/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index 44d019350cd62..af38f2ecb4b8e 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -16,6 +16,7 @@ // limitations under the License. //! Runtime API definition for nomination-pools pallet. +//! Currently supports only one rpc endpoint. #![cfg_attr(not(feature = "std"), no_std)] From 1bb1bd6ebaa2afc6f7932020ea07bce2c4f0a306 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Mon, 18 Jul 2022 10:16:42 +0300 Subject: [PATCH 31/41] Update lib.rs --- frame/nomination-pools/rpc/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs index 88ea8ece1e288..977b4a782741f 100644 --- a/frame/nomination-pools/rpc/src/lib.rs +++ b/frame/nomination-pools/rpc/src/lib.rs @@ -16,6 +16,7 @@ // limitations under the License. //! RPC interface for the nomination-pools pallet. +//! Currently supports only one rpc endpoint. use codec::Codec; use jsonrpsee::{ From 0d9477fbc16ea66b99da36e349edfb789155c0f3 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 18 Jul 2022 20:41:24 +0300 Subject: [PATCH 32/41] unexpose functions --- frame/nomination-pools/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 396c74c9947ae..c952c897b1dcd 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -378,7 +378,7 @@ pub struct PoolMember { impl PoolMember { /// The pending rewards of this member. - pub fn pending_rewards( + fn pending_rewards( &self, current_reward_counter: T::RewardCounter, ) -> Result, Error> { @@ -939,7 +939,7 @@ pub struct RewardPool { impl RewardPool { /// Getter for [`RewardPool::last_recorded_reward_counter`]. - pub fn last_recorded_reward_counter(&self) -> T::RewardCounter { + pub(crate) fn last_recorded_reward_counter(&self) -> T::RewardCounter { self.last_recorded_reward_counter } From 3964f8c67f057152bd456cd6a89bfc7380e20ee6 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 19 Jul 2022 07:35:28 +0300 Subject: [PATCH 33/41] unused dependency --- frame/nomination-pools/rpc/runtime-api/Cargo.toml | 2 -- frame/nomination-pools/rpc/runtime-api/src/lib.rs | 1 - 2 files changed, 3 deletions(-) diff --git a/frame/nomination-pools/rpc/runtime-api/Cargo.toml b/frame/nomination-pools/rpc/runtime-api/Cargo.toml index 4674c83fab7b5..5aace263d1e67 100644 --- a/frame/nomination-pools/rpc/runtime-api/Cargo.toml +++ b/frame/nomination-pools/rpc/runtime-api/Cargo.toml @@ -16,7 +16,6 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/api" } sp-std = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/std" } -pallet-nomination-pools = { default-features = false, path = "../../" } [features] default = ["std"] @@ -24,5 +23,4 @@ std = [ "codec/std", "sp-api/std", "sp-std/std", - "pallet-nomination-pools/std", ] diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index af38f2ecb4b8e..e5705f26a4a5b 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -21,7 +21,6 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::Codec; -pub use pallet_nomination_pools::PoolId; sp_api::decl_runtime_apis! { pub trait NominationPoolsApi From 8d263150a54f1d60b625595e9d85d65a0d24edb7 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 19 Jul 2022 07:42:14 +0300 Subject: [PATCH 34/41] update Cargo.lock --- Cargo.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 3888243ba1d58..3ad5b6d1aae12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6002,7 +6002,6 @@ dependencies = [ name = "pallet-nomination-pools-rpc-runtime-api" version = "1.0.0-dev" dependencies = [ - "pallet-nomination-pools", "parity-scale-codec", "sp-api", "sp-std", From f38fded38cb801ccae84485673e4760ddfda9160 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Fri, 22 Jul 2022 21:44:37 +0100 Subject: [PATCH 35/41] Update frame/nomination-pools/src/lib.rs --- frame/nomination-pools/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index c952c897b1dcd..8b78c3f8e8f60 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -2150,9 +2150,9 @@ impl Pallet { /// In the case of error the function returns balance of zero. pub fn pending_rewards(member_account: T::AccountId) -> BalanceOf { if let Some(member) = PoolMembers::::get(member_account) { - if let Some(pool) = RewardPools::::get(member.pool_id) { + if let Some(reward_pool) = RewardPools::::get(member.pool_id) { return member - .pending_rewards(pool.last_recorded_reward_counter()) + .pending_rewards(reward_pool.last_recorded_reward_counter()) .unwrap_or_default() } } From 6a25e615021abd80d1f045406b3bce157a4b7a53 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Sat, 23 Jul 2022 08:44:03 +0300 Subject: [PATCH 36/41] Update lib.rs --- frame/nomination-pools/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 8b78c3f8e8f60..6d5d2721dd2e7 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -2149,9 +2149,9 @@ impl Pallet { /// /// In the case of error the function returns balance of zero. pub fn pending_rewards(member_account: T::AccountId) -> BalanceOf { - if let Some(member) = PoolMembers::::get(member_account) { - if let Some(reward_pool) = RewardPools::::get(member.pool_id) { - return member + if let Some(pool_member) = PoolMembers::::get(member_account) { + if let Some(reward_pool) = RewardPools::::get(pool_member.pool_id) { + return pool_member .pending_rewards(reward_pool.last_recorded_reward_counter()) .unwrap_or_default() } From 38f5cf01363b3770dea04cc3461bc0b5597a42d9 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Sat, 23 Jul 2022 09:19:44 +0300 Subject: [PATCH 37/41] Update lib.rs --- frame/nomination-pools/rpc/runtime-api/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index e5705f26a4a5b..64dbbaf2df333 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -26,7 +26,7 @@ sp_api::decl_runtime_apis! { pub trait NominationPoolsApi where AccountId: Codec, Balance: Codec { - /// Returns the pending rewards for the given member. + /// Returns the pending rewards for the member that the AccountId was given for. fn pending_rewards(member: AccountId) -> Balance; } } From c198ade9114ac1bd598fa3989d0acca505391219 Mon Sep 17 00:00:00 2001 From: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Date: Mon, 25 Jul 2022 18:26:00 +0200 Subject: [PATCH 38/41] Update frame/nomination-pools/rpc/runtime-api/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- frame/nomination-pools/rpc/runtime-api/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/rpc/runtime-api/src/lib.rs index 64dbbaf2df333..aa3ca57ca5b8b 100644 --- a/frame/nomination-pools/rpc/runtime-api/src/lib.rs +++ b/frame/nomination-pools/rpc/runtime-api/src/lib.rs @@ -23,6 +23,7 @@ use codec::Codec; sp_api::decl_runtime_apis! { + /// Runtime api for accessing information about nomination pools. pub trait NominationPoolsApi where AccountId: Codec, Balance: Codec { From 75d72f4387d19cc7628a6e8d08a0691d2e5473af Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 26 Jul 2022 00:13:43 +0200 Subject: [PATCH 39/41] remove rpc --- Cargo.lock | 15 ------ Cargo.toml | 1 - bin/node/rpc/Cargo.toml | 1 - bin/node/rpc/src/lib.rs | 3 -- frame/nomination-pools/rpc/Cargo.toml | 24 --------- frame/nomination-pools/rpc/src/README.md | 3 -- frame/nomination-pools/rpc/src/lib.rs | 66 ------------------------ 7 files changed, 113 deletions(-) delete mode 100644 frame/nomination-pools/rpc/Cargo.toml delete mode 100644 frame/nomination-pools/rpc/src/README.md delete mode 100644 frame/nomination-pools/rpc/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index aba81bb7691bd..e1eeb533752c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4754,7 +4754,6 @@ dependencies = [ "node-primitives", "pallet-contracts-rpc", "pallet-mmr-rpc", - "pallet-nomination-pools-rpc", "pallet-transaction-payment-rpc", "sc-chain-spec", "sc-client-api", @@ -5985,20 +5984,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-nomination-pools-rpc" -version = "1.0.0-dev" -dependencies = [ - "jsonrpsee", - "pallet-nomination-pools-rpc-runtime-api", - "parity-scale-codec", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-rpc", - "sp-runtime", -] - [[package]] name = "pallet-nomination-pools-rpc-runtime-api" version = "1.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index c4686c017075c..d71a0cdb1fd54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,7 +116,6 @@ members = [ "frame/nomination-pools", "frame/nomination-pools/benchmarking", "frame/nomination-pools/test-staking", - "frame/nomination-pools/rpc", "frame/nomination-pools/rpc/runtime-api", "frame/randomness-collective-flip", "frame/ranked-collective", diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index 598e8997c6d2e..547d0df7a8372 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -16,7 +16,6 @@ node-primitives = { version = "2.0.0", path = "../primitives" } pallet-contracts-rpc = { version = "4.0.0-dev", path = "../../../frame/contracts/rpc/" } pallet-mmr-rpc = { version = "3.0.0", path = "../../../frame/merkle-mountain-range/rpc/" } pallet-transaction-payment-rpc = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/rpc/" } -pallet-nomination-pools-rpc = { version = "1.0.0-dev", path = "../../../frame/nomination-pools/rpc/" } sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" } sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" } sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" } diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index 48a2c5db364ce..e5b666195e1bc 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -111,7 +111,6 @@ where C::Api: pallet_contracts_rpc::ContractsRuntimeApi, C::Api: pallet_mmr_rpc::MmrRuntimeApi::Hash>, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - C::Api: pallet_nomination_pools_rpc::NominationPoolsRuntimeApi, C::Api: BabeApi, C::Api: BlockBuilder, P: TransactionPool + 'static, @@ -121,7 +120,6 @@ where { use pallet_contracts_rpc::{Contracts, ContractsApiServer}; use pallet_mmr_rpc::{Mmr, MmrApiServer}; - use pallet_nomination_pools_rpc::{NominationPoolsRpcServer, NominationPoolsRpcType}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use sc_consensus_babe_rpc::{Babe, BabeApiServer}; use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer}; @@ -149,7 +147,6 @@ where io.merge(Contracts::new(client.clone()).into_rpc())?; io.merge(Mmr::new(client.clone()).into_rpc())?; io.merge(TransactionPayment::new(client.clone()).into_rpc())?; - io.merge(NominationPoolsRpcType::new(client.clone()).into_rpc())?; io.merge( Babe::new( client.clone(), diff --git a/frame/nomination-pools/rpc/Cargo.toml b/frame/nomination-pools/rpc/Cargo.toml deleted file mode 100644 index 53b1cf818d47c..0000000000000 --- a/frame/nomination-pools/rpc/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "pallet-nomination-pools-rpc" -version = "1.0.0-dev" -authors = ["Parity Technologies "] -edition = "2021" -license = "Apache-2.0" -homepage = "https://substrate.io" -repository = "https://github.com/paritytech/substrate/" -description = "RPC interface for the nomination-pools pallet." -readme = "README.md" - -[package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.0.0" } -jsonrpsee = { version = "0.14.0", features = ["server", "macros"] } - -sp-api = { version = "4.0.0-dev", path = "../../../primitives/api" } -sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } -sp-core = { version = "6.0.0", path = "../../../primitives/core" } -sp-rpc = { version = "6.0.0", path = "../../../primitives/rpc" } -sp-runtime = { version = "6.0.0", path = "../../../primitives/runtime" } -pallet-nomination-pools-rpc-runtime-api = { path = "./runtime-api" } diff --git a/frame/nomination-pools/rpc/src/README.md b/frame/nomination-pools/rpc/src/README.md deleted file mode 100644 index 259e056014bb4..0000000000000 --- a/frame/nomination-pools/rpc/src/README.md +++ /dev/null @@ -1,3 +0,0 @@ -RPC interface for the nomination-pools pallet. - -License: Apache-2.0 \ No newline at end of file diff --git a/frame/nomination-pools/rpc/src/lib.rs b/frame/nomination-pools/rpc/src/lib.rs deleted file mode 100644 index 977b4a782741f..0000000000000 --- a/frame/nomination-pools/rpc/src/lib.rs +++ /dev/null @@ -1,66 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! RPC interface for the nomination-pools pallet. -//! Currently supports only one rpc endpoint. - -use codec::Codec; -use jsonrpsee::{ - core::{async_trait, RpcResult}, - proc_macros::rpc, -}; -pub use pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi as NominationPoolsRuntimeApi; -use sp_api::ProvideRuntimeApi; -use sp_blockchain::HeaderBackend; -use sp_runtime::{generic::BlockId, traits::Block as BlockT}; -use std::sync::Arc; - -#[rpc(client, server)] -pub trait NominationPoolsRpc { - #[method(name = "nominationPools_pending_rewards")] - fn pending_rewards(&self, member: AccountId, at: Option) -> RpcResult; -} - -pub struct NominationPoolsRpcType { - client: Arc, - _marker: std::marker::PhantomData

, -} - -impl NominationPoolsRpcType { - pub fn new(client: Arc) -> Self { - Self { client, _marker: Default::default() } - } -} - -#[async_trait] -impl - NominationPoolsRpcServer<::Hash, AccountId, Balance> - for NominationPoolsRpcType -where - Block: BlockT, - C: 'static + ProvideRuntimeApi + HeaderBackend, - C::Api: NominationPoolsRuntimeApi, - AccountId: Codec, - Balance: Codec + Default, -{ - fn pending_rewards(&self, member: AccountId, at: Option) -> RpcResult { - let api = self.client.runtime_api(); - let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash)); - - Ok(api.pending_rewards(&at, member).unwrap_or_default()) - } -} From c17560b6b24d2a56b2906c4428ca9b3e4ee7db16 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 26 Jul 2022 10:37:22 +0200 Subject: [PATCH 40/41] remove rpc directory --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- bin/node/runtime/Cargo.toml | 4 ++-- frame/nomination-pools/{rpc => }/runtime-api/Cargo.toml | 8 ++++---- frame/nomination-pools/{rpc => }/runtime-api/README.md | 0 frame/nomination-pools/{rpc => }/runtime-api/src/lib.rs | 0 6 files changed, 9 insertions(+), 9 deletions(-) rename frame/nomination-pools/{rpc => }/runtime-api/Cargo.toml (77%) rename frame/nomination-pools/{rpc => }/runtime-api/README.md (100%) rename frame/nomination-pools/{rpc => }/runtime-api/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index dd06a92a521f0..50603c6235a23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4759,7 +4759,7 @@ dependencies = [ "pallet-multisig", "pallet-nomination-pools", "pallet-nomination-pools-benchmarking", - "pallet-nomination-pools-rpc-runtime-api", + "pallet-nomination-pools-runtime-api", "pallet-offences", "pallet-offences-benchmarking", "pallet-preimage", @@ -5913,7 +5913,7 @@ dependencies = [ ] [[package]] -name = "pallet-nomination-pools-rpc-runtime-api" +name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" dependencies = [ "parity-scale-codec", diff --git a/Cargo.toml b/Cargo.toml index d71a0cdb1fd54..1f22343c002a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,7 +116,7 @@ members = [ "frame/nomination-pools", "frame/nomination-pools/benchmarking", "frame/nomination-pools/test-staking", - "frame/nomination-pools/rpc/runtime-api", + "frame/nomination-pools/runtime-api", "frame/randomness-collective-flip", "frame/ranked-collective", "frame/recovery", diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 7478c64d50bb3..d3138ce51de9c 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -79,7 +79,7 @@ pallet-mmr = { version = "4.0.0-dev", default-features = false, path = "../../.. pallet-multisig = { version = "4.0.0-dev", default-features = false, path = "../../../frame/multisig" } pallet-nomination-pools = { version = "1.0.0", default-features = false, path = "../../../frame/nomination-pools"} pallet-nomination-pools-benchmarking = { version = "1.0.0", default-features = false, optional = true, path = "../../../frame/nomination-pools/benchmarking" } -pallet-nomination-pools-rpc-runtime-api = { version = "1.0.0-dev", default-features = false, path = "../../../frame/nomination-pools/rpc/runtime-api" } +pallet-nomination-pools-runtime-api = { version = "1.0.0-dev", default-features = false, path = "../../../frame/nomination-pools/runtime-api" } pallet-offences = { version = "4.0.0-dev", default-features = false, path = "../../../frame/offences" } pallet-offences-benchmarking = { version = "4.0.0-dev", path = "../../../frame/offences/benchmarking", default-features = false, optional = true } pallet-preimage = { version = "4.0.0-dev", default-features = false, path = "../../../frame/preimage" } @@ -146,7 +146,7 @@ std = [ "pallet-mmr/std", "pallet-multisig/std", "pallet-nomination-pools/std", - "pallet-nomination-pools-rpc-runtime-api/std", + "pallet-nomination-pools-runtime-api/std", "pallet-identity/std", "pallet-scheduler/std", "node-primitives/std", diff --git a/frame/nomination-pools/rpc/runtime-api/Cargo.toml b/frame/nomination-pools/runtime-api/Cargo.toml similarity index 77% rename from frame/nomination-pools/rpc/runtime-api/Cargo.toml rename to frame/nomination-pools/runtime-api/Cargo.toml index 5aace263d1e67..dde925c62fe0d 100644 --- a/frame/nomination-pools/rpc/runtime-api/Cargo.toml +++ b/frame/nomination-pools/runtime-api/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "pallet-nomination-pools-rpc-runtime-api" +name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" authors = ["Parity Technologies "] edition = "2021" license = "Apache-2.0" homepage = "https://substrate.io" repository = "https://github.com/paritytech/substrate/" -description = "RPC runtime API for nomination-pools FRAME pallet" +description = "Runtime API for nomination-pools FRAME pallet" readme = "README.md" [package.metadata.docs.rs] @@ -14,8 +14,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } -sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/api" } -sp-std = { version = "4.0.0-dev", default-features = false, path = "../../../../primitives/std" } +sp-api = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/api" } +sp-std = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/std" } [features] default = ["std"] diff --git a/frame/nomination-pools/rpc/runtime-api/README.md b/frame/nomination-pools/runtime-api/README.md similarity index 100% rename from frame/nomination-pools/rpc/runtime-api/README.md rename to frame/nomination-pools/runtime-api/README.md diff --git a/frame/nomination-pools/rpc/runtime-api/src/lib.rs b/frame/nomination-pools/runtime-api/src/lib.rs similarity index 100% rename from frame/nomination-pools/rpc/runtime-api/src/lib.rs rename to frame/nomination-pools/runtime-api/src/lib.rs From 18cb8f51998d8f2cdb428530aab5dfa3b26d7e24 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 26 Jul 2022 10:44:37 +0200 Subject: [PATCH 41/41] final fix --- bin/node/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index c6da6298be6d6..037211155cf0e 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1835,7 +1835,7 @@ impl_runtime_apis! { } } - impl pallet_nomination_pools_rpc_runtime_api::NominationPoolsApi for Runtime { + impl pallet_nomination_pools_runtime_api::NominationPoolsApi for Runtime { fn pending_rewards(member_account: AccountId) -> Balance { NominationPools::pending_rewards(member_account) }