@@ -6,9 +6,9 @@ use fvm_shared::address::Address as FilecoinAddress;
6
6
///
7
7
/// TODO this type will eventually handle f4 address detection.
8
8
#[ derive( PartialEq , Eq , Clone ) ]
9
- pub struct Address ( [ u8 ; 20 ] ) ;
9
+ pub struct EthAddress ( [ u8 ; 20 ] ) ;
10
10
11
- impl TryFrom < U256 > for Address {
11
+ impl TryFrom < U256 > for EthAddress {
12
12
type Error = StatusCode ;
13
13
14
14
fn try_from ( v : U256 ) -> Result < Self , Self :: Error > {
@@ -24,24 +24,24 @@ impl TryFrom<U256> for Address {
24
24
}
25
25
}
26
26
27
- impl std:: fmt:: Debug for Address {
27
+ impl std:: fmt:: Debug for EthAddress {
28
28
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
29
29
f. write_str ( & hex:: encode ( self . 0 ) )
30
30
}
31
31
}
32
32
33
- impl Address {
33
+ impl EthAddress {
34
34
/// Expect a Filecoin address type containing an ID address, and return an address in EVM-form.
35
- pub fn from_id_address ( addr : & FilecoinAddress ) -> Option < Address > {
36
- addr. id ( ) . ok ( ) . map ( Address :: from_id)
35
+ pub fn from_id_address ( addr : & FilecoinAddress ) -> Option < EthAddress > {
36
+ addr. id ( ) . ok ( ) . map ( EthAddress :: from_id)
37
37
}
38
38
39
39
/// Returns an EVM-form ID address from actor ID.
40
- pub fn from_id ( id : u64 ) -> Address {
40
+ pub fn from_id ( id : u64 ) -> EthAddress {
41
41
let mut bytes = [ 0u8 ; 20 ] ;
42
42
bytes[ 0 ] = 0xff ;
43
43
bytes[ 12 ..] . copy_from_slice ( & id. to_be_bytes ( ) ) ;
44
- Address ( bytes)
44
+ EthAddress ( bytes)
45
45
}
46
46
47
47
/// Interpret the hash as an ID address in EVM-form, and return a Filecoin ID address if that's
@@ -67,7 +67,7 @@ impl Address {
67
67
68
68
#[ cfg( test) ]
69
69
mod tests {
70
- use crate :: interpreter:: address:: Address ;
70
+ use crate :: interpreter:: address:: EthAddress ;
71
71
use crate :: U256 ;
72
72
use fvm_shared:: address:: Address as FilecoinAddress ;
73
73
@@ -82,15 +82,15 @@ mod tests {
82
82
#[ test]
83
83
fn $name( ) {
84
84
let evm_bytes = $input. concat( ) ;
85
- let evm_addr = Address :: try_from( U256 :: from( evm_bytes. as_slice( ) ) ) . unwrap( ) ;
85
+ let evm_addr = EthAddress :: try_from( U256 :: from( evm_bytes. as_slice( ) ) ) . unwrap( ) ;
86
86
assert_eq!(
87
87
evm_addr. as_id_address( ) ,
88
88
$expectation
89
89
) ;
90
90
91
91
// test inverse conversion, if a valid ID address was supplied
92
92
if let Some ( fil_addr) = $expectation {
93
- assert_eq!( Address :: from_id_address( & fil_addr) , Some ( evm_addr) ) ;
93
+ assert_eq!( EthAddress :: from_id_address( & fil_addr) , Some ( evm_addr) ) ;
94
94
}
95
95
}
96
96
) *
0 commit comments