mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 15:51:04 +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:
@@ -482,5 +482,74 @@ benchmarks_instance_pallet! {
|
||||
assert_last_event::<T, I>(Event::AssetMinBalanceChanged { asset_id: asset_id.into(), new_min_balance: 50u32.into() }.into());
|
||||
}
|
||||
|
||||
touch {
|
||||
let (asset_id, asset_owner, asset_owner_lookup) = create_default_asset::<T, I>(false);
|
||||
let new_account: T::AccountId = account("newaccount", 1, SEED);
|
||||
T::Currency::make_free_balance_be(&new_account, DepositBalanceOf::<T, I>::max_value());
|
||||
assert_ne!(asset_owner, new_account);
|
||||
assert!(!Account::<T, I>::contains_key(asset_id.into(), &new_account));
|
||||
}: _(SystemOrigin::Signed(new_account.clone()), asset_id)
|
||||
verify {
|
||||
assert!(Account::<T, I>::contains_key(asset_id.into(), &new_account));
|
||||
}
|
||||
|
||||
touch_other {
|
||||
let (asset_id, asset_owner, asset_owner_lookup) = create_default_asset::<T, I>(false);
|
||||
let new_account: T::AccountId = account("newaccount", 1, SEED);
|
||||
let new_account_lookup = T::Lookup::unlookup(new_account.clone());
|
||||
T::Currency::make_free_balance_be(&asset_owner, DepositBalanceOf::<T, I>::max_value());
|
||||
assert_ne!(asset_owner, new_account);
|
||||
assert!(!Account::<T, I>::contains_key(asset_id.into(), &new_account));
|
||||
}: _(SystemOrigin::Signed(asset_owner.clone()), asset_id, new_account_lookup)
|
||||
verify {
|
||||
assert!(Account::<T, I>::contains_key(asset_id.into(), &new_account));
|
||||
}
|
||||
|
||||
refund {
|
||||
let (asset_id, asset_owner, asset_owner_lookup) = create_default_asset::<T, I>(false);
|
||||
let new_account: T::AccountId = account("newaccount", 1, SEED);
|
||||
T::Currency::make_free_balance_be(&new_account, DepositBalanceOf::<T, I>::max_value());
|
||||
assert_ne!(asset_owner, new_account);
|
||||
assert!(Assets::<T, I>::touch(
|
||||
SystemOrigin::Signed(new_account.clone()).into(),
|
||||
asset_id
|
||||
).is_ok());
|
||||
// `touch` should reserve some balance of the caller...
|
||||
assert!(!T::Currency::reserved_balance(&new_account).is_zero());
|
||||
// ...and also create an `Account` entry.
|
||||
assert!(Account::<T, I>::contains_key(asset_id.into(), &new_account));
|
||||
}: _(SystemOrigin::Signed(new_account.clone()), asset_id, true)
|
||||
verify {
|
||||
// `refund`ing should of course repatriate the reserve
|
||||
assert!(T::Currency::reserved_balance(&new_account).is_zero());
|
||||
}
|
||||
|
||||
refund_other {
|
||||
let (asset_id, asset_owner, asset_owner_lookup) = create_default_asset::<T, I>(false);
|
||||
let new_account: T::AccountId = account("newaccount", 1, SEED);
|
||||
let new_account_lookup = T::Lookup::unlookup(new_account.clone());
|
||||
T::Currency::make_free_balance_be(&asset_owner, DepositBalanceOf::<T, I>::max_value());
|
||||
assert_ne!(asset_owner, new_account);
|
||||
assert!(Assets::<T, I>::touch_other(
|
||||
SystemOrigin::Signed(asset_owner.clone()).into(),
|
||||
asset_id,
|
||||
new_account_lookup.clone()
|
||||
).is_ok());
|
||||
// `touch_other` should reserve balance of the freezer
|
||||
assert!(!T::Currency::reserved_balance(&asset_owner).is_zero());
|
||||
assert!(Account::<T, I>::contains_key(asset_id.into(), &new_account));
|
||||
}: _(SystemOrigin::Signed(asset_owner.clone()), asset_id, new_account_lookup.clone())
|
||||
verify {
|
||||
// this should repatriate the reserved balance of the freezer
|
||||
assert!(T::Currency::reserved_balance(&asset_owner).is_zero());
|
||||
}
|
||||
|
||||
block {
|
||||
let (asset_id, caller, caller_lookup) = create_default_minted_asset::<T, I>(true, 100u32.into());
|
||||
}: _(SystemOrigin::Signed(caller.clone()), asset_id, caller_lookup)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::Blocked { asset_id: asset_id.into(), who: caller }.into());
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Assets, crate::mock::new_test_ext(), crate::mock::Test)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user