mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 02:07:56 +00:00
Use 'Items' and 'Collections' in uniques pallet (#11389)
* Rename class to collection * Use "assets collection" instead of "asset collection" * Rename 'instance' to 'asset' * Change "asset `collection`" to "`collection`" * A bit more clean up * Rename Asset to Item * Add a storage hack * Typos * fix compile * fmt * Fix * cargo run --quiet --profile=production --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_uniques --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/uniques/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Update frame/uniques/src/lib.rs * cargo run --quiet --profile=production --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_uniques --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/uniques/src/weights.rs --template=./.maintain/frame-weight-template.hbs * Change 'items collection' to 'collection' * Apply suggestions Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Assets pallet benchmarking.
|
||||
//! Uniques pallet benchmarking.
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
@@ -36,32 +36,32 @@ use crate::Pallet as Uniques;
|
||||
|
||||
const SEED: u32 = 0;
|
||||
|
||||
fn create_class<T: Config<I>, I: 'static>(
|
||||
) -> (T::ClassId, T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
||||
fn create_collection<T: Config<I>, I: 'static>(
|
||||
) -> (T::CollectionId, T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||
let class = T::Helper::class(0);
|
||||
let collection = T::Helper::collection(0);
|
||||
T::Currency::make_free_balance_be(&caller, DepositBalanceOf::<T, I>::max_value());
|
||||
assert!(Uniques::<T, I>::force_create(
|
||||
SystemOrigin::Root.into(),
|
||||
class,
|
||||
collection,
|
||||
caller_lookup.clone(),
|
||||
false,
|
||||
)
|
||||
.is_ok());
|
||||
(class, caller, caller_lookup)
|
||||
(collection, caller, caller_lookup)
|
||||
}
|
||||
|
||||
fn add_class_metadata<T: Config<I>, I: 'static>(
|
||||
fn add_collection_metadata<T: Config<I>, I: 'static>(
|
||||
) -> (T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
||||
let caller = Class::<T, I>::get(T::Helper::class(0)).unwrap().owner;
|
||||
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().owner;
|
||||
if caller != whitelisted_caller() {
|
||||
whitelist_account!(caller);
|
||||
}
|
||||
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||
assert!(Uniques::<T, I>::set_class_metadata(
|
||||
assert!(Uniques::<T, I>::set_collection_metadata(
|
||||
SystemOrigin::Signed(caller.clone()).into(),
|
||||
T::Helper::class(0),
|
||||
T::Helper::collection(0),
|
||||
vec![0; T::StringLimit::get() as usize].try_into().unwrap(),
|
||||
false,
|
||||
)
|
||||
@@ -69,37 +69,37 @@ fn add_class_metadata<T: Config<I>, I: 'static>(
|
||||
(caller, caller_lookup)
|
||||
}
|
||||
|
||||
fn mint_instance<T: Config<I>, I: 'static>(
|
||||
fn mint_item<T: Config<I>, I: 'static>(
|
||||
index: u16,
|
||||
) -> (T::InstanceId, T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
||||
let caller = Class::<T, I>::get(T::Helper::class(0)).unwrap().admin;
|
||||
) -> (T::ItemId, T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
||||
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().admin;
|
||||
if caller != whitelisted_caller() {
|
||||
whitelist_account!(caller);
|
||||
}
|
||||
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||
let instance = T::Helper::instance(index);
|
||||
let item = T::Helper::item(index);
|
||||
assert!(Uniques::<T, I>::mint(
|
||||
SystemOrigin::Signed(caller.clone()).into(),
|
||||
T::Helper::class(0),
|
||||
instance,
|
||||
T::Helper::collection(0),
|
||||
item,
|
||||
caller_lookup.clone(),
|
||||
)
|
||||
.is_ok());
|
||||
(instance, caller, caller_lookup)
|
||||
(item, caller, caller_lookup)
|
||||
}
|
||||
|
||||
fn add_instance_metadata<T: Config<I>, I: 'static>(
|
||||
instance: T::InstanceId,
|
||||
fn add_item_metadata<T: Config<I>, I: 'static>(
|
||||
item: T::ItemId,
|
||||
) -> (T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
||||
let caller = Class::<T, I>::get(T::Helper::class(0)).unwrap().owner;
|
||||
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().owner;
|
||||
if caller != whitelisted_caller() {
|
||||
whitelist_account!(caller);
|
||||
}
|
||||
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||
assert!(Uniques::<T, I>::set_metadata(
|
||||
SystemOrigin::Signed(caller.clone()).into(),
|
||||
T::Helper::class(0),
|
||||
instance,
|
||||
T::Helper::collection(0),
|
||||
item,
|
||||
vec![0; T::StringLimit::get() as usize].try_into().unwrap(),
|
||||
false,
|
||||
)
|
||||
@@ -107,10 +107,10 @@ fn add_instance_metadata<T: Config<I>, I: 'static>(
|
||||
(caller, caller_lookup)
|
||||
}
|
||||
|
||||
fn add_instance_attribute<T: Config<I>, I: 'static>(
|
||||
instance: T::InstanceId,
|
||||
fn add_item_attribute<T: Config<I>, I: 'static>(
|
||||
item: T::ItemId,
|
||||
) -> (BoundedVec<u8, T::KeyLimit>, T::AccountId, <T::Lookup as StaticLookup>::Source) {
|
||||
let caller = Class::<T, I>::get(T::Helper::class(0)).unwrap().owner;
|
||||
let caller = Collection::<T, I>::get(T::Helper::collection(0)).unwrap().owner;
|
||||
if caller != whitelisted_caller() {
|
||||
whitelist_account!(caller);
|
||||
}
|
||||
@@ -118,8 +118,8 @@ fn add_instance_attribute<T: Config<I>, I: 'static>(
|
||||
let key: BoundedVec<_, _> = vec![0; T::KeyLimit::get() as usize].try_into().unwrap();
|
||||
assert!(Uniques::<T, I>::set_attribute(
|
||||
SystemOrigin::Signed(caller.clone()).into(),
|
||||
T::Helper::class(0),
|
||||
Some(instance),
|
||||
T::Helper::collection(0),
|
||||
Some(item),
|
||||
key.clone(),
|
||||
vec![0; T::ValueLimit::get() as usize].try_into().unwrap(),
|
||||
)
|
||||
@@ -137,24 +137,24 @@ fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::
|
||||
|
||||
benchmarks_instance_pallet! {
|
||||
create {
|
||||
let class = T::Helper::class(0);
|
||||
let origin = T::CreateOrigin::successful_origin(&class);
|
||||
let caller = T::CreateOrigin::ensure_origin(origin.clone(), &class).unwrap();
|
||||
let collection = T::Helper::collection(0);
|
||||
let origin = T::CreateOrigin::successful_origin(&collection);
|
||||
let caller = T::CreateOrigin::ensure_origin(origin.clone(), &collection).unwrap();
|
||||
whitelist_account!(caller);
|
||||
let admin = T::Lookup::unlookup(caller.clone());
|
||||
T::Currency::make_free_balance_be(&caller, DepositBalanceOf::<T, I>::max_value());
|
||||
let call = Call::<T, I>::create { class, admin };
|
||||
let call = Call::<T, I>::create { collection, admin };
|
||||
}: { call.dispatch_bypass_filter(origin)? }
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::Created { class: T::Helper::class(0), creator: caller.clone(), owner: caller }.into());
|
||||
assert_last_event::<T, I>(Event::Created { collection: T::Helper::collection(0), creator: caller.clone(), owner: caller }.into());
|
||||
}
|
||||
|
||||
force_create {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let caller_lookup = T::Lookup::unlookup(caller.clone());
|
||||
}: _(SystemOrigin::Root, T::Helper::class(0), caller_lookup, true)
|
||||
}: _(SystemOrigin::Root, T::Helper::collection(0), caller_lookup, true)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::ForceCreated { class: T::Helper::class(0), owner: caller }.into());
|
||||
assert_last_event::<T, I>(Event::ForceCreated { collection: T::Helper::collection(0), owner: caller }.into());
|
||||
}
|
||||
|
||||
destroy {
|
||||
@@ -162,57 +162,57 @@ benchmarks_instance_pallet! {
|
||||
let m in 0 .. 1_000;
|
||||
let a in 0 .. 1_000;
|
||||
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
add_class_metadata::<T, I>();
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
add_collection_metadata::<T, I>();
|
||||
for i in 0..n {
|
||||
mint_instance::<T, I>(i as u16);
|
||||
mint_item::<T, I>(i as u16);
|
||||
}
|
||||
for i in 0..m {
|
||||
add_instance_metadata::<T, I>(T::Helper::instance(i as u16));
|
||||
add_item_metadata::<T, I>(T::Helper::item(i as u16));
|
||||
}
|
||||
for i in 0..a {
|
||||
add_instance_attribute::<T, I>(T::Helper::instance(i as u16));
|
||||
add_item_attribute::<T, I>(T::Helper::item(i as u16));
|
||||
}
|
||||
let witness = Class::<T, I>::get(class).unwrap().destroy_witness();
|
||||
}: _(SystemOrigin::Signed(caller), class, witness)
|
||||
let witness = Collection::<T, I>::get(collection).unwrap().destroy_witness();
|
||||
}: _(SystemOrigin::Signed(caller), collection, witness)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::Destroyed { class }.into());
|
||||
assert_last_event::<T, I>(Event::Destroyed { collection }.into());
|
||||
}
|
||||
|
||||
mint {
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
let instance = T::Helper::instance(0);
|
||||
}: _(SystemOrigin::Signed(caller.clone()), class, instance, caller_lookup)
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
let item = T::Helper::item(0);
|
||||
}: _(SystemOrigin::Signed(caller.clone()), collection, item, caller_lookup)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::Issued { class, instance, owner: caller }.into());
|
||||
assert_last_event::<T, I>(Event::Issued { collection, item, owner: caller }.into());
|
||||
}
|
||||
|
||||
burn {
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
}: _(SystemOrigin::Signed(caller.clone()), class, instance, Some(caller_lookup))
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
}: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(caller_lookup))
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::Burned { class, instance, owner: caller }.into());
|
||||
assert_last_event::<T, I>(Event::Burned { collection, item, owner: caller }.into());
|
||||
}
|
||||
|
||||
transfer {
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
|
||||
let target: T::AccountId = account("target", 0, SEED);
|
||||
let target_lookup = T::Lookup::unlookup(target.clone());
|
||||
}: _(SystemOrigin::Signed(caller.clone()), class, instance, target_lookup)
|
||||
}: _(SystemOrigin::Signed(caller.clone()), collection, item, target_lookup)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::Transferred { class, instance, from: caller, to: target }.into());
|
||||
assert_last_event::<T, I>(Event::Transferred { collection, item, from: caller, to: target }.into());
|
||||
}
|
||||
|
||||
redeposit {
|
||||
let i in 0 .. 5_000;
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
let instances = (0..i).map(|x| mint_instance::<T, I>(x as u16).0).collect::<Vec<_>>();
|
||||
Uniques::<T, I>::force_asset_status(
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
let items = (0..i).map(|x| mint_item::<T, I>(x as u16).0).collect::<Vec<_>>();
|
||||
Uniques::<T, I>::force_item_status(
|
||||
SystemOrigin::Root.into(),
|
||||
class,
|
||||
collection,
|
||||
caller_lookup.clone(),
|
||||
caller_lookup.clone(),
|
||||
caller_lookup.clone(),
|
||||
@@ -220,80 +220,80 @@ benchmarks_instance_pallet! {
|
||||
true,
|
||||
false,
|
||||
)?;
|
||||
}: _(SystemOrigin::Signed(caller.clone()), class, instances.clone())
|
||||
}: _(SystemOrigin::Signed(caller.clone()), collection, items.clone())
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::Redeposited { class, successful_instances: instances }.into());
|
||||
assert_last_event::<T, I>(Event::Redeposited { collection, successful_items: items }.into());
|
||||
}
|
||||
|
||||
freeze {
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
}: _(SystemOrigin::Signed(caller.clone()), T::Helper::class(0), T::Helper::instance(0))
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
}: _(SystemOrigin::Signed(caller.clone()), T::Helper::collection(0), T::Helper::item(0))
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::Frozen { class: T::Helper::class(0), instance: T::Helper::instance(0) }.into());
|
||||
assert_last_event::<T, I>(Event::Frozen { collection: T::Helper::collection(0), item: T::Helper::item(0) }.into());
|
||||
}
|
||||
|
||||
thaw {
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
Uniques::<T, I>::freeze(
|
||||
SystemOrigin::Signed(caller.clone()).into(),
|
||||
class,
|
||||
instance,
|
||||
collection,
|
||||
item,
|
||||
)?;
|
||||
}: _(SystemOrigin::Signed(caller.clone()), class, instance)
|
||||
}: _(SystemOrigin::Signed(caller.clone()), collection, item)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::Thawed { class, instance }.into());
|
||||
assert_last_event::<T, I>(Event::Thawed { collection, item }.into());
|
||||
}
|
||||
|
||||
freeze_class {
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
}: _(SystemOrigin::Signed(caller.clone()), class)
|
||||
freeze_collection {
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
}: _(SystemOrigin::Signed(caller.clone()), collection)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::ClassFrozen { class }.into());
|
||||
assert_last_event::<T, I>(Event::CollectionFrozen { collection }.into());
|
||||
}
|
||||
|
||||
thaw_class {
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
thaw_collection {
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
let origin = SystemOrigin::Signed(caller.clone()).into();
|
||||
Uniques::<T, I>::freeze_class(origin, class)?;
|
||||
}: _(SystemOrigin::Signed(caller.clone()), class)
|
||||
Uniques::<T, I>::freeze_collection(origin, collection)?;
|
||||
}: _(SystemOrigin::Signed(caller.clone()), collection)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::ClassThawed { class }.into());
|
||||
assert_last_event::<T, I>(Event::CollectionThawed { collection }.into());
|
||||
}
|
||||
|
||||
transfer_ownership {
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
let target: T::AccountId = account("target", 0, SEED);
|
||||
let target_lookup = T::Lookup::unlookup(target.clone());
|
||||
T::Currency::make_free_balance_be(&target, T::Currency::minimum_balance());
|
||||
let origin = SystemOrigin::Signed(target.clone()).into();
|
||||
Uniques::<T, I>::set_accept_ownership(origin, Some(class))?;
|
||||
}: _(SystemOrigin::Signed(caller), class, target_lookup)
|
||||
Uniques::<T, I>::set_accept_ownership(origin, Some(collection))?;
|
||||
}: _(SystemOrigin::Signed(caller), collection, target_lookup)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::OwnerChanged { class, new_owner: target }.into());
|
||||
assert_last_event::<T, I>(Event::OwnerChanged { collection, new_owner: target }.into());
|
||||
}
|
||||
|
||||
set_team {
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
let target0 = T::Lookup::unlookup(account("target", 0, SEED));
|
||||
let target1 = T::Lookup::unlookup(account("target", 1, SEED));
|
||||
let target2 = T::Lookup::unlookup(account("target", 2, SEED));
|
||||
}: _(SystemOrigin::Signed(caller), class, target0, target1, target2)
|
||||
}: _(SystemOrigin::Signed(caller), collection, target0, target1, target2)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::TeamChanged{
|
||||
class,
|
||||
collection,
|
||||
issuer: account("target", 0, SEED),
|
||||
admin: account("target", 1, SEED),
|
||||
freezer: account("target", 2, SEED),
|
||||
}.into());
|
||||
}
|
||||
|
||||
force_asset_status {
|
||||
let (class, caller, caller_lookup) = create_class::<T, I>();
|
||||
force_item_status {
|
||||
let (collection, caller, caller_lookup) = create_collection::<T, I>();
|
||||
let origin = T::ForceOrigin::successful_origin();
|
||||
let call = Call::<T, I>::force_asset_status {
|
||||
class,
|
||||
let call = Call::<T, I>::force_item_status {
|
||||
collection,
|
||||
owner: caller_lookup.clone(),
|
||||
issuer: caller_lookup.clone(),
|
||||
admin: caller_lookup.clone(),
|
||||
@@ -303,98 +303,98 @@ benchmarks_instance_pallet! {
|
||||
};
|
||||
}: { call.dispatch_bypass_filter(origin)? }
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::AssetStatusChanged { class }.into());
|
||||
assert_last_event::<T, I>(Event::ItemStatusChanged { collection }.into());
|
||||
}
|
||||
|
||||
set_attribute {
|
||||
let key: BoundedVec<_, _> = vec![0u8; T::KeyLimit::get() as usize].try_into().unwrap();
|
||||
let value: BoundedVec<_, _> = vec![0u8; T::ValueLimit::get() as usize].try_into().unwrap();
|
||||
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
add_instance_metadata::<T, I>(instance);
|
||||
}: _(SystemOrigin::Signed(caller), class, Some(instance), key.clone(), value.clone())
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
add_item_metadata::<T, I>(item);
|
||||
}: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone(), value.clone())
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::AttributeSet { class, maybe_instance: Some(instance), key, value }.into());
|
||||
assert_last_event::<T, I>(Event::AttributeSet { collection, maybe_item: Some(item), key, value }.into());
|
||||
}
|
||||
|
||||
clear_attribute {
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
add_instance_metadata::<T, I>(instance);
|
||||
let (key, ..) = add_instance_attribute::<T, I>(instance);
|
||||
}: _(SystemOrigin::Signed(caller), class, Some(instance), key.clone())
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
add_item_metadata::<T, I>(item);
|
||||
let (key, ..) = add_item_attribute::<T, I>(item);
|
||||
}: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone())
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::AttributeCleared { class, maybe_instance: Some(instance), key }.into());
|
||||
assert_last_event::<T, I>(Event::AttributeCleared { collection, maybe_item: Some(item), key }.into());
|
||||
}
|
||||
|
||||
set_metadata {
|
||||
let data: BoundedVec<_, _> = vec![0u8; T::StringLimit::get() as usize].try_into().unwrap();
|
||||
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
}: _(SystemOrigin::Signed(caller), class, instance, data.clone(), false)
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
}: _(SystemOrigin::Signed(caller), collection, item, data.clone(), false)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::MetadataSet { class, instance, data, is_frozen: false }.into());
|
||||
assert_last_event::<T, I>(Event::MetadataSet { collection, item, data, is_frozen: false }.into());
|
||||
}
|
||||
|
||||
clear_metadata {
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
add_instance_metadata::<T, I>(instance);
|
||||
}: _(SystemOrigin::Signed(caller), class, instance)
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
add_item_metadata::<T, I>(item);
|
||||
}: _(SystemOrigin::Signed(caller), collection, item)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::MetadataCleared { class, instance }.into());
|
||||
assert_last_event::<T, I>(Event::MetadataCleared { collection, item }.into());
|
||||
}
|
||||
|
||||
set_class_metadata {
|
||||
set_collection_metadata {
|
||||
let data: BoundedVec<_, _> = vec![0u8; T::StringLimit::get() as usize].try_into().unwrap();
|
||||
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
}: _(SystemOrigin::Signed(caller), class, data.clone(), false)
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
}: _(SystemOrigin::Signed(caller), collection, data.clone(), false)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::ClassMetadataSet { class, data, is_frozen: false }.into());
|
||||
assert_last_event::<T, I>(Event::CollectionMetadataSet { collection, data, is_frozen: false }.into());
|
||||
}
|
||||
|
||||
clear_class_metadata {
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
add_class_metadata::<T, I>();
|
||||
}: _(SystemOrigin::Signed(caller), class)
|
||||
clear_collection_metadata {
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
add_collection_metadata::<T, I>();
|
||||
}: _(SystemOrigin::Signed(caller), collection)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::ClassMetadataCleared { class }.into());
|
||||
assert_last_event::<T, I>(Event::CollectionMetadataCleared { collection }.into());
|
||||
}
|
||||
|
||||
approve_transfer {
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
let delegate: T::AccountId = account("delegate", 0, SEED);
|
||||
let delegate_lookup = T::Lookup::unlookup(delegate.clone());
|
||||
}: _(SystemOrigin::Signed(caller.clone()), class, instance, delegate_lookup)
|
||||
}: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup)
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::ApprovedTransfer { class, instance, owner: caller, delegate }.into());
|
||||
assert_last_event::<T, I>(Event::ApprovedTransfer { collection, item, owner: caller, delegate }.into());
|
||||
}
|
||||
|
||||
cancel_approval {
|
||||
let (class, caller, _) = create_class::<T, I>();
|
||||
let (instance, ..) = mint_instance::<T, I>(0);
|
||||
let (collection, caller, _) = create_collection::<T, I>();
|
||||
let (item, ..) = mint_item::<T, I>(0);
|
||||
let delegate: T::AccountId = account("delegate", 0, SEED);
|
||||
let delegate_lookup = T::Lookup::unlookup(delegate.clone());
|
||||
let origin = SystemOrigin::Signed(caller.clone()).into();
|
||||
Uniques::<T, I>::approve_transfer(origin, class, instance, delegate_lookup.clone())?;
|
||||
}: _(SystemOrigin::Signed(caller.clone()), class, instance, Some(delegate_lookup))
|
||||
Uniques::<T, I>::approve_transfer(origin, collection, item, delegate_lookup.clone())?;
|
||||
}: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(delegate_lookup))
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::ApprovalCancelled { class, instance, owner: caller, delegate }.into());
|
||||
assert_last_event::<T, I>(Event::ApprovalCancelled { collection, item, owner: caller, delegate }.into());
|
||||
}
|
||||
|
||||
set_accept_ownership {
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
T::Currency::make_free_balance_be(&caller, DepositBalanceOf::<T, I>::max_value());
|
||||
let class = T::Helper::class(0);
|
||||
}: _(SystemOrigin::Signed(caller.clone()), Some(class))
|
||||
let collection = T::Helper::collection(0);
|
||||
}: _(SystemOrigin::Signed(caller.clone()), Some(collection))
|
||||
verify {
|
||||
assert_last_event::<T, I>(Event::OwnershipAcceptanceChanged {
|
||||
who: caller,
|
||||
maybe_class: Some(class),
|
||||
maybe_collection: Some(collection),
|
||||
}.into());
|
||||
}
|
||||
|
||||
|
||||
@@ -23,168 +23,174 @@ use sp_runtime::{DispatchError, DispatchResult};
|
||||
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
pub fn do_transfer(
|
||||
class: T::ClassId,
|
||||
instance: T::InstanceId,
|
||||
collection: T::CollectionId,
|
||||
item: T::ItemId,
|
||||
dest: T::AccountId,
|
||||
with_details: impl FnOnce(
|
||||
&ClassDetailsFor<T, I>,
|
||||
&mut InstanceDetailsFor<T, I>,
|
||||
&CollectionDetailsFor<T, I>,
|
||||
&mut ItemDetailsFor<T, I>,
|
||||
) -> DispatchResult,
|
||||
) -> DispatchResult {
|
||||
let class_details = Class::<T, I>::get(&class).ok_or(Error::<T, I>::UnknownClass)?;
|
||||
ensure!(!class_details.is_frozen, Error::<T, I>::Frozen);
|
||||
ensure!(!T::Locker::is_locked(class, instance), Error::<T, I>::Locked);
|
||||
let collection_details =
|
||||
Collection::<T, I>::get(&collection).ok_or(Error::<T, I>::UnknownCollection)?;
|
||||
ensure!(!collection_details.is_frozen, Error::<T, I>::Frozen);
|
||||
ensure!(!T::Locker::is_locked(collection, item), Error::<T, I>::Locked);
|
||||
|
||||
let mut details =
|
||||
Asset::<T, I>::get(&class, &instance).ok_or(Error::<T, I>::UnknownClass)?;
|
||||
Item::<T, I>::get(&collection, &item).ok_or(Error::<T, I>::UnknownCollection)?;
|
||||
ensure!(!details.is_frozen, Error::<T, I>::Frozen);
|
||||
with_details(&class_details, &mut details)?;
|
||||
with_details(&collection_details, &mut details)?;
|
||||
|
||||
Account::<T, I>::remove((&details.owner, &class, &instance));
|
||||
Account::<T, I>::insert((&dest, &class, &instance), ());
|
||||
Account::<T, I>::remove((&details.owner, &collection, &item));
|
||||
Account::<T, I>::insert((&dest, &collection, &item), ());
|
||||
let origin = details.owner;
|
||||
details.owner = dest;
|
||||
Asset::<T, I>::insert(&class, &instance, &details);
|
||||
Item::<T, I>::insert(&collection, &item, &details);
|
||||
|
||||
Self::deposit_event(Event::Transferred {
|
||||
class,
|
||||
instance,
|
||||
collection,
|
||||
item,
|
||||
from: origin,
|
||||
to: details.owner,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn do_create_class(
|
||||
class: T::ClassId,
|
||||
pub fn do_create_collection(
|
||||
collection: T::CollectionId,
|
||||
owner: T::AccountId,
|
||||
admin: T::AccountId,
|
||||
deposit: DepositBalanceOf<T, I>,
|
||||
free_holding: bool,
|
||||
event: Event<T, I>,
|
||||
) -> DispatchResult {
|
||||
ensure!(!Class::<T, I>::contains_key(class), Error::<T, I>::InUse);
|
||||
ensure!(!Collection::<T, I>::contains_key(collection), Error::<T, I>::InUse);
|
||||
|
||||
T::Currency::reserve(&owner, deposit)?;
|
||||
|
||||
Class::<T, I>::insert(
|
||||
class,
|
||||
ClassDetails {
|
||||
Collection::<T, I>::insert(
|
||||
collection,
|
||||
CollectionDetails {
|
||||
owner: owner.clone(),
|
||||
issuer: admin.clone(),
|
||||
admin: admin.clone(),
|
||||
freezer: admin,
|
||||
total_deposit: deposit,
|
||||
free_holding,
|
||||
instances: 0,
|
||||
instance_metadatas: 0,
|
||||
items: 0,
|
||||
item_metadatas: 0,
|
||||
attributes: 0,
|
||||
is_frozen: false,
|
||||
},
|
||||
);
|
||||
|
||||
ClassAccount::<T, I>::insert(&owner, &class, ());
|
||||
CollectionAccount::<T, I>::insert(&owner, &collection, ());
|
||||
Self::deposit_event(event);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn do_destroy_class(
|
||||
class: T::ClassId,
|
||||
pub fn do_destroy_collection(
|
||||
collection: T::CollectionId,
|
||||
witness: DestroyWitness,
|
||||
maybe_check_owner: Option<T::AccountId>,
|
||||
) -> Result<DestroyWitness, DispatchError> {
|
||||
Class::<T, I>::try_mutate_exists(class, |maybe_details| {
|
||||
let class_details = maybe_details.take().ok_or(Error::<T, I>::UnknownClass)?;
|
||||
Collection::<T, I>::try_mutate_exists(collection, |maybe_details| {
|
||||
let collection_details =
|
||||
maybe_details.take().ok_or(Error::<T, I>::UnknownCollection)?;
|
||||
if let Some(check_owner) = maybe_check_owner {
|
||||
ensure!(class_details.owner == check_owner, Error::<T, I>::NoPermission);
|
||||
ensure!(collection_details.owner == check_owner, Error::<T, I>::NoPermission);
|
||||
}
|
||||
ensure!(class_details.instances == witness.instances, Error::<T, I>::BadWitness);
|
||||
ensure!(collection_details.items == witness.items, Error::<T, I>::BadWitness);
|
||||
ensure!(
|
||||
class_details.instance_metadatas == witness.instance_metadatas,
|
||||
collection_details.item_metadatas == witness.item_metadatas,
|
||||
Error::<T, I>::BadWitness
|
||||
);
|
||||
ensure!(class_details.attributes == witness.attributes, Error::<T, I>::BadWitness);
|
||||
ensure!(collection_details.attributes == witness.attributes, Error::<T, I>::BadWitness);
|
||||
|
||||
for (instance, details) in Asset::<T, I>::drain_prefix(&class) {
|
||||
Account::<T, I>::remove((&details.owner, &class, &instance));
|
||||
for (item, details) in Item::<T, I>::drain_prefix(&collection) {
|
||||
Account::<T, I>::remove((&details.owner, &collection, &item));
|
||||
}
|
||||
InstanceMetadataOf::<T, I>::remove_prefix(&class, None);
|
||||
ClassMetadataOf::<T, I>::remove(&class);
|
||||
Attribute::<T, I>::remove_prefix((&class,), None);
|
||||
ClassAccount::<T, I>::remove(&class_details.owner, &class);
|
||||
T::Currency::unreserve(&class_details.owner, class_details.total_deposit);
|
||||
ItemMetadataOf::<T, I>::remove_prefix(&collection, None);
|
||||
CollectionMetadataOf::<T, I>::remove(&collection);
|
||||
Attribute::<T, I>::remove_prefix((&collection,), None);
|
||||
CollectionAccount::<T, I>::remove(&collection_details.owner, &collection);
|
||||
T::Currency::unreserve(&collection_details.owner, collection_details.total_deposit);
|
||||
|
||||
Self::deposit_event(Event::Destroyed { class });
|
||||
Self::deposit_event(Event::Destroyed { collection });
|
||||
|
||||
Ok(DestroyWitness {
|
||||
instances: class_details.instances,
|
||||
instance_metadatas: class_details.instance_metadatas,
|
||||
attributes: class_details.attributes,
|
||||
items: collection_details.items,
|
||||
item_metadatas: collection_details.item_metadatas,
|
||||
attributes: collection_details.attributes,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn do_mint(
|
||||
class: T::ClassId,
|
||||
instance: T::InstanceId,
|
||||
collection: T::CollectionId,
|
||||
item: T::ItemId,
|
||||
owner: T::AccountId,
|
||||
with_details: impl FnOnce(&ClassDetailsFor<T, I>) -> DispatchResult,
|
||||
with_details: impl FnOnce(&CollectionDetailsFor<T, I>) -> DispatchResult,
|
||||
) -> DispatchResult {
|
||||
ensure!(!Asset::<T, I>::contains_key(class, instance), Error::<T, I>::AlreadyExists);
|
||||
ensure!(!Item::<T, I>::contains_key(collection, item), Error::<T, I>::AlreadyExists);
|
||||
|
||||
Class::<T, I>::try_mutate(&class, |maybe_class_details| -> DispatchResult {
|
||||
let class_details = maybe_class_details.as_mut().ok_or(Error::<T, I>::UnknownClass)?;
|
||||
Collection::<T, I>::try_mutate(
|
||||
&collection,
|
||||
|maybe_collection_details| -> DispatchResult {
|
||||
let collection_details =
|
||||
maybe_collection_details.as_mut().ok_or(Error::<T, I>::UnknownCollection)?;
|
||||
|
||||
with_details(class_details)?;
|
||||
with_details(collection_details)?;
|
||||
|
||||
let instances =
|
||||
class_details.instances.checked_add(1).ok_or(ArithmeticError::Overflow)?;
|
||||
class_details.instances = instances;
|
||||
let items =
|
||||
collection_details.items.checked_add(1).ok_or(ArithmeticError::Overflow)?;
|
||||
collection_details.items = items;
|
||||
|
||||
let deposit = match class_details.free_holding {
|
||||
true => Zero::zero(),
|
||||
false => T::InstanceDeposit::get(),
|
||||
};
|
||||
T::Currency::reserve(&class_details.owner, deposit)?;
|
||||
class_details.total_deposit += deposit;
|
||||
let deposit = match collection_details.free_holding {
|
||||
true => Zero::zero(),
|
||||
false => T::ItemDeposit::get(),
|
||||
};
|
||||
T::Currency::reserve(&collection_details.owner, deposit)?;
|
||||
collection_details.total_deposit += deposit;
|
||||
|
||||
let owner = owner.clone();
|
||||
Account::<T, I>::insert((&owner, &class, &instance), ());
|
||||
let details = InstanceDetails { owner, approved: None, is_frozen: false, deposit };
|
||||
Asset::<T, I>::insert(&class, &instance, details);
|
||||
Ok(())
|
||||
})?;
|
||||
let owner = owner.clone();
|
||||
Account::<T, I>::insert((&owner, &collection, &item), ());
|
||||
let details = ItemDetails { owner, approved: None, is_frozen: false, deposit };
|
||||
Item::<T, I>::insert(&collection, &item, details);
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
Self::deposit_event(Event::Issued { class, instance, owner });
|
||||
Self::deposit_event(Event::Issued { collection, item, owner });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn do_burn(
|
||||
class: T::ClassId,
|
||||
instance: T::InstanceId,
|
||||
with_details: impl FnOnce(&ClassDetailsFor<T, I>, &InstanceDetailsFor<T, I>) -> DispatchResult,
|
||||
collection: T::CollectionId,
|
||||
item: T::ItemId,
|
||||
with_details: impl FnOnce(&CollectionDetailsFor<T, I>, &ItemDetailsFor<T, I>) -> DispatchResult,
|
||||
) -> DispatchResult {
|
||||
let owner = Class::<T, I>::try_mutate(
|
||||
&class,
|
||||
|maybe_class_details| -> Result<T::AccountId, DispatchError> {
|
||||
let class_details =
|
||||
maybe_class_details.as_mut().ok_or(Error::<T, I>::UnknownClass)?;
|
||||
let details =
|
||||
Asset::<T, I>::get(&class, &instance).ok_or(Error::<T, I>::UnknownClass)?;
|
||||
with_details(class_details, &details)?;
|
||||
let owner = Collection::<T, I>::try_mutate(
|
||||
&collection,
|
||||
|maybe_collection_details| -> Result<T::AccountId, DispatchError> {
|
||||
let collection_details =
|
||||
maybe_collection_details.as_mut().ok_or(Error::<T, I>::UnknownCollection)?;
|
||||
let details = Item::<T, I>::get(&collection, &item)
|
||||
.ok_or(Error::<T, I>::UnknownCollection)?;
|
||||
with_details(collection_details, &details)?;
|
||||
|
||||
// Return the deposit.
|
||||
T::Currency::unreserve(&class_details.owner, details.deposit);
|
||||
class_details.total_deposit.saturating_reduce(details.deposit);
|
||||
class_details.instances.saturating_dec();
|
||||
T::Currency::unreserve(&collection_details.owner, details.deposit);
|
||||
collection_details.total_deposit.saturating_reduce(details.deposit);
|
||||
collection_details.items.saturating_dec();
|
||||
Ok(details.owner)
|
||||
},
|
||||
)?;
|
||||
|
||||
Asset::<T, I>::remove(&class, &instance);
|
||||
Account::<T, I>::remove((&owner, &class, &instance));
|
||||
Item::<T, I>::remove(&collection, &item);
|
||||
Account::<T, I>::remove((&owner, &collection, &item));
|
||||
|
||||
Self::deposit_event(Event::Burned { class, instance, owner });
|
||||
Self::deposit_event(Event::Burned { collection, item, owner });
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,59 +26,59 @@ use sp_runtime::{DispatchError, DispatchResult};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
impl<T: Config<I>, I: 'static> Inspect<<T as SystemConfig>::AccountId> for Pallet<T, I> {
|
||||
type InstanceId = T::InstanceId;
|
||||
type ClassId = T::ClassId;
|
||||
type ItemId = T::ItemId;
|
||||
type CollectionId = T::CollectionId;
|
||||
|
||||
fn owner(
|
||||
class: &Self::ClassId,
|
||||
instance: &Self::InstanceId,
|
||||
collection: &Self::CollectionId,
|
||||
item: &Self::ItemId,
|
||||
) -> Option<<T as SystemConfig>::AccountId> {
|
||||
Asset::<T, I>::get(class, instance).map(|a| a.owner)
|
||||
Item::<T, I>::get(collection, item).map(|a| a.owner)
|
||||
}
|
||||
|
||||
fn class_owner(class: &Self::ClassId) -> Option<<T as SystemConfig>::AccountId> {
|
||||
Class::<T, I>::get(class).map(|a| a.owner)
|
||||
fn collection_owner(collection: &Self::CollectionId) -> Option<<T as SystemConfig>::AccountId> {
|
||||
Collection::<T, I>::get(collection).map(|a| a.owner)
|
||||
}
|
||||
|
||||
/// Returns the attribute value of `instance` of `class` corresponding to `key`.
|
||||
/// Returns the attribute value of `item` of `collection` corresponding to `key`.
|
||||
///
|
||||
/// When `key` is empty, we return the instance metadata value.
|
||||
/// When `key` is empty, we return the item metadata value.
|
||||
///
|
||||
/// By default this is `None`; no attributes are defined.
|
||||
fn attribute(
|
||||
class: &Self::ClassId,
|
||||
instance: &Self::InstanceId,
|
||||
collection: &Self::CollectionId,
|
||||
item: &Self::ItemId,
|
||||
key: &[u8],
|
||||
) -> Option<Vec<u8>> {
|
||||
if key.is_empty() {
|
||||
// We make the empty key map to the instance metadata value.
|
||||
InstanceMetadataOf::<T, I>::get(class, instance).map(|m| m.data.into())
|
||||
// We make the empty key map to the item metadata value.
|
||||
ItemMetadataOf::<T, I>::get(collection, item).map(|m| m.data.into())
|
||||
} else {
|
||||
let key = BoundedSlice::<_, _>::try_from(key).ok()?;
|
||||
Attribute::<T, I>::get((class, Some(instance), key)).map(|a| a.0.into())
|
||||
Attribute::<T, I>::get((collection, Some(item), key)).map(|a| a.0.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the attribute value of `instance` of `class` corresponding to `key`.
|
||||
/// Returns the attribute value of `item` of `collection` corresponding to `key`.
|
||||
///
|
||||
/// When `key` is empty, we return the instance metadata value.
|
||||
/// When `key` is empty, we return the item metadata value.
|
||||
///
|
||||
/// By default this is `None`; no attributes are defined.
|
||||
fn class_attribute(class: &Self::ClassId, key: &[u8]) -> Option<Vec<u8>> {
|
||||
fn collection_attribute(collection: &Self::CollectionId, key: &[u8]) -> Option<Vec<u8>> {
|
||||
if key.is_empty() {
|
||||
// We make the empty key map to the instance metadata value.
|
||||
ClassMetadataOf::<T, I>::get(class).map(|m| m.data.into())
|
||||
// We make the empty key map to the item metadata value.
|
||||
CollectionMetadataOf::<T, I>::get(collection).map(|m| m.data.into())
|
||||
} else {
|
||||
let key = BoundedSlice::<_, _>::try_from(key).ok()?;
|
||||
Attribute::<T, I>::get((class, Option::<T::InstanceId>::None, key)).map(|a| a.0.into())
|
||||
Attribute::<T, I>::get((collection, Option::<T::ItemId>::None, key)).map(|a| a.0.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the asset `instance` of `class` may be transferred.
|
||||
/// Returns `true` if the `item` of `collection` may be transferred.
|
||||
///
|
||||
/// Default implementation is that all assets are transferable.
|
||||
fn can_transfer(class: &Self::ClassId, instance: &Self::InstanceId) -> bool {
|
||||
match (Class::<T, I>::get(class), Asset::<T, I>::get(class, instance)) {
|
||||
/// Default implementation is that all items are transferable.
|
||||
fn can_transfer(collection: &Self::CollectionId, item: &Self::ItemId) -> bool {
|
||||
match (Collection::<T, I>::get(collection), Item::<T, I>::get(collection, item)) {
|
||||
(Some(cd), Some(id)) if !cd.is_frozen && !id.is_frozen => true,
|
||||
_ => false,
|
||||
}
|
||||
@@ -86,19 +86,19 @@ impl<T: Config<I>, I: 'static> Inspect<<T as SystemConfig>::AccountId> for Palle
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> Create<<T as SystemConfig>::AccountId> for Pallet<T, I> {
|
||||
/// Create a `class` of nonfungible assets to be owned by `who` and managed by `admin`.
|
||||
fn create_class(
|
||||
class: &Self::ClassId,
|
||||
/// Create a `collection` of nonfungible items to be owned by `who` and managed by `admin`.
|
||||
fn create_collection(
|
||||
collection: &Self::CollectionId,
|
||||
who: &T::AccountId,
|
||||
admin: &T::AccountId,
|
||||
) -> DispatchResult {
|
||||
Self::do_create_class(
|
||||
*class,
|
||||
Self::do_create_collection(
|
||||
*collection,
|
||||
who.clone(),
|
||||
admin.clone(),
|
||||
T::ClassDeposit::get(),
|
||||
T::CollectionDeposit::get(),
|
||||
false,
|
||||
Event::Created { class: *class, creator: who.clone(), owner: admin.clone() },
|
||||
Event::Created { collection: *collection, creator: who.clone(), owner: admin.clone() },
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -106,34 +106,34 @@ impl<T: Config<I>, I: 'static> Create<<T as SystemConfig>::AccountId> for Pallet
|
||||
impl<T: Config<I>, I: 'static> Destroy<<T as SystemConfig>::AccountId> for Pallet<T, I> {
|
||||
type DestroyWitness = DestroyWitness;
|
||||
|
||||
fn get_destroy_witness(class: &Self::ClassId) -> Option<DestroyWitness> {
|
||||
Class::<T, I>::get(class).map(|a| a.destroy_witness())
|
||||
fn get_destroy_witness(collection: &Self::CollectionId) -> Option<DestroyWitness> {
|
||||
Collection::<T, I>::get(collection).map(|a| a.destroy_witness())
|
||||
}
|
||||
|
||||
fn destroy(
|
||||
class: Self::ClassId,
|
||||
collection: Self::CollectionId,
|
||||
witness: Self::DestroyWitness,
|
||||
maybe_check_owner: Option<T::AccountId>,
|
||||
) -> Result<Self::DestroyWitness, DispatchError> {
|
||||
Self::do_destroy_class(class, witness, maybe_check_owner)
|
||||
Self::do_destroy_collection(collection, witness, maybe_check_owner)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> Mutate<<T as SystemConfig>::AccountId> for Pallet<T, I> {
|
||||
fn mint_into(
|
||||
class: &Self::ClassId,
|
||||
instance: &Self::InstanceId,
|
||||
collection: &Self::CollectionId,
|
||||
item: &Self::ItemId,
|
||||
who: &T::AccountId,
|
||||
) -> DispatchResult {
|
||||
Self::do_mint(*class, *instance, who.clone(), |_| Ok(()))
|
||||
Self::do_mint(*collection, *item, who.clone(), |_| Ok(()))
|
||||
}
|
||||
|
||||
fn burn(
|
||||
class: &Self::ClassId,
|
||||
instance: &Self::InstanceId,
|
||||
collection: &Self::CollectionId,
|
||||
item: &Self::ItemId,
|
||||
maybe_check_owner: Option<&T::AccountId>,
|
||||
) -> DispatchResult {
|
||||
Self::do_burn(*class, *instance, |_, d| {
|
||||
Self::do_burn(*collection, *item, |_, d| {
|
||||
if let Some(check_owner) = maybe_check_owner {
|
||||
if &d.owner != check_owner {
|
||||
return Err(Error::<T, I>::NoPermission.into())
|
||||
@@ -146,43 +146,43 @@ impl<T: Config<I>, I: 'static> Mutate<<T as SystemConfig>::AccountId> for Pallet
|
||||
|
||||
impl<T: Config<I>, I: 'static> Transfer<T::AccountId> for Pallet<T, I> {
|
||||
fn transfer(
|
||||
class: &Self::ClassId,
|
||||
instance: &Self::InstanceId,
|
||||
collection: &Self::CollectionId,
|
||||
item: &Self::ItemId,
|
||||
destination: &T::AccountId,
|
||||
) -> DispatchResult {
|
||||
Self::do_transfer(*class, *instance, destination.clone(), |_, _| Ok(()))
|
||||
Self::do_transfer(*collection, *item, destination.clone(), |_, _| Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> InspectEnumerable<T::AccountId> for Pallet<T, I> {
|
||||
/// Returns an iterator of the asset classes in existence.
|
||||
/// Returns an iterator of the collections in existence.
|
||||
///
|
||||
/// NOTE: iterating this list invokes a storage read per item.
|
||||
fn classes() -> Box<dyn Iterator<Item = Self::ClassId>> {
|
||||
Box::new(ClassMetadataOf::<T, I>::iter_keys())
|
||||
fn collections() -> Box<dyn Iterator<Item = Self::CollectionId>> {
|
||||
Box::new(CollectionMetadataOf::<T, I>::iter_keys())
|
||||
}
|
||||
|
||||
/// Returns an iterator of the instances of an asset `class` in existence.
|
||||
/// Returns an iterator of the items of a `collection` in existence.
|
||||
///
|
||||
/// NOTE: iterating this list invokes a storage read per item.
|
||||
fn instances(class: &Self::ClassId) -> Box<dyn Iterator<Item = Self::InstanceId>> {
|
||||
Box::new(InstanceMetadataOf::<T, I>::iter_key_prefix(class))
|
||||
fn items(collection: &Self::CollectionId) -> Box<dyn Iterator<Item = Self::ItemId>> {
|
||||
Box::new(ItemMetadataOf::<T, I>::iter_key_prefix(collection))
|
||||
}
|
||||
|
||||
/// Returns an iterator of the asset instances of all classes owned by `who`.
|
||||
/// Returns an iterator of the items of all collections owned by `who`.
|
||||
///
|
||||
/// NOTE: iterating this list invokes a storage read per item.
|
||||
fn owned(who: &T::AccountId) -> Box<dyn Iterator<Item = (Self::ClassId, Self::InstanceId)>> {
|
||||
fn owned(who: &T::AccountId) -> Box<dyn Iterator<Item = (Self::CollectionId, Self::ItemId)>> {
|
||||
Box::new(Account::<T, I>::iter_key_prefix((who,)))
|
||||
}
|
||||
|
||||
/// Returns an iterator of the asset instances of `class` owned by `who`.
|
||||
/// Returns an iterator of the items of `collection` owned by `who`.
|
||||
///
|
||||
/// NOTE: iterating this list invokes a storage read per item.
|
||||
fn owned_in_class(
|
||||
class: &Self::ClassId,
|
||||
fn owned_in_collection(
|
||||
collection: &Self::CollectionId,
|
||||
who: &T::AccountId,
|
||||
) -> Box<dyn Iterator<Item = Self::InstanceId>> {
|
||||
Box::new(Account::<T, I>::iter_key_prefix((who, class)))
|
||||
) -> Box<dyn Iterator<Item = Self::ItemId>> {
|
||||
Box::new(Account::<T, I>::iter_key_prefix((who, collection)))
|
||||
}
|
||||
}
|
||||
|
||||
+457
-439
File diff suppressed because it is too large
Load Diff
@@ -34,8 +34,8 @@ pub fn migrate_to_v1<T: Config<I>, I: 'static, P: GetStorageVersion + PalletInfo
|
||||
|
||||
if on_chain_storage_version < 1 {
|
||||
let mut count = 0;
|
||||
for (class, detail) in Class::<T, I>::iter() {
|
||||
ClassAccount::<T, I>::insert(&detail.owner, &class, ());
|
||||
for (collection, detail) in Collection::<T, I>::iter() {
|
||||
CollectionAccount::<T, I>::insert(&detail.owner, &collection, ());
|
||||
count += 1;
|
||||
}
|
||||
StorageVersion::new(1).put::<P>();
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Test environment for Assets pallet.
|
||||
//! Test environment for Uniques pallet.
|
||||
|
||||
use super::*;
|
||||
use crate as pallet_uniques;
|
||||
@@ -86,14 +86,14 @@ impl pallet_balances::Config for Test {
|
||||
|
||||
impl Config for Test {
|
||||
type Event = Event;
|
||||
type ClassId = u32;
|
||||
type InstanceId = u32;
|
||||
type CollectionId = u32;
|
||||
type ItemId = u32;
|
||||
type Currency = Balances;
|
||||
type CreateOrigin = AsEnsureOriginWithArg<frame_system::EnsureSigned<u64>>;
|
||||
type ForceOrigin = frame_system::EnsureRoot<u64>;
|
||||
type Locker = ();
|
||||
type ClassDeposit = ConstU64<2>;
|
||||
type InstanceDeposit = ConstU64<1>;
|
||||
type CollectionDeposit = ConstU64<2>;
|
||||
type ItemDeposit = ConstU64<1>;
|
||||
type MetadataDepositBase = ConstU64<1>;
|
||||
type AttributeDepositBase = ConstU64<1>;
|
||||
type DepositPerByte = ConstU64<1>;
|
||||
|
||||
@@ -23,13 +23,13 @@ use frame_support::{assert_noop, assert_ok, traits::Currency};
|
||||
use pallet_balances::Error as BalancesError;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
fn assets() -> Vec<(u64, u32, u32)> {
|
||||
fn items() -> Vec<(u64, u32, u32)> {
|
||||
let mut r: Vec<_> = Account::<Test>::iter().map(|x| x.0).collect();
|
||||
r.sort();
|
||||
let mut s: Vec<_> = Asset::<Test>::iter().map(|x| (x.2.owner, x.0, x.1)).collect();
|
||||
let mut s: Vec<_> = Item::<Test>::iter().map(|x| (x.2.owner, x.0, x.1)).collect();
|
||||
s.sort();
|
||||
assert_eq!(r, s);
|
||||
for class in Asset::<Test>::iter()
|
||||
for collection in Item::<Test>::iter()
|
||||
.map(|x| x.0)
|
||||
.scan(None, |s, item| {
|
||||
if s.map_or(false, |last| last == item) {
|
||||
@@ -41,17 +41,17 @@ fn assets() -> Vec<(u64, u32, u32)> {
|
||||
})
|
||||
.flatten()
|
||||
{
|
||||
let details = Class::<Test>::get(class).unwrap();
|
||||
let instances = Asset::<Test>::iter_prefix(class).count() as u32;
|
||||
assert_eq!(details.instances, instances);
|
||||
let details = Collection::<Test>::get(collection).unwrap();
|
||||
let items = Item::<Test>::iter_prefix(collection).count() as u32;
|
||||
assert_eq!(details.items, items);
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
fn classes() -> Vec<(u64, u32)> {
|
||||
let mut r: Vec<_> = ClassAccount::<Test>::iter().map(|x| (x.0, x.1)).collect();
|
||||
fn collections() -> Vec<(u64, u32)> {
|
||||
let mut r: Vec<_> = CollectionAccount::<Test>::iter().map(|x| (x.0, x.1)).collect();
|
||||
r.sort();
|
||||
let mut s: Vec<_> = Class::<Test>::iter().map(|x| (x.1.owner, x.0)).collect();
|
||||
let mut s: Vec<_> = Collection::<Test>::iter().map(|x| (x.1.owner, x.0)).collect();
|
||||
s.sort();
|
||||
assert_eq!(r, s);
|
||||
r
|
||||
@@ -63,8 +63,8 @@ macro_rules! bvec {
|
||||
}
|
||||
}
|
||||
|
||||
fn attributes(class: u32) -> Vec<(Option<u32>, Vec<u8>, Vec<u8>)> {
|
||||
let mut s: Vec<_> = Attribute::<Test>::iter_prefix((class,))
|
||||
fn attributes(collection: u32) -> Vec<(Option<u32>, Vec<u8>, Vec<u8>)> {
|
||||
let mut s: Vec<_> = Attribute::<Test>::iter_prefix((collection,))
|
||||
.map(|(k, v)| (k.0, k.1.into(), v.0.into()))
|
||||
.collect();
|
||||
s.sort();
|
||||
@@ -74,7 +74,7 @@ fn attributes(class: u32) -> Vec<(Option<u32>, Vec<u8>, Vec<u8>)> {
|
||||
#[test]
|
||||
fn basic_setup_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_eq!(assets(), vec![]);
|
||||
assert_eq!(items(), vec![]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,14 +82,14 @@ fn basic_setup_works() {
|
||||
fn basic_minting_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_eq!(classes(), vec![(1, 0)]);
|
||||
assert_eq!(collections(), vec![(1, 0)]);
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
assert_eq!(assets(), vec![(1, 0, 42)]);
|
||||
assert_eq!(items(), vec![(1, 0, 42)]);
|
||||
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, 2, true));
|
||||
assert_eq!(classes(), vec![(1, 0), (2, 1)]);
|
||||
assert_eq!(collections(), vec![(1, 0), (2, 1)]);
|
||||
assert_ok!(Uniques::mint(Origin::signed(2), 1, 69, 1));
|
||||
assert_eq!(assets(), vec![(1, 0, 42), (1, 1, 69)]);
|
||||
assert_eq!(items(), vec![(1, 0, 42), (1, 1, 69)]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,40 +99,40 @@ fn lifecycle_should_work() {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
assert_ok!(Uniques::create(Origin::signed(1), 0, 1));
|
||||
assert_eq!(Balances::reserved_balance(&1), 2);
|
||||
assert_eq!(classes(), vec![(1, 0)]);
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0, 0], false));
|
||||
assert_eq!(collections(), vec![(1, 0)]);
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0, 0], false));
|
||||
assert_eq!(Balances::reserved_balance(&1), 5);
|
||||
assert!(ClassMetadataOf::<Test>::contains_key(0));
|
||||
assert!(CollectionMetadataOf::<Test>::contains_key(0));
|
||||
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 10));
|
||||
assert_eq!(Balances::reserved_balance(&1), 6);
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 69, 20));
|
||||
assert_eq!(Balances::reserved_balance(&1), 7);
|
||||
assert_eq!(assets(), vec![(10, 0, 42), (20, 0, 69)]);
|
||||
assert_eq!(Class::<Test>::get(0).unwrap().instances, 2);
|
||||
assert_eq!(Class::<Test>::get(0).unwrap().instance_metadatas, 0);
|
||||
assert_eq!(items(), vec![(10, 0, 42), (20, 0, 69)]);
|
||||
assert_eq!(Collection::<Test>::get(0).unwrap().items, 2);
|
||||
assert_eq!(Collection::<Test>::get(0).unwrap().item_metadatas, 0);
|
||||
|
||||
assert_ok!(Uniques::set_metadata(Origin::signed(1), 0, 42, bvec![42, 42], false));
|
||||
assert_eq!(Balances::reserved_balance(&1), 10);
|
||||
assert!(InstanceMetadataOf::<Test>::contains_key(0, 42));
|
||||
assert!(ItemMetadataOf::<Test>::contains_key(0, 42));
|
||||
assert_ok!(Uniques::set_metadata(Origin::signed(1), 0, 69, bvec![69, 69], false));
|
||||
assert_eq!(Balances::reserved_balance(&1), 13);
|
||||
assert!(InstanceMetadataOf::<Test>::contains_key(0, 69));
|
||||
assert!(ItemMetadataOf::<Test>::contains_key(0, 69));
|
||||
|
||||
let w = Class::<Test>::get(0).unwrap().destroy_witness();
|
||||
assert_eq!(w.instances, 2);
|
||||
assert_eq!(w.instance_metadatas, 2);
|
||||
let w = Collection::<Test>::get(0).unwrap().destroy_witness();
|
||||
assert_eq!(w.items, 2);
|
||||
assert_eq!(w.item_metadatas, 2);
|
||||
assert_ok!(Uniques::destroy(Origin::signed(1), 0, w));
|
||||
assert_eq!(Balances::reserved_balance(&1), 0);
|
||||
|
||||
assert!(!Class::<Test>::contains_key(0));
|
||||
assert!(!Asset::<Test>::contains_key(0, 42));
|
||||
assert!(!Asset::<Test>::contains_key(0, 69));
|
||||
assert!(!ClassMetadataOf::<Test>::contains_key(0));
|
||||
assert!(!InstanceMetadataOf::<Test>::contains_key(0, 42));
|
||||
assert!(!InstanceMetadataOf::<Test>::contains_key(0, 69));
|
||||
assert_eq!(classes(), vec![]);
|
||||
assert_eq!(assets(), vec![]);
|
||||
assert!(!Collection::<Test>::contains_key(0));
|
||||
assert!(!Item::<Test>::contains_key(0, 42));
|
||||
assert!(!Item::<Test>::contains_key(0, 69));
|
||||
assert!(!CollectionMetadataOf::<Test>::contains_key(0));
|
||||
assert!(!ItemMetadataOf::<Test>::contains_key(0, 42));
|
||||
assert!(!ItemMetadataOf::<Test>::contains_key(0, 69));
|
||||
assert_eq!(collections(), vec![]);
|
||||
assert_eq!(items(), vec![]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ fn destroy_with_bad_witness_should_not_work() {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
assert_ok!(Uniques::create(Origin::signed(1), 0, 1));
|
||||
|
||||
let w = Class::<Test>::get(0).unwrap().destroy_witness();
|
||||
let w = Collection::<Test>::get(0).unwrap().destroy_witness();
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
assert_noop!(Uniques::destroy(Origin::signed(1), 0, w), Error::<Test>::BadWitness);
|
||||
});
|
||||
@@ -154,8 +154,8 @@ fn mint_should_work() {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
assert_eq!(Uniques::owner(0, 42).unwrap(), 1);
|
||||
assert_eq!(classes(), vec![(1, 0)]);
|
||||
assert_eq!(assets(), vec![(1, 0, 42)]);
|
||||
assert_eq!(collections(), vec![(1, 0)]);
|
||||
assert_eq!(items(), vec![(1, 0, 42)]);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ fn transfer_should_work() {
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 2));
|
||||
|
||||
assert_ok!(Uniques::transfer(Origin::signed(2), 0, 42, 3));
|
||||
assert_eq!(assets(), vec![(3, 0, 42)]);
|
||||
assert_eq!(items(), vec![(3, 0, 42)]);
|
||||
assert_noop!(Uniques::transfer(Origin::signed(2), 0, 42, 4), Error::<Test>::NoPermission);
|
||||
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(3), 0, 42, 2));
|
||||
@@ -183,10 +183,10 @@ fn freezing_should_work() {
|
||||
assert_noop!(Uniques::transfer(Origin::signed(1), 0, 42, 2), Error::<Test>::Frozen);
|
||||
|
||||
assert_ok!(Uniques::thaw(Origin::signed(1), 0, 42));
|
||||
assert_ok!(Uniques::freeze_class(Origin::signed(1), 0));
|
||||
assert_ok!(Uniques::freeze_collection(Origin::signed(1), 0));
|
||||
assert_noop!(Uniques::transfer(Origin::signed(1), 0, 42, 2), Error::<Test>::Frozen);
|
||||
|
||||
assert_ok!(Uniques::thaw_class(Origin::signed(1), 0));
|
||||
assert_ok!(Uniques::thaw_collection(Origin::signed(1), 0));
|
||||
assert_ok!(Uniques::transfer(Origin::signed(1), 0, 42, 2));
|
||||
});
|
||||
}
|
||||
@@ -208,7 +208,7 @@ fn origin_guards_should_work() {
|
||||
assert_noop!(Uniques::thaw(Origin::signed(2), 0, 42), Error::<Test>::NoPermission);
|
||||
assert_noop!(Uniques::mint(Origin::signed(2), 0, 69, 2), Error::<Test>::NoPermission);
|
||||
assert_noop!(Uniques::burn(Origin::signed(2), 0, 42, None), Error::<Test>::NoPermission);
|
||||
let w = Class::<Test>::get(0).unwrap().destroy_witness();
|
||||
let w = Collection::<Test>::get(0).unwrap().destroy_witness();
|
||||
assert_noop!(Uniques::destroy(Origin::signed(2), 0, w), Error::<Test>::NoPermission);
|
||||
});
|
||||
}
|
||||
@@ -220,7 +220,7 @@ fn transfer_owner_should_work() {
|
||||
Balances::make_free_balance_be(&2, 100);
|
||||
Balances::make_free_balance_be(&3, 100);
|
||||
assert_ok!(Uniques::create(Origin::signed(1), 0, 1));
|
||||
assert_eq!(classes(), vec![(1, 0)]);
|
||||
assert_eq!(collections(), vec![(1, 0)]);
|
||||
assert_noop!(
|
||||
Uniques::transfer_ownership(Origin::signed(1), 0, 2),
|
||||
Error::<Test>::Unaccepted
|
||||
@@ -228,7 +228,7 @@ fn transfer_owner_should_work() {
|
||||
assert_ok!(Uniques::set_accept_ownership(Origin::signed(2), Some(0)));
|
||||
assert_ok!(Uniques::transfer_ownership(Origin::signed(1), 0, 2));
|
||||
|
||||
assert_eq!(classes(), vec![(2, 0)]);
|
||||
assert_eq!(collections(), vec![(2, 0)]);
|
||||
assert_eq!(Balances::total_balance(&1), 98);
|
||||
assert_eq!(Balances::total_balance(&2), 102);
|
||||
assert_eq!(Balances::reserved_balance(&1), 0);
|
||||
@@ -241,12 +241,12 @@ fn transfer_owner_should_work() {
|
||||
);
|
||||
|
||||
// Mint and set metadata now and make sure that deposit gets transferred back.
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::signed(2), 0, bvec![0u8; 20], false));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(2), 0, bvec![0u8; 20], false));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
assert_ok!(Uniques::set_metadata(Origin::signed(2), 0, 42, bvec![0u8; 20], false));
|
||||
assert_ok!(Uniques::set_accept_ownership(Origin::signed(3), Some(0)));
|
||||
assert_ok!(Uniques::transfer_ownership(Origin::signed(2), 0, 3));
|
||||
assert_eq!(classes(), vec![(3, 0)]);
|
||||
assert_eq!(collections(), vec![(3, 0)]);
|
||||
assert_eq!(Balances::total_balance(&2), 57);
|
||||
assert_eq!(Balances::total_balance(&3), 145);
|
||||
assert_eq!(Balances::reserved_balance(&2), 0);
|
||||
@@ -276,73 +276,76 @@ fn set_team_should_work() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_class_metadata_should_work() {
|
||||
fn set_collection_metadata_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Cannot add metadata to unknown asset
|
||||
// Cannot add metadata to unknown item
|
||||
assert_noop!(
|
||||
Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0u8; 20], false),
|
||||
Error::<Test>::UnknownClass,
|
||||
Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0u8; 20], false),
|
||||
Error::<Test>::UnknownCollection,
|
||||
);
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
// Cannot add metadata to unowned asset
|
||||
// Cannot add metadata to unowned item
|
||||
assert_noop!(
|
||||
Uniques::set_class_metadata(Origin::signed(2), 0, bvec![0u8; 20], false),
|
||||
Uniques::set_collection_metadata(Origin::signed(2), 0, bvec![0u8; 20], false),
|
||||
Error::<Test>::NoPermission,
|
||||
);
|
||||
|
||||
// Successfully add metadata and take deposit
|
||||
Balances::make_free_balance_be(&1, 30);
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0u8; 20], false));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0u8; 20], false));
|
||||
assert_eq!(Balances::free_balance(&1), 9);
|
||||
assert!(ClassMetadataOf::<Test>::contains_key(0));
|
||||
assert!(CollectionMetadataOf::<Test>::contains_key(0));
|
||||
|
||||
// Force origin works, too.
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::root(), 0, bvec![0u8; 18], false));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::root(), 0, bvec![0u8; 18], false));
|
||||
|
||||
// Update deposit
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0u8; 15], false));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0u8; 15], false));
|
||||
assert_eq!(Balances::free_balance(&1), 14);
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0u8; 25], false));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0u8; 25], false));
|
||||
assert_eq!(Balances::free_balance(&1), 4);
|
||||
|
||||
// Cannot over-reserve
|
||||
assert_noop!(
|
||||
Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0u8; 40], false),
|
||||
Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0u8; 40], false),
|
||||
BalancesError::<Test, _>::InsufficientBalance,
|
||||
);
|
||||
|
||||
// Can't set or clear metadata once frozen
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0u8; 15], true));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0u8; 15], true));
|
||||
assert_noop!(
|
||||
Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0u8; 15], false),
|
||||
Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0u8; 15], false),
|
||||
Error::<Test, _>::Frozen,
|
||||
);
|
||||
assert_noop!(Uniques::clear_class_metadata(Origin::signed(1), 0), Error::<Test>::Frozen);
|
||||
assert_noop!(
|
||||
Uniques::clear_collection_metadata(Origin::signed(1), 0),
|
||||
Error::<Test>::Frozen
|
||||
);
|
||||
|
||||
// Clear Metadata
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::root(), 0, bvec![0u8; 15], false));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::root(), 0, bvec![0u8; 15], false));
|
||||
assert_noop!(
|
||||
Uniques::clear_class_metadata(Origin::signed(2), 0),
|
||||
Uniques::clear_collection_metadata(Origin::signed(2), 0),
|
||||
Error::<Test>::NoPermission
|
||||
);
|
||||
assert_noop!(
|
||||
Uniques::clear_class_metadata(Origin::signed(1), 1),
|
||||
Error::<Test>::UnknownClass
|
||||
Uniques::clear_collection_metadata(Origin::signed(1), 1),
|
||||
Error::<Test>::UnknownCollection
|
||||
);
|
||||
assert_ok!(Uniques::clear_class_metadata(Origin::signed(1), 0));
|
||||
assert!(!ClassMetadataOf::<Test>::contains_key(0));
|
||||
assert_ok!(Uniques::clear_collection_metadata(Origin::signed(1), 0));
|
||||
assert!(!CollectionMetadataOf::<Test>::contains_key(0));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_instance_metadata_should_work() {
|
||||
fn set_item_metadata_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&1, 30);
|
||||
|
||||
// Cannot add metadata to unknown asset
|
||||
// Cannot add metadata to unknown item
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
// Cannot add metadata to unowned asset
|
||||
// Cannot add metadata to unowned item
|
||||
assert_noop!(
|
||||
Uniques::set_metadata(Origin::signed(2), 0, 42, bvec![0u8; 20], false),
|
||||
Error::<Test>::NoPermission,
|
||||
@@ -351,7 +354,7 @@ fn set_instance_metadata_should_work() {
|
||||
// Successfully add metadata and take deposit
|
||||
assert_ok!(Uniques::set_metadata(Origin::signed(1), 0, 42, bvec![0u8; 20], false));
|
||||
assert_eq!(Balances::free_balance(&1), 8);
|
||||
assert!(InstanceMetadataOf::<Test>::contains_key(0, 42));
|
||||
assert!(ItemMetadataOf::<Test>::contains_key(0, 42));
|
||||
|
||||
// Force origin works, too.
|
||||
assert_ok!(Uniques::set_metadata(Origin::root(), 0, 42, bvec![0u8; 18], false));
|
||||
@@ -384,10 +387,10 @@ fn set_instance_metadata_should_work() {
|
||||
);
|
||||
assert_noop!(
|
||||
Uniques::clear_metadata(Origin::signed(1), 1, 42),
|
||||
Error::<Test>::UnknownClass
|
||||
Error::<Test>::UnknownCollection
|
||||
);
|
||||
assert_ok!(Uniques::clear_metadata(Origin::signed(1), 0, 42));
|
||||
assert!(!InstanceMetadataOf::<Test>::contains_key(0, 42));
|
||||
assert!(!ItemMetadataOf::<Test>::contains_key(0, 42));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -429,7 +432,7 @@ fn set_attribute_should_work() {
|
||||
);
|
||||
assert_eq!(Balances::reserved_balance(1), 15);
|
||||
|
||||
let w = Class::<Test>::get(0).unwrap().destroy_witness();
|
||||
let w = Collection::<Test>::get(0).unwrap().destroy_witness();
|
||||
assert_ok!(Uniques::destroy(Origin::signed(1), 0, w));
|
||||
assert_eq!(attributes(0), vec![]);
|
||||
assert_eq!(Balances::reserved_balance(1), 0);
|
||||
@@ -456,7 +459,7 @@ fn set_attribute_should_respect_freeze() {
|
||||
);
|
||||
assert_eq!(Balances::reserved_balance(1), 9);
|
||||
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::signed(1), 0, bvec![], true));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![], true));
|
||||
let e = Error::<Test>::Frozen;
|
||||
assert_noop!(Uniques::set_attribute(Origin::signed(1), 0, None, bvec![0], bvec![0]), e);
|
||||
assert_ok!(Uniques::set_attribute(Origin::signed(1), 0, Some(0), bvec![0], bvec![1]));
|
||||
@@ -469,20 +472,20 @@ fn set_attribute_should_respect_freeze() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn force_asset_status_should_work() {
|
||||
fn force_item_status_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 69, 2));
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0; 20], false));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0; 20], false));
|
||||
assert_ok!(Uniques::set_metadata(Origin::signed(1), 0, 42, bvec![0; 20], false));
|
||||
assert_ok!(Uniques::set_metadata(Origin::signed(1), 0, 69, bvec![0; 20], false));
|
||||
assert_eq!(Balances::reserved_balance(1), 65);
|
||||
|
||||
// force asset status to be free holding
|
||||
assert_ok!(Uniques::force_asset_status(Origin::root(), 0, 1, 1, 1, 1, true, false));
|
||||
// force item status to be free holding
|
||||
assert_ok!(Uniques::force_item_status(Origin::root(), 0, 1, 1, 1, 1, true, false));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 142, 1));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 169, 2));
|
||||
assert_ok!(Uniques::set_metadata(Origin::signed(1), 0, 142, bvec![0; 20], false));
|
||||
@@ -498,7 +501,7 @@ fn force_asset_status_should_work() {
|
||||
assert_ok!(Uniques::set_metadata(Origin::signed(1), 0, 69, bvec![0; 20], false));
|
||||
assert_eq!(Balances::reserved_balance(1), 21);
|
||||
|
||||
assert_ok!(Uniques::set_class_metadata(Origin::signed(1), 0, bvec![0; 20], false));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0; 20], false));
|
||||
assert_eq!(Balances::reserved_balance(1), 0);
|
||||
});
|
||||
}
|
||||
@@ -510,7 +513,10 @@ fn burn_works() {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
assert_ok!(Uniques::set_team(Origin::signed(1), 0, 2, 3, 4));
|
||||
|
||||
assert_noop!(Uniques::burn(Origin::signed(5), 0, 42, Some(5)), Error::<Test>::UnknownClass);
|
||||
assert_noop!(
|
||||
Uniques::burn(Origin::signed(5), 0, 42, Some(5)),
|
||||
Error::<Test>::UnknownCollection
|
||||
);
|
||||
|
||||
assert_ok!(Uniques::mint(Origin::signed(2), 0, 42, 5));
|
||||
assert_ok!(Uniques::mint(Origin::signed(2), 0, 69, 5));
|
||||
@@ -533,7 +539,7 @@ fn approval_lifecycle_works() {
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(2), 0, 42, 3));
|
||||
assert_ok!(Uniques::transfer(Origin::signed(3), 0, 42, 4));
|
||||
assert_noop!(Uniques::transfer(Origin::signed(3), 0, 42, 3), Error::<Test>::NoPermission);
|
||||
assert!(Asset::<Test>::get(0, 42).unwrap().approved.is_none());
|
||||
assert!(Item::<Test>::get(0, 42).unwrap().approved.is_none());
|
||||
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(4), 0, 42, 2));
|
||||
assert_ok!(Uniques::transfer(Origin::signed(2), 0, 42, 2));
|
||||
@@ -549,11 +555,11 @@ fn cancel_approval_works() {
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(2), 0, 42, 3));
|
||||
assert_noop!(
|
||||
Uniques::cancel_approval(Origin::signed(2), 1, 42, None),
|
||||
Error::<Test>::UnknownClass
|
||||
Error::<Test>::UnknownCollection
|
||||
);
|
||||
assert_noop!(
|
||||
Uniques::cancel_approval(Origin::signed(2), 0, 43, None),
|
||||
Error::<Test>::UnknownClass
|
||||
Error::<Test>::UnknownCollection
|
||||
);
|
||||
assert_noop!(
|
||||
Uniques::cancel_approval(Origin::signed(3), 0, 42, None),
|
||||
@@ -581,11 +587,11 @@ fn cancel_approval_works_with_admin() {
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(2), 0, 42, 3));
|
||||
assert_noop!(
|
||||
Uniques::cancel_approval(Origin::signed(1), 1, 42, None),
|
||||
Error::<Test>::UnknownClass
|
||||
Error::<Test>::UnknownCollection
|
||||
);
|
||||
assert_noop!(
|
||||
Uniques::cancel_approval(Origin::signed(1), 0, 43, None),
|
||||
Error::<Test>::UnknownClass
|
||||
Error::<Test>::UnknownCollection
|
||||
);
|
||||
assert_noop!(
|
||||
Uniques::cancel_approval(Origin::signed(1), 0, 42, Some(4)),
|
||||
@@ -609,11 +615,11 @@ fn cancel_approval_works_with_force() {
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(2), 0, 42, 3));
|
||||
assert_noop!(
|
||||
Uniques::cancel_approval(Origin::root(), 1, 42, None),
|
||||
Error::<Test>::UnknownClass
|
||||
Error::<Test>::UnknownCollection
|
||||
);
|
||||
assert_noop!(
|
||||
Uniques::cancel_approval(Origin::root(), 0, 43, None),
|
||||
Error::<Test>::UnknownClass
|
||||
Error::<Test>::UnknownCollection
|
||||
);
|
||||
assert_noop!(
|
||||
Uniques::cancel_approval(Origin::root(), 0, 42, Some(4)),
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Various basic types for use in the assets pallet.
|
||||
//! Various basic types for use in the Uniques pallet.
|
||||
|
||||
use super::*;
|
||||
use frame_support::{
|
||||
@@ -26,13 +26,13 @@ use scale_info::TypeInfo;
|
||||
|
||||
pub(super) type DepositBalanceOf<T, I = ()> =
|
||||
<<T as Config<I>>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance;
|
||||
pub(super) type ClassDetailsFor<T, I> =
|
||||
ClassDetails<<T as SystemConfig>::AccountId, DepositBalanceOf<T, I>>;
|
||||
pub(super) type InstanceDetailsFor<T, I> =
|
||||
InstanceDetails<<T as SystemConfig>::AccountId, DepositBalanceOf<T, I>>;
|
||||
pub(super) type CollectionDetailsFor<T, I> =
|
||||
CollectionDetails<<T as SystemConfig>::AccountId, DepositBalanceOf<T, I>>;
|
||||
pub(super) type ItemDetailsFor<T, I> =
|
||||
ItemDetails<<T as SystemConfig>::AccountId, DepositBalanceOf<T, I>>;
|
||||
|
||||
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
pub struct ClassDetails<AccountId, DepositBalance> {
|
||||
pub struct CollectionDetails<AccountId, DepositBalance> {
|
||||
/// Can change `owner`, `issuer`, `freezer` and `admin` accounts.
|
||||
pub(super) owner: AccountId,
|
||||
/// Can mint tokens.
|
||||
@@ -41,55 +41,55 @@ pub struct ClassDetails<AccountId, DepositBalance> {
|
||||
pub(super) admin: AccountId,
|
||||
/// Can freeze tokens.
|
||||
pub(super) freezer: AccountId,
|
||||
/// The total balance deposited for the all storage associated with this asset class. Used by
|
||||
/// `destroy`.
|
||||
/// The total balance deposited for the all storage associated with this collection.
|
||||
/// Used by `destroy`.
|
||||
pub(super) total_deposit: DepositBalance,
|
||||
/// If `true`, then no deposit is needed to hold instances of this class.
|
||||
/// If `true`, then no deposit is needed to hold items of this collection.
|
||||
pub(super) free_holding: bool,
|
||||
/// The total number of outstanding instances of this asset class.
|
||||
pub(super) instances: u32,
|
||||
/// The total number of outstanding instance metadata of this asset class.
|
||||
pub(super) instance_metadatas: u32,
|
||||
/// The total number of attributes for this asset class.
|
||||
/// The total number of outstanding items of this collection.
|
||||
pub(super) items: u32,
|
||||
/// The total number of outstanding item metadata of this collection.
|
||||
pub(super) item_metadatas: u32,
|
||||
/// The total number of attributes for this collection.
|
||||
pub(super) attributes: u32,
|
||||
/// Whether the asset is frozen for non-admin transfers.
|
||||
/// Whether the collection is frozen for non-admin transfers.
|
||||
pub(super) is_frozen: bool,
|
||||
}
|
||||
|
||||
/// Witness data for the destroy transactions.
|
||||
#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
|
||||
pub struct DestroyWitness {
|
||||
/// The total number of outstanding instances of this asset class.
|
||||
/// The total number of outstanding items of this collection.
|
||||
#[codec(compact)]
|
||||
pub instances: u32,
|
||||
/// The total number of outstanding instance metadata of this asset class.
|
||||
pub items: u32,
|
||||
/// The total number of items in this collection that have outstanding item metadata.
|
||||
#[codec(compact)]
|
||||
pub instance_metadatas: u32,
|
||||
pub item_metadatas: u32,
|
||||
#[codec(compact)]
|
||||
/// The total number of attributes for this asset class.
|
||||
/// The total number of attributes for this collection.
|
||||
pub attributes: u32,
|
||||
}
|
||||
|
||||
impl<AccountId, DepositBalance> ClassDetails<AccountId, DepositBalance> {
|
||||
impl<AccountId, DepositBalance> CollectionDetails<AccountId, DepositBalance> {
|
||||
pub fn destroy_witness(&self) -> DestroyWitness {
|
||||
DestroyWitness {
|
||||
instances: self.instances,
|
||||
instance_metadatas: self.instance_metadatas,
|
||||
items: self.items,
|
||||
item_metadatas: self.item_metadatas,
|
||||
attributes: self.attributes,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Information concerning the ownership of a single unique asset.
|
||||
/// Information concerning the ownership of a single unique item.
|
||||
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, Default, TypeInfo, MaxEncodedLen)]
|
||||
pub struct InstanceDetails<AccountId, DepositBalance> {
|
||||
/// The owner of this asset.
|
||||
pub struct ItemDetails<AccountId, DepositBalance> {
|
||||
/// The owner of this item.
|
||||
pub(super) owner: AccountId,
|
||||
/// The approved transferrer of this asset, if one is set.
|
||||
/// The approved transferrer of this item, if one is set.
|
||||
pub(super) approved: Option<AccountId>,
|
||||
/// Whether the asset can be transferred or not.
|
||||
/// Whether the item can be transferred or not.
|
||||
pub(super) is_frozen: bool,
|
||||
/// The amount held in the pallet's default account for this asset. Free-hold assets will have
|
||||
/// The amount held in the pallet's default account for this item. Free-hold items will have
|
||||
/// this as zero.
|
||||
pub(super) deposit: DepositBalance,
|
||||
}
|
||||
@@ -97,31 +97,31 @@ pub struct InstanceDetails<AccountId, DepositBalance> {
|
||||
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, Default, TypeInfo, MaxEncodedLen)]
|
||||
#[scale_info(skip_type_params(StringLimit))]
|
||||
#[codec(mel_bound(DepositBalance: MaxEncodedLen))]
|
||||
pub struct ClassMetadata<DepositBalance, StringLimit: Get<u32>> {
|
||||
pub struct CollectionMetadata<DepositBalance, StringLimit: Get<u32>> {
|
||||
/// The balance deposited for this metadata.
|
||||
///
|
||||
/// This pays for the data stored in this struct.
|
||||
pub(super) deposit: DepositBalance,
|
||||
/// General information concerning this asset. Limited in length by `StringLimit`. This will
|
||||
/// generally be either a JSON dump or the hash of some JSON which can be found on a
|
||||
/// General information concerning this collection. Limited in length by `StringLimit`. This
|
||||
/// will generally be either a JSON dump or the hash of some JSON which can be found on a
|
||||
/// hash-addressable global publication system such as IPFS.
|
||||
pub(super) data: BoundedVec<u8, StringLimit>,
|
||||
/// Whether the asset metadata may be changed by a non Force origin.
|
||||
/// Whether the collection's metadata may be changed by a non Force origin.
|
||||
pub(super) is_frozen: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, Default, TypeInfo, MaxEncodedLen)]
|
||||
#[scale_info(skip_type_params(StringLimit))]
|
||||
#[codec(mel_bound(DepositBalance: MaxEncodedLen))]
|
||||
pub struct InstanceMetadata<DepositBalance, StringLimit: Get<u32>> {
|
||||
pub struct ItemMetadata<DepositBalance, StringLimit: Get<u32>> {
|
||||
/// The balance deposited for this metadata.
|
||||
///
|
||||
/// This pays for the data stored in this struct.
|
||||
pub(super) deposit: DepositBalance,
|
||||
/// General information concerning this asset. Limited in length by `StringLimit`. This will
|
||||
/// General information concerning this item. Limited in length by `StringLimit`. This will
|
||||
/// generally be either a JSON dump or the hash of some JSON which can be found on a
|
||||
/// hash-addressable global publication system such as IPFS.
|
||||
pub(super) data: BoundedVec<u8, StringLimit>,
|
||||
/// Whether the asset metadata may be changed by a non Force origin.
|
||||
/// Whether the item metadata may be changed by a non Force origin.
|
||||
pub(super) is_frozen: bool,
|
||||
}
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
//! Autogenerated weights for pallet_uniques
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-01-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! DATE: 2022-05-12, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// ./target/production/substrate
|
||||
// target/production/substrate
|
||||
// benchmark
|
||||
// pallet
|
||||
// --chain=dev
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
@@ -33,9 +34,7 @@
|
||||
// --wasm-execution=compiled
|
||||
// --heap-pages=4096
|
||||
// --output=./frame/uniques/src/weights.rs
|
||||
// --template=.maintain/frame-weight-template.hbs
|
||||
// --header=HEADER-APACHE2
|
||||
// --raw
|
||||
// --template=./.maintain/frame-weight-template.hbs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
@@ -55,17 +54,17 @@ pub trait WeightInfo {
|
||||
fn redeposit(i: u32, ) -> Weight;
|
||||
fn freeze() -> Weight;
|
||||
fn thaw() -> Weight;
|
||||
fn freeze_class() -> Weight;
|
||||
fn thaw_class() -> Weight;
|
||||
fn freeze_collection() -> Weight;
|
||||
fn thaw_collection() -> Weight;
|
||||
fn transfer_ownership() -> Weight;
|
||||
fn set_team() -> Weight;
|
||||
fn force_asset_status() -> Weight;
|
||||
fn force_item_status() -> Weight;
|
||||
fn set_attribute() -> Weight;
|
||||
fn clear_attribute() -> Weight;
|
||||
fn set_metadata() -> Weight;
|
||||
fn clear_metadata() -> Weight;
|
||||
fn set_class_metadata() -> Weight;
|
||||
fn clear_class_metadata() -> Weight;
|
||||
fn set_collection_metadata() -> Weight;
|
||||
fn clear_collection_metadata() -> Weight;
|
||||
fn approve_transfer() -> Weight;
|
||||
fn cancel_approval() -> Weight;
|
||||
fn set_accept_ownership() -> Weight;
|
||||
@@ -77,14 +76,14 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn create() -> Weight {
|
||||
(24_063_000 as Weight)
|
||||
(24_319_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn force_create() -> Weight {
|
||||
(13_017_000 as Weight)
|
||||
(13_572_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -97,12 +96,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Account (r:0 w:20)
|
||||
fn destroy(n: u32, m: u32, a: u32, ) -> Weight {
|
||||
(0 as Weight)
|
||||
// Standard Error: 14_000
|
||||
.saturating_add((9_248_000 as Weight).saturating_mul(n as Weight))
|
||||
// Standard Error: 14_000
|
||||
.saturating_add((854_000 as Weight).saturating_mul(m as Weight))
|
||||
// Standard Error: 14_000
|
||||
.saturating_add((758_000 as Weight).saturating_mul(a as Weight))
|
||||
// Standard Error: 15_000
|
||||
.saturating_add((9_433_000 as Weight).saturating_mul(n as Weight))
|
||||
// Standard Error: 15_000
|
||||
.saturating_add((980_000 as Weight).saturating_mul(m as Weight))
|
||||
// Standard Error: 15_000
|
||||
.saturating_add((852_000 as Weight).saturating_mul(a as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight)))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
@@ -114,7 +113,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques Account (r:0 w:1)
|
||||
fn mint() -> Weight {
|
||||
(29_865_000 as Weight)
|
||||
(29_884_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
@@ -122,7 +121,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Account (r:0 w:1)
|
||||
fn burn() -> Weight {
|
||||
(31_603_000 as Weight)
|
||||
(31_384_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
@@ -130,7 +129,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Account (r:0 w:2)
|
||||
fn transfer() -> Weight {
|
||||
(23_331_000 as Weight)
|
||||
(23_254_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
@@ -138,8 +137,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Asset (r:100 w:100)
|
||||
fn redeposit(i: u32, ) -> Weight {
|
||||
(0 as Weight)
|
||||
// Standard Error: 12_000
|
||||
.saturating_add((11_527_000 as Weight).saturating_mul(i as Weight))
|
||||
// Standard Error: 13_000
|
||||
.saturating_add((11_718_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
@@ -148,47 +147,47 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn freeze() -> Weight {
|
||||
(18_617_000 as Weight)
|
||||
(17_807_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn thaw() -> Weight {
|
||||
(18_618_000 as Weight)
|
||||
(17_904_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn freeze_class() -> Weight {
|
||||
(13_570_000 as Weight)
|
||||
fn freeze_collection() -> Weight {
|
||||
(13_828_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn thaw_class() -> Weight {
|
||||
(13_937_000 as Weight)
|
||||
fn thaw_collection() -> Weight {
|
||||
(13_636_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques OwnershipAcceptance (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: System Account (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:2)
|
||||
fn transfer_ownership() -> Weight {
|
||||
(31_021_000 as Weight)
|
||||
(20_897_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn set_team() -> Weight {
|
||||
(14_739_000 as Weight)
|
||||
(14_340_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn force_asset_status() -> Weight {
|
||||
(16_826_000 as Weight)
|
||||
fn force_item_status() -> Weight {
|
||||
(16_355_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -196,7 +195,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:0)
|
||||
// Storage: Uniques Attribute (r:1 w:1)
|
||||
fn set_attribute() -> Weight {
|
||||
(37_010_000 as Weight)
|
||||
(37_035_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -204,56 +203,55 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:0)
|
||||
// Storage: Uniques Attribute (r:1 w:1)
|
||||
fn clear_attribute() -> Weight {
|
||||
(34_432_000 as Weight)
|
||||
(34_957_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:1)
|
||||
fn set_metadata() -> Weight {
|
||||
(28_575_000 as Weight)
|
||||
(28_337_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:1)
|
||||
fn clear_metadata() -> Weight {
|
||||
(28_730_000 as Weight)
|
||||
(29_166_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassMetadataOf (r:1 w:1)
|
||||
fn set_class_metadata() -> Weight {
|
||||
(28_225_000 as Weight)
|
||||
fn set_collection_metadata() -> Weight {
|
||||
(28_246_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques ClassMetadataOf (r:1 w:1)
|
||||
fn clear_class_metadata() -> Weight {
|
||||
(26_455_000 as Weight)
|
||||
fn clear_collection_metadata() -> Weight {
|
||||
(26_637_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
fn approve_transfer() -> Weight {
|
||||
(19_587_000 as Weight)
|
||||
(18_938_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
fn cancel_approval() -> Weight {
|
||||
(19_417_000 as Weight)
|
||||
(18_465_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques OwnershipAcceptance (r:1 w:1)
|
||||
fn set_accept_ownership() -> Weight {
|
||||
(19_417_000 as Weight)
|
||||
(16_675_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
@@ -264,14 +262,14 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn create() -> Weight {
|
||||
(24_063_000 as Weight)
|
||||
(24_319_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn force_create() -> Weight {
|
||||
(13_017_000 as Weight)
|
||||
(13_572_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -284,12 +282,12 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Account (r:0 w:20)
|
||||
fn destroy(n: u32, m: u32, a: u32, ) -> Weight {
|
||||
(0 as Weight)
|
||||
// Standard Error: 14_000
|
||||
.saturating_add((9_248_000 as Weight).saturating_mul(n as Weight))
|
||||
// Standard Error: 14_000
|
||||
.saturating_add((854_000 as Weight).saturating_mul(m as Weight))
|
||||
// Standard Error: 14_000
|
||||
.saturating_add((758_000 as Weight).saturating_mul(a as Weight))
|
||||
// Standard Error: 15_000
|
||||
.saturating_add((9_433_000 as Weight).saturating_mul(n as Weight))
|
||||
// Standard Error: 15_000
|
||||
.saturating_add((980_000 as Weight).saturating_mul(m as Weight))
|
||||
// Standard Error: 15_000
|
||||
.saturating_add((852_000 as Weight).saturating_mul(a as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight)))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
@@ -301,7 +299,7 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques Account (r:0 w:1)
|
||||
fn mint() -> Weight {
|
||||
(29_865_000 as Weight)
|
||||
(29_884_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
@@ -309,7 +307,7 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Account (r:0 w:1)
|
||||
fn burn() -> Weight {
|
||||
(31_603_000 as Weight)
|
||||
(31_384_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
@@ -317,7 +315,7 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Account (r:0 w:2)
|
||||
fn transfer() -> Weight {
|
||||
(23_331_000 as Weight)
|
||||
(23_254_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
@@ -325,8 +323,8 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Asset (r:100 w:100)
|
||||
fn redeposit(i: u32, ) -> Weight {
|
||||
(0 as Weight)
|
||||
// Standard Error: 12_000
|
||||
.saturating_add((11_527_000 as Weight).saturating_mul(i as Weight))
|
||||
// Standard Error: 13_000
|
||||
.saturating_add((11_718_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
@@ -335,47 +333,47 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn freeze() -> Weight {
|
||||
(18_617_000 as Weight)
|
||||
(17_807_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn thaw() -> Weight {
|
||||
(18_618_000 as Weight)
|
||||
(17_904_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn freeze_class() -> Weight {
|
||||
(13_570_000 as Weight)
|
||||
fn freeze_collection() -> Weight {
|
||||
(13_828_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn thaw_class() -> Weight {
|
||||
(13_937_000 as Weight)
|
||||
fn thaw_collection() -> Weight {
|
||||
(13_636_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques OwnershipAcceptance (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: System Account (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:2)
|
||||
fn transfer_ownership() -> Weight {
|
||||
(31_021_000 as Weight)
|
||||
(20_897_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn set_team() -> Weight {
|
||||
(14_739_000 as Weight)
|
||||
(14_340_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn force_asset_status() -> Weight {
|
||||
(16_826_000 as Weight)
|
||||
fn force_item_status() -> Weight {
|
||||
(16_355_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -383,7 +381,7 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:0)
|
||||
// Storage: Uniques Attribute (r:1 w:1)
|
||||
fn set_attribute() -> Weight {
|
||||
(37_010_000 as Weight)
|
||||
(37_035_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -391,56 +389,55 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:0)
|
||||
// Storage: Uniques Attribute (r:1 w:1)
|
||||
fn clear_attribute() -> Weight {
|
||||
(34_432_000 as Weight)
|
||||
(34_957_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:1)
|
||||
fn set_metadata() -> Weight {
|
||||
(28_575_000 as Weight)
|
||||
(28_337_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:1)
|
||||
fn clear_metadata() -> Weight {
|
||||
(28_730_000 as Weight)
|
||||
(29_166_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassMetadataOf (r:1 w:1)
|
||||
fn set_class_metadata() -> Weight {
|
||||
(28_225_000 as Weight)
|
||||
fn set_collection_metadata() -> Weight {
|
||||
(28_246_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques ClassMetadataOf (r:1 w:1)
|
||||
fn clear_class_metadata() -> Weight {
|
||||
(26_455_000 as Weight)
|
||||
fn clear_collection_metadata() -> Weight {
|
||||
(26_637_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
fn approve_transfer() -> Weight {
|
||||
(19_587_000 as Weight)
|
||||
(18_938_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
fn cancel_approval() -> Weight {
|
||||
(19_417_000 as Weight)
|
||||
(18_465_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques OwnershipAcceptance (r:1 w:1)
|
||||
fn set_accept_ownership() -> Weight {
|
||||
(19_417_000 as Weight)
|
||||
(16_675_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user