diff --git a/porteer/src/lib.rs b/porteer/src/lib.rs index d991930b..f0ce2442 100644 --- a/porteer/src/lib.rs +++ b/porteer/src/lib.rs @@ -195,7 +195,11 @@ pub mod pallet { /// The XcmFeeConfig has been set. XcmFeeConfigSet { fees: XcmFeeParams> }, /// Ported some tokens to the destination chain. - PortedTokens { who: AccountIdOf, amount: BalanceOf }, + PortedTokens { + who: AccountIdOf, + amount: BalanceOf, + source_nonce: PortTokensNonceOf, + }, /// Minted some tokens ported from another chain! MintedPortedTokens { who: AccountIdOf, @@ -203,12 +207,22 @@ pub mod pallet { source_nonce: PortTokensNonceOf, }, /// Forwarded some minted tokens to another location. - ForwardedPortedTokens { who: AccountIdOf, amount: BalanceOf, location: T::Location }, + ForwardedPortedTokens { + who: AccountIdOf, + amount: BalanceOf, + location: T::Location, + source_nonce: PortTokensNonceOf, + }, /// Failed to forward the tokens to the final destination. - FailedToForwardTokens { who: AccountIdOf, amount: BalanceOf, location: T::Location }, + FailedToForwardTokens { + who: AccountIdOf, + amount: BalanceOf, + location: T::Location, + source_nonce: PortTokensNonceOf, + }, /// Tried to forward the tokens to an illegal destination, hence the operation was /// aborted (tokens were successfully minted on this chain though). - IllegalForwardingLocation { location: T::Location }, + IllegalForwardingLocation { location: T::Location, source_nonce: PortTokensNonceOf }, } #[pallet::error] @@ -419,7 +433,7 @@ pub mod pallet { Fortitude::Polite, )?; - let nonce = PortTokensNonce::::mutate(|n| { + let source_nonce = PortTokensNonce::::mutate(|n| { *n = n.saturating_add(1u32.into()); *n }); @@ -428,14 +442,14 @@ pub mod pallet { signer.clone(), amount, forward_tokens_to_location, - nonce, + source_nonce, ) .map_err(|e| { log::error!(target: LOG_TARGET, "Port tokens error: {:?}", e); Error::::PortTokensInitError })?; - Self::deposit_event(Event::::PortedTokens { who: signer, amount }); + Self::deposit_event(Event::::PortedTokens { who: signer, amount, source_nonce }); Ok(()) } @@ -473,15 +487,20 @@ pub mod pallet { who: beneficiary.clone(), amount, location: l, + source_nonce, }), Err(_) => Self::deposit_event(Event::::FailedToForwardTokens { who: beneficiary.clone(), amount, location: l, + source_nonce, }), } } else { - Self::deposit_event(Event::::IllegalForwardingLocation { location: l }) + Self::deposit_event(Event::::IllegalForwardingLocation { + location: l, + source_nonce, + }) } } Ok(()) diff --git a/porteer/src/tests.rs b/porteer/src/tests.rs index 2960c2a3..2d20bc5a 100644 --- a/porteer/src/tests.rs +++ b/porteer/src/tests.rs @@ -492,6 +492,7 @@ fn minting_ported_tokens_with_forwarding_non_whitelisted_location_preserves_bala let expected_event = RuntimeEvent::Porteer(PorteerEvent::IllegalForwardingLocation { location: WHITELISTED_LOCATION, + source_nonce: 0, }); assert!(System::events().iter().any(|a| a.event == expected_event)); @@ -527,6 +528,7 @@ fn minting_ported_tokens_with_forwarding_to_unsupported_location_preserves_balan who: bob.clone(), amount: mint_amount, location: WHITELISTED_BUT_UNSUPPORTED_LOCATION, + source_nonce: 0, }); assert!(System::events().iter().any(|a| a.event == expected_event));