Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snowbridge: Emit sent event from BH to AH #6965

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions bridges/snowbridge/pallets/inbound-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ pub mod pallet {
nonce: u64,
/// ID of the XCM message which was forwarded to the final destination parachain
message_id: [u8; 32],
/// Fee burned for the teleport
fee_burned: BalanceOf<T>,
},
/// Set OperatingMode
OperatingModeChanged { mode: BasicOperatingMode },
/// A XCM message was sent.
Sent { destination: Location, message_id: XcmHash },
}

#[pallet::error]
Expand Down Expand Up @@ -241,6 +241,12 @@ pub mod pallet {
let envelope =
Envelope::try_from(&message.event_log).map_err(|_| Error::<T>::InvalidEnvelope)?;

Self::deposit_event(Event::MessageReceived {
channel_id: envelope.channel_id,
nonce: envelope.nonce,
message_id: envelope.message_id.into(),
});

// Verify that the message was submitted from the known Gateway contract
ensure!(T::GatewayAddress::get() == envelope.gateway, Error::<T>::InvalidGateway);

Expand Down Expand Up @@ -293,14 +299,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)?;

Self::deposit_event(Event::MessageReceived {
channel_id: envelope.channel_id,
nonce: envelope.nonce,
message_id,
fee_burned: fee,
});
Self::send_xcm(xcm, channel.para_id)?;

Ok(())
}
Expand Down Expand Up @@ -331,7 +330,9 @@ pub mod pallet {

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

Expand Down
9 changes: 9 additions & 0 deletions prdoc/pr_6965.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: 'Snowbridge: Emit sent xcm from BH to AH'
doc:
- audience: Runtime Dev
description: Emit the sent xcm from BH to AH which is helpful
to index the transfer across multiple chains.
crates:
- name: snowbridge-pallet-inbound-queue
bump: patch

Loading