File tree Expand file tree Collapse file tree 2 files changed +3
-6
lines changed Expand file tree Collapse file tree 2 files changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,8 @@ pub enum Error {
43
43
HexError ( #[ from] FromHexError ) ,
44
44
#[ error( "unsupported operation: {0}" ) ]
45
45
UnsupportedOperation ( String ) ,
46
- #[ error( "failed to convert vector to array" ) ]
47
- PrivateKeyConversionError ,
46
+ #[ error( "failed to convert vector {0:?} to array" ) ]
47
+ VectorToArrayConversionError ( Vec < u8 > ) ,
48
48
#[ error( "alias must be {min_length:?} to {max_length:?} length of {alphabet:?} and may have a prefix \" {max_length:?}{chain_id:?}:\" " ) ]
49
49
InvalidAliasName {
50
50
min_length : u8 ,
Original file line number Diff line number Diff line change @@ -17,10 +17,7 @@ impl std::str::FromStr for PrivateKey {
17
17
18
18
fn from_str ( base58string : & str ) -> Result < PrivateKey > {
19
19
let bytes = Base58 :: decode ( base58string) ?;
20
- let bytes_array: [ u8 ; 32 ] = match bytes. try_into ( ) {
21
- Ok ( v) => v,
22
- Err ( _) => return Err ( Error :: PrivateKeyConversionError ) ,
23
- } ;
20
+ let bytes_array: [ u8 ; 32 ] = bytes. try_into ( ) . map_err ( |e| Error :: VectorToArrayConversionError ( e) ) ?;
24
21
PrivateKey :: from_bytes ( bytes_array)
25
22
}
26
23
}
You can’t perform that action at this time.
0 commit comments