Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Companion for paritytech/polkadot#4097
Browse files Browse the repository at this point in the history
  • Loading branch information
Guantong committed Mar 2, 2023
1 parent 7c67b90 commit 412a7eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions runtime/common/src/xcm_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub struct LocalAssetTrader<
OnUnbalanced: OnUnbalancedT<Currency::NegativeImbalance>,
R: TakeRevenue,
>(
XcmWeight,
Weight,
Currency::Balance,
PhantomData<(WeightToFee, AssetId, AccountId, Currency, OnUnbalanced, R)>,
);
Expand All @@ -161,12 +161,12 @@ impl<
> WeightTrader for LocalAssetTrader<WeightToFee, AssetId, AccountId, Currency, OnUnbalanced, R>
{
fn new() -> Self {
Self(0, Zero::zero(), PhantomData)
Self(Weight::zero(), Zero::zero(), PhantomData)
}

fn buy_weight(&mut self, weight: XcmWeight, payment: Assets) -> Result<Assets, XcmError> {
log::trace!(target: "xcm::weight", "LocalAssetTrader::buy_weight weight: {:?}, payment: {:?}", weight, payment);
let amount = WeightToFee::weight_to_fee(&Weight::from_ref_time(weight));
let amount = WeightToFee::weight_to_fee(&weight);
let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;
let required: MultiAsset = (Concrete(AssetId::get()), u128_amount).into();
let unused = payment.checked_sub(required.clone()).map_err(|_| XcmError::TooExpensive)?;
Expand All @@ -179,7 +179,7 @@ impl<
fn refund_weight(&mut self, weight: XcmWeight) -> Option<MultiAsset> {
log::trace!(target: "xcm::weight", "LocalAssetTrader::refund_weight weight: {:?}", weight);
let weight = weight.min(self.0);
let amount = WeightToFee::weight_to_fee(&Weight::from_ref_time(weight));
let amount = WeightToFee::weight_to_fee(&weight);
self.0 -= weight;
self.1 = self.1.saturating_sub(amount);
let amount: u128 = amount.saturated_into();
Expand Down

0 comments on commit 412a7eb

Please sign in to comment.