Companion for substrate #7159 (#1747)

* Companion for paritytech/substrate#7159

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* update WithdrawReason in xcm

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* "Update Substrate"

Co-authored-by: parity-processbot <>
This commit is contained in:
Qinxuan Chen
2020-10-29 20:35:58 +08:00
committed by GitHub
parent 724321cd2d
commit 39db0688de
4 changed files with 146 additions and 152 deletions
+137 -143
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -69,7 +69,7 @@
use frame_support::{
decl_module, decl_storage, decl_event, decl_error, storage::child, ensure,
traits::{
Currency, Get, OnUnbalanced, WithdrawReason, ExistenceRequirement::AllowDeath
Currency, Get, OnUnbalanced, WithdrawReasons, ExistenceRequirement::AllowDeath
},
};
use frame_system::ensure_signed;
@@ -273,7 +273,7 @@ decl_module! {
ensure!(end > <frame_system::Module<T>>::block_number(), Error::<T>::CannotEndInPast);
let deposit = T::SubmissionDeposit::get();
let transfer = WithdrawReason::Transfer.into();
let transfer = WithdrawReasons::TRANSFER;
let imb = T::Currency::withdraw(&owner, deposit, transfer, AllowDeath)?;
let index = FundCount::get();
@@ -455,7 +455,7 @@ decl_module! {
// Avoid using transfer to ensure we don't pay any fees.
let fund_account = &Self::fund_account_id(index);
let transfer = WithdrawReason::Transfer.into();
let transfer = WithdrawReasons::TRANSFER;
let imbalance = T::Currency::withdraw(fund_account, balance, transfer, AllowDeath)?;
let _ = T::Currency::resolve_into_existing(&who, imbalance);
@@ -485,7 +485,7 @@ decl_module! {
let account = Self::fund_account_id(index);
// Avoid using transfer to ensure we don't pay any fees.
let transfer = WithdrawReason::Transfer.into();
let transfer = WithdrawReasons::TRANSFER;
let imbalance = T::Currency::withdraw(&account, fund.deposit, transfer, AllowDeath)?;
let _ = T::Currency::resolve_into_existing(&fund.owner, imbalance);
+3 -3
View File
@@ -25,7 +25,7 @@ use sp_runtime::traits::{
use codec::{Encode, Decode, Codec};
use frame_support::{
decl_module, decl_storage, decl_event, decl_error, ensure, dispatch::DispatchResult,
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness},
traits::{Currency, ReservableCurrency, WithdrawReasons, ExistenceRequirement, Get, Randomness},
weights::{DispatchClass, Weight},
};
use primitives::v1::{
@@ -630,7 +630,7 @@ impl<T: Trait> Module<T> {
if T::Currency::withdraw(
&bidder.who,
amount,
WithdrawReason::Fee.into(),
WithdrawReasons::FEE,
ExistenceRequirement::AllowDeath
).is_err() {
continue;
@@ -667,7 +667,7 @@ impl<T: Trait> Module<T> {
if T::Currency::withdraw(
&para_id.into_account(),
additional,
WithdrawReason::Fee.into(),
WithdrawReasons::FEE,
ExistenceRequirement::AllowDeath
).is_err() {
continue;
@@ -17,7 +17,7 @@
use sp_std::{result, convert::TryInto, marker::PhantomData};
use xcm::v0::{Error, Result, MultiAsset, MultiLocation};
use sp_arithmetic::traits::SaturatedConversion;
use frame_support::traits::{ExistenceRequirement::AllowDeath, WithdrawReason};
use frame_support::traits::{ExistenceRequirement::AllowDeath, WithdrawReasons};
use xcm_executor::traits::{MatchesFungible, LocationConversion, TransactAsset};
pub struct CurrencyAdapter<Currency, Matcher, AccountIdConverter, AccountId>(
@@ -48,7 +48,7 @@ impl<
let amount = Matcher::matches_fungible(&what).ok_or(())?.saturated_into();
let who = AccountIdConverter::from_location(who).ok_or(())?;
let balance_amount = amount.try_into().map_err(|_| ())?;
Currency::withdraw(&who, balance_amount, WithdrawReason::Transfer.into(), AllowDeath).map_err(|_| ())?;
Currency::withdraw(&who, balance_amount, WithdrawReasons::TRANSFER, AllowDeath).map_err(|_| ())?;
Ok(what.clone())
}
}