Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions polkadot/xcm/src/v3/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,16 @@ impl TryFrom<OldNetworkId> for NetworkId {

impl From<NewNetworkId> for Option<NetworkId> {
fn from(new: NewNetworkId) -> Self {
Some(NetworkId::from(new))
NetworkId::try_from(new).ok()
}
}

impl From<NewNetworkId> for NetworkId {
fn from(new: NewNetworkId) -> Self {
impl TryFrom<NewNetworkId> for NetworkId {
type Error = ();

fn try_from(new: NewNetworkId) -> Result<Self, Self::Error> {
use NewNetworkId::*;
match new {
Ok(match new {
ByGenesis(hash) => Self::ByGenesis(hash),
ByFork { block_number, block_hash } => Self::ByFork { block_number, block_hash },
Polkadot => Self::Polkadot,
Expand All @@ -126,7 +128,8 @@ impl From<NewNetworkId> for NetworkId {
BitcoinCore => Self::BitcoinCore,
BitcoinCash => Self::BitcoinCash,
PolkadotBulletin => Self::PolkadotBulletin,
}
Paseo => return Err(()),
Copy link
Copy Markdown
Contributor

@hbulgarini hbulgarini Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@franciscoaguirre i'm struggling to understand the logic here: Why Paseo would return an error?

This means that Paseo NetworkId would not be supported for XCM v3?

})
}
}

Expand Down Expand Up @@ -447,18 +450,24 @@ impl TryFrom<NewJunction> for Junction {
use NewJunction::*;
Ok(match value {
Parachain(id) => Self::Parachain(id),
AccountId32 { network: maybe_network, id } =>
Self::AccountId32 { network: maybe_network.map(|network| network.into()), id },
AccountIndex64 { network: maybe_network, index } =>
Self::AccountIndex64 { network: maybe_network.map(|network| network.into()), index },
AccountKey20 { network: maybe_network, key } =>
Self::AccountKey20 { network: maybe_network.map(|network| network.into()), key },
AccountId32 { network: maybe_network, id } => Self::AccountId32 {
network: maybe_network.map(|network| network.try_into()).transpose()?,
id,
},
AccountIndex64 { network: maybe_network, index } => Self::AccountIndex64 {
network: maybe_network.map(|network| network.try_into()).transpose()?,
index,
},
AccountKey20 { network: maybe_network, key } => Self::AccountKey20 {
network: maybe_network.map(|network| network.try_into()).transpose()?,
key,
},
PalletInstance(index) => Self::PalletInstance(index),
GeneralIndex(id) => Self::GeneralIndex(id),
GeneralKey { length, data } => Self::GeneralKey { length, data },
OnlyChild => Self::OnlyChild,
Plurality { id, part } => Self::Plurality { id, part },
GlobalConsensus(network) => Self::GlobalConsensus(network.into()),
GlobalConsensus(network) => Self::GlobalConsensus(network.try_into()?),
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion polkadot/xcm/src/v3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ impl<Call> TryFrom<NewInstruction<Call>> for Instruction<Call> {
ClearTransactStatus => Self::ClearTransactStatus,
UniversalOrigin(junction) => Self::UniversalOrigin(junction.try_into()?),
ExportMessage { network, destination, xcm } => Self::ExportMessage {
network: network.into(),
network: network.try_into()?,
destination: destination.try_into()?,
xcm: xcm.try_into()?,
},
Expand Down
2 changes: 2 additions & 0 deletions polkadot/xcm/src/v4/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ pub enum NetworkId {
BitcoinCash,
/// The Polkadot Bulletin chain.
PolkadotBulletin,
/// The Paseo testnet Relay-chain.
Paseo,
}

impl From<OldNetworkId> for Option<NetworkId> {
Expand Down
13 changes: 13 additions & 0 deletions prdoc/pr_3328.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Add Paseo NetworkId to XCM

doc:
- audience: Runtime Dev
description: |
A new NetworkId was added to XCMv4 for the new [Paseo testnet](https://forum.polkadot.network/t/the-new-polkadot-community-testnet/4956).
Conversion from v4::NetworkId to v3::NetworkId is now fallible because of this extra variant.

crates:
- name: "staging-xcm"