mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 11:38:01 +00:00
Allow Creation of Asset Accounts That Don't Exist Yet and Add Blocked Status (#13843)
* prevent frozen accounts from receiving assets * refund deposits correctly * plus refund_other * add benchmarks * start migration work * docs * add migration logic * fix freeze_creating benchmark * support instanced migrations * review * correct deposit refund * only allow depositor, admin, or account origin to refund deposits * make sure refund actually removes account * do refund changes * Asset's account deposit owner (#13874) * assets deposit owner * doc typo * remove migration * empty commit * can transfer to frozen account * remove allow_burn from refund_other * storage version back to 1 * update doc * fix benches * update docs * more tests * Update frame/assets/src/types.rs * refund updating the reason * refactor * separate refund and refund_foreign * refunds, touch_other, tests * fixes * fmt * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_assets * tests: asserts asset account counts * Account touch trait (#14063) * assets touch trait * docs * move touch trait into support/traits * permissionless flag for do_touch * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * move trait to misc, drop option * Apply suggestions from code review Co-authored-by: Gavin Wood <gavin@parity.io> * correct doc * Update frame/assets/src/functions.rs --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Gavin Wood <gavin@parity.io> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Block asset account (#14070) * replace is_fronzen flag by status enum * block asset account * remove redundant brackets * fix typo * fmt * Apply suggestions from code review Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> * rename permissionless to check_depositor * doc fix * use account id lookup instead account id * add benchmark for touch_other --------- Co-authored-by: muharem <ismailov.m.h@gmail.com> Co-authored-by: command-bot <> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Gavin Wood <gavin@parity.io> Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com>
This commit is contained in:
@@ -55,8 +55,8 @@ pub use filter::{ClearFilterGuard, FilterStack, FilterStackGuard, InstanceFilter
|
||||
mod misc;
|
||||
pub use misc::{
|
||||
defensive_prelude::{self, *},
|
||||
Backing, ConstBool, ConstI128, ConstI16, ConstI32, ConstI64, ConstI8, ConstU128, ConstU16,
|
||||
ConstU32, ConstU64, ConstU8, DefensiveMax, DefensiveMin, DefensiveSaturating,
|
||||
AccountTouch, Backing, ConstBool, ConstI128, ConstI16, ConstI32, ConstI64, ConstI8, ConstU128,
|
||||
ConstU16, ConstU32, ConstU64, ConstU8, DefensiveMax, DefensiveMin, DefensiveSaturating,
|
||||
DefensiveTruncateFrom, EnsureInherentsAreFirst, EqualPrivilegeOnly, EstimateCallFee,
|
||||
ExecuteBlock, ExtrinsicCall, Get, GetBacking, GetDefault, HandleLifetime, IsSubType, IsType,
|
||||
Len, OffchainWorker, OnKilledAccount, OnNewAccount, PrivilegeCmp, SameOrOther, Time,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
//! Smaller traits used in FRAME which don't need their own file.
|
||||
|
||||
use crate::dispatch::Parameter;
|
||||
use crate::dispatch::{DispatchResult, Parameter};
|
||||
use codec::{CompactLen, Decode, DecodeLimit, Encode, EncodeLike, Input, MaxEncodedLen};
|
||||
use impl_trait_for_tuples::impl_for_tuples;
|
||||
use scale_info::{build::Fields, meta_type, Path, Type, TypeInfo, TypeParameter};
|
||||
@@ -1154,6 +1154,19 @@ impl<Hash> PreimageRecipient<Hash> for () {
|
||||
fn unnote_preimage(_: &Hash) {}
|
||||
}
|
||||
|
||||
/// Trait for creating an asset account with a deposit taken from a designated depositor specified
|
||||
/// by the client.
|
||||
pub trait AccountTouch<AssetId, AccountId> {
|
||||
/// The type for currency units of the deposit.
|
||||
type Balance;
|
||||
|
||||
/// The deposit amount of a native currency required for creating an asset account.
|
||||
fn deposit_required() -> Self::Balance;
|
||||
|
||||
/// Create an account for `who` of the `asset` with a deposit taken from the `depositor`.
|
||||
fn touch(asset: AssetId, who: AccountId, depositor: AccountId) -> DispatchResult;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
@@ -141,6 +141,8 @@ pub enum DepositConsequence {
|
||||
Overflow,
|
||||
/// Account continued in existence.
|
||||
Success,
|
||||
/// Account cannot receive the assets.
|
||||
Blocked,
|
||||
}
|
||||
|
||||
impl DepositConsequence {
|
||||
@@ -152,6 +154,7 @@ impl DepositConsequence {
|
||||
CannotCreate => TokenError::CannotCreate.into(),
|
||||
UnknownAsset => TokenError::UnknownAsset.into(),
|
||||
Overflow => ArithmeticError::Overflow.into(),
|
||||
Blocked => TokenError::Blocked.into(),
|
||||
Success => return Ok(()),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user