From 89ae0f0ea0ddc467176f8f50d87b9c7a38e2533e Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Tue, 5 Feb 2019 13:31:19 +0000 Subject: [PATCH] Convert to jsonrpc-derive, use jsonrpc-* from crates.io (#10298) * Use jsonrpc crates on local path * Convert all RPC traits to use jsonrpc-derive * Use local jsonrpc at top level * Upgrade remaining jsonrpc dependencies * Checkout Cargo.lock to master HEAD * Use jsonrpc-* 10.0.1 from crates.io * Attribute after docs --- Cargo.lock | 188 +++++++-------- Cargo.toml | 2 +- cli-signer/rpc-client/Cargo.toml | 4 +- ipfs/Cargo.toml | 4 +- miner/stratum/Cargo.toml | 5 +- miner/stratum/src/lib.rs | 4 +- rpc/Cargo.toml | 12 +- rpc/src/lib.rs | 3 +- rpc/src/v1/helpers/light_fetch.rs | 3 +- rpc/src/v1/helpers/subscribers.rs | 2 +- rpc/src/v1/impls/eth.rs | 17 +- rpc/src/v1/impls/eth_pubsub.rs | 8 +- rpc/src/v1/impls/light/eth.rs | 17 +- rpc/src/v1/impls/light/parity.rs | 13 +- rpc/src/v1/impls/light/trace.rs | 7 +- rpc/src/v1/impls/parity.rs | 13 +- rpc/src/v1/impls/pubsub.rs | 7 +- rpc/src/v1/impls/signer.rs | 5 +- rpc/src/v1/impls/traces.rs | 7 +- rpc/src/v1/traits/debug.rs | 14 +- rpc/src/v1/traits/eth.rs | 297 ++++++++++++----------- rpc/src/v1/traits/eth_pubsub.rs | 29 +-- rpc/src/v1/traits/eth_signing.rs | 37 +-- rpc/src/v1/traits/net.rs | 28 +-- rpc/src/v1/traits/parity.rs | 341 +++++++++++++-------------- rpc/src/v1/traits/parity_accounts.rs | 184 +++++++-------- rpc/src/v1/traits/parity_set.rs | 146 ++++++------ rpc/src/v1/traits/parity_signing.rs | 51 ++-- rpc/src/v1/traits/personal.rs | 79 ++++--- rpc/src/v1/traits/private.rs | 35 +-- rpc/src/v1/traits/pubsub.rs | 29 +-- rpc/src/v1/traits/rpc.rs | 24 +- rpc/src/v1/traits/secretstore.rs | 60 ++--- rpc/src/v1/traits/signer.rs | 70 +++--- rpc/src/v1/traits/traces.rs | 66 +++--- rpc/src/v1/traits/web3.rs | 20 +- whisper/Cargo.toml | 6 +- whisper/cli/Cargo.toml | 6 +- whisper/src/lib.rs | 4 +- whisper/src/rpc/filter.rs | 2 +- whisper/src/rpc/mod.rs | 123 +++++----- 41 files changed, 973 insertions(+), 999 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f24f667f..3a16c22d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -637,7 +637,7 @@ dependencies = [ "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1060,9 +1060,8 @@ version = "1.12.0" dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-macros 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-tcp-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-tcp-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1279,7 +1278,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1778,8 +1777,8 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2#84360bf1d03821b8fd669a6a95fcdf847aaf6cca" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1788,14 +1787,24 @@ dependencies = [ "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "jsonrpc-derive" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "jsonrpc-http-server" -version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2#84360bf1d03821b8fd669a6a95fcdf847aaf6cca" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hyper 0.12.11 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-server-utils 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1803,45 +1812,36 @@ dependencies = [ [[package]] name = "jsonrpc-ipc-server" -version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2#84360bf1d03821b8fd669a6a95fcdf847aaf6cca" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-server-utils 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-tokio-ipc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "jsonrpc-macros" -version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2#84360bf1d03821b8fd669a6a95fcdf847aaf6cca" +name = "jsonrpc-pubsub" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-pubsub 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "jsonrpc-pubsub" -version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2#84360bf1d03821b8fd669a6a95fcdf847aaf6cca" -dependencies = [ - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "jsonrpc-server-utils" -version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2#84360bf1d03821b8fd669a6a95fcdf847aaf6cca" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1852,28 +1852,28 @@ dependencies = [ [[package]] name = "jsonrpc-tcp-server" -version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2#84360bf1d03821b8fd669a6a95fcdf847aaf6cca" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-server-utils 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-service 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-ws-server" -version = "9.0.0" -source = "git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2#84360bf1d03821b8fd669a6a95fcdf847aaf6cca" +version = "10.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-server-utils 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-ws 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ws 0.7.9 (git+https://github.com/tomusdrw/ws-rs)", ] [[package]] @@ -2457,7 +2457,7 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.8 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2527,8 +2527,8 @@ dependencies = [ "cid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.12.0", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-http-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "multihash 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2612,12 +2612,12 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "hardware-wallet 1.12.0", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-http-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-ipc-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-macros 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-pubsub 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-ws-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ipc-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ws-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2653,8 +2653,8 @@ name = "parity-rpc-client" version = "1.4.0" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-ws-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ws-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2764,9 +2764,9 @@ dependencies = [ "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-macros 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-pubsub 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memzero 0.1.0", "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2792,6 +2792,23 @@ dependencies = [ "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-ws" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "parking_lot" version = "0.6.4" @@ -3318,7 +3335,7 @@ dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3452,7 +3469,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3592,7 +3609,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.15.11" +version = "0.15.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3615,7 +3632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4181,7 +4198,7 @@ dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "validator 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4306,9 +4323,9 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-network 1.12.0", "ethcore-network-devp2p 1.12.0", - "jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-http-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", - "jsonrpc-pubsub 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", + "jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.1.0", "parity-whisper 0.1.0", @@ -4362,23 +4379,6 @@ dependencies = [ "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ws" -version = "0.7.9" -source = "git+https://github.com/tomusdrw/ws-rs#4baef2dc1abc8e216559af51cfc120bbcc777e21" -dependencies = [ - "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ws2_32-sys" version = "0.2.1" @@ -4529,14 +4529,14 @@ dependencies = [ "checksum jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3" "checksum jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ecfa3b81afc64d9a6539c4eece96ac9a93c551c713a313800dade8e33d7b5c1" "checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" -"checksum jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" -"checksum jsonrpc-http-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" -"checksum jsonrpc-ipc-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" -"checksum jsonrpc-macros 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" -"checksum jsonrpc-pubsub 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" -"checksum jsonrpc-server-utils 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" -"checksum jsonrpc-tcp-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" -"checksum jsonrpc-ws-server 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" +"checksum jsonrpc-core 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a5152c3fda235dfd68341b3edf4121bc4428642c93acbd6de88c26bf95fc5d7" +"checksum jsonrpc-derive 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8de4e89cf0938dec51a14255556172b1f5208e4d8999d613813eceeae1405d37" +"checksum jsonrpc-http-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "99e1ce36c7cc9dcab398024d76849ab2cb917ee812653bce6f74fc9eb7c82d16" +"checksum jsonrpc-ipc-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fac6b8682243740a32bfb288880c71cc06eca29616cdf551e4136a190b11b96d" +"checksum jsonrpc-pubsub 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "56608ed54b1b2a69f4357cb8bdfbcbd99fe1179383c03a09bb428931bd35f592" +"checksum jsonrpc-server-utils 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5521613b31ea22d36d9f95ad642058dccec846a94ed8690957652d479f620707" +"checksum jsonrpc-tcp-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c873dac37a601fb88d40ba49eeac3f1aa60953c06b2e99ddbf0569b6f8028478" +"checksum jsonrpc-ws-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20b8333a5a6e6ccbcf5c90f90919de557cba4929efa164e9bd0e8e497eb20e46" "checksum keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "253bbe643c32c816bf58fa5a88248fafedeebb139705ad17a62add3517854a86" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72ae89206cea31c32014b39d5a454b96135894221610dbfd19cf4d2d044fa546" @@ -4600,6 +4600,7 @@ dependencies = [ "checksum parity-tokio-ipc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb002c2d3539ccd3b82bd915ec060028d4ab350ad203dbffa20028c1e483af5b" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parity-wordlist 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf13102febd98f4ad416a526b42deb82daf482626ba6ab10d0ebf8f45327514c" +"checksum parity-ws 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2fec5048fba72a2e01baeb0d08089db79aead4b57e2443df172fb1840075a233" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9723236a9525c757d9725b993511e3fc941e33f27751942232f0058298297edf" "checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" @@ -4688,7 +4689,7 @@ dependencies = [ "checksum string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00caf261d6f90f588f8450b8e1230fa0d5be49ee6140fdfbcb55335aff350970" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b036b7b35e846707c0e55c2c9441fa47867c0f87fca416921db3261b1d8c741a" +"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" @@ -4768,7 +4769,6 @@ dependencies = [ "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" -"checksum ws 0.7.9 (git+https://github.com/tomusdrw/ws-rs)" = "" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum xdg 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a66b7c2281ebde13cf4391d70d4c7e5946c3c25e72a7b859ca8f677dcd0b0c61" "checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2" diff --git a/Cargo.toml b/Cargo.toml index 54b89b0f1..547a4af20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ serde_derive = "1.0" futures = "0.1" fdlimit = "0.1" ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" } -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } +jsonrpc-core = "10.0.1" ethcore = { path = "ethcore", features = ["parity"] } parity-bytes = "0.1" common-types = { path = "ethcore/types" } diff --git a/cli-signer/rpc-client/Cargo.toml b/cli-signer/rpc-client/Cargo.toml index 0ffdae770..e7eb35461 100644 --- a/cli-signer/rpc-client/Cargo.toml +++ b/cli-signer/rpc-client/Cargo.toml @@ -14,7 +14,7 @@ serde_json = "1.0" url = "1.2.0" matches = "0.1" parking_lot = "0.7" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } +jsonrpc-core = "10.0.1" +jsonrpc-ws-server = "10.0.1" parity-rpc = { path = "../../rpc" } keccak-hash = "0.1" diff --git a/ipfs/Cargo.toml b/ipfs/Cargo.toml index 23ada21ea..23dc8d689 100644 --- a/ipfs/Cargo.toml +++ b/ipfs/Cargo.toml @@ -9,8 +9,8 @@ authors = ["Parity Technologies "] ethcore = { path = "../ethcore" } parity-bytes = "0.1" ethereum-types = "0.4" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } +jsonrpc-core = "10.0.1" +jsonrpc-http-server = "10.0.1" rlp = { version = "0.3.0", features = ["ethereum"] } cid = "0.3" multihash = "0.8" diff --git a/miner/stratum/Cargo.toml b/miner/stratum/Cargo.toml index 137604d53..a7e13ef68 100644 --- a/miner/stratum/Cargo.toml +++ b/miner/stratum/Cargo.toml @@ -8,9 +8,8 @@ authors = ["Parity Technologies "] [dependencies] ethereum-types = "0.4" keccak-hash = "0.1" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-tcp-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } +jsonrpc-core = "10.0.1" +jsonrpc-tcp-server = "10.0.1" log = "0.4" parking_lot = "0.7" diff --git a/miner/stratum/src/lib.rs b/miner/stratum/src/lib.rs index 5d2cb68a3..5ee0296da 100644 --- a/miner/stratum/src/lib.rs +++ b/miner/stratum/src/lib.rs @@ -18,7 +18,6 @@ extern crate jsonrpc_tcp_server; extern crate jsonrpc_core; -extern crate jsonrpc_macros; extern crate ethereum_types; extern crate keccak_hash as hash; extern crate parking_lot; @@ -39,8 +38,7 @@ use jsonrpc_tcp_server::{ Server as JsonRpcServer, ServerBuilder as JsonRpcServerBuilder, RequestContext, MetaExtractor, Dispatcher, PushMessageError, }; -use jsonrpc_core::{MetaIoHandler, Params, to_value, Value, Metadata, Compatibility}; -use jsonrpc_macros::IoDelegate; +use jsonrpc_core::{MetaIoHandler, Params, to_value, Value, Metadata, Compatibility, IoDelegate}; use std::sync::Arc; use std::net::SocketAddr; diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index c3acc4664..f64ead6b3 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -27,12 +27,12 @@ tokio-timer = "0.1" transient-hashmap = "0.4" itertools = "0.5" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-ipc-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } +jsonrpc-core = "10.0.1" +jsonrpc-derive = "10.0.1" +jsonrpc-http-server = "10.0.1" +jsonrpc-ws-server = "10.0.1" +jsonrpc-ipc-server = "10.0.1" +jsonrpc-pubsub = "10.0.1" common-types = { path = "../ethcore/types" } ethash = { path = "../ethash" } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 2de2f0542..3a9856451 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -37,6 +37,7 @@ extern crate tokio_timer; extern crate transient_hashmap; extern crate jsonrpc_core; +extern crate jsonrpc_derive; extern crate jsonrpc_http_server as http; extern crate jsonrpc_ipc_server as ipc; extern crate jsonrpc_pubsub; @@ -75,8 +76,6 @@ extern crate fake_hardware_wallet as hardware_wallet; #[macro_use] extern crate log; #[macro_use] -extern crate jsonrpc_macros; -#[macro_use] extern crate serde_derive; #[cfg(test)] diff --git a/rpc/src/v1/helpers/light_fetch.rs b/rpc/src/v1/helpers/light_fetch.rs index ba6e13b16..d026b5f0f 100644 --- a/rpc/src/v1/helpers/light_fetch.rs +++ b/rpc/src/v1/helpers/light_fetch.rs @@ -29,7 +29,6 @@ use ethcore::executed::ExecutionError; use jsonrpc_core::{Result, Error}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_core::futures::future::Either; -use jsonrpc_macros::Trailing; use light::cache::Cache; use light::client::LightChainClient; @@ -202,7 +201,7 @@ impl LightFetch { } /// Helper for getting proved execution. - pub fn proved_read_only_execution(&self, req: CallRequest, num: Trailing) -> impl Future + Send { + pub fn proved_read_only_execution(&self, req: CallRequest, num: Option) -> impl Future + Send { const DEFAULT_GAS_PRICE: u64 = 21_000; // (21000 G_transaction + 32000 G_create + some marginal to allow a few operations) const START_GAS: u64 = 60_000; diff --git a/rpc/src/v1/helpers/subscribers.rs b/rpc/src/v1/helpers/subscribers.rs index 80a6bfe8b..5b48b67a2 100644 --- a/rpc/src/v1/helpers/subscribers.rs +++ b/rpc/src/v1/helpers/subscribers.rs @@ -18,7 +18,7 @@ use std::{ops, str}; use std::collections::HashMap; -use jsonrpc_macros::pubsub::{Subscriber, Sink, SubscriptionId}; +use jsonrpc_pubsub::{typed::{Subscriber, Sink}, SubscriptionId}; use rand::{Rng, StdRng}; use v1::types::H64; diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs index bf39557d1..15482645d 100644 --- a/rpc/src/v1/impls/eth.rs +++ b/rpc/src/v1/impls/eth.rs @@ -39,7 +39,6 @@ use types::filter::Filter as EthcoreFilter; use jsonrpc_core::{BoxFuture, Result}; use jsonrpc_core::futures::future; -use jsonrpc_macros::Trailing; use v1::helpers::{self, errors, limit_logs, fake_sign}; use v1::helpers::dispatch::{FullDispatcher, default_gas_price}; @@ -568,7 +567,7 @@ impl Eth for EthClient< Ok(RpcU256::from(self.client.chain_info().best_block_number)) } - fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn balance(&self, address: RpcH160, num: Option) -> BoxFuture { let address = address.into(); let num = num.unwrap_or_default(); @@ -582,7 +581,7 @@ impl Eth for EthClient< Box::new(future::done(res)) } - fn proof(&self, address: RpcH160, values: Vec, num: Trailing) -> BoxFuture { + fn proof(&self, address: RpcH160, values: Vec, num: Option) -> BoxFuture { try_bf!(errors::require_experimental(self.options.allow_experimental_rpcs, "1186")); let a: H160 = address.clone().into(); @@ -625,7 +624,7 @@ impl Eth for EthClient< Box::new(future::done(res)) } - fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Trailing) -> BoxFuture { + fn storage_at(&self, address: RpcH160, pos: RpcU256, num: Option) -> BoxFuture { let address: Address = RpcH160::into(address); let position: U256 = RpcU256::into(pos); @@ -640,7 +639,7 @@ impl Eth for EthClient< Box::new(future::done(res)) } - fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn transaction_count(&self, address: RpcH160, num: Option) -> BoxFuture { let address: Address = RpcH160::into(address); let res = match num.unwrap_or_default() { @@ -723,7 +722,7 @@ impl Eth for EthClient< })) } - fn code_at(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn code_at(&self, address: RpcH160, num: Option) -> BoxFuture { let address: Address = RpcH160::into(address); let num = num.unwrap_or_default(); @@ -832,7 +831,7 @@ impl Eth for EthClient< base_logs(&*self.client, &*self.miner, filter.into()) } - fn work(&self, no_new_work_timeout: Trailing) -> Result { + fn work(&self, no_new_work_timeout: Option) -> Result { let no_new_work_timeout = no_new_work_timeout.unwrap_or_default(); // check if we're still syncing and return empty strings in that case @@ -918,7 +917,7 @@ impl Eth for EthClient< self.send_raw_transaction(raw) } - fn call(&self, request: CallRequest, num: Trailing) -> BoxFuture { + fn call(&self, request: CallRequest, num: Option) -> BoxFuture { let request = CallRequest::into(request); let signed = try_bf!(fake_sign::sign_call(request)); @@ -958,7 +957,7 @@ impl Eth for EthClient< )) } - fn estimate_gas(&self, request: CallRequest, num: Trailing) -> BoxFuture { + fn estimate_gas(&self, request: CallRequest, num: Option) -> BoxFuture { let request = CallRequest::into(request); let signed = try_bf!(fake_sign::sign_call(request)); let num = num.unwrap_or_default(); diff --git a/rpc/src/v1/impls/eth_pubsub.rs b/rpc/src/v1/impls/eth_pubsub.rs index 86340d73d..4d452a479 100644 --- a/rpc/src/v1/impls/eth_pubsub.rs +++ b/rpc/src/v1/impls/eth_pubsub.rs @@ -21,9 +21,7 @@ use std::collections::BTreeMap; use jsonrpc_core::{BoxFuture, Result, Error}; use jsonrpc_core::futures::{self, Future, IntoFuture}; -use jsonrpc_macros::Trailing; -use jsonrpc_macros::pubsub::{Sink, Subscriber}; -use jsonrpc_pubsub::SubscriptionId; +use jsonrpc_pubsub::{SubscriptionId, typed::{Sink, Subscriber}}; use v1::helpers::{errors, limit_logs, Subscribers}; use v1::helpers::light_fetch::LightFetch; @@ -262,7 +260,7 @@ impl EthPubSub for EthPubSubClient { _meta: Metadata, subscriber: Subscriber, kind: pubsub::Kind, - params: Trailing, + params: Option, ) { let error = match (kind, params.into()) { (pubsub::Kind::NewHeads, None) => { @@ -299,7 +297,7 @@ impl EthPubSub for EthPubSubClient { let _ = subscriber.reject(error); } - fn unsubscribe(&self, id: SubscriptionId) -> Result { + fn unsubscribe(&self, _: Option, id: SubscriptionId) -> Result { let res = self.heads_subscribers.write().remove(&id).is_some(); let res2 = self.logs_subscribers.write().remove(&id).is_some(); let res3 = self.transactions_subscribers.write().remove(&id).is_some(); diff --git a/rpc/src/v1/impls/light/eth.rs b/rpc/src/v1/impls/light/eth.rs index 87e87c309..914b05f96 100644 --- a/rpc/src/v1/impls/light/eth.rs +++ b/rpc/src/v1/impls/light/eth.rs @@ -22,7 +22,6 @@ use std::sync::Arc; use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::{future, Future}; use jsonrpc_core::futures::future::Either; -use jsonrpc_macros::Trailing; use light::cache::Cache as LightDataCache; use light::client::LightChainClient; @@ -272,12 +271,12 @@ impl Eth for EthClient { Ok(self.client.chain_info().best_block_number.into()) } - fn balance(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn balance(&self, address: RpcH160, num: Option) -> BoxFuture { Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().to_block_id()) .map(|acc| acc.map_or(0.into(), |a| a.balance).into())) } - fn storage_at(&self, _address: RpcH160, _key: RpcU256, _num: Trailing) -> BoxFuture { + fn storage_at(&self, _address: RpcH160, _key: RpcU256, _num: Option) -> BoxFuture { Box::new(future::err(errors::unimplemented(None))) } @@ -289,7 +288,7 @@ impl Eth for EthClient { Box::new(self.rich_block(num.to_block_id(), include_txs).map(Some)) } - fn transaction_count(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn transaction_count(&self, address: RpcH160, num: Option) -> BoxFuture { Box::new(self.fetcher().account(address.into(), num.unwrap_or_default().to_block_id()) .map(|acc| acc.map_or(0.into(), |a| a.nonce).into())) } @@ -358,7 +357,7 @@ impl Eth for EthClient { })) } - fn code_at(&self, address: RpcH160, num: Trailing) -> BoxFuture { + fn code_at(&self, address: RpcH160, num: Option) -> BoxFuture { Box::new(self.fetcher().code(address.into(), num.unwrap_or_default().to_block_id()).map(Into::into)) } @@ -385,7 +384,7 @@ impl Eth for EthClient { self.send_raw_transaction(raw) } - fn call(&self, req: CallRequest, num: Trailing) -> BoxFuture { + fn call(&self, req: CallRequest, num: Option) -> BoxFuture { Box::new(self.fetcher().proved_read_only_execution(req, num).and_then(|res| { match res { Ok(exec) => Ok(exec.output.into()), @@ -394,7 +393,7 @@ impl Eth for EthClient { })) } - fn estimate_gas(&self, req: CallRequest, num: Trailing) -> BoxFuture { + fn estimate_gas(&self, req: CallRequest, num: Option) -> BoxFuture { // TODO: binary chop for more accurate estimates. Box::new(self.fetcher().proved_read_only_execution(req, num).and_then(|res| { match res { @@ -475,7 +474,7 @@ impl Eth for EthClient { })) } - fn proof(&self, _address: RpcH160, _values:Vec, _num: Trailing) -> BoxFuture { + fn proof(&self, _address: RpcH160, _values:Vec, _num: Option) -> BoxFuture { Box::new(future::err(errors::unimplemented(None))) } @@ -505,7 +504,7 @@ impl Eth for EthClient { }).map(move |logs| limit_logs(logs, limit))) } - fn work(&self, _timeout: Trailing) -> Result { + fn work(&self, _timeout: Option) -> Result { Err(errors::light_unimplemented(None)) } diff --git a/rpc/src/v1/impls/light/parity.rs b/rpc/src/v1/impls/light/parity.rs index f179ab236..8a19232c1 100644 --- a/rpc/src/v1/impls/light/parity.rs +++ b/rpc/src/v1/impls/light/parity.rs @@ -29,7 +29,6 @@ use ethcore_logger::RotatingLogger; use jsonrpc_core::{Result, BoxFuture}; use jsonrpc_core::futures::{future, Future}; -use jsonrpc_macros::Trailing; use v1::helpers::{self, errors, ipfs, SigningQueue, SignerService, NetworkSettings, verify_signature}; use v1::helpers::dispatch::LightDispatcher; use v1::helpers::light_fetch::{LightFetch, light_all_transactions}; @@ -232,11 +231,11 @@ impl Parity for ParityClient { Ok(Brain::new(phrase).generate().unwrap().address().into()) } - fn list_accounts(&self, _: u64, _: Option, _: Trailing) -> Result>> { + fn list_accounts(&self, _: u64, _: Option, _: Option) -> Result>> { Err(errors::light_unimplemented(None)) } - fn list_storage_keys(&self, _: H160, _: u64, _: Option, _: Trailing) -> Result>> { + fn list_storage_keys(&self, _: H160, _: u64, _: Option, _: Option) -> Result>> { Err(errors::light_unimplemented(None)) } @@ -246,7 +245,7 @@ impl Parity for ParityClient { .map(Into::into) } - fn pending_transactions(&self, limit: Trailing) -> Result> { + fn pending_transactions(&self, limit: Option) -> Result> { let txq = self.light_dispatch.transaction_queue.read(); let chain_info = self.light_dispatch.client.chain_info(); Ok( @@ -365,7 +364,7 @@ impl Parity for ParityClient { }) } - fn block_header(&self, number: Trailing) -> BoxFuture { + fn block_header(&self, number: Option) -> BoxFuture { use types::encoded; let engine = self.light_dispatch.client.engine().clone(); @@ -399,7 +398,7 @@ impl Parity for ParityClient { Box::new(self.fetcher().header(id).and_then(from_encoded)) } - fn block_receipts(&self, number: Trailing) -> BoxFuture> { + fn block_receipts(&self, number: Option) -> BoxFuture> { let id = number.unwrap_or_default().to_block_id(); Box::new(self.fetcher().receipts(id).and_then(|receipts| Ok(receipts.into_iter().map(Into::into).collect()))) } @@ -408,7 +407,7 @@ impl Parity for ParityClient { ipfs::cid(content) } - fn call(&self, _requests: Vec, _block: Trailing) -> Result> { + fn call(&self, _requests: Vec, _block: Option) -> Result> { Err(errors::light_unimplemented(None)) } diff --git a/rpc/src/v1/impls/light/trace.rs b/rpc/src/v1/impls/light/trace.rs index 092189b74..42f62e0c4 100644 --- a/rpc/src/v1/impls/light/trace.rs +++ b/rpc/src/v1/impls/light/trace.rs @@ -17,7 +17,6 @@ //! Traces api implementation. use jsonrpc_core::Result; -use jsonrpc_macros::Trailing; use v1::Metadata; use v1::traits::Traces; use v1::helpers::errors; @@ -46,15 +45,15 @@ impl Traces for TracesClient { Err(errors::light_unimplemented(None)) } - fn call(&self, _request: CallRequest, _flags: TraceOptions, _block: Trailing) -> Result { + fn call(&self, _request: CallRequest, _flags: TraceOptions, _block: Option) -> Result { Err(errors::light_unimplemented(None)) } - fn call_many(&self, _request: Vec<(CallRequest, TraceOptions)>, _block: Trailing) -> Result> { + fn call_many(&self, _request: Vec<(CallRequest, TraceOptions)>, _block: Option) -> Result> { Err(errors::light_unimplemented(None)) } - fn raw_transaction(&self, _raw_transaction: Bytes, _flags: TraceOptions, _block: Trailing) -> Result { + fn raw_transaction(&self, _raw_transaction: Bytes, _flags: TraceOptions, _block: Option) -> Result { Err(errors::light_unimplemented(None)) } diff --git a/rpc/src/v1/impls/parity.rs b/rpc/src/v1/impls/parity.rs index 46e93bc73..60a7bd83d 100644 --- a/rpc/src/v1/impls/parity.rs +++ b/rpc/src/v1/impls/parity.rs @@ -33,7 +33,6 @@ use ethkey::{crypto::ecies, Brain, Generator}; use ethstore::random_phrase; use jsonrpc_core::futures::future; use jsonrpc_core::{BoxFuture, Result}; -use jsonrpc_macros::Trailing; use sync::{SyncProvider, ManageNetwork}; use types::ids::BlockId; use updater::{Service as UpdateService}; @@ -252,7 +251,7 @@ impl Parity for ParityClient where Ok(Brain::new(phrase).generate().unwrap().address().into()) } - fn list_accounts(&self, count: u64, after: Option, block_number: Trailing) -> Result>> { + fn list_accounts(&self, count: u64, after: Option, block_number: Option) -> Result>> { let number = match block_number.unwrap_or_default() { BlockNumber::Pending => { warn!("BlockNumber::Pending is unsupported"); @@ -267,7 +266,7 @@ impl Parity for ParityClient where .map(|a| a.into_iter().map(Into::into).collect())) } - fn list_storage_keys(&self, address: H160, count: u64, after: Option, block_number: Trailing) -> Result>> { + fn list_storage_keys(&self, address: H160, count: u64, after: Option, block_number: Option) -> Result>> { let number = match block_number.unwrap_or_default() { BlockNumber::Pending => { warn!("BlockNumber::Pending is unsupported"); @@ -288,7 +287,7 @@ impl Parity for ParityClient where .map(Into::into) } - fn pending_transactions(&self, limit: Trailing) -> Result> { + fn pending_transactions(&self, limit: Option) -> Result> { let ready_transactions = self.miner.ready_transactions( &*self.client, limit.unwrap_or_else(usize::max_value), @@ -394,7 +393,7 @@ impl Parity for ParityClient where }) } - fn block_header(&self, number: Trailing) -> BoxFuture { + fn block_header(&self, number: Option) -> BoxFuture { const EXTRA_INFO_PROOF: &str = "Object exists in blockchain (fetched earlier), extra_info is always available if object exists; qed"; let number = number.unwrap_or_default(); @@ -424,7 +423,7 @@ impl Parity for ParityClient where })) } - fn block_receipts(&self, number: Trailing) -> BoxFuture> { + fn block_receipts(&self, number: Option) -> BoxFuture> { let number = number.unwrap_or_default(); let id = match number { @@ -449,7 +448,7 @@ impl Parity for ParityClient where ipfs::cid(content) } - fn call(&self, requests: Vec, num: Trailing) -> Result> { + fn call(&self, requests: Vec, num: Option) -> Result> { let requests = requests .into_iter() .map(|request| Ok(( diff --git a/rpc/src/v1/impls/pubsub.rs b/rpc/src/v1/impls/pubsub.rs index fb147768d..9650fd2d0 100644 --- a/rpc/src/v1/impls/pubsub.rs +++ b/rpc/src/v1/impls/pubsub.rs @@ -22,8 +22,7 @@ use parking_lot::RwLock; use jsonrpc_core::{self as core, Result, MetaIoHandler}; use jsonrpc_core::futures::{future, Future, Stream, Sink}; -use jsonrpc_macros::Trailing; -use jsonrpc_macros::pubsub::Subscriber; +use jsonrpc_pubsub::typed::Subscriber; use jsonrpc_pubsub::SubscriptionId; use tokio_timer; @@ -81,7 +80,7 @@ impl PubSubClient { impl> PubSub for PubSubClient { type Metadata = Metadata; - fn parity_subscribe(&self, mut meta: Metadata, subscriber: Subscriber, method: String, params: Trailing) { + fn parity_subscribe(&self, mut meta: Metadata, subscriber: Subscriber, method: String, params: Option) { let params = params.unwrap_or(core::Params::Array(vec![])); // Make sure to get rid of PubSub session otherwise it will never be dropped. meta.session = None; @@ -100,7 +99,7 @@ impl> PubSub for PubSubClient { } } - fn parity_unsubscribe(&self, id: SubscriptionId) -> Result { + fn parity_unsubscribe(&self, _: Option, id: SubscriptionId) -> Result { let res = self.poll_manager.write().unsubscribe(&id); Ok(res) } diff --git a/rpc/src/v1/impls/signer.rs b/rpc/src/v1/impls/signer.rs index 8f83547ab..64e91e09f 100644 --- a/rpc/src/v1/impls/signer.rs +++ b/rpc/src/v1/impls/signer.rs @@ -28,8 +28,7 @@ use types::transaction::{SignedTransaction, PendingTransaction}; use jsonrpc_core::{Result, BoxFuture, Error}; use jsonrpc_core::futures::{future, Future, IntoFuture}; use jsonrpc_core::futures::future::Either; -use jsonrpc_pubsub::SubscriptionId; -use jsonrpc_macros::pubsub::{Sink, Subscriber}; +use jsonrpc_pubsub::{SubscriptionId, typed::{Sink, Subscriber}}; use v1::helpers::dispatch::{self, Dispatcher, WithToken, eth_data_hash}; use v1::helpers::{errors, SignerService, SigningQueue, ConfirmationPayload, FilledTransactionRequest, Subscribers}; use v1::metadata::Metadata; @@ -255,7 +254,7 @@ impl Signer for SignerClient { self.subscribers.lock().push(sub) } - fn unsubscribe_pending(&self, id: SubscriptionId) -> Result { + fn unsubscribe_pending(&self, _: Option, id: SubscriptionId) -> Result { let res = self.subscribers.lock().remove(&id).is_some(); Ok(res) } diff --git a/rpc/src/v1/impls/traces.rs b/rpc/src/v1/impls/traces.rs index 92bf045f4..f2a5c83d4 100644 --- a/rpc/src/v1/impls/traces.rs +++ b/rpc/src/v1/impls/traces.rs @@ -23,7 +23,6 @@ use rlp::Rlp; use types::transaction::SignedTransaction; use jsonrpc_core::Result; -use jsonrpc_macros::Trailing; use v1::Metadata; use v1::traits::Traces; use v1::helpers::{errors, fake_sign}; @@ -87,7 +86,7 @@ impl Traces for TracesClient where .map(LocalizedTrace::from)) } - fn call(&self, request: CallRequest, flags: TraceOptions, block: Trailing) -> Result { + fn call(&self, request: CallRequest, flags: TraceOptions, block: Option) -> Result { let block = block.unwrap_or_default(); let request = CallRequest::into(request); @@ -109,7 +108,7 @@ impl Traces for TracesClient where .map_err(errors::call) } - fn call_many(&self, requests: Vec<(CallRequest, TraceOptions)>, block: Trailing) -> Result> { + fn call_many(&self, requests: Vec<(CallRequest, TraceOptions)>, block: Option) -> Result> { let block = block.unwrap_or_default(); let requests = requests.into_iter() @@ -136,7 +135,7 @@ impl Traces for TracesClient where .map_err(errors::call) } - fn raw_transaction(&self, raw_transaction: Bytes, flags: TraceOptions, block: Trailing) -> Result { + fn raw_transaction(&self, raw_transaction: Bytes, flags: TraceOptions, block: Option) -> Result { let block = block.unwrap_or_default(); let tx = Rlp::new(&raw_transaction.into_vec()).as_val().map_err(|e| errors::invalid_params("Transaction is not valid RLP", e))?; diff --git a/rpc/src/v1/traits/debug.rs b/rpc/src/v1/traits/debug.rs index 3b490e6f2..5d332d434 100644 --- a/rpc/src/v1/traits/debug.rs +++ b/rpc/src/v1/traits/debug.rs @@ -17,14 +17,14 @@ //! Debug RPC interface. use jsonrpc_core::Result; +use jsonrpc_derive::rpc; use v1::types::RichBlock; -build_rpc_trait! { - /// Debug RPC interface. - pub trait Debug { - /// Returns recently seen bad blocks. - #[rpc(name = "debug_getBadBlocks")] - fn bad_blocks(&self) -> Result>; - } +/// Debug RPC interface. +#[rpc] +pub trait Debug { + /// Returns recently seen bad blocks. + #[rpc(name = "debug_getBadBlocks")] + fn bad_blocks(&self) -> Result>; } diff --git a/rpc/src/v1/traits/eth.rs b/rpc/src/v1/traits/eth.rs index cf5469773..0f0dc48a5 100644 --- a/rpc/src/v1/traits/eth.rs +++ b/rpc/src/v1/traits/eth.rs @@ -16,203 +16,202 @@ //! Eth rpc interface. use jsonrpc_core::{Result, BoxFuture}; -use jsonrpc_macros::Trailing; +use jsonrpc_derive::rpc; use v1::types::{RichBlock, BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index, EthAccount}; use v1::types::{Log, Receipt, SyncStatus, Transaction, Work}; use v1::types::{H64, H160, H256, U256, U64}; -build_rpc_trait! { - /// Eth rpc interface. - pub trait Eth { - type Metadata; +/// Eth rpc interface. +#[rpc] +pub trait Eth { + /// RPC Metadata + type Metadata; - /// Returns protocol version encoded as a string (quotes are necessary). - #[rpc(name = "eth_protocolVersion")] - fn protocol_version(&self) -> Result; + /// Returns protocol version encoded as a string (quotes are necessary). + #[rpc(name = "eth_protocolVersion")] + fn protocol_version(&self) -> Result; - /// Returns an object with data about the sync status or false. (wtf?) - #[rpc(name = "eth_syncing")] - fn syncing(&self) -> Result; + /// Returns an object with data about the sync status or false. (wtf?) + #[rpc(name = "eth_syncing")] + fn syncing(&self) -> Result; - /// Returns the number of hashes per second that the node is mining with. - #[rpc(name = "eth_hashrate")] - fn hashrate(&self) -> Result; + /// Returns the number of hashes per second that the node is mining with. + #[rpc(name = "eth_hashrate")] + fn hashrate(&self) -> Result; - /// Returns block author. - #[rpc(name = "eth_coinbase")] - fn author(&self) -> Result; + /// Returns block author. + #[rpc(name = "eth_coinbase")] + fn author(&self) -> Result; - /// Returns true if client is actively mining new blocks. - #[rpc(name = "eth_mining")] - fn is_mining(&self) -> Result; + /// Returns true if client is actively mining new blocks. + #[rpc(name = "eth_mining")] + fn is_mining(&self) -> Result; - /// Returns the chain ID used for transaction signing at the - /// current best block. None is returned if not - /// available. - #[rpc(name = "eth_chainId")] - fn chain_id(&self) -> Result>; + /// Returns the chain ID used for transaction signing at the + /// current best block. None is returned if not + /// available. + #[rpc(name = "eth_chainId")] + fn chain_id(&self) -> Result>; - /// Returns current gas_price. - #[rpc(name = "eth_gasPrice")] - fn gas_price(&self) -> Result; + /// Returns current gas_price. + #[rpc(name = "eth_gasPrice")] + fn gas_price(&self) -> Result; - /// Returns accounts list. - #[rpc(name = "eth_accounts")] - fn accounts(&self) -> Result>; + /// Returns accounts list. + #[rpc(name = "eth_accounts")] + fn accounts(&self) -> Result>; - /// Returns highest block number. - #[rpc(name = "eth_blockNumber")] - fn block_number(&self) -> Result; + /// Returns highest block number. + #[rpc(name = "eth_blockNumber")] + fn block_number(&self) -> Result; - /// Returns balance of the given account. - #[rpc(name = "eth_getBalance")] - fn balance(&self, H160, Trailing) -> BoxFuture; + /// Returns balance of the given account. + #[rpc(name = "eth_getBalance")] + fn balance(&self, H160, Option) -> BoxFuture; - /// Returns the account- and storage-values of the specified account including the Merkle-proof - #[rpc(name = "eth_getProof")] - fn proof(&self, H160, Vec, Trailing) -> BoxFuture; + /// Returns the account- and storage-values of the specified account including the Merkle-proof + #[rpc(name = "eth_getProof")] + fn proof(&self, H160, Vec, Option) -> BoxFuture; - /// Returns content of the storage at given address. - #[rpc(name = "eth_getStorageAt")] - fn storage_at(&self, H160, U256, Trailing) -> BoxFuture; + /// Returns content of the storage at given address. + #[rpc(name = "eth_getStorageAt")] + fn storage_at(&self, H160, U256, Option) -> BoxFuture; - /// Returns block with given hash. - #[rpc(name = "eth_getBlockByHash")] - fn block_by_hash(&self, H256, bool) -> BoxFuture>; + /// Returns block with given hash. + #[rpc(name = "eth_getBlockByHash")] + fn block_by_hash(&self, H256, bool) -> BoxFuture>; - /// Returns block with given number. - #[rpc(name = "eth_getBlockByNumber")] - fn block_by_number(&self, BlockNumber, bool) -> BoxFuture>; + /// Returns block with given number. + #[rpc(name = "eth_getBlockByNumber")] + fn block_by_number(&self, BlockNumber, bool) -> BoxFuture>; - /// Returns the number of transactions sent from given address at given time (block number). - #[rpc(name = "eth_getTransactionCount")] - fn transaction_count(&self, H160, Trailing) -> BoxFuture; + /// Returns the number of transactions sent from given address at given time (block number). + #[rpc(name = "eth_getTransactionCount")] + fn transaction_count(&self, H160, Option) -> BoxFuture; - /// Returns the number of transactions in a block with given hash. - #[rpc(name = "eth_getBlockTransactionCountByHash")] - fn block_transaction_count_by_hash(&self, H256) -> BoxFuture>; + /// Returns the number of transactions in a block with given hash. + #[rpc(name = "eth_getBlockTransactionCountByHash")] + fn block_transaction_count_by_hash(&self, H256) -> BoxFuture>; - /// Returns the number of transactions in a block with given block number. - #[rpc(name = "eth_getBlockTransactionCountByNumber")] - fn block_transaction_count_by_number(&self, BlockNumber) -> BoxFuture>; + /// Returns the number of transactions in a block with given block number. + #[rpc(name = "eth_getBlockTransactionCountByNumber")] + fn block_transaction_count_by_number(&self, BlockNumber) -> BoxFuture>; - /// Returns the number of uncles in a block with given hash. - #[rpc(name = "eth_getUncleCountByBlockHash")] - fn block_uncles_count_by_hash(&self, H256) -> BoxFuture>; + /// Returns the number of uncles in a block with given hash. + #[rpc(name = "eth_getUncleCountByBlockHash")] + fn block_uncles_count_by_hash(&self, H256) -> BoxFuture>; - /// Returns the number of uncles in a block with given block number. - #[rpc(name = "eth_getUncleCountByBlockNumber")] - fn block_uncles_count_by_number(&self, BlockNumber) -> BoxFuture>; + /// Returns the number of uncles in a block with given block number. + #[rpc(name = "eth_getUncleCountByBlockNumber")] + fn block_uncles_count_by_number(&self, BlockNumber) -> BoxFuture>; - /// Returns the code at given address at given time (block number). - #[rpc(name = "eth_getCode")] - fn code_at(&self, H160, Trailing) -> BoxFuture; + /// Returns the code at given address at given time (block number). + #[rpc(name = "eth_getCode")] + fn code_at(&self, H160, Option) -> BoxFuture; - /// Sends signed transaction, returning its hash. - #[rpc(name = "eth_sendRawTransaction")] - fn send_raw_transaction(&self, Bytes) -> Result; + /// Sends signed transaction, returning its hash. + #[rpc(name = "eth_sendRawTransaction")] + fn send_raw_transaction(&self, Bytes) -> Result; - /// @alias of `eth_sendRawTransaction`. - #[rpc(name = "eth_submitTransaction")] - fn submit_transaction(&self, Bytes) -> Result; + /// @alias of `eth_sendRawTransaction`. + #[rpc(name = "eth_submitTransaction")] + fn submit_transaction(&self, Bytes) -> Result; - /// Call contract, returning the output data. - #[rpc(name = "eth_call")] - fn call(&self, CallRequest, Trailing) -> BoxFuture; + /// Call contract, returning the output data. + #[rpc(name = "eth_call")] + fn call(&self, CallRequest, Option) -> BoxFuture; - /// Estimate gas needed for execution of given contract. - #[rpc(name = "eth_estimateGas")] - fn estimate_gas(&self, CallRequest, Trailing) -> BoxFuture; + /// Estimate gas needed for execution of given contract. + #[rpc(name = "eth_estimateGas")] + fn estimate_gas(&self, CallRequest, Option) -> BoxFuture; - /// Get transaction by its hash. - #[rpc(name = "eth_getTransactionByHash")] - fn transaction_by_hash(&self, H256) -> BoxFuture>; + /// Get transaction by its hash. + #[rpc(name = "eth_getTransactionByHash")] + fn transaction_by_hash(&self, H256) -> BoxFuture>; - /// Returns transaction at given block hash and index. - #[rpc(name = "eth_getTransactionByBlockHashAndIndex")] - fn transaction_by_block_hash_and_index(&self, H256, Index) -> BoxFuture>; + /// Returns transaction at given block hash and index. + #[rpc(name = "eth_getTransactionByBlockHashAndIndex")] + fn transaction_by_block_hash_and_index(&self, H256, Index) -> BoxFuture>; - /// Returns transaction by given block number and index. - #[rpc(name = "eth_getTransactionByBlockNumberAndIndex")] - fn transaction_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture>; + /// Returns transaction by given block number and index. + #[rpc(name = "eth_getTransactionByBlockNumberAndIndex")] + fn transaction_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture>; - /// Returns transaction receipt by transaction hash. - #[rpc(name = "eth_getTransactionReceipt")] - fn transaction_receipt(&self, H256) -> BoxFuture>; + /// Returns transaction receipt by transaction hash. + #[rpc(name = "eth_getTransactionReceipt")] + fn transaction_receipt(&self, H256) -> BoxFuture>; - /// Returns an uncles at given block and index. - #[rpc(name = "eth_getUncleByBlockHashAndIndex")] - fn uncle_by_block_hash_and_index(&self, H256, Index) -> BoxFuture>; + /// Returns an uncles at given block and index. + #[rpc(name = "eth_getUncleByBlockHashAndIndex")] + fn uncle_by_block_hash_and_index(&self, H256, Index) -> BoxFuture>; - /// Returns an uncles at given block and index. - #[rpc(name = "eth_getUncleByBlockNumberAndIndex")] - fn uncle_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture>; + /// Returns an uncles at given block and index. + #[rpc(name = "eth_getUncleByBlockNumberAndIndex")] + fn uncle_by_block_number_and_index(&self, BlockNumber, Index) -> BoxFuture>; - /// Returns available compilers. - /// @deprecated - #[rpc(name = "eth_getCompilers")] - fn compilers(&self) -> Result>; + /// Returns available compilers. + /// @deprecated + #[rpc(name = "eth_getCompilers")] + fn compilers(&self) -> Result>; - /// Compiles lll code. - /// @deprecated - #[rpc(name = "eth_compileLLL")] - fn compile_lll(&self, String) -> Result; + /// Compiles lll code. + /// @deprecated + #[rpc(name = "eth_compileLLL")] + fn compile_lll(&self, String) -> Result; - /// Compiles solidity. - /// @deprecated - #[rpc(name = "eth_compileSolidity")] - fn compile_solidity(&self, String) -> Result; + /// Compiles solidity. + /// @deprecated + #[rpc(name = "eth_compileSolidity")] + fn compile_solidity(&self, String) -> Result; - /// Compiles serpent. - /// @deprecated - #[rpc(name = "eth_compileSerpent")] - fn compile_serpent(&self, String) -> Result; + /// Compiles serpent. + /// @deprecated + #[rpc(name = "eth_compileSerpent")] + fn compile_serpent(&self, String) -> Result; - /// Returns logs matching given filter object. - #[rpc(name = "eth_getLogs")] - fn logs(&self, Filter) -> BoxFuture>; + /// Returns logs matching given filter object. + #[rpc(name = "eth_getLogs")] + fn logs(&self, Filter) -> BoxFuture>; - /// Returns the hash of the current block, the seedHash, and the boundary condition to be met. - #[rpc(name = "eth_getWork")] - fn work(&self, Trailing) -> Result; + /// Returns the hash of the current block, the seedHash, and the boundary condition to be met. + #[rpc(name = "eth_getWork")] + fn work(&self, Option) -> Result; - /// Used for submitting a proof-of-work solution. - #[rpc(name = "eth_submitWork")] - fn submit_work(&self, H64, H256, H256) -> Result; + /// Used for submitting a proof-of-work solution. + #[rpc(name = "eth_submitWork")] + fn submit_work(&self, H64, H256, H256) -> Result; - /// Used for submitting mining hashrate. - #[rpc(name = "eth_submitHashrate")] - fn submit_hashrate(&self, U256, H256) -> Result; - } + /// Used for submitting mining hashrate. + #[rpc(name = "eth_submitHashrate")] + fn submit_hashrate(&self, U256, H256) -> Result; } -build_rpc_trait! { - /// Eth filters rpc api (polling). - // TODO: do filters api properly - pub trait EthFilter { - /// Returns id of new filter. - #[rpc(name = "eth_newFilter")] - fn new_filter(&self, Filter) -> Result; +/// Eth filters rpc api (polling). +// TODO: do filters api properly +#[rpc] +pub trait EthFilter { + /// Returns id of new filter. + #[rpc(name = "eth_newFilter")] + fn new_filter(&self, Filter) -> Result; - /// Returns id of new block filter. - #[rpc(name = "eth_newBlockFilter")] - fn new_block_filter(&self) -> Result; + /// Returns id of new block filter. + #[rpc(name = "eth_newBlockFilter")] + fn new_block_filter(&self) -> Result; - /// Returns id of new block filter. - #[rpc(name = "eth_newPendingTransactionFilter")] - fn new_pending_transaction_filter(&self) -> Result; + /// Returns id of new block filter. + #[rpc(name = "eth_newPendingTransactionFilter")] + fn new_pending_transaction_filter(&self) -> Result; - /// Returns filter changes since last poll. - #[rpc(name = "eth_getFilterChanges")] - fn filter_changes(&self, Index) -> BoxFuture; + /// Returns filter changes since last poll. + #[rpc(name = "eth_getFilterChanges")] + fn filter_changes(&self, Index) -> BoxFuture; - /// Returns all logs matching given filter (in a range 'from' - 'to'). - #[rpc(name = "eth_getFilterLogs")] - fn filter_logs(&self, Index) -> BoxFuture>; + /// Returns all logs matching given filter (in a range 'from' - 'to'). + #[rpc(name = "eth_getFilterLogs")] + fn filter_logs(&self, Index) -> BoxFuture>; - /// Uninstalls filter. - #[rpc(name = "eth_uninstallFilter")] - fn uninstall_filter(&self, Index) -> Result; - } + /// Uninstalls filter. + #[rpc(name = "eth_uninstallFilter")] + fn uninstall_filter(&self, Index) -> Result; } diff --git a/rpc/src/v1/traits/eth_pubsub.rs b/rpc/src/v1/traits/eth_pubsub.rs index d584b7dbc..062878139 100644 --- a/rpc/src/v1/traits/eth_pubsub.rs +++ b/rpc/src/v1/traits/eth_pubsub.rs @@ -17,25 +17,22 @@ //! Eth PUB-SUB rpc interface. use jsonrpc_core::Result; -use jsonrpc_macros::Trailing; -use jsonrpc_macros::pubsub::Subscriber; -use jsonrpc_pubsub::SubscriptionId; +use jsonrpc_derive::rpc; +use jsonrpc_pubsub::{typed, SubscriptionId}; use v1::types::pubsub; -build_rpc_trait! { - /// Eth PUB-SUB rpc interface. - pub trait EthPubSub { - type Metadata; +/// Eth PUB-SUB rpc interface. +#[rpc] +pub trait EthPubSub { + /// RPC Metadata + type Metadata; - #[pubsub(name = "eth_subscription")] { - /// Subscribe to Eth subscription. - #[rpc(name = "eth_subscribe")] - fn subscribe(&self, Self::Metadata, Subscriber, pubsub::Kind, Trailing); + /// Subscribe to Eth subscription. + #[pubsub(subscription = "eth_subscription", subscribe, name = "eth_subscribe")] + fn subscribe(&self, Self::Metadata, typed::Subscriber, pubsub::Kind, Option); - /// Unsubscribe from existing Eth subscription. - #[rpc(name = "eth_unsubscribe")] - fn unsubscribe(&self, SubscriptionId) -> Result; - } - } + /// Unsubscribe from existing Eth subscription. + #[pubsub(subscription = "eth_subscription", unsubscribe, name = "eth_unsubscribe")] + fn unsubscribe(&self, Option, SubscriptionId) -> Result; } diff --git a/rpc/src/v1/traits/eth_signing.rs b/rpc/src/v1/traits/eth_signing.rs index 3b7d88446..c272a42e4 100644 --- a/rpc/src/v1/traits/eth_signing.rs +++ b/rpc/src/v1/traits/eth_signing.rs @@ -17,28 +17,29 @@ //! Eth rpc interface. use jsonrpc_core::BoxFuture; +use jsonrpc_derive::rpc; use v1::types::{Bytes, H160, H256, H520, TransactionRequest, RichRawTransaction}; -build_rpc_trait! { - /// Signing methods implementation relying on unlocked accounts. - pub trait EthSigning { - type Metadata; +/// Signing methods implementation relying on unlocked accounts. +#[rpc] +pub trait EthSigning { + /// RPC Metadata + type Metadata; - /// Signs the hash of data with given address signature. - #[rpc(meta, name = "eth_sign")] - fn sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture; + /// Signs the hash of data with given address signature. + #[rpc(meta, name = "eth_sign")] + fn sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture; - /// Sends transaction; will block waiting for signer to return the - /// transaction hash. - /// If Signer is disable it will require the account to be unlocked. - #[rpc(meta, name = "eth_sendTransaction")] - fn send_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; + /// Sends transaction; will block waiting for signer to return the + /// transaction hash. + /// If Signer is disable it will require the account to be unlocked. + #[rpc(meta, name = "eth_sendTransaction")] + fn send_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; - /// Signs transactions without dispatching it to the network. - /// Returns signed transaction RLP representation and the transaction itself. - /// It can be later submitted using `eth_sendRawTransaction/eth_submitTransaction`. - #[rpc(meta, name = "eth_signTransaction")] - fn sign_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; - } + /// Signs transactions without dispatching it to the network. + /// Returns signed transaction RLP representation and the transaction itself. + /// It can be later submitted using `eth_sendRawTransaction/eth_submitTransaction`. + #[rpc(meta, name = "eth_signTransaction")] + fn sign_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; } diff --git a/rpc/src/v1/traits/net.rs b/rpc/src/v1/traits/net.rs index b8bdb1960..a16729294 100644 --- a/rpc/src/v1/traits/net.rs +++ b/rpc/src/v1/traits/net.rs @@ -16,21 +16,21 @@ //! Net rpc interface. use jsonrpc_core::Result; +use jsonrpc_derive::rpc; -build_rpc_trait! { - /// Net rpc interface. - pub trait Net { - /// Returns protocol version. - #[rpc(name = "net_version")] - fn version(&self) -> Result; +/// Net rpc interface. +#[rpc] +pub trait Net { + /// Returns protocol version. + #[rpc(name = "net_version")] + fn version(&self) -> Result; - /// Returns number of peers connected to node. - #[rpc(name = "net_peerCount")] - fn peer_count(&self) -> Result; + /// Returns number of peers connected to node. + #[rpc(name = "net_peerCount")] + fn peer_count(&self) -> Result; - /// Returns true if client is actively listening for network connections. - /// Otherwise false. - #[rpc(name = "net_listening")] - fn is_listening(&self) -> Result; - } + /// Returns true if client is actively listening for network connections. + /// Otherwise false. + #[rpc(name = "net_listening")] + fn is_listening(&self) -> Result; } diff --git a/rpc/src/v1/traits/parity.rs b/rpc/src/v1/traits/parity.rs index 833349880..836f58161 100644 --- a/rpc/src/v1/traits/parity.rs +++ b/rpc/src/v1/traits/parity.rs @@ -19,7 +19,7 @@ use std::collections::BTreeMap; use jsonrpc_core::{BoxFuture, Result}; -use jsonrpc_macros::Trailing; +use jsonrpc_derive::rpc; use v1::types::{ H160, H256, H512, U256, U64, H64, Bytes, CallRequest, Peers, Transaction, RpcSettings, Histogram, RecoveredAccount, @@ -29,223 +29,222 @@ use v1::types::{ AccountInfo, HwAccountInfo, RichHeader, Receipt, }; -build_rpc_trait! { - /// Parity-specific rpc interface. - pub trait Parity { - type Metadata; +/// Parity-specific rpc interface. +#[rpc] +pub trait Parity { + /// RPC Metadata + type Metadata; - /// Returns accounts information. - #[rpc(name = "parity_accountsInfo")] - fn accounts_info(&self) -> Result>; + /// Returns accounts information. + #[rpc(name = "parity_accountsInfo")] + fn accounts_info(&self) -> Result>; - /// Returns hardware accounts information. - #[rpc(name = "parity_hardwareAccountsInfo")] - fn hardware_accounts_info(&self) -> Result>; + /// Returns hardware accounts information. + #[rpc(name = "parity_hardwareAccountsInfo")] + fn hardware_accounts_info(&self) -> Result>; - /// Get a list of paths to locked hardware wallets - #[rpc(name = "parity_lockedHardwareAccountsInfo")] - fn locked_hardware_accounts_info(&self) -> Result>; + /// Get a list of paths to locked hardware wallets + #[rpc(name = "parity_lockedHardwareAccountsInfo")] + fn locked_hardware_accounts_info(&self) -> Result>; - /// Returns default account for dapp. - #[rpc(name = "parity_defaultAccount")] - fn default_account(&self) -> Result; + /// Returns default account for dapp. + #[rpc(name = "parity_defaultAccount")] + fn default_account(&self) -> Result; - /// Returns current transactions limit. - #[rpc(name = "parity_transactionsLimit")] - fn transactions_limit(&self) -> Result; + /// Returns current transactions limit. + #[rpc(name = "parity_transactionsLimit")] + fn transactions_limit(&self) -> Result; - /// Returns mining extra data. - #[rpc(name = "parity_extraData")] - fn extra_data(&self) -> Result; + /// Returns mining extra data. + #[rpc(name = "parity_extraData")] + fn extra_data(&self) -> Result; - /// Returns mining gas floor target. - #[rpc(name = "parity_gasFloorTarget")] - fn gas_floor_target(&self) -> Result; + /// Returns mining gas floor target. + #[rpc(name = "parity_gasFloorTarget")] + fn gas_floor_target(&self) -> Result; - /// Returns mining gas floor cap. - #[rpc(name = "parity_gasCeilTarget")] - fn gas_ceil_target(&self) -> Result; + /// Returns mining gas floor cap. + #[rpc(name = "parity_gasCeilTarget")] + fn gas_ceil_target(&self) -> Result; - /// Returns minimal gas price for transaction to be included in queue. - #[rpc(name = "parity_minGasPrice")] - fn min_gas_price(&self) -> Result; + /// Returns minimal gas price for transaction to be included in queue. + #[rpc(name = "parity_minGasPrice")] + fn min_gas_price(&self) -> Result; - /// Returns latest logs - #[rpc(name = "parity_devLogs")] - fn dev_logs(&self) -> Result>; + /// Returns latest logs + #[rpc(name = "parity_devLogs")] + fn dev_logs(&self) -> Result>; - /// Returns logs levels - #[rpc(name = "parity_devLogsLevels")] - fn dev_logs_levels(&self) -> Result; + /// Returns logs levels + #[rpc(name = "parity_devLogsLevels")] + fn dev_logs_levels(&self) -> Result; - /// Returns chain name - DEPRECATED. Use `parity_chainName` instead. - #[rpc(name = "parity_netChain")] - fn net_chain(&self) -> Result; + /// Returns chain name - DEPRECATED. Use `parity_chainName` instead. + #[rpc(name = "parity_netChain")] + fn net_chain(&self) -> Result; - /// Returns peers details - #[rpc(name = "parity_netPeers")] - fn net_peers(&self) -> Result; + /// Returns peers details + #[rpc(name = "parity_netPeers")] + fn net_peers(&self) -> Result; - /// Returns network port - #[rpc(name = "parity_netPort")] - fn net_port(&self) -> Result; + /// Returns network port + #[rpc(name = "parity_netPort")] + fn net_port(&self) -> Result; - /// Returns rpc settings - #[rpc(name = "parity_rpcSettings")] - fn rpc_settings(&self) -> Result; + /// Returns rpc settings + #[rpc(name = "parity_rpcSettings")] + fn rpc_settings(&self) -> Result; - /// Returns node name - #[rpc(name = "parity_nodeName")] - fn node_name(&self) -> Result; + /// Returns node name + #[rpc(name = "parity_nodeName")] + fn node_name(&self) -> Result; - /// Returns default extra data - #[rpc(name = "parity_defaultExtraData")] - fn default_extra_data(&self) -> Result; + /// Returns default extra data + #[rpc(name = "parity_defaultExtraData")] + fn default_extra_data(&self) -> Result; - /// Returns distribution of gas price in latest blocks. - #[rpc(name = "parity_gasPriceHistogram")] - fn gas_price_histogram(&self) -> BoxFuture; + /// Returns distribution of gas price in latest blocks. + #[rpc(name = "parity_gasPriceHistogram")] + fn gas_price_histogram(&self) -> BoxFuture; - /// Returns number of unsigned transactions waiting in the signer queue (if signer enabled) - /// Returns error when signer is disabled - #[rpc(name = "parity_unsignedTransactionsCount")] - fn unsigned_transactions_count(&self) -> Result; + /// Returns number of unsigned transactions waiting in the signer queue (if signer enabled) + /// Returns error when signer is disabled + #[rpc(name = "parity_unsignedTransactionsCount")] + fn unsigned_transactions_count(&self) -> Result; - /// Returns a cryptographically random phrase sufficient for securely seeding a secret key. - #[rpc(name = "parity_generateSecretPhrase")] - fn generate_secret_phrase(&self) -> Result; + /// Returns a cryptographically random phrase sufficient for securely seeding a secret key. + #[rpc(name = "parity_generateSecretPhrase")] + fn generate_secret_phrase(&self) -> Result; - /// Returns whatever address would be derived from the given phrase if it were to seed a brainwallet. - #[rpc(name = "parity_phraseToAddress")] - fn phrase_to_address(&self, String) -> Result; + /// Returns whatever address would be derived from the given phrase if it were to seed a brainwallet. + #[rpc(name = "parity_phraseToAddress")] + fn phrase_to_address(&self, String) -> Result; - /// Returns the value of the registrar for this network. - #[rpc(name = "parity_registryAddress")] - fn registry_address(&self) -> Result>; + /// Returns the value of the registrar for this network. + #[rpc(name = "parity_registryAddress")] + fn registry_address(&self) -> Result>; - /// Returns all addresses if Fat DB is enabled (`--fat-db`), or null if not. - #[rpc(name = "parity_listAccounts")] - fn list_accounts(&self, u64, Option, Trailing) -> Result>>; + /// Returns all addresses if Fat DB is enabled (`--fat-db`), or null if not. + #[rpc(name = "parity_listAccounts")] + fn list_accounts(&self, u64, Option, Option) -> Result>>; - /// Returns all storage keys of the given address (first parameter) if Fat DB is enabled (`--fat-db`), - /// or null if not. - #[rpc(name = "parity_listStorageKeys")] - fn list_storage_keys(&self, H160, u64, Option, Trailing) -> Result>>; + /// Returns all storage keys of the given address (first parameter) if Fat DB is enabled (`--fat-db`), + /// or null if not. + #[rpc(name = "parity_listStorageKeys")] + fn list_storage_keys(&self, H160, u64, Option, Option) -> Result>>; - /// Encrypt some data with a public key under ECIES. - /// First parameter is the 512-byte destination public key, second is the message. - #[rpc(name = "parity_encryptMessage")] - fn encrypt_message(&self, H512, Bytes) -> Result; + /// Encrypt some data with a public key under ECIES. + /// First parameter is the 512-byte destination public key, second is the message. + #[rpc(name = "parity_encryptMessage")] + fn encrypt_message(&self, H512, Bytes) -> Result; - /// Returns all pending transactions from transaction queue. - #[rpc(name = "parity_pendingTransactions")] - fn pending_transactions(&self, Trailing) -> Result>; + /// Returns all pending transactions from transaction queue. + #[rpc(name = "parity_pendingTransactions")] + fn pending_transactions(&self, Option) -> Result>; - /// Returns all transactions from transaction queue. - /// - /// Some of them might not be ready to be included in a block yet. - #[rpc(name = "parity_allTransactions")] - fn all_transactions(&self) -> Result>; + /// Returns all transactions from transaction queue. + /// + /// Some of them might not be ready to be included in a block yet. + #[rpc(name = "parity_allTransactions")] + fn all_transactions(&self) -> Result>; - /// Same as parity_allTransactions, but return only transactions hashes. - #[rpc(name = "parity_allTransactionHashes")] - fn all_transaction_hashes(&self) -> Result>; + /// Same as parity_allTransactions, but return only transactions hashes. + #[rpc(name = "parity_allTransactionHashes")] + fn all_transaction_hashes(&self) -> Result>; - /// Returns all future transactions from transaction queue (deprecated) - #[rpc(name = "parity_futureTransactions")] - fn future_transactions(&self) -> Result>; + /// Returns all future transactions from transaction queue (deprecated) + #[rpc(name = "parity_futureTransactions")] + fn future_transactions(&self) -> Result>; - /// Returns propagation statistics on transactions pending in the queue. - #[rpc(name = "parity_pendingTransactionsStats")] - fn pending_transactions_stats(&self) -> Result>; + /// Returns propagation statistics on transactions pending in the queue. + #[rpc(name = "parity_pendingTransactionsStats")] + fn pending_transactions_stats(&self) -> Result>; - /// Returns a list of current and past local transactions with status details. - #[rpc(name = "parity_localTransactions")] - fn local_transactions(&self) -> Result>; + /// Returns a list of current and past local transactions with status details. + #[rpc(name = "parity_localTransactions")] + fn local_transactions(&self) -> Result>; - /// Returns current WS Server interface and port or an error if ws server is disabled. - #[rpc(name = "parity_wsUrl")] - fn ws_url(&self) -> Result; + /// Returns current WS Server interface and port or an error if ws server is disabled. + #[rpc(name = "parity_wsUrl")] + fn ws_url(&self) -> Result; - /// Returns next nonce for particular sender. Should include all transactions in the queue. - #[rpc(name = "parity_nextNonce")] - fn next_nonce(&self, H160) -> BoxFuture; + /// Returns next nonce for particular sender. Should include all transactions in the queue. + #[rpc(name = "parity_nextNonce")] + fn next_nonce(&self, H160) -> BoxFuture; - /// Get the mode. Returns one of: "active", "passive", "dark", "offline". - #[rpc(name = "parity_mode")] - fn mode(&self) -> Result; + /// Get the mode. Returns one of: "active", "passive", "dark", "offline". + #[rpc(name = "parity_mode")] + fn mode(&self) -> Result; - /// Get the chain name. Returns one of the pre-configured chain names or a filename. - #[rpc(name = "parity_chain")] - fn chain(&self) -> Result; + /// Get the chain name. Returns one of the pre-configured chain names or a filename. + #[rpc(name = "parity_chain")] + fn chain(&self) -> Result; - /// Get the enode of this node. - #[rpc(name = "parity_enode")] - fn enode(&self) -> Result; + /// Get the enode of this node. + #[rpc(name = "parity_enode")] + fn enode(&self) -> Result; - /// Returns information on current consensus capability. - #[rpc(name = "parity_consensusCapability")] - fn consensus_capability(&self) -> Result; + /// Returns information on current consensus capability. + #[rpc(name = "parity_consensusCapability")] + fn consensus_capability(&self) -> Result; - /// Get our version information in a nice object. - #[rpc(name = "parity_versionInfo")] - fn version_info(&self) -> Result; + /// Get our version information in a nice object. + #[rpc(name = "parity_versionInfo")] + fn version_info(&self) -> Result; - /// Get information concerning the latest releases if available. - #[rpc(name = "parity_releasesInfo")] - fn releases_info(&self) -> Result>; + /// Get information concerning the latest releases if available. + #[rpc(name = "parity_releasesInfo")] + fn releases_info(&self) -> Result>; - /// Get the current chain status. - #[rpc(name = "parity_chainStatus")] - fn chain_status(&self) -> Result; + /// Get the current chain status. + #[rpc(name = "parity_chainStatus")] + fn chain_status(&self) -> Result; - /// Get node kind info. - #[rpc(name = "parity_nodeKind")] - fn node_kind(&self) -> Result<::v1::types::NodeKind>; + /// Get node kind info. + #[rpc(name = "parity_nodeKind")] + fn node_kind(&self) -> Result<::v1::types::NodeKind>; - /// Get block header. - /// Same as `eth_getBlockByNumber` but without uncles and transactions. - #[rpc(name = "parity_getBlockHeaderByNumber")] - fn block_header(&self, Trailing) -> BoxFuture; + /// Get block header. + /// Same as `eth_getBlockByNumber` but without uncles and transactions. + #[rpc(name = "parity_getBlockHeaderByNumber")] + fn block_header(&self, Option) -> BoxFuture; - /// Get block receipts. - /// Allows you to fetch receipts from the entire block at once. - /// If no parameter is provided defaults to `latest`. - #[rpc(name = "parity_getBlockReceipts")] - fn block_receipts(&self, Trailing) -> BoxFuture>; + /// Get block receipts. + /// Allows you to fetch receipts from the entire block at once. + /// If no parameter is provided defaults to `latest`. + #[rpc(name = "parity_getBlockReceipts")] + fn block_receipts(&self, Option) -> BoxFuture>; - /// Get IPFS CIDv0 given protobuf encoded bytes. - #[rpc(name = "parity_cidV0")] - fn ipfs_cid(&self, Bytes) -> Result; + /// Get IPFS CIDv0 given protobuf encoded bytes. + #[rpc(name = "parity_cidV0")] + fn ipfs_cid(&self, Bytes) -> Result; - /// Call contract, returning the output data. - #[rpc(name = "parity_call")] - fn call(&self, Vec, Trailing) -> Result>; + /// Call contract, returning the output data. + #[rpc(name = "parity_call")] + fn call(&self, Vec, Option) -> Result>; - /// Used for submitting a proof-of-work solution (similar to `eth_submitWork`, - /// but returns block hash on success, and returns an explicit error message on failure). - #[rpc(name = "parity_submitWorkDetail")] - fn submit_work_detail(&self, H64, H256, H256) -> Result; + /// Used for submitting a proof-of-work solution (similar to `eth_submitWork`, + /// but returns block hash on success, and returns an explicit error message on failure). + #[rpc(name = "parity_submitWorkDetail")] + fn submit_work_detail(&self, H64, H256, H256) -> Result; - /// Returns the status of the node. Used as the health endpoint. - /// - /// The RPC returns successful response if: - /// - The node have a peer (unless running a dev chain) - /// - The node is not syncing. - /// - /// Otherwise the RPC returns error. - #[rpc(name = "parity_nodeStatus")] - fn status(&self) -> Result<()>; + /// Returns the status of the node. Used as the health endpoint. + /// + /// The RPC returns successful response if: + /// - The node have a peer (unless running a dev chain) + /// - The node is not syncing. + /// + /// Otherwise the RPC returns error. + #[rpc(name = "parity_nodeStatus")] + fn status(&self) -> Result<()>; - /// Extracts Address and public key from signature using the r, s and v params. Equivalent to Solidity erecover - /// as well as checks the signature for chain replay protection - #[rpc(name = "parity_verifySignature")] - fn verify_signature(&self, bool, Bytes, H256, H256, U64) -> Result; + /// Extracts Address and public key from signature using the r, s and v params. Equivalent to Solidity erecover + /// as well as checks the signature for chain replay protection + #[rpc(name = "parity_verifySignature")] + fn verify_signature(&self, bool, Bytes, H256, H256, U64) -> Result; - /// Returns logs matching given filter object. - /// Is allowed to skip filling transaction hash for faster query. - #[rpc(name = "parity_getLogsNoTransactionHash")] - fn logs_no_tx_hash(&self, Filter) -> BoxFuture>; - - } + /// Returns logs matching given filter object. + /// Is allowed to skip filling transaction hash for faster query. + #[rpc(name = "parity_getLogsNoTransactionHash")] + fn logs_no_tx_hash(&self, Filter) -> BoxFuture>; } diff --git a/rpc/src/v1/traits/parity_accounts.rs b/rpc/src/v1/traits/parity_accounts.rs index 8037161e0..f10f10971 100644 --- a/rpc/src/v1/traits/parity_accounts.rs +++ b/rpc/src/v1/traits/parity_accounts.rs @@ -18,125 +18,125 @@ use std::collections::BTreeMap; use jsonrpc_core::Result; +use jsonrpc_derive::rpc; use ethkey::Password; use ethstore::KeyFile; use v1::types::{H160, H256, H520, DeriveHash, DeriveHierarchical, ExtAccountInfo}; -build_rpc_trait! { - /// Personal Parity rpc interface. - pub trait ParityAccounts { - /// Returns accounts information. - #[rpc(name = "parity_allAccountsInfo")] - fn all_accounts_info(&self) -> Result>; +/// Personal Parity rpc interface. +#[rpc] +pub trait ParityAccounts { + /// Returns accounts information. + #[rpc(name = "parity_allAccountsInfo")] + fn all_accounts_info(&self) -> Result>; - /// Creates new account from the given phrase using standard brainwallet mechanism. - /// Second parameter is password for the new account. - #[rpc(name = "parity_newAccountFromPhrase")] - fn new_account_from_phrase(&self, String, Password) -> Result; + /// Creates new account from the given phrase using standard brainwallet mechanism. + /// Second parameter is password for the new account. + #[rpc(name = "parity_newAccountFromPhrase")] + fn new_account_from_phrase(&self, String, Password) -> Result; - /// Creates new account from the given JSON wallet. - /// Second parameter is password for the wallet and the new account. - #[rpc(name = "parity_newAccountFromWallet")] - fn new_account_from_wallet(&self, String, Password) -> Result; + /// Creates new account from the given JSON wallet. + /// Second parameter is password for the wallet and the new account. + #[rpc(name = "parity_newAccountFromWallet")] + fn new_account_from_wallet(&self, String, Password) -> Result; - /// Creates new account from the given raw secret. - /// Second parameter is password for the new account. - #[rpc(name = "parity_newAccountFromSecret")] - fn new_account_from_secret(&self, H256, Password) -> Result; + /// Creates new account from the given raw secret. + /// Second parameter is password for the new account. + #[rpc(name = "parity_newAccountFromSecret")] + fn new_account_from_secret(&self, H256, Password) -> Result; - /// Returns true if given `password` would unlock given `account`. - /// Arguments: `account`, `password`. - #[rpc(name = "parity_testPassword")] - fn test_password(&self, H160, Password) -> Result; + /// Returns true if given `password` would unlock given `account`. + /// Arguments: `account`, `password`. + #[rpc(name = "parity_testPassword")] + fn test_password(&self, H160, Password) -> Result; - /// Changes an account's password. - /// Arguments: `account`, `password`, `new_password`. - #[rpc(name = "parity_changePassword")] - fn change_password(&self, H160, Password, Password) -> Result; + /// Changes an account's password. + /// Arguments: `account`, `password`, `new_password`. + #[rpc(name = "parity_changePassword")] + fn change_password(&self, H160, Password, Password) -> Result; - /// Permanently deletes an account. - /// Arguments: `account`, `password`. - #[rpc(name = "parity_killAccount")] - fn kill_account(&self, H160, Password) -> Result; + /// Permanently deletes an account. + /// Arguments: `account`, `password`. + #[rpc(name = "parity_killAccount")] + fn kill_account(&self, H160, Password) -> Result; - /// Permanently deletes an address from the addressbook - /// Arguments: `address` - #[rpc(name = "parity_removeAddress")] - fn remove_address(&self, H160) -> Result; + /// Permanently deletes an address from the addressbook + /// Arguments: `address` + #[rpc(name = "parity_removeAddress")] + fn remove_address(&self, H160) -> Result; - /// Set an account's name. - #[rpc(name = "parity_setAccountName")] - fn set_account_name(&self, H160, String) -> Result; + /// Set an account's name. + #[rpc(name = "parity_setAccountName")] + fn set_account_name(&self, H160, String) -> Result; - /// Set an account's metadata string. - #[rpc(name = "parity_setAccountMeta")] - fn set_account_meta(&self, H160, String) -> Result; + /// Set an account's metadata string. + #[rpc(name = "parity_setAccountMeta")] + fn set_account_meta(&self, H160, String) -> Result; - /// Imports a number of Geth accounts, with the list provided as the argument. - #[rpc(name = "parity_importGethAccounts")] - fn import_geth_accounts(&self, Vec) -> Result>; + /// Imports a number of Geth accounts, with the list provided as the argument. + #[rpc(name = "parity_importGethAccounts")] + fn import_geth_accounts(&self, Vec) -> Result>; - /// Returns the accounts available for importing from Geth. - #[rpc(name = "parity_listGethAccounts")] - fn geth_accounts(&self) -> Result>; + /// Returns the accounts available for importing from Geth. + #[rpc(name = "parity_listGethAccounts")] + fn geth_accounts(&self) -> Result>; - /// Create new vault. - #[rpc(name = "parity_newVault")] - fn create_vault(&self, String, Password) -> Result; + /// Create new vault. + #[rpc(name = "parity_newVault")] + fn create_vault(&self, String, Password) -> Result; - /// Open existing vault. - #[rpc(name = "parity_openVault")] - fn open_vault(&self, String, Password) -> Result; + /// Open existing vault. + #[rpc(name = "parity_openVault")] + fn open_vault(&self, String, Password) -> Result; - /// Close previously opened vault. - #[rpc(name = "parity_closeVault")] - fn close_vault(&self, String) -> Result; + /// Close previously opened vault. + #[rpc(name = "parity_closeVault")] + fn close_vault(&self, String) -> Result; - /// List all vaults. - #[rpc(name = "parity_listVaults")] - fn list_vaults(&self) -> Result>; + /// List all vaults. + #[rpc(name = "parity_listVaults")] + fn list_vaults(&self) -> Result>; - /// List all currently opened vaults. - #[rpc(name = "parity_listOpenedVaults")] - fn list_opened_vaults(&self) -> Result>; + /// List all currently opened vaults. + #[rpc(name = "parity_listOpenedVaults")] + fn list_opened_vaults(&self) -> Result>; - /// Change vault password. - #[rpc(name = "parity_changeVaultPassword")] - fn change_vault_password(&self, String, Password) -> Result; + /// Change vault password. + #[rpc(name = "parity_changeVaultPassword")] + fn change_vault_password(&self, String, Password) -> Result; - /// Change vault of the given address. - #[rpc(name = "parity_changeVault")] - fn change_vault(&self, H160, String) -> Result; + /// Change vault of the given address. + #[rpc(name = "parity_changeVault")] + fn change_vault(&self, H160, String) -> Result; - /// Get vault metadata string. - #[rpc(name = "parity_getVaultMeta")] - fn get_vault_meta(&self, String) -> Result; + /// Get vault metadata string. + #[rpc(name = "parity_getVaultMeta")] + fn get_vault_meta(&self, String) -> Result; - /// Set vault metadata string. - #[rpc(name = "parity_setVaultMeta")] - fn set_vault_meta(&self, String, String) -> Result; + /// Set vault metadata string. + #[rpc(name = "parity_setVaultMeta")] + fn set_vault_meta(&self, String, String) -> Result; - /// Derive new address from given account address using specific hash. - /// Resulting address can be either saved as a new account (with the same password). - #[rpc(name = "parity_deriveAddressHash")] - fn derive_key_hash(&self, H160, Password, DeriveHash, bool) -> Result; + /// Derive new address from given account address using specific hash. + /// Resulting address can be either saved as a new account (with the same password). + #[rpc(name = "parity_deriveAddressHash")] + fn derive_key_hash(&self, H160, Password, DeriveHash, bool) -> Result; - /// Derive new address from given account address using - /// hierarchical derivation (sequence of 32-bit integer indices). - /// Resulting address can be either saved as a new account (with the same password). - #[rpc(name = "parity_deriveAddressIndex")] - fn derive_key_index(&self, H160, Password, DeriveHierarchical, bool) -> Result; + /// Derive new address from given account address using + /// hierarchical derivation (sequence of 32-bit integer indices). + /// Resulting address can be either saved as a new account (with the same password). + #[rpc(name = "parity_deriveAddressIndex")] + fn derive_key_index(&self, H160, Password, DeriveHierarchical, bool) -> Result; - /// Exports an account with given address if provided password matches. - #[rpc(name = "parity_exportAccount")] - fn export_account(&self, H160, Password) -> Result; + /// Exports an account with given address if provided password matches. + #[rpc(name = "parity_exportAccount")] + fn export_account(&self, H160, Password) -> Result; - /// Sign raw hash with the key corresponding to address and password. - #[rpc(name = "parity_signMessage")] - fn sign_message(&self, H160, Password, H256) -> Result; + /// Sign raw hash with the key corresponding to address and password. + #[rpc(name = "parity_signMessage")] + fn sign_message(&self, H160, Password, H256) -> Result; - /// Send a PinMatrixAck to a hardware wallet, unlocking it - #[rpc(name = "parity_hardwarePinMatrixAck")] - fn hardware_pin_matrix_ack(&self, String, String) -> Result; - } + /// Send a PinMatrixAck to a hardware wallet, unlocking it + #[rpc(name = "parity_hardwarePinMatrixAck")] + fn hardware_pin_matrix_ack(&self, String, String) -> Result; } diff --git a/rpc/src/v1/traits/parity_set.rs b/rpc/src/v1/traits/parity_set.rs index 66f91a524..9a0badaa2 100644 --- a/rpc/src/v1/traits/parity_set.rs +++ b/rpc/src/v1/traits/parity_set.rs @@ -17,99 +17,99 @@ //! Parity-specific rpc interface for operations altering the settings. use jsonrpc_core::{BoxFuture, Result}; +use jsonrpc_derive::rpc; use v1::types::{Bytes, H160, H256, U256, ReleaseInfo, Transaction}; -build_rpc_trait! { - /// Parity-specific rpc interface for operations altering the settings. - pub trait ParitySet { - /// Sets new minimal gas price for mined blocks. - #[rpc(name = "parity_setMinGasPrice")] - fn set_min_gas_price(&self, U256) -> Result; +/// Parity-specific rpc interface for operations altering the settings. +#[rpc] +pub trait ParitySet { + /// Sets new minimal gas price for mined blocks. + #[rpc(name = "parity_setMinGasPrice")] + fn set_min_gas_price(&self, U256) -> Result; - /// Sets new gas floor target for mined blocks. - #[rpc(name = "parity_setGasFloorTarget")] - fn set_gas_floor_target(&self, U256) -> Result; + /// Sets new gas floor target for mined blocks. + #[rpc(name = "parity_setGasFloorTarget")] + fn set_gas_floor_target(&self, U256) -> Result; - /// Sets new gas ceiling target for mined blocks. - #[rpc(name = "parity_setGasCeilTarget")] - fn set_gas_ceil_target(&self, U256) -> Result; + /// Sets new gas ceiling target for mined blocks. + #[rpc(name = "parity_setGasCeilTarget")] + fn set_gas_ceil_target(&self, U256) -> Result; - /// Sets new extra data for mined blocks. - #[rpc(name = "parity_setExtraData")] - fn set_extra_data(&self, Bytes) -> Result; + /// Sets new extra data for mined blocks. + #[rpc(name = "parity_setExtraData")] + fn set_extra_data(&self, Bytes) -> Result; - /// Sets new author for mined block. - #[rpc(name = "parity_setAuthor")] - fn set_author(&self, H160) -> Result; + /// Sets new author for mined block. + #[rpc(name = "parity_setAuthor")] + fn set_author(&self, H160) -> Result; - /// Sets account for signing consensus messages. - #[rpc(name = "parity_setEngineSigner")] - fn set_engine_signer(&self, H160, String) -> Result; + /// Sets account for signing consensus messages. + #[rpc(name = "parity_setEngineSigner")] + fn set_engine_signer(&self, H160, String) -> Result; - /// Sets the limits for transaction queue. - #[rpc(name = "parity_setTransactionsLimit")] - fn set_transactions_limit(&self, usize) -> Result; + /// Sets the limits for transaction queue. + #[rpc(name = "parity_setTransactionsLimit")] + fn set_transactions_limit(&self, usize) -> Result; - /// Sets the maximum amount of gas a single transaction may consume. - #[rpc(name = "parity_setMaxTransactionGas")] - fn set_tx_gas_limit(&self, U256) -> Result; + /// Sets the maximum amount of gas a single transaction may consume. + #[rpc(name = "parity_setMaxTransactionGas")] + fn set_tx_gas_limit(&self, U256) -> Result; - /// Add a reserved peer. - #[rpc(name = "parity_addReservedPeer")] - fn add_reserved_peer(&self, String) -> Result; + /// Add a reserved peer. + #[rpc(name = "parity_addReservedPeer")] + fn add_reserved_peer(&self, String) -> Result; - /// Remove a reserved peer. - #[rpc(name = "parity_removeReservedPeer")] - fn remove_reserved_peer(&self, String) -> Result; + /// Remove a reserved peer. + #[rpc(name = "parity_removeReservedPeer")] + fn remove_reserved_peer(&self, String) -> Result; - /// Drop all non-reserved peers. - #[rpc(name = "parity_dropNonReservedPeers")] - fn drop_non_reserved_peers(&self) -> Result; + /// Drop all non-reserved peers. + #[rpc(name = "parity_dropNonReservedPeers")] + fn drop_non_reserved_peers(&self) -> Result; - /// Accept non-reserved peers (default behavior) - #[rpc(name = "parity_acceptNonReservedPeers")] - fn accept_non_reserved_peers(&self) -> Result; + /// Accept non-reserved peers (default behavior) + #[rpc(name = "parity_acceptNonReservedPeers")] + fn accept_non_reserved_peers(&self) -> Result; - /// Start the network. - /// - /// @deprecated - Use `set_mode("active")` instead. - #[rpc(name = "parity_startNetwork")] - fn start_network(&self) -> Result; + /// Start the network. + /// + /// @deprecated - Use `set_mode("active")` instead. + #[rpc(name = "parity_startNetwork")] + fn start_network(&self) -> Result; - /// Stop the network. - /// - /// @deprecated - Use `set_mode("offline")` instead. - #[rpc(name = "parity_stopNetwork")] - fn stop_network(&self) -> Result; + /// Stop the network. + /// + /// @deprecated - Use `set_mode("offline")` instead. + #[rpc(name = "parity_stopNetwork")] + fn stop_network(&self) -> Result; - /// Set the mode. Argument must be one of: "active", "passive", "dark", "offline". - #[rpc(name = "parity_setMode")] - fn set_mode(&self, String) -> Result; + /// Set the mode. Argument must be one of: "active", "passive", "dark", "offline". + #[rpc(name = "parity_setMode")] + fn set_mode(&self, String) -> Result; - /// Set the network spec. Argument must be one of pre-configured chains or a filename. - #[rpc(name = "parity_setChain")] - fn set_spec_name(&self, String) -> Result; + /// Set the network spec. Argument must be one of pre-configured chains or a filename. + #[rpc(name = "parity_setChain")] + fn set_spec_name(&self, String) -> Result; - /// Hash a file content under given URL. - #[rpc(name = "parity_hashContent")] - fn hash_content(&self, String) -> BoxFuture; + /// Hash a file content under given URL. + #[rpc(name = "parity_hashContent")] + fn hash_content(&self, String) -> BoxFuture; - /// Is there a release ready for install? - #[rpc(name = "parity_upgradeReady")] - fn upgrade_ready(&self) -> Result>; + /// Is there a release ready for install? + #[rpc(name = "parity_upgradeReady")] + fn upgrade_ready(&self) -> Result>; - /// Execute a release which is ready according to upgrade_ready(). - #[rpc(name = "parity_executeUpgrade")] - fn execute_upgrade(&self) -> Result; + /// Execute a release which is ready according to upgrade_ready(). + #[rpc(name = "parity_executeUpgrade")] + fn execute_upgrade(&self) -> Result; - /// Removes transaction from transaction queue. - /// Makes sense only for transactions that were not propagated to other peers yet - /// like scheduled transactions or transactions in future. - /// It might also work for some local transactions with to low gas price - /// or excessive gas limit that are not accepted by other peers whp. - /// Returns `true` when transaction was removed, `false` if it was not found. - #[rpc(name = "parity_removeTransaction")] - fn remove_transaction(&self, H256) -> Result>; - } + /// Removes transaction from transaction queue. + /// Makes sense only for transactions that were not propagated to other peers yet + /// like scheduled transactions or transactions in future. + /// It might also work for some local transactions with to low gas price + /// or excessive gas limit that are not accepted by other peers whp. + /// Returns `true` when transaction was removed, `false` if it was not found. + #[rpc(name = "parity_removeTransaction")] + fn remove_transaction(&self, H256) -> Result>; } diff --git a/rpc/src/v1/traits/parity_signing.rs b/rpc/src/v1/traits/parity_signing.rs index e716204be..26495831a 100644 --- a/rpc/src/v1/traits/parity_signing.rs +++ b/rpc/src/v1/traits/parity_signing.rs @@ -16,37 +16,38 @@ //! ParitySigning rpc interface. use jsonrpc_core::{BoxFuture, Result}; +use jsonrpc_derive::rpc; use v1::types::{U256, H160, Bytes, ConfirmationResponse, TransactionRequest, Either}; -build_rpc_trait! { - /// Signing methods implementation. - pub trait ParitySigning { - type Metadata; +/// Signing methods implementation. +#[rpc] +pub trait ParitySigning { + /// RPC Metadata + type Metadata; - /// Given partial transaction request produces transaction with all fields filled in. - /// Such transaction can be then signed externally. - #[rpc(meta, name = "parity_composeTransaction")] - fn compose_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; + /// Given partial transaction request produces transaction with all fields filled in. + /// Such transaction can be then signed externally. + #[rpc(meta, name = "parity_composeTransaction")] + fn compose_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture; - /// Posts sign request asynchronously. - /// Will return a confirmation ID for later use with check_transaction. - #[rpc(meta, name = "parity_postSign")] - fn post_sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture>; + /// Posts sign request asynchronously. + /// Will return a confirmation ID for later use with check_transaction. + #[rpc(meta, name = "parity_postSign")] + fn post_sign(&self, Self::Metadata, H160, Bytes) -> BoxFuture>; - /// Posts transaction asynchronously. - /// Will return a transaction ID for later use with check_transaction. - #[rpc(meta, name = "parity_postTransaction")] - fn post_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture>; + /// Posts transaction asynchronously. + /// Will return a transaction ID for later use with check_transaction. + #[rpc(meta, name = "parity_postTransaction")] + fn post_transaction(&self, Self::Metadata, TransactionRequest) -> BoxFuture>; - /// Checks the progress of a previously posted request (transaction/sign). - /// Should be given a valid send_transaction ID. - #[rpc(name = "parity_checkRequest")] - fn check_request(&self, U256) -> Result>; + /// Checks the progress of a previously posted request (transaction/sign). + /// Should be given a valid send_transaction ID. + #[rpc(name = "parity_checkRequest")] + fn check_request(&self, U256) -> Result>; - /// Decrypt some ECIES-encrypted message. - /// First parameter is the address with which it is encrypted, second is the ciphertext. - #[rpc(meta, name = "parity_decryptMessage")] - fn decrypt_message(&self, Self::Metadata, H160, Bytes) -> BoxFuture; - } + /// Decrypt some ECIES-encrypted message. + /// First parameter is the address with which it is encrypted, second is the ciphertext. + #[rpc(meta, name = "parity_decryptMessage")] + fn decrypt_message(&self, Self::Metadata, H160, Bytes) -> BoxFuture; } diff --git a/rpc/src/v1/traits/personal.rs b/rpc/src/v1/traits/personal.rs index 8965564e7..25412f664 100644 --- a/rpc/src/v1/traits/personal.rs +++ b/rpc/src/v1/traits/personal.rs @@ -18,56 +18,57 @@ use eip_712::EIP712; use jsonrpc_core::types::Value; use jsonrpc_core::{BoxFuture, Result}; +use jsonrpc_derive::rpc; use v1::types::{Bytes, U128, H160, H256, H520, TransactionRequest, RichRawTransaction as RpcRichRawTransaction, EIP191Version}; -build_rpc_trait! { - /// Personal rpc interface. Safe (read-only) functions. - pub trait Personal { - type Metadata; +/// Personal rpc interface. Safe (read-only) functions. +#[rpc] +pub trait Personal { + /// RPC Metadata + type Metadata; - /// Lists all stored accounts - #[rpc(name = "personal_listAccounts")] - fn accounts(&self) -> Result>; + /// Lists all stored accounts + #[rpc(name = "personal_listAccounts")] + fn accounts(&self) -> Result>; - /// Creates new account (it becomes new current unlocked account) - /// Param is the password for the account. - #[rpc(name = "personal_newAccount")] - fn new_account(&self, String) -> Result; + /// Creates new account (it becomes new current unlocked account) + /// Param is the password for the account. + #[rpc(name = "personal_newAccount")] + fn new_account(&self, String) -> Result; - /// Unlocks specified account for use (can only be one unlocked account at one moment) - #[rpc(name = "personal_unlockAccount")] - fn unlock_account(&self, H160, String, Option) -> Result; + /// Unlocks specified account for use (can only be one unlocked account at one moment) + #[rpc(name = "personal_unlockAccount")] + fn unlock_account(&self, H160, String, Option) -> Result; - /// Signs the hash of data with given account signature using the given password to unlock the account during - /// the request. - #[rpc(name = "personal_sign")] - fn sign(&self, Bytes, H160, String) -> BoxFuture; + /// Signs the hash of data with given account signature using the given password to unlock the account during + /// the request. + #[rpc(name = "personal_sign")] + fn sign(&self, Bytes, H160, String) -> BoxFuture; - /// Produces an EIP-712 compliant signature with given account using the given password to unlock the - /// account during the request. - #[rpc(name = "personal_signTypedData")] - fn sign_typed_data(&self, EIP712, H160, String) -> BoxFuture; + /// Produces an EIP-712 compliant signature with given account using the given password to unlock the + /// account during the request. + #[rpc(name = "personal_signTypedData")] + fn sign_typed_data(&self, EIP712, H160, String) -> BoxFuture; - /// Signs an arbitrary message based on the version specified - #[rpc(name = "personal_sign191")] - fn sign_191(&self, EIP191Version, Value, H160, String) -> BoxFuture; + /// Signs an arbitrary message based on the version specified + #[rpc(name = "personal_sign191")] + fn sign_191(&self, EIP191Version, Value, H160, String) -> BoxFuture; - /// Returns the account associated with the private key that was used to calculate the signature in - /// `personal_sign`. - #[rpc(name = "personal_ecRecover")] - fn ec_recover(&self, Bytes, H520) -> BoxFuture; + /// Returns the account associated with the private key that was used to calculate the signature in + /// `personal_sign`. + #[rpc(name = "personal_ecRecover")] + fn ec_recover(&self, Bytes, H520) -> BoxFuture; - /// Signs transaction. The account is not unlocked in such case. - #[rpc(meta, name = "personal_signTransaction")] - fn sign_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; + /// Signs transaction. The account is not unlocked in such case. + #[rpc(meta, name = "personal_signTransaction")] + fn sign_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; - /// Sends transaction and signs it in single call. The account is not unlocked in such case. - #[rpc(meta, name = "personal_sendTransaction")] - fn send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; + /// Sends transaction and signs it in single call. The account is not unlocked in such case. + #[rpc(meta, name = "personal_sendTransaction")] + fn send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; - /// @deprecated alias for `personal_sendTransaction`. - #[rpc(meta, name = "personal_signAndSendTransaction")] - fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; + /// @deprecated alias for `personal_sendTransaction`. + #[rpc(meta, name = "personal_signAndSendTransaction")] + fn sign_and_send_transaction(&self, Self::Metadata, TransactionRequest, String) -> BoxFuture; - } } diff --git a/rpc/src/v1/traits/private.rs b/rpc/src/v1/traits/private.rs index f7168c06c..b7b871df0 100644 --- a/rpc/src/v1/traits/private.rs +++ b/rpc/src/v1/traits/private.rs @@ -17,29 +17,30 @@ //! SecretStore-specific rpc interface. use jsonrpc_core::Error; +use jsonrpc_derive::rpc; use v1::types::{Bytes, PrivateTransactionReceipt, H160, H256, U256, BlockNumber, PrivateTransactionReceiptAndTransaction, CallRequest}; -build_rpc_trait! { - /// Private transaction management RPC interface. - pub trait Private { - type Metadata; +/// Private transaction management RPC interface. +#[rpc] +pub trait Private { + /// RPC Metadata + type Metadata; - /// Sends private transaction; Transaction will be added to the validation queue and sent out when ready. - #[rpc(name = "private_sendTransaction")] - fn send_transaction(&self, Bytes) -> Result; + /// Sends private transaction; Transaction will be added to the validation queue and sent out when ready. + #[rpc(name = "private_sendTransaction")] + fn send_transaction(&self, Bytes) -> Result; - /// Creates a transaction for contract's deployment from origin (signed transaction) - #[rpc(name = "private_composeDeploymentTransaction")] - fn compose_deployment_transaction(&self, BlockNumber, Bytes, Vec, U256) -> Result; + /// Creates a transaction for contract's deployment from origin (signed transaction) + #[rpc(name = "private_composeDeploymentTransaction")] + fn compose_deployment_transaction(&self, BlockNumber, Bytes, Vec, U256) -> Result; - /// Make a call to the private contract - #[rpc(name = "private_call")] - fn private_call(&self, BlockNumber, CallRequest) -> Result; + /// Make a call to the private contract + #[rpc(name = "private_call")] + fn private_call(&self, BlockNumber, CallRequest) -> Result; - /// Retrieve the id of the key associated with the contract - #[rpc(name = "private_contractKey")] - fn private_contract_key(&self, H160) -> Result; - } + /// Retrieve the id of the key associated with the contract + #[rpc(name = "private_contractKey")] + fn private_contract_key(&self, H160) -> Result; } diff --git a/rpc/src/v1/traits/pubsub.rs b/rpc/src/v1/traits/pubsub.rs index 007e1dae4..c91b33561 100644 --- a/rpc/src/v1/traits/pubsub.rs +++ b/rpc/src/v1/traits/pubsub.rs @@ -17,23 +17,20 @@ //! Parity-specific PUB-SUB rpc interface. use jsonrpc_core::{Result, Value, Params}; -use jsonrpc_pubsub::SubscriptionId; -use jsonrpc_macros::Trailing; -use jsonrpc_macros::pubsub::Subscriber; +use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; +use jsonrpc_derive::rpc; -build_rpc_trait! { - /// Parity-specific PUB-SUB rpc interface. - pub trait PubSub { - type Metadata; +/// Parity-specific PUB-SUB rpc interface. +#[rpc] +pub trait PubSub { + /// Pub/Sub Metadata + type Metadata; - #[pubsub(name = "parity_subscription")] { - /// Subscribe to changes of any RPC method in Parity. - #[rpc(name = "parity_subscribe")] - fn parity_subscribe(&self, Self::Metadata, Subscriber, String, Trailing); + /// Subscribe to changes of any RPC method in Parity. + #[pubsub(subscription = "parity_subscription", subscribe, name = "parity_subscribe")] + fn parity_subscribe(&self, Self::Metadata, Subscriber, String, Option); - /// Unsubscribe from existing Parity subscription. - #[rpc(name = "parity_unsubscribe")] - fn parity_unsubscribe(&self, SubscriptionId) -> Result; - } - } + /// Unsubscribe from existing Parity subscription. + #[pubsub(subscription = "parity_subscription", unsubscribe, name = "parity_unsubscribe")] + fn parity_unsubscribe(&self, Option, SubscriptionId) -> Result; } diff --git a/rpc/src/v1/traits/rpc.rs b/rpc/src/v1/traits/rpc.rs index 4ec58b242..9600630fe 100644 --- a/rpc/src/v1/traits/rpc.rs +++ b/rpc/src/v1/traits/rpc.rs @@ -19,18 +19,18 @@ use std::collections::BTreeMap; use jsonrpc_core::Result; +use jsonrpc_derive::rpc; -build_rpc_trait! { - /// RPC Interface. - pub trait Rpc { - /// Returns supported modules for Geth 1.3.6 - /// @ignore - #[rpc(name = "modules")] - fn modules(&self) -> Result>; +/// RPC Interface. +#[rpc] +pub trait Rpc { + /// Returns supported modules for Geth 1.3.6 + /// @ignore + #[rpc(name = "modules")] + fn modules(&self) -> Result>; - /// Returns supported modules for Geth 1.4.0 - /// @ignore - #[rpc(name = "rpc_modules")] - fn rpc_modules(&self) -> Result>; - } + /// Returns supported modules for Geth 1.4.0 + /// @ignore + #[rpc(name = "rpc_modules")] + fn rpc_modules(&self) -> Result>; } diff --git a/rpc/src/v1/traits/secretstore.rs b/rpc/src/v1/traits/secretstore.rs index 0a5216c49..8ff1c0e99 100644 --- a/rpc/src/v1/traits/secretstore.rs +++ b/rpc/src/v1/traits/secretstore.rs @@ -18,43 +18,43 @@ use std::collections::BTreeSet; use jsonrpc_core::Result; +use jsonrpc_derive::rpc; use ethkey::Password; use v1::types::{H160, H256, H512, Bytes, EncryptedDocumentKey}; -build_rpc_trait! { - /// Parity-specific rpc interface. - pub trait SecretStore { - /// Generate document key to store in secret store. - /// Arguments: `account`, `password`, `server_key_public`. - #[rpc(name = "secretstore_generateDocumentKey")] - fn generate_document_key(&self, H160, Password, H512) -> Result; +/// Parity-specific rpc interface. +#[rpc] +pub trait SecretStore { + /// Generate document key to store in secret store. + /// Arguments: `account`, `password`, `server_key_public`. + #[rpc(name = "secretstore_generateDocumentKey")] + fn generate_document_key(&self, H160, Password, H512) -> Result; - /// Encrypt data with key, received from secret store. - /// Arguments: `account`, `password`, `key`, `data`. - #[rpc(name = "secretstore_encrypt")] - fn encrypt(&self, H160, Password, Bytes, Bytes) -> Result; + /// Encrypt data with key, received from secret store. + /// Arguments: `account`, `password`, `key`, `data`. + #[rpc(name = "secretstore_encrypt")] + fn encrypt(&self, H160, Password, Bytes, Bytes) -> Result; - /// Decrypt data with key, received from secret store. - /// Arguments: `account`, `password`, `key`, `data`. - #[rpc(name = "secretstore_decrypt")] - fn decrypt(&self, H160, Password, Bytes, Bytes) -> Result; + /// Decrypt data with key, received from secret store. + /// Arguments: `account`, `password`, `key`, `data`. + #[rpc(name = "secretstore_decrypt")] + fn decrypt(&self, H160, Password, Bytes, Bytes) -> Result; - /// Decrypt data with shadow key, received from secret store. - /// Arguments: `account`, `password`, `decrypted_secret`, `common_point`, `decrypt_shadows`, `data`. - #[rpc(name = "secretstore_shadowDecrypt")] - fn shadow_decrypt(&self, H160, Password, H512, H512, Vec, Bytes) -> Result; + /// Decrypt data with shadow key, received from secret store. + /// Arguments: `account`, `password`, `decrypted_secret`, `common_point`, `decrypt_shadows`, `data`. + #[rpc(name = "secretstore_shadowDecrypt")] + fn shadow_decrypt(&self, H160, Password, H512, H512, Vec, Bytes) -> Result; - /// Calculates the hash (keccak256) of servers set for using in ServersSetChange session. - /// Returned hash must be signed later by using `secretstore_signRawHash` method. - /// Arguments: `servers_set`. - #[rpc(name = "secretstore_serversSetHash")] - fn servers_set_hash(&self, BTreeSet) -> Result; + /// Calculates the hash (keccak256) of servers set for using in ServersSetChange session. + /// Returned hash must be signed later by using `secretstore_signRawHash` method. + /// Arguments: `servers_set`. + #[rpc(name = "secretstore_serversSetHash")] + fn servers_set_hash(&self, BTreeSet) -> Result; - /// Generate recoverable ECDSA signature of raw hash. - /// Passed hash is treated as an input to the `sign` function (no prefixes added, no hash function is applied). - /// Arguments: `account`, `password`, `raw_hash`. - #[rpc(name = "secretstore_signRawHash")] - fn sign_raw_hash(&self, H160, Password, H256) -> Result; - } + /// Generate recoverable ECDSA signature of raw hash. + /// Passed hash is treated as an input to the `sign` function (no prefixes added, no hash function is applied). + /// Arguments: `account`, `password`, `raw_hash`. + #[rpc(name = "secretstore_signRawHash")] + fn sign_raw_hash(&self, H160, Password, H256) -> Result; } diff --git a/rpc/src/v1/traits/signer.rs b/rpc/src/v1/traits/signer.rs index afaba5ebe..84eccf0d3 100644 --- a/rpc/src/v1/traits/signer.rs +++ b/rpc/src/v1/traits/signer.rs @@ -16,52 +16,50 @@ //! Parity Signer-related rpc interface. use jsonrpc_core::{BoxFuture, Result}; -use jsonrpc_pubsub::SubscriptionId; -use jsonrpc_macros::pubsub::Subscriber; +use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; +use jsonrpc_derive::rpc; use v1::types::{U256, Bytes, TransactionModification, ConfirmationRequest, ConfirmationResponse, ConfirmationResponseWithToken}; -build_rpc_trait! { - /// Signer extension for confirmations rpc interface. - pub trait Signer { - type Metadata; +/// Signer extension for confirmations rpc interface. +#[rpc] +pub trait Signer { + /// RPC Metadata + type Metadata; - /// Returns a list of items to confirm. - #[rpc(name = "signer_requestsToConfirm")] - fn requests_to_confirm(&self) -> Result>; + /// Returns a list of items to confirm. + #[rpc(name = "signer_requestsToConfirm")] + fn requests_to_confirm(&self) -> Result>; - /// Confirm specific request. - #[rpc(name = "signer_confirmRequest")] - fn confirm_request(&self, U256, TransactionModification, String) -> BoxFuture; + /// Confirm specific request. + #[rpc(name = "signer_confirmRequest")] + fn confirm_request(&self, U256, TransactionModification, String) -> BoxFuture; - /// Confirm specific request with token. - #[rpc(name = "signer_confirmRequestWithToken")] - fn confirm_request_with_token(&self, U256, TransactionModification, String) -> BoxFuture; + /// Confirm specific request with token. + #[rpc(name = "signer_confirmRequestWithToken")] + fn confirm_request_with_token(&self, U256, TransactionModification, String) -> BoxFuture; - /// Confirm specific request with already signed data. - #[rpc(name = "signer_confirmRequestRaw")] - fn confirm_request_raw(&self, U256, Bytes) -> Result; + /// Confirm specific request with already signed data. + #[rpc(name = "signer_confirmRequestRaw")] + fn confirm_request_raw(&self, U256, Bytes) -> Result; - /// Reject the confirmation request. - #[rpc(name = "signer_rejectRequest")] - fn reject_request(&self, U256) -> Result; + /// Reject the confirmation request. + #[rpc(name = "signer_rejectRequest")] + fn reject_request(&self, U256) -> Result; - /// Generates new authorization token. - #[rpc(name = "signer_generateAuthorizationToken")] - fn generate_token(&self) -> Result; + /// Generates new authorization token. + #[rpc(name = "signer_generateAuthorizationToken")] + fn generate_token(&self) -> Result; - /// Generates new web proxy access token for particular domain. - #[rpc(name = "signer_generateWebProxyAccessToken")] - fn generate_web_proxy_token(&self, String) -> Result; + /// Generates new web proxy access token for particular domain. + #[rpc(name = "signer_generateWebProxyAccessToken")] + fn generate_web_proxy_token(&self, String) -> Result; - #[pubsub(name = "signer_pending")] { - /// Subscribe to new pending requests on signer interface. - #[rpc(name = "signer_subscribePending")] - fn subscribe_pending(&self, Self::Metadata, Subscriber>); + /// Subscribe to new pending requests on signer interface. + #[pubsub(subscription = "signer_pending", subscribe, name = "signer_subscribePending")] + fn subscribe_pending(&self, Self::Metadata, Subscriber>); - /// Unsubscribe from pending requests subscription. - #[rpc(name = "signer_unsubscribePending")] - fn unsubscribe_pending(&self, SubscriptionId) -> Result; - } - } + /// Unsubscribe from pending requests subscription. + #[pubsub(subscription = "signer_pending", unsubscribe, name = "signer_unsubscribePending")] + fn unsubscribe_pending(&self, Option, SubscriptionId) -> Result; } diff --git a/rpc/src/v1/traits/traces.rs b/rpc/src/v1/traits/traces.rs index f6efae739..3ac4964bd 100644 --- a/rpc/src/v1/traits/traces.rs +++ b/rpc/src/v1/traits/traces.rs @@ -17,48 +17,48 @@ //! Traces specific rpc interface. use jsonrpc_core::Result; -use jsonrpc_macros::Trailing; +use jsonrpc_derive::rpc; use v1::types::{TraceFilter, LocalizedTrace, BlockNumber, Index, CallRequest, Bytes, TraceResults, TraceResultsWithTransactionHash, H256, TraceOptions}; -build_rpc_trait! { - /// Traces specific rpc interface. - pub trait Traces { - type Metadata; +/// Traces specific rpc interface. +#[rpc] +pub trait Traces { + /// RPC Metadata + type Metadata; - /// Returns traces matching given filter. - #[rpc(name = "trace_filter")] - fn filter(&self, TraceFilter) -> Result>>; + /// Returns traces matching given filter. + #[rpc(name = "trace_filter")] + fn filter(&self, TraceFilter) -> Result>>; - /// Returns transaction trace at given index. - #[rpc(name = "trace_get")] - fn trace(&self, H256, Vec) -> Result>; + /// Returns transaction trace at given index. + #[rpc(name = "trace_get")] + fn trace(&self, H256, Vec) -> Result>; - /// Returns all traces of given transaction. - #[rpc(name = "trace_transaction")] - fn transaction_traces(&self, H256) -> Result>>; + /// Returns all traces of given transaction. + #[rpc(name = "trace_transaction")] + fn transaction_traces(&self, H256) -> Result>>; - /// Returns all traces produced at given block. - #[rpc(name = "trace_block")] - fn block_traces(&self, BlockNumber) -> Result>>; + /// Returns all traces produced at given block. + #[rpc(name = "trace_block")] + fn block_traces(&self, BlockNumber) -> Result>>; - /// Executes the given call and returns a number of possible traces for it. - #[rpc(name = "trace_call")] - fn call(&self, CallRequest, TraceOptions, Trailing) -> Result; + /// Executes the given call and returns a number of possible traces for it. + #[rpc(name = "trace_call")] + fn call(&self, CallRequest, TraceOptions, Option) -> Result; - /// Executes all given calls and returns a number of possible traces for each of it. - #[rpc(name = "trace_callMany")] - fn call_many(&self, Vec<(CallRequest, TraceOptions)>, Trailing) -> Result>; + /// Executes all given calls and returns a number of possible traces for each of it. + #[rpc(name = "trace_callMany")] + fn call_many(&self, Vec<(CallRequest, TraceOptions)>, Option) -> Result>; - /// Executes the given raw transaction and returns a number of possible traces for it. - #[rpc(name = "trace_rawTransaction")] - fn raw_transaction(&self, Bytes, TraceOptions, Trailing) -> Result; + /// Executes the given raw transaction and returns a number of possible traces for it. + #[rpc(name = "trace_rawTransaction")] + fn raw_transaction(&self, Bytes, TraceOptions, Option) -> Result; - /// Executes the transaction with the given hash and returns a number of possible traces for it. - #[rpc(name = "trace_replayTransaction")] - fn replay_transaction(&self, H256, TraceOptions) -> Result; + /// Executes the transaction with the given hash and returns a number of possible traces for it. + #[rpc(name = "trace_replayTransaction")] + fn replay_transaction(&self, H256, TraceOptions) -> Result; - /// Executes all the transactions at the given block and returns a number of possible traces for each transaction. - #[rpc(name = "trace_replayBlockTransactions")] - fn replay_block_transactions(&self, BlockNumber, TraceOptions) -> Result>; - } + /// Executes all the transactions at the given block and returns a number of possible traces for each transaction. + #[rpc(name = "trace_replayBlockTransactions")] + fn replay_block_transactions(&self, BlockNumber, TraceOptions) -> Result>; } diff --git a/rpc/src/v1/traits/web3.rs b/rpc/src/v1/traits/web3.rs index e50c0963a..69d74756e 100644 --- a/rpc/src/v1/traits/web3.rs +++ b/rpc/src/v1/traits/web3.rs @@ -16,18 +16,18 @@ //! Web3 rpc interface. use jsonrpc_core::Result; +use jsonrpc_derive::rpc; use v1::types::{H256, Bytes}; -build_rpc_trait! { - /// Web3 rpc interface. - pub trait Web3 { - /// Returns current client version. - #[rpc(name = "web3_clientVersion")] - fn client_version(&self) -> Result; +/// Web3 rpc interface. +#[rpc] +pub trait Web3 { + /// Returns current client version. + #[rpc(name = "web3_clientVersion")] + fn client_version(&self) -> Result; - /// Returns sha3 of the given data - #[rpc(name = "web3_sha3")] - fn sha3(&self, Bytes) -> Result; - } + /// Returns sha3 of the given data + #[rpc(name = "web3_sha3")] + fn sha3(&self, Bytes) -> Result; } diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index fec601586..8bb59bb5d 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -25,6 +25,6 @@ slab = "0.3" smallvec = "0.6" tiny-keccak = "1.4" -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } +jsonrpc-core = "10.0.1" +jsonrpc-derive = "10.0.1" +jsonrpc-pubsub = "10.0.1" diff --git a/whisper/cli/Cargo.toml b/whisper/cli/Cargo.toml index 5147a6b56..4d123c09a 100644 --- a/whisper/cli/Cargo.toml +++ b/whisper/cli/Cargo.toml @@ -10,9 +10,9 @@ docopt = "1.0" env_logger = "0.5" ethcore-network = { path = "../../util/network" } ethcore-network-devp2p = { path = "../../util/network-devp2p" } -jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } -jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-2.2" } +jsonrpc-core = "10.0.1" +jsonrpc-http-server = "10.0.1" +jsonrpc-pubsub = "10.0.1" log = "0.4" panic_hook = { path = "../../util/panic-hook" } parity-whisper = { path = "../" } diff --git a/whisper/src/lib.rs b/whisper/src/lib.rs index 2db7108f7..0e79946d9 100644 --- a/whisper/src/lib.rs +++ b/whisper/src/lib.rs @@ -34,6 +34,7 @@ extern crate smallvec; extern crate tiny_keccak; extern crate jsonrpc_core; +extern crate jsonrpc_derive; extern crate jsonrpc_pubsub; #[macro_use] @@ -42,9 +43,6 @@ extern crate bitflags; #[macro_use] extern crate log; -#[macro_use] -extern crate jsonrpc_macros; - #[macro_use] extern crate serde_derive; diff --git a/whisper/src/rpc/filter.rs b/whisper/src/rpc/filter.rs index 9c091de0b..46cefd61e 100644 --- a/whisper/src/rpc/filter.rs +++ b/whisper/src/rpc/filter.rs @@ -21,7 +21,7 @@ use std::{sync::{Arc, atomic, atomic::AtomicBool, mpsc}, thread}; use ethereum_types::{H256, H512}; use ethkey::Public; -use jsonrpc_macros::pubsub::{Subscriber, Sink}; +use jsonrpc_pubsub::typed::{Subscriber, Sink}; use parking_lot::{Mutex, RwLock}; use rand::{Rng, OsRng}; diff --git a/whisper/src/rpc/mod.rs b/whisper/src/rpc/mod.rs index c3958f77f..03d98b51f 100644 --- a/whisper/src/rpc/mod.rs +++ b/whisper/src/rpc/mod.rs @@ -24,8 +24,8 @@ use std::sync::Arc; use jsonrpc_core::{Error, ErrorCode, Metadata}; -use jsonrpc_pubsub::{Session, PubSubMetadata, SubscriptionId}; -use jsonrpc_macros::pubsub; +use jsonrpc_derive::rpc; +use jsonrpc_pubsub::{Session, PubSubMetadata, SubscriptionId, typed::Subscriber}; use ethereum_types::H256; use memzero::Memzero; @@ -68,81 +68,78 @@ fn abridge_topic(topic: &[u8]) -> Topic { abridged.into() } -build_rpc_trait! { - /// Whisper RPC interface. - pub trait Whisper { - /// Info about the node. - #[rpc(name = "shh_info")] - fn info(&self) -> Result; +/// Whisper RPC interface. +#[rpc] +pub trait Whisper { + /// Info about the node. + #[rpc(name = "shh_info")] + fn info(&self) -> Result; - /// Generate a new asymmetric key pair and return an identity. - #[rpc(name = "shh_newKeyPair")] - fn new_key_pair(&self) -> Result; + /// Generate a new asymmetric key pair and return an identity. + #[rpc(name = "shh_newKeyPair")] + fn new_key_pair(&self) -> Result; - /// Import the given SECP2561k private key and return an identity. - #[rpc(name = "shh_addPrivateKey")] - fn add_private_key(&self, types::Private) -> Result; + /// Import the given SECP2561k private key and return an identity. + #[rpc(name = "shh_addPrivateKey")] + fn add_private_key(&self, types::Private) -> Result; - /// Generate a new symmetric key and return an identity. - #[rpc(name = "shh_newSymKey")] - fn new_sym_key(&self) -> Result; + /// Generate a new symmetric key and return an identity. + #[rpc(name = "shh_newSymKey")] + fn new_sym_key(&self) -> Result; - /// Import the given symmetric key and return an identity. - #[rpc(name = "shh_addSymKey")] - fn add_sym_key(&self, types::Symmetric) -> Result; + /// Import the given symmetric key and return an identity. + #[rpc(name = "shh_addSymKey")] + fn add_sym_key(&self, types::Symmetric) -> Result; - /// Get public key. Succeeds if identity is stored and asymmetric. - #[rpc(name = "shh_getPublicKey")] - fn get_public(&self, types::Identity) -> Result; + /// Get public key. Succeeds if identity is stored and asymmetric. + #[rpc(name = "shh_getPublicKey")] + fn get_public(&self, types::Identity) -> Result; - /// Get private key. Succeeds if identity is stored and asymmetric. - #[rpc(name = "shh_getPrivateKey")] - fn get_private(&self, types::Identity) -> Result; + /// Get private key. Succeeds if identity is stored and asymmetric. + #[rpc(name = "shh_getPrivateKey")] + fn get_private(&self, types::Identity) -> Result; - #[rpc(name = "shh_getSymKey")] - fn get_symmetric(&self, types::Identity) -> Result; + #[rpc(name = "shh_getSymKey")] + fn get_symmetric(&self, types::Identity) -> Result; - /// Delete key pair denoted by given identity. - /// - /// Return true if successfully removed, false if unknown, - /// and error otherwise. - #[rpc(name = "shh_deleteKey")] - fn remove_key(&self, types::Identity) -> Result; + /// Delete key pair denoted by given identity. + /// + /// Return true if successfully removed, false if unknown, + /// and error otherwise. + #[rpc(name = "shh_deleteKey")] + fn remove_key(&self, types::Identity) -> Result; - /// Post a message to the network with given parameters. - #[rpc(name = "shh_post")] - fn post(&self, types::PostRequest) -> Result; + /// Post a message to the network with given parameters. + #[rpc(name = "shh_post")] + fn post(&self, types::PostRequest) -> Result; - /// Create a new polled filter. - #[rpc(name = "shh_newMessageFilter")] - fn new_filter(&self, types::FilterRequest) -> Result; + /// Create a new polled filter. + #[rpc(name = "shh_newMessageFilter")] + fn new_filter(&self, types::FilterRequest) -> Result; - /// Poll changes on a polled filter. - #[rpc(name = "shh_getFilterMessages")] - fn poll_changes(&self, types::Identity) -> Result, Error>; + /// Poll changes on a polled filter. + #[rpc(name = "shh_getFilterMessages")] + fn poll_changes(&self, types::Identity) -> Result, Error>; - /// Delete polled filter. Return bool indicating success. - #[rpc(name = "shh_deleteMessageFilter")] - fn delete_filter(&self, types::Identity) -> Result; - } + /// Delete polled filter. Return bool indicating success. + #[rpc(name = "shh_deleteMessageFilter")] + fn delete_filter(&self, types::Identity) -> Result; } -build_rpc_trait! { - /// Whisper RPC pubsub. - pub trait WhisperPubSub { - type Metadata; +/// Whisper RPC pubsub. +#[rpc] +pub trait WhisperPubSub { + // RPC Metadata + type Metadata; - #[pubsub(name = "shh_subscription")] { - /// Subscribe to messages matching the filter. - #[rpc(name = "shh_subscribe")] - fn subscribe(&self, Self::Metadata, pubsub::Subscriber, types::FilterRequest); + /// Subscribe to messages matching the filter. + #[pubsub(subscription = "shh_subscription", subscribe, name = "shh_subscribe")] + fn subscribe(&self, Self::Metadata, Subscriber, types::FilterRequest); - /// Unsubscribe from filter matching given ID. Return - /// true on success, error otherwise. - #[rpc(name = "shh_unsubscribe")] - fn unsubscribe(&self, SubscriptionId) -> Result; - } - } + /// Unsubscribe from filter matching given ID. Return + /// true on success, error otherwise. + #[pubsub(subscription = "shh_subscription", unsubscribe, name = "shh_unsubscribe")] + fn unsubscribe(&self, Option, SubscriptionId) -> Result; } /// Something which can send messages to the network. @@ -364,7 +361,7 @@ impl WhisperPubSub for fn subscribe( &self, _meta: Self::Metadata, - subscriber: pubsub::Subscriber, + subscriber: Subscriber, req: types::FilterRequest, ) { match Filter::new(req) { @@ -377,7 +374,7 @@ impl WhisperPubSub for } } - fn unsubscribe(&self, id: SubscriptionId) -> Result { + fn unsubscribe(&self, _: Option, id: SubscriptionId) -> Result { use std::str::FromStr; let res = match id {