Skip to content

Commit 1506648

Browse files
committed
Merge branch 'dev' into runtime-issues-221-220-218
2 parents 2db1c05 + 53a1e52 commit 1506648

27 files changed

+1844
-990
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ target
44
*.iml
55
.idea
66
.old
7-
Migrant.toml
7+
Migrant.toml
8+
node_modules/

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: rust
22
rust:
33
- stable
4+
# add nodejs for ganche-cli
5+
node_js: "12.12.0"
46
# Need to cache the whole `.cargo` directory to keep .crates.toml for
57
# cargo-update to work
68
cache:

Cargo.lock

Lines changed: 668 additions & 700 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adapter/Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ edition = "2018"
66

77
[dependencies]
88
primitives = {path = "../primitives"}
9-
# Futures
10-
futures-preview = {version = "=0.3.0-alpha.19"}
119
# Time handling
1210
chrono = "0.4"
1311
# To/From Hex
@@ -16,16 +14,19 @@ serde = {version = "^1.0", features = ['derive']}
1614
serde_json = "1.0"
1715
serde-hex = "0.1.0"
1816
# Ethereum
19-
web3 = { git = "https://github.com/tomusdrw/rust-web3" }
17+
web3 = { git = "https://github.com/samparsky/rust-web3" }
2018
eth_checksum = "0.1.1"
21-
ethabi = "8.0.1"
19+
ethabi = { git = "https://github.com/samparsky/ethabi", branch = "graph-patches" }
2220
tiny-keccak = "1.5"
23-
parity-crypto = { version = "0.4.2", features = ["publickey"], git = "https://github.com/paritytech/parity-common" }
21+
parity-crypto = { version = "0.4.2", features = ["publickey"] }
2422
ethstore = { version = "0.2.1", git = "https://github.com/paritytech/parity-ethereum"}
2523
ethkey = { version = "0.4.0", git = "https://github.com/paritytech/parity-ethereum"}
2624
sha2 = "0.8.0"
2725
base64 = "0.10.1"
2826
lazy_static = "1.4.0"
27+
# Futures
28+
futures = { version = "0.3.1", features = ["compat"] }
2929

3030
[dev-dependencies]
31-
byteorder = "1.3"
31+
byteorder = "1.3"
32+
tokio = { version = "0.2", features = ["macros", "rt-core"] }

adapter/Makefile.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[tasks.pre-test]
2+
script = [
3+
"npm install",
4+
"../scripts/ethereum.sh"
5+
]

adapter/src/dummy.rs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use futures::future::BoxFuture;
12
use primitives::adapter::{Adapter, AdapterError, AdapterResult, DummyAdapterOptions, Session};
23
use primitives::channel_validator::ChannelValidator;
34
use primitives::config::Config;
@@ -63,29 +64,33 @@ impl Adapter for DummyAdapter {
6364
Ok(is_same)
6465
}
6566

66-
fn validate_channel(&self, channel: &Channel) -> AdapterResult<bool> {
67-
match DummyAdapter::is_channel_valid(&self.config, self.whoami(), channel) {
68-
Ok(_) => Ok(true),
69-
Err(e) => Err(AdapterError::InvalidChannel(e.to_string())),
70-
}
67+
fn validate_channel<'a>(&'a self, channel: &'a Channel) -> BoxFuture<'a, AdapterResult<bool>> {
68+
Box::pin(async move {
69+
match DummyAdapter::is_channel_valid(&self.config, self.whoami(), channel) {
70+
Ok(_) => Ok(true),
71+
Err(e) => Err(AdapterError::InvalidChannel(e.to_string())),
72+
}
73+
})
7174
}
7275

73-
fn session_from_token(&self, token: &str) -> AdapterResult<Session> {
74-
let identity = self
75-
.authorization_tokens
76-
.iter()
77-
.find(|(_, id)| *id == token);
76+
fn session_from_token<'a>(&'a self, token: &'a str) -> BoxFuture<'a, AdapterResult<Session>> {
77+
Box::pin(async move {
78+
let identity = self
79+
.authorization_tokens
80+
.iter()
81+
.find(|(_, id)| *id == token);
7882

79-
match identity {
80-
Some((id, _)) => Ok(Session {
81-
uid: self.session_tokens[id].clone(),
82-
era: 0,
83-
}),
84-
None => Err(AdapterError::Authentication(format!(
85-
"no session token for this auth: {}",
86-
token
87-
))),
88-
}
83+
match identity {
84+
Some((id, _)) => Ok(Session {
85+
uid: self.session_tokens[id].clone(),
86+
era: 0,
87+
}),
88+
None => Err(AdapterError::Authentication(format!(
89+
"no session token for this auth: {}",
90+
token
91+
))),
92+
}
93+
})
8994
}
9095

9196
fn get_auth(&self, _validator: &ValidatorId) -> AdapterResult<String> {

0 commit comments

Comments
 (0)