Merge branch 'master' into gav-xcm-v3

This commit is contained in:
Keith Yeung
2022-09-22 21:36:30 +08:00
203 changed files with 5861 additions and 3564 deletions
+9 -4
View File
@@ -31,7 +31,10 @@ use frame_support::{
use polkadot_runtime_common::xcm_sender::ConstantPrice;
use sp_runtime::{traits::Saturating, SaturatedConversion};
use sp_std::{marker::PhantomData, prelude::*};
use xcm::{latest::prelude::*, WrapVersion};
use xcm::{
latest::{prelude::*, Weight as XCMWeight},
WrapVersion,
};
use xcm_builder::TakeRevenue;
use xcm_executor::traits::{MatchesFungibles, TransactAsset, WeightTrader};
@@ -147,7 +150,7 @@ impl<
// If everything goes well, we charge.
fn buy_weight(
&mut self,
weight: Weight,
weight: XCMWeight,
payment: xcm_executor::Assets,
) -> Result<xcm_executor::Assets, XcmError> {
log::trace!(target: "xcm::weight", "TakeFirstAssetTrader::buy_weight weight: {:?}, payment: {:?}", weight, payment);
@@ -157,6 +160,8 @@ impl<
return Err(XcmError::NotWithdrawable)
}
let weight = Weight::from_ref_time(weight);
// We take the very first multiasset from payment
let multiassets: MultiAssets = payment.clone().into();
@@ -197,14 +202,14 @@ impl<
Ok(unused)
}
fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
fn refund_weight(&mut self, weight: XCMWeight) -> Option<MultiAsset> {
log::trace!(target: "xcm::weight", "TakeFirstAssetTrader::refund_weight weight: {:?}", weight);
if let Some(AssetTraderRefunder {
mut weight_outstanding,
outstanding_concrete_asset: MultiAsset { id, fun },
}) = self.0.clone()
{
let weight = weight.min(weight_outstanding);
let weight = Weight::from_ref_time(weight).min(weight_outstanding);
// Get the local asset id in which we can refund fees
let (local_asset_id, outstanding_balance) =