Skip to content

Commit 6c1a330

Browse files
committed
fix: ethereum adapter, remove mut
1 parent bd5404e commit 6c1a330

File tree

11 files changed

+147
-146
lines changed

11 files changed

+147
-146
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adapter/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ethkey = { git = "https://github.com/paritytech/parity.git" }
2525
ethstore = { git = "https://github.com/paritytech/parity.git" }
2626
sha2 = "0.8.0"
2727
base64 = "0.10.1"
28-
28+
lazy_static = "1.4.0"
2929

3030
[dev-dependencies]
3131
byteorder = "1.3"

adapter/src/dummy.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#![deny(clippy::all)]
2-
#![deny(rust_2018_idioms)]
3-
41
use primitives::adapter::{Adapter, AdapterError, AdapterOptions, AdapterResult, Session};
52
use primitives::channel_validator::ChannelValidator;
63
use primitives::config::Config;
@@ -23,9 +20,17 @@ impl Adapter for DummyAdapter {
2320
type Output = DummyAdapter;
2421

2522
fn init(opts: AdapterOptions, config: &Config) -> AdapterResult<DummyAdapter> {
26-
let identity = opts.dummy_identity.expect("dummyIdentity required");
27-
let tokens_for_auth = opts.dummy_auth.expect("dummy auth required");
28-
let tokens_verified = opts.dummy_auth_tokens.expect("dummy auth tokens required");
23+
let (identity, tokens_for_auth, tokens_verified) =
24+
match (opts.dummy_identity, opts.dummy_auth, opts.dummy_auth_tokens) {
25+
(Some(identity), Some(tokens_for_auth), Some(tokens_verified)) => {
26+
(identity, tokens_for_auth, tokens_verified)
27+
}
28+
(_, _, _) => {
29+
return Err(AdapterError::Configuration(
30+
"dummy_identity, dummy_auth, dummy_auth_tokens required".to_string(),
31+
))
32+
}
33+
};
2934

3035
Ok(Self {
3136
identity,
@@ -66,7 +71,7 @@ impl Adapter for DummyAdapter {
6671
fn validate_channel(&self, channel: &Channel) -> AdapterResult<bool> {
6772
match DummyAdapter::is_channel_valid(&self.config, channel) {
6873
Ok(_) => Ok(true),
69-
Err(e) => Err(AdapterError::InvalidChannel(format!("{}", e))),
74+
Err(e) => Err(AdapterError::InvalidChannel(e.to_string())),
7075
}
7176
}
7277

0 commit comments

Comments
 (0)