@@ -88,15 +88,15 @@ impl TryFrom<&Channel> for EthereumChannel {
88
88
. spec
89
89
. validators
90
90
. into_iter ( )
91
- . map ( |v| v. id . to_string ( ) )
92
- . collect ( ) ;
91
+ . map ( |v| & v. id )
92
+ . collect :: < Vec < _ > > ( ) ;
93
93
94
94
EthereumChannel :: new (
95
95
& channel. creator ,
96
96
& channel. deposit_asset ,
97
97
& channel. deposit_amount . to_string ( ) ,
98
98
channel. valid_until ,
99
- validators,
99
+ & validators,
100
100
& spec_hash,
101
101
)
102
102
}
@@ -108,10 +108,10 @@ impl EthereumChannel {
108
108
token_addr : & str ,
109
109
token_amount : & str ,
110
110
valid_until : DateTime < Utc > ,
111
- validators : Vec < String > ,
111
+ validators : & [ & ValidatorId ] ,
112
112
spec : & str ,
113
113
) -> Result < Self , ChannelError > {
114
- // check creator addres
114
+ // check creator address
115
115
if creator != eth_checksum:: checksum ( creator) {
116
116
return Err ( ChannelError :: InvalidArgument (
117
117
"Invalid creator address" . into ( ) ,
@@ -120,7 +120,7 @@ impl EthereumChannel {
120
120
121
121
if token_addr != eth_checksum:: checksum ( token_addr) {
122
122
return Err ( ChannelError :: InvalidArgument (
123
- "invalid token addresss " . into ( ) ,
123
+ "invalid token address " . into ( ) ,
124
124
) ) ;
125
125
}
126
126
@@ -134,18 +134,19 @@ impl EthereumChannel {
134
134
) ) ;
135
135
}
136
136
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
-
143
137
Ok ( Self {
144
138
creator : creator. to_owned ( ) ,
145
139
token_addr : token_addr. to_owned ( ) ,
146
140
token_amount : token_amount. to_owned ( ) ,
147
141
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
+ ) ,
149
150
spec : spec. to_owned ( ) ,
150
151
} )
151
152
}
0 commit comments