Skip to content

Commit a9ee98d

Browse files
committed
Fix #215
1 parent f1c8fd4 commit a9ee98d

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

adapter/src/lib.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ impl TryFrom<&Channel> for EthereumChannel {
8888
.spec
8989
.validators
9090
.into_iter()
91-
.map(|v| v.id.to_string())
92-
.collect();
91+
.map(|v| &v.id)
92+
.collect::<Vec<_>>();
9393

9494
EthereumChannel::new(
9595
&channel.creator,
9696
&channel.deposit_asset,
9797
&channel.deposit_amount.to_string(),
9898
channel.valid_until,
99-
validators,
99+
&validators,
100100
&spec_hash,
101101
)
102102
}
@@ -108,10 +108,10 @@ impl EthereumChannel {
108108
token_addr: &str,
109109
token_amount: &str,
110110
valid_until: DateTime<Utc>,
111-
validators: Vec<String>,
111+
validators: &[&ValidatorId],
112112
spec: &str,
113113
) -> Result<Self, ChannelError> {
114-
// check creator addres
114+
// check creator address
115115
if creator != eth_checksum::checksum(creator) {
116116
return Err(ChannelError::InvalidArgument(
117117
"Invalid creator address".into(),
@@ -120,7 +120,7 @@ impl EthereumChannel {
120120

121121
if token_addr != eth_checksum::checksum(token_addr) {
122122
return Err(ChannelError::InvalidArgument(
123-
"invalid token addresss".into(),
123+
"invalid token address".into(),
124124
));
125125
}
126126

@@ -134,18 +134,19 @@ impl EthereumChannel {
134134
));
135135
}
136136

137-
if validators.iter().any(|v| *v != eth_checksum::checksum(v)) {
138-
return Err(ChannelError::InvalidArgument(
139-
"invalid validator address: must start with a 0x and be 42 characters long".into(),
140-
));
141-
}
142-
143137
Ok(Self {
144138
creator: creator.to_owned(),
145139
token_addr: token_addr.to_owned(),
146140
token_amount: token_amount.to_owned(),
147141
valid_until: valid_until.timestamp_millis(),
148-
validators: format!("[{}]", validators.join(",")),
142+
validators: format!(
143+
"[{}]",
144+
validators
145+
.iter()
146+
.map(|v_id| v_id.to_hex_checksummed_string())
147+
.collect::<Vec<_>>()
148+
.join(",")
149+
),
149150
spec: spec.to_owned(),
150151
})
151152
}

0 commit comments

Comments
 (0)