-
Notifications
You must be signed in to change notification settings - Fork 739
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
add FeeManager to pallet xcm #5363
Changes from 7 commits
a5fe494
03f521e
e8cba6e
be37848
c7b575a
28ffa84
1cddea5
43da487
a08783e
74506e5
f5b6334
79ad2c6
6762b4e
ddf5ac3
fbea24e
94aa5c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -74,6 +74,7 @@ use xcm_runtime_apis::{ | |||||||||||||
|
||||||||||||||
#[cfg(any(feature = "try-runtime", test))] | ||||||||||||||
use sp_runtime::TryRuntimeError; | ||||||||||||||
use xcm_executor::traits::{FeeManager, FeeReason}; | ||||||||||||||
|
||||||||||||||
pub trait WeightInfo { | ||||||||||||||
fn send() -> Weight; | ||||||||||||||
|
@@ -239,7 +240,7 @@ pub mod pallet { | |||||||||||||
type XcmExecuteFilter: Contains<(Location, Xcm<<Self as Config>::RuntimeCall>)>; | ||||||||||||||
|
||||||||||||||
/// Something to execute an XCM message. | ||||||||||||||
type XcmExecutor: ExecuteXcm<<Self as Config>::RuntimeCall> + XcmAssetTransfers; | ||||||||||||||
type XcmExecutor: ExecuteXcm<<Self as Config>::RuntimeCall> + XcmAssetTransfers + FeeManager; | ||||||||||||||
|
||||||||||||||
/// Our XCM filter which messages to be teleported using the dedicated extrinsic must pass. | ||||||||||||||
type XcmTeleportFilter: Contains<(Location, Vec<Asset>)>; | ||||||||||||||
|
@@ -2421,17 +2422,16 @@ impl<T: Config> Pallet<T> { | |||||||||||||
mut message: Xcm<()>, | ||||||||||||||
) -> Result<XcmHash, SendError> { | ||||||||||||||
let interior = interior.into(); | ||||||||||||||
let origin_dest = interior.clone().into(); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the
Suggested change
|
||||||||||||||
let dest = dest.into(); | ||||||||||||||
let maybe_fee_payer = if interior != Junctions::Here { | ||||||||||||||
message.0.insert(0, DescendOrigin(interior.clone())); | ||||||||||||||
Some(interior.into()) | ||||||||||||||
} else { | ||||||||||||||
None | ||||||||||||||
}; | ||||||||||||||
let is_waived = <T::XcmExecutor as FeeManager>::is_waived(Some(&origin_dest), FeeReason::ChargeFees); | ||||||||||||||
if !is_waived { | ||||||||||||||
message.0.insert(0, DescendOrigin(interior)); | ||||||||||||||
} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not really what we want. Whether or not
Suggested change
|
||||||||||||||
log::debug!(target: "xcm::send_xcm", "dest: {:?}, message: {:?}", &dest, &message); | ||||||||||||||
let (ticket, price) = validate_send::<T::XcmRouter>(dest, message)?; | ||||||||||||||
if let Some(fee_payer) = maybe_fee_payer { | ||||||||||||||
Self::charge_fees(fee_payer, price).map_err(|_| SendError::Fees)?; | ||||||||||||||
if !is_waived { | ||||||||||||||
Self::charge_fees(origin_dest, price).map_err(|_| SendError::Fees)?; | ||||||||||||||
} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition is good! 👍 Just rename the var
Suggested change
|
||||||||||||||
T::XcmRouter::deliver(ticket) | ||||||||||||||
} | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already something you can use here:
Also please make sure all the other system chain runtimes have
Equals<RootLocation>
part of theirWaivedLocations
so as not to break functionality.Hint: they currently do not, for example collectives-westend has it, make sure the others do too.