Skip to content

Commit 2373c5d

Browse files
committed
from AccountId20 to Location
1 parent 5f13853 commit 2373c5d

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Cargo.lock

Lines changed: 3 additions & 2 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ use sp_io::hashing::keccak_256;
3131
use sp_runtime::MultiSignature;
3232
use sp_runtime_interface::pass_by::PassByInner;
3333

34+
use xcm::latest::{Junction, Location};
35+
3436
/// A fully Ethereum-compatible `AccountId`.
3537
/// Conforms to H160 address and ECDSA key standards.
3638
/// Alternative to H256->H160 mapping.
@@ -171,6 +173,16 @@ impl From<AccountId32> for AccountId20 {
171173
}
172174
}
173175

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

0 commit comments

Comments
 (0)