Follow-up on #1518 (#1546)

* Adjustments for the xcm messages sending logic

Signed-off-by: Serban Iorga <serban@parity.io>

* Deduplicate XCM destination

Signed-off-by: Serban Iorga <serban@parity.io>

* [send_message] small changes

Signed-off-by: Serban Iorga <serban@parity.io>

* Define CustomNetworkId

Right now we use some associations between Rialto, RialtoParachain and
Millau chains and chains defined in the NetworkId enum. But if we are
not carreful we might do mistakes like:
In Millau:
pub const ThisNetwork: NetworkId = Kusama;
pub const RialtoNetwork: NetworkId = Polkadot;
In Rialto:
pub const ThisNetwork: NetworkId = Kusama;
pub const MillauNetwork: NetworkId = Polkadot;

We're introducing CustomNetworkId to have a centralized mapping between
NetworkId chains and our custom chains.

Signed-off-by: Serban Iorga <serban@parity.io>

* Revert "Deduplicate XCM destination"

This reverts commit 3a0a950e1d7484e3ecac45f5c00b152f0485cd11.

Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
Serban Iorga
2022-08-12 12:05:46 +03:00
committed by Bastian Köcher
parent 050b12f3aa
commit e0b42dfae7
11 changed files with 89 additions and 72 deletions
@@ -33,23 +33,20 @@ impl CliEncodeMessage for RialtoParachain {
message: xcm::VersionedXcm<()>,
bridge_instance_index: u8,
) -> anyhow::Result<EncodedOrDecodedCall<Self::Call>> {
Ok(match bridge_instance_index {
bridge::RIALTO_PARACHAIN_TO_MILLAU_INDEX => {
let dest =
(Parent, X1(GlobalConsensus(rialto_parachain_runtime::MillauNetwork::get())));
rialto_parachain_runtime::Call::PolkadotXcm(
rialto_parachain_runtime::XcmCall::send {
dest: Box::new(dest.into()),
message: Box::new(message),
},
)
.into()
},
let dest = match bridge_instance_index {
bridge::RIALTO_PARACHAIN_TO_MILLAU_INDEX =>
(Parent, X1(GlobalConsensus(rialto_parachain_runtime::MillauNetwork::get()))),
_ => anyhow::bail!(
"Unsupported target bridge pallet with instance index: {}",
bridge_instance_index
),
};
Ok(rialto_parachain_runtime::Call::PolkadotXcm(rialto_parachain_runtime::XcmCall::send {
dest: Box::new(dest.into()),
message: Box::new(message),
})
.into())
}
fn encode_send_message_call(