Skip to content

Commit

Permalink
Cleanup primitives/consts
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Nov 5, 2024
1 parent f8db8a5 commit f415d55
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 102 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions bridges/chains/chain-asset-hub-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,7 @@ exclude-from-umbrella = true
workspace = true

[dependencies]
codec = { workspace = true }
scale-info = { features = ["derive"], workspace = true }

# Substrate Dependencies
frame-support = { workspace = true }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { workspace = true }

[features]
default = ["std"]
std = [
"bp-xcm-bridge-hub-router/std",
"codec/std",
"frame-support/std",
"scale-info/std",
]
std = []
26 changes: 0 additions & 26 deletions bridges/chains/chain-asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,5 @@
#![cfg_attr(not(feature = "std"), no_std)]

use codec::{Decode, Encode};
use scale_info::TypeInfo;

pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;

/// `AssetHubRococo` Runtime `Call` enum.
///
/// The enum represents a subset of possible `Call`s we can send to `AssetHubRococo` chain.
/// Ideally this code would be auto-generated from metadata, because we want to
/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s.
///
/// All entries here (like pretty much in the entire file) must be kept in sync with
/// `AssetHubRococo` `construct_runtime`, so that we maintain SCALE-compatibility.
#[allow(clippy::large_enum_variant)]
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum Call {
/// `ToWestendXcmRouter` bridge pallet.
#[codec(index = 45)]
ToWestendXcmRouter(XcmBridgeHubRouterCall),
}

frame_support::parameter_types! {
/// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`.
pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144);
}

/// Identifier of AssetHubRococo in the Rococo relay chain.
pub const ASSET_HUB_ROCOCO_PARACHAIN_ID: u32 = 1000;
15 changes: 1 addition & 14 deletions bridges/chains/chain-asset-hub-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,7 @@ exclude-from-umbrella = true
workspace = true

[dependencies]
codec = { workspace = true }
scale-info = { features = ["derive"], workspace = true }

# Substrate Dependencies
frame-support = { workspace = true }

# Bridge Dependencies
bp-xcm-bridge-hub-router = { workspace = true }

[features]
default = ["std"]
std = [
"bp-xcm-bridge-hub-router/std",
"codec/std",
"frame-support/std",
"scale-info/std",
]
std = []
26 changes: 0 additions & 26 deletions bridges/chains/chain-asset-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,5 @@
#![cfg_attr(not(feature = "std"), no_std)]

use codec::{Decode, Encode};
use scale_info::TypeInfo;

pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall;

/// `AssetHubWestend` Runtime `Call` enum.
///
/// The enum represents a subset of possible `Call`s we can send to `AssetHubWestend` chain.
/// Ideally this code would be auto-generated from metadata, because we want to
/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s.
///
/// All entries here (like pretty much in the entire file) must be kept in sync with
/// `AssetHubWestend` `construct_runtime`, so that we maintain SCALE-compatibility.
#[allow(clippy::large_enum_variant)]
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
pub enum Call {
/// `ToRococoXcmRouter` bridge pallet.
#[codec(index = 34)]
ToRococoXcmRouter(XcmBridgeHubRouterCall),
}

frame_support::parameter_types! {
/// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`.
pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144);
}

/// Identifier of AssetHubWestend in the Westend relay chain.
pub const ASSET_HUB_WESTEND_PARACHAIN_ID: u32 = 1000;
6 changes: 6 additions & 0 deletions bridges/chains/chain-bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,9 @@ pub enum RuntimeCall {
#[codec(index = 52)]
XcmOverBridgeHubWestend(bp_xcm_bridge_hub::XcmBridgeHubCall),
}

// TODO: remove when xcm:v5
frame_support::parameter_types! {
/// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`.
pub const XcmBridgeHubRouterTransactCallMaxWeight: Weight = Weight::from_parts(1_000_000_000, 1024*8);
}
6 changes: 6 additions & 0 deletions bridges/chains/chain-bridge-hub-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,9 @@ pub enum RuntimeCall {
#[codec(index = 45)]
XcmOverBridgeHubRococo(bp_xcm_bridge_hub::XcmBridgeHubCall),
}

// TODO: remove when xcm:v5
frame_support::parameter_types! {
/// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`.
pub const XcmBridgeHubRouterTransactCallMaxWeight: Weight = Weight::from_parts(1_000_000_000, 1024*8);
}
11 changes: 1 addition & 10 deletions bridges/primitives/xcm-bridge-hub-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

use codec::{Decode, Encode, FullCodec, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::{H256, sp_std::fmt::Debug};
use sp_core::sp_std::fmt::Debug;
use sp_runtime::{FixedU128, RuntimeDebug};
use xcm::latest::prelude::{Location, NetworkId, InteriorLocation};

Expand Down Expand Up @@ -56,12 +56,3 @@ impl ResolveBridgeId for () {
None
}
}

/// A minimized version of `pallet-xcm-bridge-hub-router::Call` that can be used without a runtime.
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
#[allow(non_camel_case_types)]
pub enum XcmBridgeHubRouterCall {
/// `pallet-xcm-bridge-hub-router::Call::report_bridge_status`
#[codec(index = 0)]
report_bridge_status { bridge_id: H256, is_congested: bool },
}

0 comments on commit f415d55

Please sign in to comment.