Trait pallet_revive::AddressMapper
source · pub trait AddressMapper<T>: Sealed {
// Required methods
fn to_address(account_id: &T) -> H160;
fn to_account_id(address: &H160) -> T;
fn to_account_id_contract(address: &H160) -> T;
}
Expand description
Map between the native chain account id T
and an Ethereum H160
.
This trait exists only to emulate specialization for different concrete
native account ids. Not to make the mapping user configurable. Hence
the trait is Sealed
and only one mandatory implementor DefaultAddressMapper
exists.
Please note that we assume that the native account is at least 20 bytes and
only implement this type for a T
where this is the case. Luckily, this is the
case for all existing runtimes as of right now. Reasing is that this will allow
us to reverse an address -> account_id mapping by just stripping the prefix.
Required Methods§
sourcefn to_address(account_id: &T) -> H160
fn to_address(account_id: &T) -> H160
Convert an account id to an ethereum address.
This mapping is not required to be reversible.
sourcefn to_account_id(address: &H160) -> T
fn to_account_id(address: &H160) -> T
Convert an ethereum address to a native account id.
This mapping is required to be reversible.
sourcefn to_account_id_contract(address: &H160) -> T
fn to_account_id_contract(address: &H160) -> T
Same as Self::to_account_id
but when we know the address is a contract.
This is only the case when we just generated the new address.