@@ -90,7 +90,7 @@ impl Adapter for EthereumAdapter {
9090 ) )
9191 }
9292 } ;
93- println ! ( "{:?}" , json_file ) ;
93+
9494 let key_file: KeyFile = match serde_json:: from_reader ( json_file) {
9595 Ok ( data) => data,
9696 Err ( e) => return Err ( AdapterError :: Configuration ( format ! ( "{}" , e) ) ) ,
@@ -189,7 +189,13 @@ impl Adapter for EthereumAdapter {
189189 ) ) ;
190190 }
191191
192- // @TODO checksum ethereum address
192+ let validators: Vec < & str > = channel. spec . validators . into_iter ( ) . map ( |v| & v. id [ ..] ) . collect ( ) ;
193+ let invalid_address_checkum = check_address_checksum ( & validators) ;
194+ if invalid_address_checkum {
195+ return Err ( AdapterError :: Configuration (
196+ "channel.validators: all addresses are checksummed" . to_string ( )
197+ ) )
198+ }
193199 // check if channel is valid
194200 let is_channel_valid = EthereumAdapter :: is_channel_valid ( & self . config , channel) ;
195201 if is_channel_valid. is_err ( ) {
@@ -293,6 +299,19 @@ impl Adapter for EthereumAdapter {
293299 }
294300}
295301
302+ fn check_address_checksum ( addresses : & [ & str ] ) -> bool {
303+ let mut invalid_address_checkum = false ;
304+
305+ for address in addresses {
306+ if eth_checksum:: checksum ( address) != * address {
307+ invalid_address_checkum = true ;
308+ break ;
309+ }
310+ }
311+
312+ invalid_address_checkum
313+ }
314+
296315fn hash_message ( message : & str ) -> [ u8 ; 32 ] {
297316 let eth = "\x19 Ethereum Signed Message:\n " ;
298317 let message_length = message. len ( ) ;
0 commit comments