difftreelog
feat createMultipleItemsEx call
in: master
16 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -17,7 +17,7 @@
TokenId, Weight, WithdrawReasons, CollectionStats, MAX_TOKEN_OWNERSHIP, CollectionMode,
NFT_SPONSOR_TRANSFER_TIMEOUT, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MAX_SPONSOR_TIMEOUT, CUSTOM_DATA_LIMIT, CollectionLimits,
- CustomDataLimit, CreateCollectionData, SponsorshipState,
+ CustomDataLimit, CreateCollectionData, SponsorshipState, CreateItemExData,
};
pub use pallet::*;
use sp_core::H160;
@@ -624,9 +624,10 @@
}
/// Worst cases
-pub trait CommonWeightInfo {
+pub trait CommonWeightInfo<CrossAccountId> {
fn create_item() -> Weight;
fn create_multiple_items(amount: u32) -> Weight;
+ fn create_multiple_items_ex(cost: &CreateItemExData<CrossAccountId>) -> Weight;
fn burn_item() -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
@@ -648,6 +649,11 @@
to: T::CrossAccountId,
data: Vec<CreateItemData>,
) -> DispatchResultWithPostInfo;
+ fn create_multiple_items_ex(
+ &self,
+ sender: T::CrossAccountId,
+ data: CreateItemExData<T::CrossAccountId>,
+ ) -> DispatchResultWithPostInfo;
fn burn_item(
&self,
sender: T::CrossAccountId,
pallets/fungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -4,7 +4,7 @@
use sp_std::prelude::*;
use pallet_common::benchmarking::create_collection_raw;
use frame_benchmarking::{benchmarks, account};
-use up_data_structs::{CollectionMode};
+use up_data_structs::{CollectionMode, MAX_ITEMS_PER_BATCH};
use pallet_common::bench_init;
const SEED: u32 = 1;
@@ -26,6 +26,18 @@
};
}: {<Pallet<T>>::create_item(&collection, &sender, (to, 200))?}
+ create_multiple_items_ex {
+ let b in 0..MAX_ITEMS_PER_BATCH;
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ sender: cross_from_sub(owner);
+ };
+ let data = (0..b).map(|i| {
+ bench_init!(to: cross_sub(i););
+ (to, 200)
+ }).collect::<BTreeMap<_, _>>().try_into().unwrap();
+ }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)}
+
burn_item {
bench_init!{
owner: sub; collection: collection(owner);
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -1,7 +1,7 @@
use core::marker::PhantomData;
use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, BoundedVec};
-use up_data_structs::TokenId;
+use up_data_structs::{TokenId, CreateItemExData};
use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
use sp_runtime::ArithmeticError;
use sp_std::{vec::Vec, vec};
@@ -21,6 +21,15 @@
Self::create_item()
}
+ fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
+ match data {
+ CreateItemExData::Fungible(f) => {
+ <SelfWeightOf<T>>::create_multiple_items_ex(f.len() as u32)
+ }
+ _ => 0,
+ }
+ }
+
fn burn_item() -> Weight {
<SelfWeightOf<T>>::burn_item()
}
@@ -87,6 +96,23 @@
)
}
+ fn create_multiple_items_ex(
+ &self,
+ sender: <T>::CrossAccountId,
+ data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,
+ ) -> DispatchResultWithPostInfo {
+ let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);
+ let data = match data {
+ up_data_structs::CreateItemExData::Fungible(f) => f,
+ _ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),
+ };
+
+ with_weight(
+ <Pallet<T>>::create_multiple_items(self, &sender, data.into_inner()),
+ weight,
+ )
+ }
+
fn burn_item(
&self,
sender: T::CrossAccountId,
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -392,6 +392,6 @@
sender: &T::CrossAccountId,
data: CreateItemData<T>,
) -> DispatchResult {
- Self::create_multiple_items(collection, sender, vec![data])
+ Self::create_multiple_items(collection, sender, [(data.0, data.1)].into_iter().collect())
}
}
pallets/fungible/src/weights.rsdiffbeforeafterboth--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -33,6 +33,7 @@
/// Weight functions needed for pallet_fungible.
pub trait WeightInfo {
fn create_item() -> Weight;
+ fn create_multiple_items_ex(b: u32, ) -> Weight;
fn burn_item() -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
@@ -51,6 +52,17 @@
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: Fungible TotalSupply (r:1 w:1)
+ // Storage: Fungible Balance (r:4 w:4)
+ fn create_multiple_items_ex(b: u32, ) -> Weight {
+ (1_055_000 as Weight)
+ // Standard Error: 22_000
+ .saturating_add((5_273_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(T::DbWeight::get().reads(1 as Weight))
+ .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
+ .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(b as Weight)))
+ }
+ // Storage: Fungible TotalSupply (r:1 w:1)
// Storage: Fungible Balance (r:1 w:1)
fn burn_item() -> Weight {
(14_096_000 as Weight)
@@ -97,6 +109,17 @@
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
// Storage: Fungible TotalSupply (r:1 w:1)
+ // Storage: Fungible Balance (r:4 w:4)
+ fn create_multiple_items_ex(b: u32, ) -> Weight {
+ (1_055_000 as Weight)
+ // Standard Error: 22_000
+ .saturating_add((5_273_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(RocksDbWeight::get().reads(1 as Weight))
+ .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
+ .saturating_add(RocksDbWeight::get().writes(1 as Weight))
+ .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(b as Weight)))
+ }
+ // Storage: Fungible TotalSupply (r:1 w:1)
// Storage: Fungible Balance (r:1 w:1)
fn burn_item() -> Weight {
(14_096_000 as Weight)
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -56,6 +56,16 @@
let data = (0..b).map(|_| create_max_item_data::<T>(to.clone())).collect();
}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+ create_multiple_items_ex {
+ let b in 0..MAX_ITEMS_PER_BATCH;
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ sender: cross_from_sub(owner);
+ };
+ let data = (0..b).map(|i| {
+ bench_init!(to: cross_sub(i););
+ create_max_item_data::<T>(to)
+ }).collect();
}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
burn_item {
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -1,7 +1,7 @@
use core::marker::PhantomData;
use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight, BoundedVec};
-use up_data_structs::{TokenId, CustomDataLimit};
+use up_data_structs::{TokenId, CustomDataLimit, CreateItemExData};
use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
use sp_runtime::DispatchError;
use sp_std::vec::Vec;
@@ -17,6 +17,13 @@
<SelfWeightOf<T>>::create_item()
}
+ fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
+ match data {
+ CreateItemExData::NFT(t) => <SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32),
+ _ => 0,
+ }
+ }
+
fn create_multiple_items(amount: u32) -> Weight {
<SelfWeightOf<T>>::create_multiple_items(amount)
}
@@ -91,6 +98,23 @@
)
}
+ fn create_multiple_items_ex(
+ &self,
+ sender: <T>::CrossAccountId,
+ data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,
+ ) -> DispatchResultWithPostInfo {
+ let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);
+ let data = match data {
+ up_data_structs::CreateItemExData::NFT(nft) => nft,
+ _ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),
+ };
+
+ with_weight(
+ <Pallet<T>>::create_multiple_items(self, &sender, data.into_inner()),
+ weight,
+ )
+ }
+
fn burn_item(
&self,
sender: T::CrossAccountId,
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -2,7 +2,9 @@
use erc::ERC721Events;
use frame_support::{BoundedVec, ensure};
-use up_data_structs::{AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData};
+use up_data_structs::{
+ AccessMode, CollectionId, CustomDataLimit, TokenId, CreateCollectionData, CreateNftExData,
+};
use pallet_common::{
Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, account::CrossAccountId,
};
@@ -22,11 +24,7 @@
pub mod erc;
pub mod weights;
-pub struct CreateItemData<T: Config> {
- pub const_data: BoundedVec<u8, CustomDataLimit>,
- pub variable_data: BoundedVec<u8, CustomDataLimit>,
- pub owner: T::CrossAccountId,
-}
+pub type CreateItemData<T> = CreateNftExData<<T as pallet_common::Config>::CrossAccountId>;
pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;
#[derive(Encode, Decode, TypeInfo, MaxEncodedLen)]
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -34,6 +34,7 @@
pub trait WeightInfo {
fn create_item() -> Weight;
fn create_multiple_items(b: u32, ) -> Weight;
+ fn create_multiple_items_ex(b: u32, ) -> Weight;
fn burn_item() -> Weight;
fn transfer() -> Weight;
fn approve() -> Weight;
@@ -66,6 +67,19 @@
.saturating_add(T::DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))
}
+ // Storage: Nonfungible TokensMinted (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:4 w:4)
+ // Storage: Nonfungible TokenData (r:0 w:4)
+ // Storage: Nonfungible Owned (r:0 w:4)
+ fn create_multiple_items_ex(b: u32, ) -> Weight {
+ (2_090_000 as Weight)
+ // Standard Error: 10_000
+ .saturating_add((9_230_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(T::DbWeight::get().reads(1 as Weight))
+ .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
+ .saturating_add(T::DbWeight::get().writes(1 as Weight))
+ .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
+ }
// Storage: Nonfungible TokenData (r:1 w:1)
// Storage: Nonfungible TokensBurnt (r:1 w:1)
// Storage: Nonfungible Allowance (r:1 w:0)
@@ -140,6 +154,19 @@
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
.saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(b as Weight)))
}
+ // Storage: Nonfungible TokensMinted (r:1 w:1)
+ // Storage: Nonfungible AccountBalance (r:4 w:4)
+ // Storage: Nonfungible TokenData (r:0 w:4)
+ // Storage: Nonfungible Owned (r:0 w:4)
+ fn create_multiple_items_ex(b: u32, ) -> Weight {
+ (2_090_000 as Weight)
+ // Standard Error: 10_000
+ .saturating_add((9_230_000 as Weight).saturating_mul(b as Weight))
+ .saturating_add(RocksDbWeight::get().reads(1 as Weight))
+ .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))
+ .saturating_add(RocksDbWeight::get().writes(1 as Weight))
+ .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))
+ }
// Storage: Nonfungible TokenData (r:1 w:1)
// Storage: Nonfungible TokensBurnt (r:1 w:1)
// Storage: Nonfungible Allowance (r:1 w:0)
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -31,7 +31,8 @@
sender: &T::CrossAccountId,
users: impl IntoIterator<Item = (T::CrossAccountId, u128)>,
) -> Result<TokenId, DispatchError> {
- <Pallet<T>>::create_item(&collection, sender, create_max_item_data(users))?;
+ let data: CreateRefungibleExData<T::CrossAccountId> = create_max_item_data(users);
+ <Pallet<T>>::create_item(&collection, sender, data)?;
Ok(TokenId(<TokensMinted<T>>::get(&collection.id)))
}
@@ -60,6 +61,30 @@
let data = (0..b).map(|_| create_max_item_data([(to.clone(), 200)])).collect();
}: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+ create_multiple_items_ex_multiple_items {
+ let b in 0..MAX_ITEMS_PER_BATCH;
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ sender: cross_from_sub(owner);
+ };
+ let data = (0..b).map(|t| {
+ bench_init!(to: cross_sub(t););
+ create_max_item_data([(to, 200)])
+ }).collect();
+ }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+
+ create_multiple_items_ex_multiple_owners {
+ let b in 0..MAX_ITEMS_PER_BATCH;
+ bench_init!{
+ owner: sub; collection: collection(owner);
+ sender: cross_from_sub(owner);
+ };
+ let data = vec![create_max_item_data((0..b).map(|u| {
+ bench_init!(to: cross_sub(u););
+ (to, 200)
+ }))].try_into().unwrap();
+ }: {<Pallet<T>>::create_multiple_items(&collection, &sender, data)?}
+
// Other user left, token data is kept
burn_item_partial {
bench_init!{
@@ -170,6 +195,6 @@
sender: cross_from_sub(owner);
};
let item = create_max_item(&collection, &sender, [(sender.clone(), 200)])?;
- let data = create_data(b as usize);
+ let data = create_var_data(b).try_into().unwrap();
}: {<Pallet<T>>::set_variable_metadata(&collection, &sender, item, data)?}
}
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -2,10 +2,10 @@
use sp_std::collections::btree_map::BTreeMap;
use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight, BoundedVec};
-use up_data_structs::{TokenId, CustomDataLimit};
+use up_data_structs::{TokenId, CustomDataLimit, CreateItemExData, CreateRefungibleExData};
use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
use sp_runtime::DispatchError;
-use sp_std::vec::Vec;
+use sp_std::{vec::Vec, vec};
use crate::{
AccountBalance, Allowance, Balance, Config, Error, Owned, Pallet, RefungibleHandle,
@@ -31,6 +31,18 @@
<SelfWeightOf<T>>::create_multiple_items(amount)
}
+ fn create_multiple_items_ex(call: &CreateItemExData<T::CrossAccountId>) -> Weight {
+ match call {
+ CreateItemExData::RefungibleMultipleOwners(i) => {
+ <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32)
+ }
+ CreateItemExData::RefungibleMultipleItems(i) => {
+ <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32)
+ }
+ _ => 0,
+ }
+ }
+
fn burn_item() -> Weight {
max_weight_of!(burn_item_partial(), burn_item_fully())
}
@@ -69,15 +81,15 @@
fn map_create_data<T: Config>(
data: up_data_structs::CreateItemData,
to: &T::CrossAccountId,
-) -> Result<CreateItemData<T>, DispatchError> {
+) -> Result<CreateRefungibleExData<T::CrossAccountId>, DispatchError> {
match data {
- up_data_structs::CreateItemData::ReFungible(data) => Ok(CreateItemData {
+ up_data_structs::CreateItemData::ReFungible(data) => Ok(CreateRefungibleExData {
const_data: data.const_data,
variable_data: data.variable_data,
users: {
let mut out = BTreeMap::new();
out.insert(to.clone(), data.pieces);
- out
+ out.try_into().expect("limit > 0")
},
}),
_ => fail!(<Error<T>>::NotRefungibleDataUsedToMintFungibleCollectionToken),
@@ -92,7 +104,7 @@
data: up_data_structs::CreateItemData,
) -> DispatchResultWithPostInfo {
with_weight(
- <Pallet<T>>::create_item(self, &sender, map_create_data(data, &to)?),
+ <Pallet<T>>::create_item(self, &sender, map_create_data::<T>(data, &to)?),
<CommonWeights<T>>::create_item(),
)
}
@@ -115,6 +127,28 @@
)
}
+ fn create_multiple_items_ex(
+ &self,
+ sender: <T>::CrossAccountId,
+ data: CreateItemExData<T::CrossAccountId>,
+ ) -> DispatchResultWithPostInfo {
+ let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);
+ let data = match data {
+ CreateItemExData::RefungibleMultipleOwners(r) => vec![r],
+ CreateItemExData::RefungibleMultipleItems(r)
+ if r.iter().all(|i| i.users.len() == 1) =>
+ {
+ r.into_inner()
+ }
+ _ => fail!(<Error<T>>::NotRefungibleDataUsedToMintFungibleCollectionToken),
+ };
+
+ with_weight(
+ <Pallet<T>>::create_multiple_items(self, &sender, data),
+ weight,
+ )
+ }
+
fn burn_item(
&self,
sender: T::CrossAccountId,
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -2,7 +2,8 @@
use frame_support::{ensure, BoundedVec};
use up_data_structs::{
- AccessMode, CollectionId, CustomDataLimit, MAX_REFUNGIBLE_PIECES, TokenId, CreateCollectionData,
+ AccessMode, CollectionId, CustomDataLimit, MAX_REFUNGIBLE_PIECES, TokenId,
+ CreateCollectionData, CreateRefungibleExData,
};
use pallet_common::{
Error as CommonError, Event as CommonEvent, Pallet as PalletCommon, account::CrossAccountId,
@@ -19,11 +20,6 @@
pub mod common;
pub mod erc;
pub mod weights;
-pub struct CreateItemData<T: Config> {
- pub const_data: BoundedVec<u8, CustomDataLimit>,
- pub variable_data: BoundedVec<u8, CustomDataLimit>,
- pub users: BTreeMap<T::CrossAccountId, u128>,
-}
pub(crate) type SelfWeightOf<T> = <T as Config>::WeightInfo;
#[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen)]
@@ -361,7 +357,7 @@
pub fn create_multiple_items(
collection: &RefungibleHandle<T>,
sender: &T::CrossAccountId,
- data: Vec<CreateItemData<T>>,
+ data: Vec<CreateRefungibleExData<T::CrossAccountId>>,
) -> DispatchResult {
if !collection.is_owner_or_admin(sender) {
ensure!(
@@ -606,7 +602,7 @@
pub fn create_item(
collection: &RefungibleHandle<T>,
sender: &T::CrossAccountId,
- data: CreateItemData<T>,
+ data: CreateRefungibleExData<T::CrossAccountId>,
) -> DispatchResult {
Self::create_multiple_items(collection, sender, vec![data])
}
pallets/refungible/src/weights.rsdiffbeforeafterboth1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_refungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2021-10-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 12889// Executed Command:10// target/release/unique-collator11// benchmark12// --pallet13// pallet-refungible14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=2022// --output=./pallets/refungible/src/weights.rs232425#![cfg_attr(rustfmt, rustfmt_skip)]26#![allow(unused_parens)]27#![allow(unused_imports)]28#![allow(clippy::unnecessary_cast)]2930use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};31use sp_std::marker::PhantomData;3233/// Weight functions needed for pallet_refungible.34pub trait WeightInfo {35 fn create_item() -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;37 fn burn_item_partial() -> Weight;38 fn burn_item_fully() -> Weight;39 fn transfer_normal() -> Weight;40 fn transfer_creating() -> Weight;41 fn transfer_removing() -> Weight;42 fn transfer_creating_removing() -> Weight;43 fn approve() -> Weight;44 fn transfer_from_normal() -> Weight;45 fn transfer_from_creating() -> Weight;46 fn transfer_from_removing() -> Weight;47 fn transfer_from_creating_removing() -> Weight;48 fn burn_from() -> Weight;49 fn set_variable_metadata(b: u32, ) -> Weight;50}5152/// Weights for pallet_refungible using the Substrate node and recommended hardware.53pub struct SubstrateWeight<T>(PhantomData<T>);54impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {55 // Storage: Refungible TokensMinted (r:1 w:1)56 // Storage: Refungible AccountBalance (r:1 w:1)57 // Storage: Refungible Balance (r:0 w:1)58 // Storage: Refungible TotalSupply (r:0 w:1)59 // Storage: Refungible TokenData (r:0 w:1)60 // Storage: Refungible Owned (r:0 w:1)61 fn create_item() -> Weight {62 (18_681_000 as Weight)63 .saturating_add(T::DbWeight::get().reads(2 as Weight))64 .saturating_add(T::DbWeight::get().writes(6 as Weight))65 }66 // Storage: Refungible TokensMinted (r:1 w:1)67 // Storage: Refungible AccountBalance (r:1 w:1)68 // Storage: Refungible Balance (r:0 w:4)69 // Storage: Refungible TotalSupply (r:0 w:4)70 // Storage: Refungible TokenData (r:0 w:4)71 // Storage: Refungible Owned (r:0 w:4)72 fn create_multiple_items(b: u32, ) -> Weight {73 (13_869_000 as Weight)74 // Standard Error: 28_00075 .saturating_add((5_611_000 as Weight).saturating_mul(b as Weight))76 .saturating_add(T::DbWeight::get().reads(2 as Weight))77 .saturating_add(T::DbWeight::get().writes(2 as Weight))78 .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))79 }80 // Storage: Refungible TotalSupply (r:1 w:1)81 // Storage: Refungible Balance (r:1 w:1)82 // Storage: Refungible AccountBalance (r:1 w:1)83 // Storage: Refungible Owned (r:0 w:1)84 fn burn_item_partial() -> Weight {85 (21_591_000 as Weight)86 .saturating_add(T::DbWeight::get().reads(3 as Weight))87 .saturating_add(T::DbWeight::get().writes(4 as Weight))88 }89 // Storage: Refungible TotalSupply (r:1 w:1)90 // Storage: Refungible Balance (r:1 w:1)91 // Storage: Refungible AccountBalance (r:1 w:1)92 // Storage: Refungible TokensBurnt (r:1 w:1)93 // Storage: Refungible TokenData (r:0 w:1)94 // Storage: Refungible Owned (r:0 w:1)95 fn burn_item_fully() -> Weight {96 (29_257_000 as Weight)97 .saturating_add(T::DbWeight::get().reads(4 as Weight))98 .saturating_add(T::DbWeight::get().writes(6 as Weight))99 }100 // Storage: Refungible Balance (r:2 w:2)101 fn transfer_normal() -> Weight {102 (17_733_000 as Weight)103 .saturating_add(T::DbWeight::get().reads(2 as Weight))104 .saturating_add(T::DbWeight::get().writes(2 as Weight))105 }106 // Storage: Refungible Balance (r:2 w:2)107 // Storage: Refungible AccountBalance (r:1 w:1)108 // Storage: Refungible Owned (r:0 w:1)109 fn transfer_creating() -> Weight {110 (20_943_000 as Weight)111 .saturating_add(T::DbWeight::get().reads(3 as Weight))112 .saturating_add(T::DbWeight::get().writes(4 as Weight))113 }114 // Storage: Refungible Balance (r:2 w:2)115 // Storage: Refungible AccountBalance (r:1 w:1)116 // Storage: Refungible Owned (r:0 w:1)117 fn transfer_removing() -> Weight {118 (22_406_000 as Weight)119 .saturating_add(T::DbWeight::get().reads(3 as Weight))120 .saturating_add(T::DbWeight::get().writes(4 as Weight))121 }122 // Storage: Refungible Balance (r:2 w:2)123 // Storage: Refungible AccountBalance (r:2 w:2)124 // Storage: Refungible Owned (r:0 w:2)125 fn transfer_creating_removing() -> Weight {126 (24_762_000 as Weight)127 .saturating_add(T::DbWeight::get().reads(4 as Weight))128 .saturating_add(T::DbWeight::get().writes(6 as Weight))129 }130 // Storage: Refungible Balance (r:1 w:0)131 // Storage: Refungible Allowance (r:0 w:1)132 fn approve() -> Weight {133 (14_109_000 as Weight)134 .saturating_add(T::DbWeight::get().reads(1 as Weight))135 .saturating_add(T::DbWeight::get().writes(1 as Weight))136 }137 // Storage: Refungible Allowance (r:1 w:1)138 // Storage: Refungible Balance (r:2 w:2)139 fn transfer_from_normal() -> Weight {140 (25_348_000 as Weight)141 .saturating_add(T::DbWeight::get().reads(3 as Weight))142 .saturating_add(T::DbWeight::get().writes(3 as Weight))143 }144 // Storage: Refungible Allowance (r:1 w:1)145 // Storage: Refungible Balance (r:2 w:2)146 // Storage: Refungible AccountBalance (r:1 w:1)147 // Storage: Refungible Owned (r:0 w:1)148 fn transfer_from_creating() -> Weight {149 (28_647_000 as Weight)150 .saturating_add(T::DbWeight::get().reads(4 as Weight))151 .saturating_add(T::DbWeight::get().writes(5 as Weight))152 }153 // Storage: Refungible Allowance (r:1 w:1)154 // Storage: Refungible Balance (r:2 w:2)155 // Storage: Refungible AccountBalance (r:1 w:1)156 // Storage: Refungible Owned (r:0 w:1)157 fn transfer_from_removing() -> Weight {158 (30_472_000 as Weight)159 .saturating_add(T::DbWeight::get().reads(4 as Weight))160 .saturating_add(T::DbWeight::get().writes(5 as Weight))161 }162 // Storage: Refungible Allowance (r:1 w:1)163 // Storage: Refungible Balance (r:2 w:2)164 // Storage: Refungible AccountBalance (r:2 w:2)165 // Storage: Refungible Owned (r:0 w:2)166 fn transfer_from_creating_removing() -> Weight {167 (32_362_000 as Weight)168 .saturating_add(T::DbWeight::get().reads(5 as Weight))169 .saturating_add(T::DbWeight::get().writes(7 as Weight))170 }171 // Storage: Refungible Allowance (r:1 w:1)172 // Storage: Refungible TotalSupply (r:1 w:1)173 // Storage: Refungible Balance (r:1 w:1)174 // Storage: Refungible AccountBalance (r:1 w:1)175 // Storage: Refungible TokensBurnt (r:1 w:1)176 // Storage: Refungible TokenData (r:0 w:1)177 // Storage: Refungible Owned (r:0 w:1)178 fn burn_from() -> Weight {179 (60_903_000 as Weight)180 .saturating_add(T::DbWeight::get().reads(5 as Weight))181 .saturating_add(T::DbWeight::get().writes(7 as Weight))182 }183 // Storage: Refungible TokenData (r:1 w:1)184 fn set_variable_metadata(_b: u32, ) -> Weight {185 (6_801_000 as Weight)186 .saturating_add(T::DbWeight::get().reads(1 as Weight))187 .saturating_add(T::DbWeight::get().writes(1 as Weight))188 }189}190191// For backwards compatibility and tests192impl WeightInfo for () {193 // Storage: Refungible TokensMinted (r:1 w:1)194 // Storage: Refungible AccountBalance (r:1 w:1)195 // Storage: Refungible Balance (r:0 w:1)196 // Storage: Refungible TotalSupply (r:0 w:1)197 // Storage: Refungible TokenData (r:0 w:1)198 // Storage: Refungible Owned (r:0 w:1)199 fn create_item() -> Weight {200 (18_681_000 as Weight)201 .saturating_add(RocksDbWeight::get().reads(2 as Weight))202 .saturating_add(RocksDbWeight::get().writes(6 as Weight))203 }204 // Storage: Refungible TokensMinted (r:1 w:1)205 // Storage: Refungible AccountBalance (r:1 w:1)206 // Storage: Refungible Balance (r:0 w:4)207 // Storage: Refungible TotalSupply (r:0 w:4)208 // Storage: Refungible TokenData (r:0 w:4)209 // Storage: Refungible Owned (r:0 w:4)210 fn create_multiple_items(b: u32, ) -> Weight {211 (13_869_000 as Weight)212 // Standard Error: 28_000213 .saturating_add((5_611_000 as Weight).saturating_mul(b as Weight))214 .saturating_add(RocksDbWeight::get().reads(2 as Weight))215 .saturating_add(RocksDbWeight::get().writes(2 as Weight))216 .saturating_add(RocksDbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))217 }218 // Storage: Refungible TotalSupply (r:1 w:1)219 // Storage: Refungible Balance (r:1 w:1)220 // Storage: Refungible AccountBalance (r:1 w:1)221 // Storage: Refungible Owned (r:0 w:1)222 fn burn_item_partial() -> Weight {223 (21_591_000 as Weight)224 .saturating_add(RocksDbWeight::get().reads(3 as Weight))225 .saturating_add(RocksDbWeight::get().writes(4 as Weight))226 }227 // Storage: Refungible TotalSupply (r:1 w:1)228 // Storage: Refungible Balance (r:1 w:1)229 // Storage: Refungible AccountBalance (r:1 w:1)230 // Storage: Refungible TokensBurnt (r:1 w:1)231 // Storage: Refungible TokenData (r:0 w:1)232 // Storage: Refungible Owned (r:0 w:1)233 fn burn_item_fully() -> Weight {234 (29_257_000 as Weight)235 .saturating_add(RocksDbWeight::get().reads(4 as Weight))236 .saturating_add(RocksDbWeight::get().writes(6 as Weight))237 }238 // Storage: Refungible Balance (r:2 w:2)239 fn transfer_normal() -> Weight {240 (17_733_000 as Weight)241 .saturating_add(RocksDbWeight::get().reads(2 as Weight))242 .saturating_add(RocksDbWeight::get().writes(2 as Weight))243 }244 // Storage: Refungible Balance (r:2 w:2)245 // Storage: Refungible AccountBalance (r:1 w:1)246 // Storage: Refungible Owned (r:0 w:1)247 fn transfer_creating() -> Weight {248 (20_943_000 as Weight)249 .saturating_add(RocksDbWeight::get().reads(3 as Weight))250 .saturating_add(RocksDbWeight::get().writes(4 as Weight))251 }252 // Storage: Refungible Balance (r:2 w:2)253 // Storage: Refungible AccountBalance (r:1 w:1)254 // Storage: Refungible Owned (r:0 w:1)255 fn transfer_removing() -> Weight {256 (22_406_000 as Weight)257 .saturating_add(RocksDbWeight::get().reads(3 as Weight))258 .saturating_add(RocksDbWeight::get().writes(4 as Weight))259 }260 // Storage: Refungible Balance (r:2 w:2)261 // Storage: Refungible AccountBalance (r:2 w:2)262 // Storage: Refungible Owned (r:0 w:2)263 fn transfer_creating_removing() -> Weight {264 (24_762_000 as Weight)265 .saturating_add(RocksDbWeight::get().reads(4 as Weight))266 .saturating_add(RocksDbWeight::get().writes(6 as Weight))267 }268 // Storage: Refungible Balance (r:1 w:0)269 // Storage: Refungible Allowance (r:0 w:1)270 fn approve() -> Weight {271 (14_109_000 as Weight)272 .saturating_add(RocksDbWeight::get().reads(1 as Weight))273 .saturating_add(RocksDbWeight::get().writes(1 as Weight))274 }275 // Storage: Refungible Allowance (r:1 w:1)276 // Storage: Refungible Balance (r:2 w:2)277 fn transfer_from_normal() -> Weight {278 (25_348_000 as Weight)279 .saturating_add(RocksDbWeight::get().reads(3 as Weight))280 .saturating_add(RocksDbWeight::get().writes(3 as Weight))281 }282 // Storage: Refungible Allowance (r:1 w:1)283 // Storage: Refungible Balance (r:2 w:2)284 // Storage: Refungible AccountBalance (r:1 w:1)285 // Storage: Refungible Owned (r:0 w:1)286 fn transfer_from_creating() -> Weight {287 (28_647_000 as Weight)288 .saturating_add(RocksDbWeight::get().reads(4 as Weight))289 .saturating_add(RocksDbWeight::get().writes(5 as Weight))290 }291 // Storage: Refungible Allowance (r:1 w:1)292 // Storage: Refungible Balance (r:2 w:2)293 // Storage: Refungible AccountBalance (r:1 w:1)294 // Storage: Refungible Owned (r:0 w:1)295 fn transfer_from_removing() -> Weight {296 (30_472_000 as Weight)297 .saturating_add(RocksDbWeight::get().reads(4 as Weight))298 .saturating_add(RocksDbWeight::get().writes(5 as Weight))299 }300 // Storage: Refungible Allowance (r:1 w:1)301 // Storage: Refungible Balance (r:2 w:2)302 // Storage: Refungible AccountBalance (r:2 w:2)303 // Storage: Refungible Owned (r:0 w:2)304 fn transfer_from_creating_removing() -> Weight {305 (32_362_000 as Weight)306 .saturating_add(RocksDbWeight::get().reads(5 as Weight))307 .saturating_add(RocksDbWeight::get().writes(7 as Weight))308 }309 // Storage: Refungible Allowance (r:1 w:1)310 // Storage: Refungible TotalSupply (r:1 w:1)311 // Storage: Refungible Balance (r:1 w:1)312 // Storage: Refungible AccountBalance (r:1 w:1)313 // Storage: Refungible TokensBurnt (r:1 w:1)314 // Storage: Refungible TokenData (r:0 w:1)315 // Storage: Refungible Owned (r:0 w:1)316 fn burn_from() -> Weight {317 (60_903_000 as Weight)318 .saturating_add(RocksDbWeight::get().reads(5 as Weight))319 .saturating_add(RocksDbWeight::get().writes(7 as Weight))320 }321 // Storage: Refungible TokenData (r:1 w:1)322 fn set_variable_metadata(_b: u32, ) -> Weight {323 (6_801_000 as Weight)324 .saturating_add(RocksDbWeight::get().reads(1 as Weight))325 .saturating_add(RocksDbWeight::get().writes(1 as Weight))326 }327}1// Template adopted from https://github.com/paritytech/substrate/blob/master/.maintain/frame-weight-template.hbs23//! Autogenerated weights for pallet_refungible4//!5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev6//! DATE: 2021-10-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`7//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 12889// Executed Command:10// target/release/unique-collator11// benchmark12// --pallet13// pallet-refungible14// --wasm-execution15// compiled16// --extrinsic17// *18// --template19// .maintain/frame-weight-template.hbs20// --steps=5021// --repeat=2022// --output=./pallets/refungible/src/weights.rs232425#![cfg_attr(rustfmt, rustfmt_skip)]26#![allow(unused_parens)]27#![allow(unused_imports)]28#![allow(clippy::unnecessary_cast)]2930use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};31use sp_std::marker::PhantomData;3233/// Weight functions needed for pallet_refungible.34pub trait WeightInfo {35 fn create_item() -> Weight;36 fn create_multiple_items(b: u32, ) -> Weight;37 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight;38 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight;39 fn burn_item_partial() -> Weight;40 fn burn_item_fully() -> Weight;41 fn transfer_normal() -> Weight;42 fn transfer_creating() -> Weight;43 fn transfer_removing() -> Weight;44 fn transfer_creating_removing() -> Weight;45 fn approve() -> Weight;46 fn transfer_from_normal() -> Weight;47 fn transfer_from_creating() -> Weight;48 fn transfer_from_removing() -> Weight;49 fn transfer_from_creating_removing() -> Weight;50 fn burn_from() -> Weight;51 fn set_variable_metadata(b: u32, ) -> Weight;52}5354/// Weights for pallet_refungible using the Substrate node and recommended hardware.55pub struct SubstrateWeight<T>(PhantomData<T>);56impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {57 // Storage: Refungible TokensMinted (r:1 w:1)58 // Storage: Refungible AccountBalance (r:1 w:1)59 // Storage: Refungible Balance (r:0 w:1)60 // Storage: Refungible TotalSupply (r:0 w:1)61 // Storage: Refungible TokenData (r:0 w:1)62 // Storage: Refungible Owned (r:0 w:1)63 fn create_item() -> Weight {64 (18_681_000 as Weight)65 .saturating_add(T::DbWeight::get().reads(2 as Weight))66 .saturating_add(T::DbWeight::get().writes(6 as Weight))67 }68 // Storage: Refungible TokensMinted (r:1 w:1)69 // Storage: Refungible AccountBalance (r:1 w:1)70 // Storage: Refungible Balance (r:0 w:4)71 // Storage: Refungible TotalSupply (r:0 w:4)72 // Storage: Refungible TokenData (r:0 w:4)73 // Storage: Refungible Owned (r:0 w:4)74 fn create_multiple_items(b: u32, ) -> Weight {75 (13_869_000 as Weight)76 // Standard Error: 28_00077 .saturating_add((5_611_000 as Weight).saturating_mul(b as Weight))78 .saturating_add(T::DbWeight::get().reads(2 as Weight))79 .saturating_add(T::DbWeight::get().writes(2 as Weight))80 .saturating_add(T::DbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))81 }82 // Storage: Refungible TokensMinted (r:1 w:1)83 // Storage: Refungible AccountBalance (r:4 w:4)84 // Storage: Refungible Balance (r:0 w:4)85 // Storage: Refungible TotalSupply (r:0 w:4)86 // Storage: Refungible TokenData (r:0 w:4)87 // Storage: Refungible Owned (r:0 w:4)88 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {89 (11_953_000 as Weight)90 // Standard Error: 27_00091 .saturating_add((10_775_000 as Weight).saturating_mul(b as Weight))92 .saturating_add(T::DbWeight::get().reads(1 as Weight))93 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))94 .saturating_add(T::DbWeight::get().writes(1 as Weight))95 .saturating_add(T::DbWeight::get().writes((5 as Weight).saturating_mul(b as Weight)))96 }97 // Storage: Refungible TokensMinted (r:1 w:1)98 // Storage: Refungible TotalSupply (r:0 w:1)99 // Storage: Refungible TokenData (r:0 w:1)100 // Storage: Refungible AccountBalance (r:4 w:4)101 // Storage: Refungible Balance (r:0 w:4)102 // Storage: Refungible Owned (r:0 w:4)103 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {104 (0 as Weight)105 // Standard Error: 13_000106 .saturating_add((8_528_000 as Weight).saturating_mul(b as Weight))107 .saturating_add(T::DbWeight::get().reads(1 as Weight))108 .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))109 .saturating_add(T::DbWeight::get().writes(3 as Weight))110 .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))111 }112 // Storage: Refungible TotalSupply (r:1 w:1)113 // Storage: Refungible Balance (r:1 w:1)114 // Storage: Refungible AccountBalance (r:1 w:1)115 // Storage: Refungible Owned (r:0 w:1)116 fn burn_item_partial() -> Weight {117 (21_591_000 as Weight)118 .saturating_add(T::DbWeight::get().reads(3 as Weight))119 .saturating_add(T::DbWeight::get().writes(4 as Weight))120 }121 // Storage: Refungible TotalSupply (r:1 w:1)122 // Storage: Refungible Balance (r:1 w:1)123 // Storage: Refungible AccountBalance (r:1 w:1)124 // Storage: Refungible TokensBurnt (r:1 w:1)125 // Storage: Refungible TokenData (r:0 w:1)126 // Storage: Refungible Owned (r:0 w:1)127 fn burn_item_fully() -> Weight {128 (29_257_000 as Weight)129 .saturating_add(T::DbWeight::get().reads(4 as Weight))130 .saturating_add(T::DbWeight::get().writes(6 as Weight))131 }132 // Storage: Refungible Balance (r:2 w:2)133 fn transfer_normal() -> Weight {134 (17_733_000 as Weight)135 .saturating_add(T::DbWeight::get().reads(2 as Weight))136 .saturating_add(T::DbWeight::get().writes(2 as Weight))137 }138 // Storage: Refungible Balance (r:2 w:2)139 // Storage: Refungible AccountBalance (r:1 w:1)140 // Storage: Refungible Owned (r:0 w:1)141 fn transfer_creating() -> Weight {142 (20_943_000 as Weight)143 .saturating_add(T::DbWeight::get().reads(3 as Weight))144 .saturating_add(T::DbWeight::get().writes(4 as Weight))145 }146 // Storage: Refungible Balance (r:2 w:2)147 // Storage: Refungible AccountBalance (r:1 w:1)148 // Storage: Refungible Owned (r:0 w:1)149 fn transfer_removing() -> Weight {150 (22_406_000 as Weight)151 .saturating_add(T::DbWeight::get().reads(3 as Weight))152 .saturating_add(T::DbWeight::get().writes(4 as Weight))153 }154 // Storage: Refungible Balance (r:2 w:2)155 // Storage: Refungible AccountBalance (r:2 w:2)156 // Storage: Refungible Owned (r:0 w:2)157 fn transfer_creating_removing() -> Weight {158 (24_762_000 as Weight)159 .saturating_add(T::DbWeight::get().reads(4 as Weight))160 .saturating_add(T::DbWeight::get().writes(6 as Weight))161 }162 // Storage: Refungible Balance (r:1 w:0)163 // Storage: Refungible Allowance (r:0 w:1)164 fn approve() -> Weight {165 (14_109_000 as Weight)166 .saturating_add(T::DbWeight::get().reads(1 as Weight))167 .saturating_add(T::DbWeight::get().writes(1 as Weight))168 }169 // Storage: Refungible Allowance (r:1 w:1)170 // Storage: Refungible Balance (r:2 w:2)171 fn transfer_from_normal() -> Weight {172 (25_348_000 as Weight)173 .saturating_add(T::DbWeight::get().reads(3 as Weight))174 .saturating_add(T::DbWeight::get().writes(3 as Weight))175 }176 // Storage: Refungible Allowance (r:1 w:1)177 // Storage: Refungible Balance (r:2 w:2)178 // Storage: Refungible AccountBalance (r:1 w:1)179 // Storage: Refungible Owned (r:0 w:1)180 fn transfer_from_creating() -> Weight {181 (28_647_000 as Weight)182 .saturating_add(T::DbWeight::get().reads(4 as Weight))183 .saturating_add(T::DbWeight::get().writes(5 as Weight))184 }185 // Storage: Refungible Allowance (r:1 w:1)186 // Storage: Refungible Balance (r:2 w:2)187 // Storage: Refungible AccountBalance (r:1 w:1)188 // Storage: Refungible Owned (r:0 w:1)189 fn transfer_from_removing() -> Weight {190 (30_472_000 as Weight)191 .saturating_add(T::DbWeight::get().reads(4 as Weight))192 .saturating_add(T::DbWeight::get().writes(5 as Weight))193 }194 // Storage: Refungible Allowance (r:1 w:1)195 // Storage: Refungible Balance (r:2 w:2)196 // Storage: Refungible AccountBalance (r:2 w:2)197 // Storage: Refungible Owned (r:0 w:2)198 fn transfer_from_creating_removing() -> Weight {199 (32_362_000 as Weight)200 .saturating_add(T::DbWeight::get().reads(5 as Weight))201 .saturating_add(T::DbWeight::get().writes(7 as Weight))202 }203 // Storage: Refungible Allowance (r:1 w:1)204 // Storage: Refungible TotalSupply (r:1 w:1)205 // Storage: Refungible Balance (r:1 w:1)206 // Storage: Refungible AccountBalance (r:1 w:1)207 // Storage: Refungible TokensBurnt (r:1 w:1)208 // Storage: Refungible TokenData (r:0 w:1)209 // Storage: Refungible Owned (r:0 w:1)210 fn burn_from() -> Weight {211 (60_903_000 as Weight)212 .saturating_add(T::DbWeight::get().reads(5 as Weight))213 .saturating_add(T::DbWeight::get().writes(7 as Weight))214 }215 // Storage: Refungible TokenData (r:1 w:1)216 fn set_variable_metadata(_b: u32, ) -> Weight {217 (6_801_000 as Weight)218 .saturating_add(T::DbWeight::get().reads(1 as Weight))219 .saturating_add(T::DbWeight::get().writes(1 as Weight))220 }221}222223// For backwards compatibility and tests224impl WeightInfo for () {225 // Storage: Refungible TokensMinted (r:1 w:1)226 // Storage: Refungible AccountBalance (r:1 w:1)227 // Storage: Refungible Balance (r:0 w:1)228 // Storage: Refungible TotalSupply (r:0 w:1)229 // Storage: Refungible TokenData (r:0 w:1)230 // Storage: Refungible Owned (r:0 w:1)231 fn create_item() -> Weight {232 (18_681_000 as Weight)233 .saturating_add(RocksDbWeight::get().reads(2 as Weight))234 .saturating_add(RocksDbWeight::get().writes(6 as Weight))235 }236 // Storage: Refungible TokensMinted (r:1 w:1)237 // Storage: Refungible AccountBalance (r:1 w:1)238 // Storage: Refungible Balance (r:0 w:4)239 // Storage: Refungible TotalSupply (r:0 w:4)240 // Storage: Refungible TokenData (r:0 w:4)241 // Storage: Refungible Owned (r:0 w:4)242 fn create_multiple_items(b: u32, ) -> Weight {243 (13_869_000 as Weight)244 // Standard Error: 28_000245 .saturating_add((5_611_000 as Weight).saturating_mul(b as Weight))246 .saturating_add(RocksDbWeight::get().reads(2 as Weight))247 .saturating_add(RocksDbWeight::get().writes(2 as Weight))248 .saturating_add(RocksDbWeight::get().writes((4 as Weight).saturating_mul(b as Weight)))249 }250 // Storage: Refungible TokensMinted (r:1 w:1)251 // Storage: Refungible AccountBalance (r:4 w:4)252 // Storage: Refungible Balance (r:0 w:4)253 // Storage: Refungible TotalSupply (r:0 w:4)254 // Storage: Refungible TokenData (r:0 w:4)255 // Storage: Refungible Owned (r:0 w:4)256 fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {257 (11_953_000 as Weight)258 // Standard Error: 27_000259 .saturating_add((10_775_000 as Weight).saturating_mul(b as Weight))260 .saturating_add(RocksDbWeight::get().reads(1 as Weight))261 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))262 .saturating_add(RocksDbWeight::get().writes(1 as Weight))263 .saturating_add(RocksDbWeight::get().writes((5 as Weight).saturating_mul(b as Weight)))264 }265 // Storage: Refungible TokensMinted (r:1 w:1)266 // Storage: Refungible TotalSupply (r:0 w:1)267 // Storage: Refungible TokenData (r:0 w:1)268 // Storage: Refungible AccountBalance (r:4 w:4)269 // Storage: Refungible Balance (r:0 w:4)270 // Storage: Refungible Owned (r:0 w:4)271 fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {272 (0 as Weight)273 // Standard Error: 13_000274 .saturating_add((8_528_000 as Weight).saturating_mul(b as Weight))275 .saturating_add(RocksDbWeight::get().reads(1 as Weight))276 .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(b as Weight)))277 .saturating_add(RocksDbWeight::get().writes(3 as Weight))278 .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(b as Weight)))279 }280 // Storage: Refungible TotalSupply (r:1 w:1)281 // Storage: Refungible Balance (r:1 w:1)282 // Storage: Refungible AccountBalance (r:1 w:1)283 // Storage: Refungible Owned (r:0 w:1)284 fn burn_item_partial() -> Weight {285 (21_591_000 as Weight)286 .saturating_add(RocksDbWeight::get().reads(3 as Weight))287 .saturating_add(RocksDbWeight::get().writes(4 as Weight))288 }289 // Storage: Refungible TotalSupply (r:1 w:1)290 // Storage: Refungible Balance (r:1 w:1)291 // Storage: Refungible AccountBalance (r:1 w:1)292 // Storage: Refungible TokensBurnt (r:1 w:1)293 // Storage: Refungible TokenData (r:0 w:1)294 // Storage: Refungible Owned (r:0 w:1)295 fn burn_item_fully() -> Weight {296 (29_257_000 as Weight)297 .saturating_add(RocksDbWeight::get().reads(4 as Weight))298 .saturating_add(RocksDbWeight::get().writes(6 as Weight))299 }300 // Storage: Refungible Balance (r:2 w:2)301 fn transfer_normal() -> Weight {302 (17_733_000 as Weight)303 .saturating_add(RocksDbWeight::get().reads(2 as Weight))304 .saturating_add(RocksDbWeight::get().writes(2 as Weight))305 }306 // Storage: Refungible Balance (r:2 w:2)307 // Storage: Refungible AccountBalance (r:1 w:1)308 // Storage: Refungible Owned (r:0 w:1)309 fn transfer_creating() -> Weight {310 (20_943_000 as Weight)311 .saturating_add(RocksDbWeight::get().reads(3 as Weight))312 .saturating_add(RocksDbWeight::get().writes(4 as Weight))313 }314 // Storage: Refungible Balance (r:2 w:2)315 // Storage: Refungible AccountBalance (r:1 w:1)316 // Storage: Refungible Owned (r:0 w:1)317 fn transfer_removing() -> Weight {318 (22_406_000 as Weight)319 .saturating_add(RocksDbWeight::get().reads(3 as Weight))320 .saturating_add(RocksDbWeight::get().writes(4 as Weight))321 }322 // Storage: Refungible Balance (r:2 w:2)323 // Storage: Refungible AccountBalance (r:2 w:2)324 // Storage: Refungible Owned (r:0 w:2)325 fn transfer_creating_removing() -> Weight {326 (24_762_000 as Weight)327 .saturating_add(RocksDbWeight::get().reads(4 as Weight))328 .saturating_add(RocksDbWeight::get().writes(6 as Weight))329 }330 // Storage: Refungible Balance (r:1 w:0)331 // Storage: Refungible Allowance (r:0 w:1)332 fn approve() -> Weight {333 (14_109_000 as Weight)334 .saturating_add(RocksDbWeight::get().reads(1 as Weight))335 .saturating_add(RocksDbWeight::get().writes(1 as Weight))336 }337 // Storage: Refungible Allowance (r:1 w:1)338 // Storage: Refungible Balance (r:2 w:2)339 fn transfer_from_normal() -> Weight {340 (25_348_000 as Weight)341 .saturating_add(RocksDbWeight::get().reads(3 as Weight))342 .saturating_add(RocksDbWeight::get().writes(3 as Weight))343 }344 // Storage: Refungible Allowance (r:1 w:1)345 // Storage: Refungible Balance (r:2 w:2)346 // Storage: Refungible AccountBalance (r:1 w:1)347 // Storage: Refungible Owned (r:0 w:1)348 fn transfer_from_creating() -> Weight {349 (28_647_000 as Weight)350 .saturating_add(RocksDbWeight::get().reads(4 as Weight))351 .saturating_add(RocksDbWeight::get().writes(5 as Weight))352 }353 // Storage: Refungible Allowance (r:1 w:1)354 // Storage: Refungible Balance (r:2 w:2)355 // Storage: Refungible AccountBalance (r:1 w:1)356 // Storage: Refungible Owned (r:0 w:1)357 fn transfer_from_removing() -> Weight {358 (30_472_000 as Weight)359 .saturating_add(RocksDbWeight::get().reads(4 as Weight))360 .saturating_add(RocksDbWeight::get().writes(5 as Weight))361 }362 // Storage: Refungible Allowance (r:1 w:1)363 // Storage: Refungible Balance (r:2 w:2)364 // Storage: Refungible AccountBalance (r:2 w:2)365 // Storage: Refungible Owned (r:0 w:2)366 fn transfer_from_creating_removing() -> Weight {367 (32_362_000 as Weight)368 .saturating_add(RocksDbWeight::get().reads(5 as Weight))369 .saturating_add(RocksDbWeight::get().writes(7 as Weight))370 }371 // Storage: Refungible Allowance (r:1 w:1)372 // Storage: Refungible TotalSupply (r:1 w:1)373 // Storage: Refungible Balance (r:1 w:1)374 // Storage: Refungible AccountBalance (r:1 w:1)375 // Storage: Refungible TokensBurnt (r:1 w:1)376 // Storage: Refungible TokenData (r:0 w:1)377 // Storage: Refungible Owned (r:0 w:1)378 fn burn_from() -> Weight {379 (60_903_000 as Weight)380 .saturating_add(RocksDbWeight::get().reads(5 as Weight))381 .saturating_add(RocksDbWeight::get().writes(7 as Weight))382 }383 // Storage: Refungible TokenData (r:1 w:1)384 fn set_variable_metadata(_b: u32, ) -> Weight {385 (6_801_000 as Weight)386 .saturating_add(RocksDbWeight::get().reads(1 as Weight))387 .saturating_add(RocksDbWeight::get().writes(1 as Weight))388 }389}pallets/unique/src/common.rsdiffbeforeafterboth--- a/pallets/unique/src/common.rs
+++ b/pallets/unique/src/common.rs
@@ -5,6 +5,7 @@
use pallet_fungible::{common::CommonWeights as FungibleWeights};
use pallet_nonfungible::{common::CommonWeights as NonfungibleWeights};
use pallet_refungible::{common::CommonWeights as RefungibleWeights};
+use up_data_structs::CreateItemExData;
use crate::{Config, dispatch::dispatch_weight};
@@ -17,7 +18,7 @@
}
pub struct CommonWeights<T: Config>(PhantomData<T>);
-impl<T: Config> CommonWeightInfo for CommonWeights<T> {
+impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
fn create_item() -> up_data_structs::Weight {
dispatch_weight::<T>() + max_weight_of!(create_item())
}
@@ -26,6 +27,10 @@
dispatch_weight::<T>() + max_weight_of!(create_multiple_items(amount))
}
+ fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
+ dispatch_weight::<T>() + max_weight_of!(create_multiple_items_ex(data))
+ }
+
fn burn_item() -> Weight {
dispatch_weight::<T>() + max_weight_of!(burn_item())
}
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -40,7 +40,7 @@
OFFCHAIN_SCHEMA_LIMIT, MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH,
MAX_TOKEN_PREFIX_LENGTH, AccessMode, CreateItemData, CollectionLimits, CollectionId,
CollectionMode, TokenId, SchemaVersion, SponsorshipState, MetaUpdatePermission,
- CreateCollectionData, CustomDataLimit,
+ CreateCollectionData, CustomDataLimit, CreateItemExData,
};
use pallet_common::{
account::CrossAccountId, CollectionHandle, Pallet as PalletCommon, Error as CommonError,
@@ -735,6 +735,14 @@
dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items(sender, owner, items_data))
}
+ #[weight = <CommonWeights<T>>::create_multiple_items_ex(&data)]
+ #[transactional]
+ pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {
+ let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
+
+ dispatch_call::<T, _>(collection_id, |d| d.create_multiple_items_ex(sender, data))
+ }
+
// TODO! transaction weight
/// Set transfers_enabled value for particular collection
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -1,6 +1,11 @@
#![cfg_attr(not(feature = "std"), no_std)]
-use core::convert::{TryFrom, TryInto};
+use core::{
+ convert::{TryFrom, TryInto},
+ fmt,
+};
+use frame_support::storage::bounded_btree_map::BoundedBTreeMap;
+use sp_std::collections::btree_map::BTreeMap;
#[cfg(feature = "serde")]
pub use serde::{Serialize, Deserialize};
@@ -525,6 +530,47 @@
ReFungible(CreateReFungibleData),
}
+#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]
+#[derivative(Debug)]
+pub struct CreateNftExData<CrossAccountId> {
+ #[derivative(Debug(format_with = "bounded_debug"))]
+ pub const_data: BoundedVec<u8, CustomDataLimit>,
+ #[derivative(Debug(format_with = "bounded_debug"))]
+ pub variable_data: BoundedVec<u8, CustomDataLimit>,
+ pub owner: CrossAccountId,
+}
+
+#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]
+#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]
+pub struct CreateRefungibleExData<CrossAccountId> {
+ #[derivative(Debug(format_with = "bounded_debug"))]
+ pub const_data: BoundedVec<u8, CustomDataLimit>,
+ #[derivative(Debug(format_with = "bounded_debug"))]
+ pub variable_data: BoundedVec<u8, CustomDataLimit>,
+ #[derivative(Debug(format_with = "bounded_map_debug"))]
+ pub users: BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,
+}
+
+#[derive(Encode, Decode, MaxEncodedLen, PartialEq, Clone, TypeInfo, Derivative)]
+#[derivative(Debug(bound = "CrossAccountId: fmt::Debug + Ord"))]
+pub enum CreateItemExData<CrossAccountId> {
+ NFT(
+ #[derivative(Debug(format_with = "bounded_debug"))]
+ BoundedVec<CreateNftExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,
+ ),
+ Fungible(
+ #[derivative(Debug(format_with = "bounded_map_debug"))]
+ BoundedBTreeMap<CrossAccountId, u128, ConstU32<MAX_ITEMS_PER_BATCH>>,
+ ),
+ /// Many tokens, each may have only one owner
+ RefungibleMultipleItems(
+ #[derivative(Debug(format_with = "bounded_debug"))]
+ BoundedVec<CreateRefungibleExData<CrossAccountId>, ConstU32<MAX_ITEMS_PER_BATCH>>,
+ ),
+ /// Single token, which may have many owners
+ RefungibleMultipleOwners(CreateRefungibleExData<CrossAccountId>),
+}
+
impl CreateItemData {
pub fn data_size(&self) -> usize {
match self {