Deprecate Currency: Companion for #12951 (#6780)

* Some renames

* Fix

* Fix build for new APIs

* Remove diener

* Fixes

* Fixes

* Fix integration tests

* Fixes

* fix nis issuance

* Update Cargo.toml

* Polkadot doesn't have freezes/holds yet

* No networks use freezes/holds

* update lockfile for {"substrate"}

* Fix tests

There are more failing tests; just starting with the easy ones.
Reserved balance does not count towards ED anymore, therefore reducing
all the reserves by ED (1).

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fixes for Polkadot pallets

* Fix parachains benchmarks

* Update Substrate

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: parity-processbot <>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Gavin Wood
2023-03-20 13:20:22 +00:00
committed by GitHub
parent 67035d6436
commit 2e656dcd6e
33 changed files with 481 additions and 305 deletions
@@ -16,7 +16,12 @@
//! Adapters to work with `frame_support::traits::tokens::fungibles` through XCM.
use frame_support::traits::{tokens::fungibles, Contains, Get};
use frame_support::traits::{
tokens::{
fungibles, Fortitude::Polite, Precision::Exact, Preservation::Preserve, Provenance::Minted,
},
Contains, Get,
};
use sp_std::{marker::PhantomData, prelude::*, result};
use xcm::latest::prelude::*;
use xcm_executor::traits::{Convert, Error as MatchError, MatchesFungibles, TransactAsset};
@@ -26,7 +31,7 @@ pub struct FungiblesTransferAdapter<Assets, Matcher, AccountIdConverter, Account
PhantomData<(Assets, Matcher, AccountIdConverter, AccountId)>,
);
impl<
Assets: fungibles::Transfer<AccountId>,
Assets: fungibles::Mutate<AccountId>,
Matcher: MatchesFungibles<Assets::AssetId, Assets::Balance>,
AccountIdConverter: Convert<MultiLocation, AccountId>,
AccountId: Clone, // can't get away without it since Currency is generic over it.
@@ -49,7 +54,7 @@ impl<
.map_err(|()| MatchError::AccountIdConversionFailed)?;
let dest = AccountIdConverter::convert_ref(to)
.map_err(|()| MatchError::AccountIdConversionFailed)?;
Assets::transfer(asset_id, &source, &dest, amount, true)
Assets::transfer(asset_id, &source, &dest, amount, Preserve)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
Ok(what.clone().into())
}
@@ -153,14 +158,14 @@ impl<
{
fn can_accrue_checked(asset_id: Assets::AssetId, amount: Assets::Balance) -> XcmResult {
let checking_account = CheckingAccount::get();
Assets::can_deposit(asset_id, &checking_account, amount, true)
Assets::can_deposit(asset_id, &checking_account, amount, Minted)
.into_result()
.map_err(|_| XcmError::NotDepositable)
}
fn can_reduce_checked(asset_id: Assets::AssetId, amount: Assets::Balance) -> XcmResult {
let checking_account = CheckingAccount::get();
Assets::can_withdraw(asset_id, &checking_account, amount)
.into_result()
.into_result(false)
.map_err(|_| XcmError::NotWithdrawable)
.map(|_| ())
}
@@ -171,7 +176,7 @@ impl<
}
fn reduce_checked(asset_id: Assets::AssetId, amount: Assets::Balance) {
let checking_account = CheckingAccount::get();
let ok = Assets::burn_from(asset_id, &checking_account, amount).is_ok();
let ok = Assets::burn_from(asset_id, &checking_account, amount, Exact, Polite).is_ok();
debug_assert!(ok, "`can_reduce_checked` must have returned `true` immediately prior; qed");
}
}
@@ -280,7 +285,8 @@ impl<
let who = AccountIdConverter::convert_ref(who)
.map_err(|()| MatchError::AccountIdConversionFailed)?;
Assets::mint_into(asset_id, &who, amount)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
Ok(())
}
fn withdraw_asset(
@@ -297,7 +303,7 @@ impl<
let (asset_id, amount) = Matcher::matches_fungibles(what)?;
let who = AccountIdConverter::convert_ref(who)
.map_err(|()| MatchError::AccountIdConversionFailed)?;
Assets::burn_from(asset_id, &who, amount)
Assets::burn_from(asset_id, &who, amount, Exact, Polite)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
Ok(what.clone().into())
}
@@ -312,7 +318,7 @@ pub struct FungiblesAdapter<
CheckingAccount,
>(PhantomData<(Assets, Matcher, AccountIdConverter, AccountId, CheckAsset, CheckingAccount)>);
impl<
Assets: fungibles::Mutate<AccountId> + fungibles::Transfer<AccountId>,
Assets: fungibles::Mutate<AccountId>,
Matcher: MatchesFungibles<Assets::AssetId, Assets::Balance>,
AccountIdConverter: Convert<MultiLocation, AccountId>,
AccountId: Clone, // can't get away without it since Currency is generic over it.