Skip to content

Commit 42b4490

Browse files
authored
impl From<AccountId20> for Location (#1472)
* from AccountId20 to Location * suggestion
1 parent d200959 commit 42b4490

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

primitives/account/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ sp-io = { workspace = true }
2222
sp-runtime = { workspace = true }
2323
sp-runtime-interface = { workspace = true }
2424

25+
# Polkadot / XCM
26+
xcm = { workspace = true }
27+
2528
[dev-dependencies]
2629

2730
[features]
@@ -39,6 +42,7 @@ std = [
3942
"sp-io/std",
4043
"sp-runtime/std",
4144
"sp-runtime-interface/std",
45+
"xcm/std",
4246
]
4347
serde = [
4448
"dep:serde",

primitives/account/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ use sp_io::hashing::keccak_256;
3131
use sp_runtime::MultiSignature;
3232
use sp_runtime_interface::pass_by::PassByInner;
3333

34+
// Polkadot / XCM
35+
use xcm::latest::{Junction, Location};
36+
3437
/// A fully Ethereum-compatible `AccountId`.
3538
/// Conforms to H160 address and ECDSA key standards.
3639
/// Alternative to H256->H160 mapping.
@@ -171,6 +174,16 @@ impl From<AccountId32> for AccountId20 {
171174
}
172175
}
173176

177+
impl From<AccountId20> for Location {
178+
fn from(id: AccountId20) -> Self {
179+
Junction::AccountKey20 {
180+
network: None,
181+
key: id.into(),
182+
}
183+
.into()
184+
}
185+
}
186+
174187
#[derive(Clone, Eq, PartialEq)]
175188
#[derive(RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)]
176189
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]

0 commit comments

Comments
 (0)