Direct XCM ExportMessage fees for different bridges to different receiver accounts (#2021)

This commit is contained in:
Serban Iorga
2023-11-01 17:11:07 +02:00
committed by GitHub
parent 8507f45cef
commit dce5a8da66
14 changed files with 275 additions and 71 deletions
+3 -3
View File
@@ -248,7 +248,7 @@ impl<Config: config::Config> ExecuteXcm<Config::RuntimeCall> for XcmExecutor<Con
for asset in fees.inner() {
Config::AssetTransactor::withdraw_asset(&asset, &origin, None)?;
}
Config::FeeManager::handle_fee(fees, None);
Config::FeeManager::handle_fee(fees, None, FeeReason::ChargeFees);
}
Ok(())
}
@@ -851,7 +851,7 @@ impl<Config: config::Config> XcmExecutor<Config> {
destination,
xcm,
)?;
self.take_fee(fee, FeeReason::Export(network))?;
self.take_fee(fee, FeeReason::Export { network, destination })?;
Config::MessageExporter::deliver(ticket)?;
Ok(())
},
@@ -962,7 +962,7 @@ impl<Config: config::Config> XcmExecutor<Config> {
} else {
self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?.into()
};
Config::FeeManager::handle_fee(paid, Some(&self.context));
Config::FeeManager::handle_fee(paid, Some(&self.context), reason);
Ok(())
}
@@ -18,12 +18,12 @@ use xcm::prelude::*;
/// Handle stuff to do with taking fees in certain XCM instructions.
pub trait FeeManager {
/// Determine if a fee which would normally payable should be waived.
/// Determine if a fee should be waived.
fn is_waived(origin: Option<&MultiLocation>, r: FeeReason) -> bool;
/// Do something with the fee which has been paid. Doing nothing here silently burns the
/// fees.
fn handle_fee(fee: MultiAssets, context: Option<&XcmContext>);
fn handle_fee(fee: MultiAssets, context: Option<&XcmContext>, r: FeeReason);
}
/// Context under which a fee is paid.
@@ -42,7 +42,7 @@ pub enum FeeReason {
/// When the `QueryPallet` instruction is called.
QueryPallet,
/// When the `ExportMessage` instruction is called (and includes the network ID).
Export(NetworkId),
Export { network: NetworkId, destination: InteriorMultiLocation },
/// The `charge_fees` API.
ChargeFees,
/// When the `LockAsset` instruction is called.
@@ -55,5 +55,6 @@ impl FeeManager for () {
fn is_waived(_: Option<&MultiLocation>, _: FeeReason) -> bool {
false
}
fn handle_fee(_: MultiAssets, _: Option<&XcmContext>) {}
fn handle_fee(_: MultiAssets, _: Option<&XcmContext>, _: FeeReason) {}
}