Skip to content

Commit

Permalink
Add topic_id
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Dec 19, 2024
1 parent 4d754da commit 4aa1a7f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
16 changes: 8 additions & 8 deletions bridges/snowbridge/pallets/inbound-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub mod pallet {
/// Set OperatingMode
OperatingModeChanged { mode: BasicOperatingMode },
/// A XCM message was sent.
Sent { destination: Location, message: Xcm<()>, message_id: XcmHash },
Sent { destination: Location, message_id: XcmHash, topic_id: XcmHash },
}

#[pallet::error]
Expand Down Expand Up @@ -295,7 +295,7 @@ pub mod pallet {
Self::burn_fees(channel.para_id, fee)?;

// Attempt to send XCM to a dest parachain
let message_id = Self::send_xcm(xcm, channel.para_id)?;
let message_id = Self::send_xcm(xcm, channel.para_id, envelope.message_id.into())?;

Self::deposit_event(Event::MessageReceived {
channel_id: envelope.channel_id,
Expand Down Expand Up @@ -331,15 +331,15 @@ pub mod pallet {
Ok((xcm, fee))
}

pub fn send_xcm(xcm: Xcm<()>, dest: ParaId) -> Result<XcmHash, Error<T>> {
pub fn send_xcm(
xcm: Xcm<()>,
dest: ParaId,
topic_id: [u8; 32],
) -> Result<XcmHash, Error<T>> {
let dest = Location::new(1, [Parachain(dest.into())]);
let (xcm_hash, _) =
send_xcm::<T::XcmSender>(dest.clone(), xcm.clone()).map_err(Error::<T>::from)?;
Self::deposit_event(Event::Sent {
destination: dest,
message: xcm,
message_id: xcm_hash,
});
Self::deposit_event(Event::Sent { destination: dest, message_id: xcm_hash, topic_id });
Ok(xcm_hash)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ fn register_weth_token_in_asset_hub_fail_for_insufficient_fee() {
},
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into()).unwrap();
let _ =
EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into(), [0; 32]).unwrap();

assert_expected_events!(
BridgeHubRococo,
Expand Down Expand Up @@ -610,7 +611,7 @@ fn send_token_from_ethereum_to_asset_hub_with_fee(account_id: [u8; 32], fee: u12
},
});
let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap();
assert_ok!(EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into()));
assert_ok!(EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into(), [0; 32]));

// Check that the message was sent
assert_expected_events!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ fn register_weth_token_from_ethereum_to_asset_hub() {
command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE },
});
let (xcm, _) = EthereumInboundQueue::do_convert([0; 32].into(), message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into()).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into(), [0; 32])
.unwrap();

assert_expected_events!(
BridgeHubWestend,
Expand Down Expand Up @@ -130,7 +131,8 @@ fn send_token_from_ethereum_to_asset_hub() {
},
});
let (xcm, _) = EthereumInboundQueue::do_convert([0; 32].into(), message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into()).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into(), [0; 32])
.unwrap();

// Check that the message was sent
assert_expected_events!(
Expand Down Expand Up @@ -193,7 +195,8 @@ fn send_weth_asset_from_asset_hub_to_ethereum() {
},
});
let (xcm, _) = EthereumInboundQueue::do_convert([0; 32].into(), message).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into()).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into(), [0; 32])
.unwrap();

// Check that the send token message was sent using xcm
assert_expected_events!(
Expand Down Expand Up @@ -400,7 +403,8 @@ fn transfer_relay_token() {
// Convert the message to XCM
let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap();
// Send the XCM
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into()).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into(), [0; 32])
.unwrap();

assert_expected_events!(
BridgeHubWestend,
Expand Down Expand Up @@ -566,7 +570,8 @@ fn transfer_ah_token() {
// Convert the message to XCM
let (xcm, _) = EthereumInboundQueue::do_convert([0; 32].into(), message).unwrap();
// Send the XCM
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into()).unwrap();
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubWestend::para_id().into(), [0; 32])
.unwrap();

assert_expected_events!(
BridgeHubWestend,
Expand Down

0 comments on commit 4aa1a7f

Please sign in to comment.