Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KiChjang committed Aug 28, 2023
1 parent 758b977 commit 3a9bcb8
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions polkadot/xcm/xcm-executor/src/traits/transact_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ pub trait TransactAsset {
/// Deposit the `what` asset into the account of `who`.
///
/// Implementations should return `XcmError::FailedToTransactAsset` if deposit failed.
fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation, _context: &XcmContext) -> XcmResult {
fn deposit_asset(
_what: &MultiAsset,
_who: &MultiLocation,
_context: Option<&XcmContext>,
) -> XcmResult {
Err(XcmError::Unimplemented)
}

Expand Down Expand Up @@ -139,7 +143,7 @@ pub trait TransactAsset {
Err(XcmError::AssetNotFound | XcmError::Unimplemented) => {
let assets = Self::withdraw_asset(asset, from, Some(context))?;
// Not a very forgiving attitude; once we implement roll-backs then it'll be nicer.
Self::deposit_asset(asset, to, context)?;
Self::deposit_asset(asset, to, Some(context))?;
Ok(assets)
},
result => result,
Expand Down Expand Up @@ -195,7 +199,7 @@ impl TransactAsset for Tuple {
)* );
}

fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult {
fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: Option<&XcmContext>) -> XcmResult {
for_tuples!( #(
match Tuple::deposit_asset(what, who, context) {
Err(XcmError::AssetNotFound) | Err(XcmError::Unimplemented) => (),
Expand Down Expand Up @@ -286,7 +290,7 @@ mod tests {
fn deposit_asset(
_what: &MultiAsset,
_who: &MultiLocation,
_context: &XcmContext,
_context: Option<&XcmContext>,
) -> XcmResult {
Err(XcmError::AssetNotFound)
}
Expand Down Expand Up @@ -330,7 +334,7 @@ mod tests {
fn deposit_asset(
_what: &MultiAsset,
_who: &MultiLocation,
_context: &XcmContext,
_context: Option<&XcmContext>,
) -> XcmResult {
Err(XcmError::Overflow)
}
Expand Down Expand Up @@ -374,7 +378,7 @@ mod tests {
fn deposit_asset(
_what: &MultiAsset,
_who: &MultiLocation,
_context: &XcmContext,
_context: Option<&XcmContext>,
) -> XcmResult {
Ok(())
}
Expand Down Expand Up @@ -406,7 +410,7 @@ mod tests {
MultiTransactor::deposit_asset(
&(Here, 1u128).into(),
&Here.into(),
&XcmContext::with_message_id([0; 32]),
Some(&XcmContext::with_message_id([0; 32])),
),
Err(XcmError::AssetNotFound)
);
Expand All @@ -420,7 +424,7 @@ mod tests {
MultiTransactor::deposit_asset(
&(Here, 1u128).into(),
&Here.into(),
&XcmContext::with_message_id([0; 32]),
Some(&XcmContext::with_message_id([0; 32])),
),
Ok(())
);
Expand All @@ -434,7 +438,7 @@ mod tests {
MultiTransactor::deposit_asset(
&(Here, 1u128).into(),
&Here.into(),
&XcmContext::with_message_id([0; 32]),
Some(&XcmContext::with_message_id([0; 32])),
),
Err(XcmError::Overflow)
);
Expand All @@ -448,7 +452,7 @@ mod tests {
MultiTransactor::deposit_asset(
&(Here, 1u128).into(),
&Here.into(),
&XcmContext::with_message_id([0; 32]),
Some(&XcmContext::with_message_id([0; 32])),
),
Ok(()),
);
Expand Down

0 comments on commit 3a9bcb8

Please sign in to comment.