Skip to content

Commit

Permalink
remove networkis in xcm-v5
Browse files Browse the repository at this point in the history
  • Loading branch information
programskillforverification committed Aug 19, 2024
1 parent 856a3fe commit 4f16f3c
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ mod imports {
latest::{ParentThen, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::{AccountId32 as AccountId32Junction, *},
v5,
v5::NetworkId::Westend as WestendId,
};
pub use xcm_executor::traits::TransferType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod imports {
pub use xcm::{
latest::{ParentThen, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
prelude::{AccountId32 as AccountId32Junction, *},
v5::{self, NetworkId::Rococo as RococoId},
v5,
};
pub use xcm_executor::traits::TransferType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,10 @@ fn receive_reserve_asset_deposited_roc_from_asset_hub_rococo_fees_paid_by_pool_s
let block_author_account = AccountId::from(BLOCK_AUTHOR_ACCOUNT);
let staking_pot = StakingPot::get();

let foreign_asset_id_location =
xcm::v5::Location::new(2, [xcm::v5::Junction::GlobalConsensus(xcm::v5::NetworkId::Rococo)]);
let foreign_asset_id_location = xcm::v5::Location::new(
2,
[xcm::v5::Junction::GlobalConsensus(xcm::v5::NetworkId::ByGenesis(ROCOCO_GENESIS_HASH))],
);
let foreign_asset_id_minimum_balance = 1_000_000_000;
// sovereign account as foreign asset owner (can be whoever for this scenario)
let foreign_asset_owner = LocationToAccountId::convert_location(&Location::parent()).unwrap();
Expand Down Expand Up @@ -1194,8 +1196,10 @@ fn receive_reserve_asset_deposited_roc_from_asset_hub_rococo_fees_paid_by_suffic
let block_author_account = AccountId::from(BLOCK_AUTHOR_ACCOUNT);
let staking_pot = StakingPot::get();

let foreign_asset_id_location =
xcm::v5::Location::new(2, [xcm::v5::Junction::GlobalConsensus(xcm::v5::NetworkId::Rococo)]);
let foreign_asset_id_location = xcm::v5::Location::new(
2,
[xcm::v5::Junction::GlobalConsensus(xcm::v5::NetworkId::ByGenesis(ROCOCO_GENESIS_HASH))],
);
let foreign_asset_id_minimum_balance = 1_000_000_000;
// sovereign account as foreign asset owner (can be whoever for this scenario)
let foreign_asset_owner = LocationToAccountId::convert_location(&Location::parent()).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ use bridge_hub_common::{
use pallet_xcm::EnsureXcm;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm::{latest::WESTEND_GENESIS_HASH, VersionedLocation};
use xcm::{
latest::{ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH},
VersionedLocation,
};
use xcm_config::{TreasuryAccount, XcmOriginToTransactDispatchOrigin, XcmRouter};

#[cfg(any(feature = "std", test))]
Expand Down Expand Up @@ -1439,7 +1442,7 @@ impl_runtime_apis! {
Runtime,
bridge_common_config::BridgeGrandpaWestendInstance,
bridge_to_westend_config::WithBridgeHubWestendMessagesInstance,
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(Rococo), Parachain(42)].into()))
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(42)].into()))
}

fn prepare_message_delivery_proof(
Expand Down Expand Up @@ -1474,7 +1477,7 @@ impl_runtime_apis! {
Runtime,
bridge_common_config::BridgeGrandpaRococoBulletinInstance,
bridge_to_bulletin_config::WithRococoBulletinMessagesInstance,
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(Rococo), Parachain(42)].into()))
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(ByGenesis(ROCOCO_GENESIS_HASH)), Parachain(42)].into()))
}

fn prepare_message_delivery_proof(
Expand Down
6 changes: 6 additions & 0 deletions polkadot/xcm/src/v3/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ pub enum NetworkId {
Polkadot,
/// The Kusama canary-net Relay-chain.
Kusama,
/// The Westend testnet Relay-chain.
Westend,
/// The Rococo testnet Relay-chain.
Rococo,
/// The Wococo testnet Relay-chain.
Wococo,
/// An Ethereum network specified by its chain ID.
Expand Down Expand Up @@ -86,6 +90,8 @@ impl From<NewNetworkId> for NetworkId {
ByFork { block_number, block_hash } => Self::ByFork { block_number, block_hash },
Polkadot => Self::Polkadot,
Kusama => Self::Kusama,
Westend => Self::Westend,
Rococo => Self::Rococo,
Wococo => Self::Wococo,
Ethereum { chain_id } => Self::Ethereum { chain_id },
BitcoinCore => Self::BitcoinCore,
Expand Down
13 changes: 6 additions & 7 deletions polkadot/xcm/src/v4/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use crate::{
};
use bounded_collections::{BoundedSlice, BoundedVec, ConstU32};
use codec::{self, Decode, Encode, MaxEncodedLen};
use hex_literal::hex;
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -129,12 +128,6 @@ impl From<NewNetworkId> for NetworkId {
}
}

pub const WESTEND_GENESIS_HASH: [u8; 32] =
hex!["e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e"];

pub const ROCOCO_GENESIS_HASH: [u8; 32] =
hex!["6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e"];

/// A global identifier of a data structure existing within consensus.
///
/// Maintenance note: Networks with global consensus and which are practically bridgeable within the
Expand Down Expand Up @@ -163,6 +156,10 @@ pub enum NetworkId {
Polkadot,
/// The Kusama canary-net Relay-chain.
Kusama,
/// The Westend testnet Relay-chain.
Westend,
/// The Rococo testnet Relay-chain.
Rococo,
/// The Wococo testnet Relay-chain.
Wococo,
/// An Ethereum network specified by its chain ID.
Expand Down Expand Up @@ -193,6 +190,8 @@ impl From<OldNetworkId> for NetworkId {
ByFork { block_number, block_hash } => Self::ByFork { block_number, block_hash },
Polkadot => Self::Polkadot,
Kusama => Self::Kusama,
Westend => Self::Westend,
Rococo => Self::Rococo,
Wococo => Self::Wococo,
Ethereum { chain_id } => Self::Ethereum { chain_id },
BitcoinCore => Self::BitcoinCore,
Expand Down
4 changes: 1 addition & 3 deletions polkadot/xcm/src/v4/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ pub use asset::{
Asset, AssetFilter, AssetId, AssetInstance, Assets, Fungibility, WildAsset, WildFungibility,
MAX_ITEMS_IN_ASSETS,
};
pub use junction::{
BodyId, BodyPart, Junction, NetworkId, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH,
};
pub use junction::{BodyId, BodyPart, Junction, NetworkId};
pub use junctions::Junctions;
pub use location::{Ancestor, AncestorThen, InteriorLocation, Location, Parent, ParentThen};
pub use traits::{
Expand Down
15 changes: 9 additions & 6 deletions polkadot/xcm/src/v5/junction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
};
use bounded_collections::{BoundedSlice, BoundedVec, ConstU32};
use codec::{self, Decode, Encode, MaxEncodedLen};
use hex_literal::hex;
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -102,6 +103,12 @@ pub enum Junction {
GlobalConsensus(NetworkId),
}

pub const WESTEND_GENESIS_HASH: [u8; 32] =
hex!["e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e"];

pub const ROCOCO_GENESIS_HASH: [u8; 32] =
hex!["6408de7737c59c238890533af25896a2c20608d8b380bb01029acb392781063e"];

/// A global identifier of a data structure existing within consensus.
///
/// Maintenance note: Networks with global consensus and which are practically bridgeable within the
Expand Down Expand Up @@ -130,10 +137,6 @@ pub enum NetworkId {
Polkadot,
/// The Kusama canary-net Relay-chain.
Kusama,
/// The Westend testnet Relay-chain.
Westend,
/// The Rococo testnet Relay-chain.
Rococo,
/// The Wococo testnet Relay-chain.
Wococo,
/// An Ethereum network specified by its chain ID.
Expand Down Expand Up @@ -164,8 +167,8 @@ impl From<OldNetworkId> for NetworkId {
ByFork { block_number, block_hash } => Self::ByFork { block_number, block_hash },
Polkadot => Self::Polkadot,
Kusama => Self::Kusama,
Westend => Self::Westend,
Rococo => Self::Rococo,
Westend => Self::ByGenesis(WESTEND_GENESIS_HASH),
Rococo => Self::ByGenesis(ROCOCO_GENESIS_HASH),
Wococo => Self::Wococo,
Ethereum { chain_id } => Self::Ethereum { chain_id },
BitcoinCore => Self::BitcoinCore,
Expand Down
4 changes: 3 additions & 1 deletion polkadot/xcm/src/v5/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ pub use asset::{
Asset, AssetFilter, AssetId, AssetInstance, Assets, Fungibility, WildAsset, WildFungibility,
MAX_ITEMS_IN_ASSETS,
};
pub use junction::{BodyId, BodyPart, Junction, NetworkId};
pub use junction::{
BodyId, BodyPart, Junction, NetworkId, ROCOCO_GENESIS_HASH, WESTEND_GENESIS_HASH,
};
pub use junctions::Junctions;
pub use location::{Ancestor, AncestorThen, InteriorLocation, Location, Parent, ParentThen};
pub use traits::{
Expand Down

0 comments on commit 4f16f3c

Please sign in to comment.