NFT Fractionalization on Westmint (#2600)

* NFT Fractionalization on Westmint

* Typos

* One more typo

* Undo Cargo.lock

* Point to master

* Referense the first instance of the assets pallet

* Update cargo.lock

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Jegor Sidorenko
2023-05-23 13:04:44 +02:00
committed by GitHub
parent 4023f519b6
commit 93b30fe8d8
6 changed files with 149 additions and 19 deletions
+33 -15
View File
@@ -6707,7 +6707,7 @@ dependencies = [
[[package]]
name = "pallet-alliance"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"array-bytes 4.2.0",
"frame-benchmarking",
@@ -6728,7 +6728,7 @@ dependencies = [
[[package]]
name = "pallet-asset-tx-payment"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -6746,7 +6746,7 @@ dependencies = [
[[package]]
name = "pallet-assets"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -6761,7 +6761,7 @@ dependencies = [
[[package]]
name = "pallet-aura"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"frame-support",
"frame-system",
@@ -7076,7 +7076,7 @@ dependencies = [
[[package]]
name = "pallet-contracts"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"bitflags",
"environmental",
@@ -7106,7 +7106,7 @@ dependencies = [
[[package]]
name = "pallet-contracts-primitives"
version = "7.0.0"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"bitflags",
"parity-scale-codec",
@@ -7119,7 +7119,7 @@ dependencies = [
[[package]]
name = "pallet-contracts-proc-macro"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"proc-macro2",
"quote",
@@ -7236,7 +7236,7 @@ dependencies = [
[[package]]
name = "pallet-glutton"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"blake2",
"frame-benchmarking",
@@ -7330,7 +7330,7 @@ dependencies = [
[[package]]
name = "pallet-insecure-randomness-collective-flip"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"frame-support",
"frame-system",
@@ -7410,10 +7410,27 @@ dependencies = [
"sp-std",
]
[[package]]
name = "pallet-nft-fractionalization"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"frame-benchmarking",
"frame-support",
"frame-system",
"log",
"pallet-assets",
"pallet-nfts",
"parity-scale-codec",
"scale-info",
"sp-runtime",
"sp-std",
]
[[package]]
name = "pallet-nfts"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"enumflags2",
"frame-benchmarking",
@@ -7431,7 +7448,7 @@ dependencies = [
[[package]]
name = "pallet-nfts-runtime-api"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"frame-support",
"pallet-nfts",
@@ -7896,7 +7913,7 @@ dependencies = [
[[package]]
name = "pallet-uniques"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"frame-benchmarking",
"frame-support",
@@ -11300,7 +11317,7 @@ dependencies = [
[[package]]
name = "sc-consensus-aura"
version = "0.10.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"async-trait",
"futures",
@@ -13924,7 +13941,7 @@ dependencies = [
[[package]]
name = "substrate-test-utils"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"futures",
"substrate-test-utils-derive",
@@ -13934,7 +13951,7 @@ dependencies = [
[[package]]
name = "substrate-test-utils-derive"
version = "0.10.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=master#784ac7e9cf42a88cf5ad105281633f705688bae9"
source = "git+https://github.com/paritytech/substrate?branch=master#bc3ce835964347166414203d68dccc26b9e9044f"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -15678,6 +15695,7 @@ dependencies = [
"pallet-balances",
"pallet-collator-selection",
"pallet-multisig",
"pallet-nft-fractionalization",
"pallet-nfts",
"pallet-nfts-runtime-api",
"pallet-proxy",
@@ -26,6 +26,7 @@ pallet-aura = { git = "https://github.com/paritytech/substrate", default-feature
pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-nft-fractionalization = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-nfts = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-nfts-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
pallet-proxy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
@@ -91,6 +92,7 @@ runtime-benchmarks = [
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-nft-fractionalization/runtime-benchmarks",
"pallet-nfts/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
@@ -121,6 +123,7 @@ try-runtime = [
"pallet-balances/try-runtime",
"pallet-collator-selection/try-runtime",
"pallet-multisig/try-runtime",
"pallet-nft-fractionalization/try-runtime",
"pallet-nfts/try-runtime",
"pallet-proxy/try-runtime",
"pallet-session/try-runtime",
@@ -145,6 +148,7 @@ std = [
"pallet-authorship/std",
"pallet-balances/std",
"pallet-multisig/std",
"pallet-nft-fractionalization/std",
"pallet-nfts/std",
"pallet-nfts-runtime-api/std",
"pallet-proxy/std",
@@ -54,7 +54,7 @@ use frame_support::{
InstanceFilter,
},
weights::{ConstantMultiplier, Weight},
PalletId, RuntimeDebug,
BoundedVec, PalletId, RuntimeDebug,
};
use frame_system::{
limits::{BlockLength, BlockWeights},
@@ -68,6 +68,7 @@ use parachains_common::{
Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT,
NORMAL_DISPATCH_RATIO, SLOT_DURATION,
};
use scale_info::TypeInfo;
use xcm_config::{
ForeignAssetsConvertedConcreteId, TrustBackedAssetsConvertedConcreteId, WestendLocation,
XcmConfig, XcmOriginToTransactDispatchOrigin,
@@ -179,6 +180,15 @@ parameter_types! {
pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
}
/// A reason for placing a hold on funds.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo,
)]
pub enum HoldReason {
/// Used by the NFT Fractionalization Pallet.
NftFractionalization,
}
impl pallet_balances::Config for Runtime {
type MaxLocks = ConstU32<50>;
/// The type for recording an account's balance.
@@ -191,9 +201,9 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type HoldIdentifier = HoldReason;
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<0>;
}
@@ -376,6 +386,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
c,
RuntimeCall::Balances { .. } |
RuntimeCall::Assets { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } |
RuntimeCall::Uniques { .. }
),
@@ -391,6 +402,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Assets { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. } |
RuntimeCall::NftFractionalization { .. } |
RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. }
)
},
@@ -624,6 +636,33 @@ 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();
pub const NftFractionalizationHoldReason: HoldReason = HoldReason::NftFractionalization;
}
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 HoldReason = NftFractionalizationHoldReason;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}
parameter_types! {
pub NftsPalletFeatures: PalletFeatures = PalletFeatures::all_enabled();
pub const NftsMaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
@@ -708,6 +747,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>} = 54,
}
);
@@ -736,7 +776,7 @@ pub type UncheckedExtrinsic =
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
/// Migrations to apply on runtime upgrade.
pub type Migrations = (pallet_nfts::migration::v1::MigrateToV1<Runtime>,);
pub type Migrations = ();
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
@@ -760,6 +800,7 @@ mod benches {
[pallet_assets, ForeignAssets]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
[pallet_nft_fractionalization, NftFractionalization]
[pallet_nfts, Nfts]
[pallet_proxy, Proxy]
[pallet_session, SessionBench::<Runtime>]
@@ -6,6 +6,7 @@ pub mod pallet_assets;
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;
@@ -0,0 +1,63 @@
// 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_nfts`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-05-05, 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("westmint-dev"), DB CACHE: 1024
// Executed Command:
// ./artifacts/polkadot-parachain
// benchmark
// pallet
// --chain=westmint-dev
// --execution=wasm
// --wasm-execution=compiled
// --pallet=pallet_nft_fractionalization
// --extrinsic=*
// --steps=50
// --repeat=20
// --json
// --header=./file_header.txt
// --output=./parachains/runtimes/assets/westmint/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_nfts`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_nft_fractionalization::WeightInfo for WeightInfo<T> {
fn fractionalize() -> Weight {
// Minimum execution time: 44_312 nanoseconds.
Weight::from_parts(25_147_000, 3549)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
fn unify() -> Weight {
// Minimum execution time: 31_654 nanoseconds.
Weight::from_parts(25_147_000, 3549)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
}
@@ -271,6 +271,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 { .. } |