Init of pallet with transfer_asset_via_bridge call

Init of pallet with `transfer_asset_via_bridge` call

Init of pallet with `transfer_asset_via_bridge` call - setup basic tests
This commit is contained in:
Branislav Kontur
2022-11-11 11:29:20 +01:00
parent d9d5a9dd0b
commit 4a9dec9d7e
7 changed files with 472 additions and 5 deletions
@@ -68,6 +68,7 @@ cumulus-primitives-utility = { path = "../../../../primitives/utility", default-
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
parachains-common = { path = "../../../common", default-features = false }
bridge-assets-transfer = { path = "../../../../parachains/pallets/bridge-assets-transfer", default-features = false }
pallet-xcm-benchmarks = { git = "https://github.com/paritytech/polkadot", branch = "master", default-features = false, optional = true }
@@ -177,4 +178,5 @@ std = [
"pallet-collator-selection/std",
"parachain-info/std",
"parachains-common/std",
"bridge-assets-transfer/std",
]
@@ -63,7 +63,7 @@ use parachains_common::{
opaque, AccountId, AssetId, AuraId, Balance, BlockNumber, Hash, Header, Index, Signature,
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use xcm_config::{KsmLocation, XcmConfig};
use xcm_config::{BridgeXcmSender, KsmLocation, XcmConfig};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
@@ -74,6 +74,7 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use xcm::latest::BodyId;
use xcm_executor::XcmExecutor;
use crate::xcm_config::{BridgeTable, UniversalLocation};
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
impl_opaque_keys! {
@@ -569,6 +570,13 @@ impl pallet_uniques::Config for Runtime {
type Locker = ();
}
impl bridge_assets_transfer::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type BridgeXcmSender = BridgeXcmSender;
type SupportedBridges = BridgeTable;
type UniversalLocation = UniversalLocation;
}
// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime where
@@ -611,6 +619,7 @@ construct_runtime!(
// The main stage.
TrustBackedAssets: pallet_assets::<Instance1>::{Pallet, Call, Storage, Event<T>} = 50,
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51,
BridgeAssetsTransfer: bridge_assets_transfer::{Pallet, Call, Event<T>} = 52,
}
);
@@ -36,9 +36,10 @@ use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex,
ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
NativeAsset, NetworkExportTable, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UnpaidRemoteExporter,
UsingComponents, WeightInfoBounds,
};
use xcm_executor::{traits::JustTry, XcmExecutor};
@@ -46,7 +47,7 @@ parameter_types! {
pub const KsmLocation: MultiLocation = MultiLocation::parent();
pub const RelayNetwork: NetworkId = NetworkId::Kusama;
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into()));
pub UniversalLocation: InteriorMultiLocation = X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
pub const Local: MultiLocation = Here.into_location();
pub TrustBackedAssetsPalletLocation: MultiLocation =
PalletInstance(<TrustBackedAssets as PalletInfoAccess>::index() as u8).into();
@@ -266,3 +267,15 @@ impl cumulus_pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
}
parameter_types! {
/// BridgedNetworkConsensus + Multilocation-to-LocalGlobalConsensusBridgeHub + LocalGlobalConsensusBridgeHub
pub BridgeTable: sp_std::prelude::Vec<(NetworkId, MultiLocation, Option<MultiAsset>)> = sp_std::vec![
(NetworkId::Wococo, (Parent, Parachain(1013)).into(), None),
(NetworkId::Polkadot, (Parent, Parachain(1003)).into(), None),
];
}
/// Bridge router, which wraps and sends xcm to BridgeHub to be delivered to the different GlobalConsensus
pub type BridgeXcmSender =
UnpaidRemoteExporter<NetworkExportTable<BridgeTable>, XcmRouter, UniversalLocation>;