Remove the Copy bound on AssetId (#14158)

* Remove the `Copy` bound on `AssetId`

* Also relax the `Copy` bound in the assets pallet

* Fix warnings on the newest nightly Rust

* Remove some unnecessary `clone()`s

* Try to satisfy clippy

* Remove some more unnecessary `clone()`s

* Add more `.clone()`s for newly merged code

* Also add `clone()`s in the benchmarks

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Koute
2023-05-23 20:34:04 +09:00
committed by GitHub
parent 06865d4c08
commit 194c9edd4a
13 changed files with 223 additions and 187 deletions
@@ -93,7 +93,7 @@ benchmarks! {
let collection = T::BenchmarkHelper::collection(0);
let nft = T::BenchmarkHelper::nft(0);
let (caller, caller_lookup) = mint_nft::<T>(nft);
}: _(SystemOrigin::Signed(caller.clone()), collection, nft, asset, caller_lookup, 1000u32.into())
}: _(SystemOrigin::Signed(caller.clone()), collection, nft, asset.clone(), caller_lookup, 1000u32.into())
verify {
assert_last_event::<T>(
Event::NftFractionalized {
@@ -115,11 +115,11 @@ benchmarks! {
SystemOrigin::Signed(caller.clone()).into(),
collection,
nft,
asset,
asset.clone(),
caller_lookup.clone(),
1000u32.into(),
)?;
}: _(SystemOrigin::Signed(caller.clone()), collection, nft, asset, caller_lookup)
}: _(SystemOrigin::Signed(caller.clone()), collection, nft, asset.clone(), caller_lookup)
verify {
assert_last_event::<T>(
Event::NftUnified {
@@ -241,13 +241,19 @@ pub mod pallet {
let deposit = T::Deposit::get();
T::Currency::hold(&T::HoldReason::get(), &nft_owner, deposit)?;
Self::do_lock_nft(nft_collection_id, nft_id)?;
Self::do_create_asset(asset_id, pallet_account.clone())?;
Self::do_mint_asset(asset_id, &beneficiary, fractions)?;
Self::do_set_metadata(asset_id, &who, &pallet_account, &nft_collection_id, &nft_id)?;
Self::do_create_asset(asset_id.clone(), pallet_account.clone())?;
Self::do_mint_asset(asset_id.clone(), &beneficiary, fractions)?;
Self::do_set_metadata(
asset_id.clone(),
&who,
&pallet_account,
&nft_collection_id,
&nft_id,
)?;
NftToAsset::<T>::insert(
(nft_collection_id, nft_id),
Details { asset: asset_id, fractions, asset_creator: nft_owner, deposit },
Details { asset: asset_id.clone(), fractions, asset_creator: nft_owner, deposit },
);
Self::deposit_event(Event::NftFractionalized {
@@ -295,7 +301,7 @@ pub mod pallet {
let deposit = details.deposit;
let asset_creator = details.asset_creator;
Self::do_burn_asset(asset_id, &who, details.fractions)?;
Self::do_burn_asset(asset_id.clone(), &who, details.fractions)?;
Self::do_unlock_nft(nft_collection_id, nft_id, &beneficiary)?;
T::Currency::release(&T::HoldReason::get(), &asset_creator, deposit, BestEffort)?;
@@ -356,7 +362,7 @@ pub mod pallet {
account: &T::AccountId,
amount: AssetBalanceOf<T>,
) -> DispatchResult {
T::Assets::burn_from(asset_id, account, amount, Exact, Polite)?;
T::Assets::burn_from(asset_id.clone(), account, amount, Exact, Polite)?;
T::Assets::start_destroy(asset_id, None)
}