mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-01 04:31:02 +00:00
add accountkey20 conversion impls (#2576)
This commit is contained in:
@@ -124,3 +124,27 @@ impl<
|
||||
Ok(Junction::AccountId32 { id: who.into(), network: Network::get() }.into())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AccountKey20Aliases<Network, AccountId>(PhantomData<(Network, AccountId)>);
|
||||
|
||||
impl<
|
||||
Network: Get<NetworkId>,
|
||||
AccountId: From<[u8; 20]> + Into<[u8; 20]>
|
||||
> LocationConversion<AccountId> for AccountKey20Aliases<Network, AccountId> {
|
||||
fn from_location(location: &MultiLocation) -> Option<AccountId> {
|
||||
if let MultiLocation::X1(Junction::AccountKey20 { key, network }) = location {
|
||||
if matches!(network, NetworkId::Any) || network == &Network::get() {
|
||||
return Some((*key).into());
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn try_into_location(who: AccountId) -> Result<MultiLocation, AccountId> {
|
||||
Ok(Junction::AccountKey20 {
|
||||
key: who.into(),
|
||||
network: Network::get(),
|
||||
}
|
||||
.into())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user