Skip to content

Commit

Permalink
Feature/withdraw rpc (paritytech#270)
Browse files Browse the repository at this point in the history
* FIx extracter panic

* Change rpc 'chainx_getAddressByAccount'

* Add chainx_getDepositList

* Add withdraw_list

* Update wasm

* Update btc header info

* Flow substrate-rpc

* Fix build error

* Add 'state_getKeys' rpc

* Delete old bind

* Add withdrawal id in result
Fix rebind bug

* Refine a bit

* Fix sign error

* Update wasm
Modify test
  • Loading branch information
eee-byte authored and liuchengxu committed Feb 15, 2019
1 parent 1b3aa62 commit 286c401
Show file tree
Hide file tree
Showing 26 changed files with 923 additions and 648 deletions.
68 changes: 34 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
extern crate vergen;

use vergen::{ConstantsFlags, generate_cargo_keys};
use vergen::{generate_cargo_keys, ConstantsFlags};

const ERROR_MSG: &'static str = "Failed to generate metadata files";

fn main() {
generate_cargo_keys(ConstantsFlags::all()).expect(ERROR_MSG);
println!("cargo:rerun-if-changed=.git/HEAD");
generate_cargo_keys(ConstantsFlags::all()).expect(ERROR_MSG);
println!("cargo:rerun-if-changed=.git/HEAD");
}
12 changes: 6 additions & 6 deletions cli/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
// start genesis block: (genesis, blocknumber)
genesis: (BlockHeader {
version: 536870912,
previous_header_hash: H256::from_reversed_str("00000000f1c80c38f9bd6ebf9ca796d92122e5b2a1539ac06e09252a1a7e3d01"),
merkle_root_hash: H256::from_reversed_str("815ca8bbed88af8afaa6c4995acba6e6e7453e705e0bc7039472aa3b6191a707"),
time: 1546999089,
bits: Compact::new(436290411),
nonce: 562223693,
}, 1451572),
previous_header_hash: H256::from_reversed_str("000000000009a5e5b8b7154bcac5f28f43e22bc3b61883ce65c8caf09f9fa03b"),
merkle_root_hash: H256::from_reversed_str("89323c349e2ec768dcb5b0740eb221103a4490a00e1d137e5c9a4082521bff5e"),
time: 1549942457,
bits: Compact::new(436283074),
nonce: 2885019376,
}, 1456835),
params_info: Params::new(520159231, // max_bits
2 * 60 * 60, // block_max_future
3, // max_fork_route_preset
Expand Down
6 changes: 3 additions & 3 deletions rpc-servers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]

[dependencies]
jsonrpc-http-server = { git = "https://github.com/paritytech/jsonrpc.git" }
jsonrpc-pubsub = { git = "https://github.com/paritytech/jsonrpc.git" }
jsonrpc-ws-server = { git = "https://github.com/paritytech/jsonrpc.git" }
jsonrpc-http-server = "10.0.1"
jsonrpc-pubsub = "10.0.1"
jsonrpc-ws-server = "10.0.1"
log = "0.4"
serde = "1.0"
substrate-rpc = { path = "../rpc", version = "0.1" }
Expand Down
6 changes: 3 additions & 3 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ authors = ["Parity Technologies <[email protected]>"]

[dependencies]
error-chain = "0.12"
jsonrpc-core = { git="https://github.com/paritytech/jsonrpc.git" }
jsonrpc-macros = { git="https://github.com/paritytech/jsonrpc.git" }
jsonrpc-pubsub = { git="https://github.com/paritytech/jsonrpc.git" }
jsonrpc-core = "10.0.1"
jsonrpc-pubsub = "10.0.1"
jsonrpc-derive = "10.0.1"
log = "0.4"
parking_lot = "0.4"
parity-codec = "3.0"
Expand Down
58 changes: 31 additions & 27 deletions rpc/src/author/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use std::sync::Arc;

use client::{self, Client};
use codec::{Decode, Encode};
use jsonrpc_macros::pubsub;
use jsonrpc_pubsub::SubscriptionId;
use jsonrpc_derive::rpc;
use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId};
use primitives::{Blake2Hasher, Bytes, H256};
use rpc::futures::{Future, Sink, Stream};
use runtime_primitives::{generic, traits};
Expand All @@ -37,30 +37,34 @@ mod tests;

use self::error::Result;

build_rpc_trait! {
/// Substrate authoring RPC API
pub trait AuthorApi<Hash, BlockHash> {
type Metadata;

/// Submit hex-encoded extrinsic for inclusion in block.
#[rpc(name = "author_submitExtrinsic")]
fn submit_extrinsic(&self, Bytes) -> Result<Hash>;

/// Returns all pending extrinsics, potentially grouped by sender.
#[rpc(name = "author_pendingExtrinsics")]
fn pending_extrinsics(&self) -> Result<Vec<Bytes>>;

#[pubsub(name = "author_extrinsicUpdate")] {
/// Submit an extrinsic to watch.
#[rpc(name = "author_submitAndWatchExtrinsic")]
fn watch_extrinsic(&self, Self::Metadata, pubsub::Subscriber<Status<Hash, BlockHash>>, Bytes);

/// Unsubscribe from extrinsic watching.
#[rpc(name = "author_unwatchExtrinsic")]
fn unwatch_extrinsic(&self, Option<Self::Metadata>, SubscriptionId) -> Result<bool>;
}

}
/// Substrate authoring RPC API
#[rpc]
pub trait AuthorApi<Hash, BlockHash> {
type Metadata;

/// Submit hex-encoded extrinsic for inclusion in block.
#[rpc(name = "author_submitExtrinsic")]
fn submit_extrinsic(&self, Bytes) -> Result<Hash>;

/// Returns all pending extrinsics, potentially grouped by sender.
#[rpc(name = "author_pendingExtrinsics")]
fn pending_extrinsics(&self) -> Result<Vec<Bytes>>;

/// Submit an extrinsic to watch.
#[pubsub(
subscription = "author_extrinsicUpdate",
subscribe,
name = "author_submitAndWatchExtrinsic"
)]
fn watch_extrinsic(&self, Self::Metadata, Subscriber<Status<Hash, BlockHash>>, Bytes);

/// Unsubscribe from extrinsic watching.
#[pubsub(
subscription = "author_extrinsicUpdate",
unsubscribe,
name = "author_unwatchExtrinsic"
)]
fn unwatch_extrinsic(&self, Option<Self::Metadata>, SubscriptionId) -> Result<bool>;
}

/// Authoring API
Expand Down Expand Up @@ -129,7 +133,7 @@ where
fn watch_extrinsic(
&self,
_metadata: Self::Metadata,
subscriber: pubsub::Subscriber<Status<ExHash<P>, BlockHash<P>>>,
subscriber: Subscriber<Status<ExHash<P>, BlockHash<P>>>,
xt: Bytes,
) {
let submit = || -> Result<_> {
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/author/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn should_watch_extrinsic() {
pool: pool.clone(),
subscriptions: Subscriptions::new(runtime.executor()),
};
let (subscriber, id_rx, data) = ::jsonrpc_macros::pubsub::Subscriber::new_test("test");
let (subscriber, id_rx, data) = ::jsonrpc_pubsub::typed::Subscriber::new_test("test");

// when
p.watch_extrinsic(
Expand Down
Loading

0 comments on commit 286c401

Please sign in to comment.