mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
NFT Fractionalization on AssetHub Kusama (#2769)
* Add nft-fractionalization pallet to AssetHub Kusama * Update Cargo.lock * Update parachains/runtimes/assets/asset-hub-kusama/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Set MaxHolds = 10 * Change MaxHolds back to 1 --------- Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
This commit is contained in:
@@ -57,7 +57,7 @@ use frame_support::{
|
||||
InstanceFilter,
|
||||
},
|
||||
weights::{ConstantMultiplier, Weight},
|
||||
PalletId, RuntimeDebug,
|
||||
BoundedVec, PalletId, RuntimeDebug,
|
||||
};
|
||||
use frame_system::{
|
||||
limits::{BlockLength, BlockWeights},
|
||||
@@ -216,7 +216,9 @@ impl pallet_balances::Config for Runtime {
|
||||
type ReserveIdentifier = [u8; 8];
|
||||
type RuntimeHoldReason = RuntimeHoldReason;
|
||||
type FreezeIdentifier = ();
|
||||
type MaxHolds = ConstU32<0>;
|
||||
// We allow each account to have holds on it from:
|
||||
// - `NftFractionalization`: 1
|
||||
type MaxHolds = ConstU32<1>;
|
||||
type MaxFreezes = ConstU32<0>;
|
||||
}
|
||||
|
||||
@@ -400,6 +402,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
|
||||
c,
|
||||
RuntimeCall::Balances { .. } |
|
||||
RuntimeCall::Assets { .. } |
|
||||
RuntimeCall::NftFractionalization { .. } |
|
||||
RuntimeCall::Nfts { .. } |
|
||||
RuntimeCall::Uniques { .. }
|
||||
),
|
||||
@@ -415,6 +418,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
|
||||
RuntimeCall::Assets { .. } |
|
||||
RuntimeCall::Utility { .. } |
|
||||
RuntimeCall::Multisig { .. } |
|
||||
RuntimeCall::NftFractionalization { .. } |
|
||||
RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. }
|
||||
)
|
||||
},
|
||||
@@ -663,6 +667,32 @@ impl pallet_uniques::Config for Runtime {
|
||||
type Locker = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const NftFractionalizationPalletId: PalletId = PalletId(*b"fraction");
|
||||
pub NewAssetSymbol: BoundedVec<u8, AssetsStringLimit> = (*b"FRAC").to_vec().try_into().unwrap();
|
||||
pub NewAssetName: BoundedVec<u8, AssetsStringLimit> = (*b"Frac").to_vec().try_into().unwrap();
|
||||
}
|
||||
|
||||
impl pallet_nft_fractionalization::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Deposit = AssetDeposit;
|
||||
type Currency = Balances;
|
||||
type NewAssetSymbol = NewAssetSymbol;
|
||||
type NewAssetName = NewAssetName;
|
||||
type StringLimit = AssetsStringLimit;
|
||||
type NftCollectionId = <Self as pallet_nfts::Config>::CollectionId;
|
||||
type NftId = <Self as pallet_nfts::Config>::ItemId;
|
||||
type AssetBalance = <Self as pallet_balances::Config>::Balance;
|
||||
type AssetId = <Self as pallet_assets::Config<TrustBackedAssetsInstance>>::AssetId;
|
||||
type Assets = Assets;
|
||||
type Nfts = Nfts;
|
||||
type PalletId = NftFractionalizationPalletId;
|
||||
type WeightInfo = pallet_nft_fractionalization::weights::SubstrateWeight<Runtime>;
|
||||
type RuntimeHoldReason = RuntimeHoldReason;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub NftsPalletFeatures: PalletFeatures = PalletFeatures::all_enabled();
|
||||
pub const NftsMaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
|
||||
@@ -747,6 +777,7 @@ construct_runtime!(
|
||||
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51,
|
||||
Nfts: pallet_nfts::{Pallet, Call, Storage, Event<T>} = 52,
|
||||
ForeignAssets: pallet_assets::<Instance2>::{Pallet, Call, Storage, Event<T>} = 53,
|
||||
NftFractionalization: pallet_nft_fractionalization::{Pallet, Call, Storage, Event<T>, HoldReason} = 54,
|
||||
|
||||
#[cfg(feature = "state-trie-version-1")]
|
||||
StateTrieMigration: pallet_state_trie_migration = 70,
|
||||
@@ -802,6 +833,7 @@ mod benches {
|
||||
[pallet_assets, Foreign]
|
||||
[pallet_balances, Balances]
|
||||
[pallet_multisig, Multisig]
|
||||
[pallet_nft_fractionalization, NftFractionalization]
|
||||
[pallet_nfts, Nfts]
|
||||
[pallet_proxy, Proxy]
|
||||
[pallet_session, SessionBench::<Runtime>]
|
||||
|
||||
@@ -7,6 +7,7 @@ pub mod pallet_assets_local;
|
||||
pub mod pallet_balances;
|
||||
pub mod pallet_collator_selection;
|
||||
pub mod pallet_multisig;
|
||||
pub mod pallet_nft_fractionalization;
|
||||
pub mod pallet_nfts;
|
||||
pub mod pallet_proxy;
|
||||
pub mod pallet_session;
|
||||
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
// Copyright Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_nft_fractionalization`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2023-05-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-kusama-dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./artifacts/polkadot-parachain
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=asset-hub-kusama-dev
|
||||
// --execution=wasm
|
||||
// --wasm-execution=compiled
|
||||
// --pallet=pallet_nft_fractionalization
|
||||
// --extrinsic=*
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --json
|
||||
// --header=./file_header.txt
|
||||
// --output=./parachains/runtimes/assets/asset-hub-kusama/src/weights/pallet_nft_fractionalization.rs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use frame_support::{traits::Get, weights::Weight};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions for `pallet_nft_fractionalization`.
|
||||
pub struct WeightInfo<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> pallet_nft_fractionalization::WeightInfo for WeightInfo<T> {
|
||||
/// Storage: Nfts Item (r:1 w:0)
|
||||
/// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen)
|
||||
/// Storage: Balances Holds (r:1 w:1)
|
||||
/// Proof: Balances Holds (max_values: None, max_size: Some(66), added: 2541, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts Collection (r:1 w:1)
|
||||
/// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts Attribute (r:1 w:1)
|
||||
/// Proof: Nfts Attribute (max_values: None, max_size: Some(479), added: 2954, mode: MaxEncodedLen)
|
||||
/// Storage: Assets Asset (r:1 w:1)
|
||||
/// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen)
|
||||
/// Storage: Assets Account (r:1 w:1)
|
||||
/// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen)
|
||||
/// Storage: System Account (r:1 w:1)
|
||||
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
|
||||
/// Storage: Assets Metadata (r:1 w:1)
|
||||
/// Proof: Assets Metadata (max_values: None, max_size: Some(140), added: 2615, mode: MaxEncodedLen)
|
||||
/// Storage: NftFractionalization NftToAsset (r:0 w:1)
|
||||
/// Proof: NftFractionalization NftToAsset (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen)
|
||||
fn fractionalize() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `462`
|
||||
// Estimated: `4326`
|
||||
// Minimum execution time: 167_532_000 picoseconds.
|
||||
Weight::from_parts(168_850_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 4326))
|
||||
.saturating_add(T::DbWeight::get().reads(8))
|
||||
.saturating_add(T::DbWeight::get().writes(8))
|
||||
}
|
||||
/// Storage: NftFractionalization NftToAsset (r:1 w:1)
|
||||
/// Proof: NftFractionalization NftToAsset (max_values: None, max_size: Some(92), added: 2567, mode: MaxEncodedLen)
|
||||
/// Storage: Assets Asset (r:1 w:1)
|
||||
/// Proof: Assets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen)
|
||||
/// Storage: Assets Account (r:1 w:1)
|
||||
/// Proof: Assets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts Attribute (r:1 w:1)
|
||||
/// Proof: Nfts Attribute (max_values: None, max_size: Some(479), added: 2954, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts Collection (r:1 w:1)
|
||||
/// Proof: Nfts Collection (max_values: None, max_size: Some(84), added: 2559, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts CollectionConfigOf (r:1 w:0)
|
||||
/// Proof: Nfts CollectionConfigOf (max_values: None, max_size: Some(73), added: 2548, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts ItemConfigOf (r:1 w:0)
|
||||
/// Proof: Nfts ItemConfigOf (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts Item (r:1 w:1)
|
||||
/// Proof: Nfts Item (max_values: None, max_size: Some(861), added: 3336, mode: MaxEncodedLen)
|
||||
/// Storage: Balances Holds (r:1 w:1)
|
||||
/// Proof: Balances Holds (max_values: None, max_size: Some(66), added: 2541, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts Account (r:0 w:1)
|
||||
/// Proof: Nfts Account (max_values: None, max_size: Some(88), added: 2563, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts ItemPriceOf (r:0 w:1)
|
||||
/// Proof: Nfts ItemPriceOf (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
|
||||
/// Storage: Nfts PendingSwapOf (r:0 w:1)
|
||||
/// Proof: Nfts PendingSwapOf (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen)
|
||||
fn unify() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `1274`
|
||||
// Estimated: `4326`
|
||||
// Minimum execution time: 122_877_000 picoseconds.
|
||||
Weight::from_parts(124_095_000, 0)
|
||||
.saturating_add(Weight::from_parts(0, 4326))
|
||||
.saturating_add(T::DbWeight::get().reads(9))
|
||||
.saturating_add(T::DbWeight::get().writes(10))
|
||||
}
|
||||
}
|
||||
@@ -274,6 +274,9 @@ impl Contains<RuntimeCall> for SafeCallFilter {
|
||||
pallet_assets::Call::transfer_approved { .. } |
|
||||
pallet_assets::Call::touch { .. } |
|
||||
pallet_assets::Call::refund { .. },
|
||||
) | RuntimeCall::NftFractionalization(
|
||||
pallet_nft_fractionalization::Call::fractionalize { .. } |
|
||||
pallet_nft_fractionalization::Call::unify { .. },
|
||||
) | RuntimeCall::Nfts(
|
||||
pallet_nfts::Call::create { .. } |
|
||||
pallet_nfts::Call::force_create { .. } |
|
||||
|
||||
Reference in New Issue
Block a user