xcmp research
XCMP Research
workflow
xcm types
transact
call data(pallet & call index required)
#[derive(Encode, Decode)]
pub enum RelayTemplatePalletCall {
#[codec(index = 100)] // the index should match the position of the module in `construct_runtime!`
DoSomething(DoSomethingCall),
}
#[derive(Encode, Decode)]
pub enum DoSomethingCall {
#[codec(index = 0)] // the index should match the position of the dispatchable in the target pallet
Something(u32),
}
#[derive(Encode, Decode)]
pub enum CrowdloanPalletCall {
#[codec(index = 27)] // the index should match the position of the module in `construct_runtime!`
CrowdloanContribute(ContributeCall),
}
#[derive(Debug, PartialEq, Encode, Decode)]
pub struct Contribution {
#[codec(compact)]
index: ParaId,
#[codec(compact)]
value: BalanceOf,
signature: Option<MultiSignature>,
}
#[derive(Encode, Decode)]
pub enum ContributeCall {
#[codec(index = 1)] // the index should match the position of the dispatchable in the target pallet
Contribute(Contribution),
}
let call = RelayTemplatePalletCall::DoSomething(DoSomethingCall::Something(some_value)).encode();
let msg = Xcm::Transact {
origin_type: OriginKind::SovereignAccount,
require_weight_at_most: u64::MAX,
call: call.into(),
};
asset transfer
DepositReserveAsset
Xcm::WithdrawAsset {
assets: vec![MultiAsset::ConcreteFungible {
id: location,
amount: amount.into(),
}],
effects: vec![
Order::BuyExecution {
fees: MultiAsset::All,
weight: 0,
debt,
halt_on_error: false,
xcm: vec![]
},
Order::DepositReserveAsset {
assets: vec![MultiAsset::All],
dest: MultiLocation::X1(
Junction::Parent,
),
effects: vec![
Order::DepositAsset {
assets: vec![MultiAsset::All],
dest: MultiLocation::X1(Junction::AccountId32 {
network: NetworkId::Any,
id: T::AccountId32Converter::convert(account),
}),
}],
}],
}
Teleport
let msg = Xcm::WithdrawAsset {
assets:vec![MultiAsset::ConcreteFungible { id: MultiLocation::Null, amount: some_value }],
effects: vec![
Order::BuyExecution {
fees: MultiAsset::All,
weight: 0,
debt,
halt_on_error: false,
xcm: vec![]
},
Order::InitiateTeleport {
assets: vec![MultiAsset::All],
dest: MultiLocation::X1(Junction::Parachain(para_id)),
effects: vec![
Order::BuyExecution {
fees: MultiAsset::All,
weight: 0,
debt,
halt_on_error: false,
xcm: vec![]
},
Order::DepositAsset {
assets: vec![MultiAsset::All],
dest: MultiLocation::X1(account_32.clone()),
},
]
}
]
};
test code
relax xcm filter
callable function
test envirionment
host:bifrost-build-machine
relaychain:19944
parachain:19947
todo