difftreelog
Transaction payment and weights fix
in: master
4 files changed
pallets/nft/src/default_weights.rsdiffbeforeafterbothno changes
pallets/nft/src/lib.rsdiffbeforeafterboth44#[cfg(test)]44#[cfg(test)]45mod tests;45mod tests;4647mod default_weights;464847// Structs49// Structs48// #region50// #region182 pub refungible_sponsor_transfer_timeout: u32,184 pub refungible_sponsor_transfer_timeout: u32,183}185}186187pub trait WeightInfo {188 fn create_collection() -> Weight;189 fn destroy_collection() -> Weight;190 fn add_to_white_list() -> Weight;191 fn remove_from_white_list() -> Weight;192 fn set_public_access_mode() -> Weight;193 fn set_mint_permission() -> Weight;194 fn change_collection_owner() -> Weight;195 fn add_collection_admin() -> Weight;196 fn remove_collection_admin() -> Weight;197 fn set_collection_sponsor() -> Weight;198 fn confirm_sponsorship() -> Weight;199 fn remove_collection_sponsor() -> Weight;200 fn create_item(s: usize, ) -> Weight;201 fn burn_item() -> Weight;202 fn transfer() -> Weight;203 fn approve() -> Weight;204 fn transfer_from() -> Weight;205 fn set_offchain_schema() -> Weight;206}184207185pub trait Trait: system::Trait {208pub trait Trait: system::Trait + Sized {186 type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;209 type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;210211 /// Weight information for extrinsics in this pallet.212 type WeightInfo: WeightInfo;187}213}188214189#[cfg(feature = "runtime-benchmarks")]215#[cfg(feature = "runtime-benchmarks")]326 /// 352 /// 327 /// * mode: [CollectionMode] collection type and type dependent data.353 /// * mode: [CollectionMode] collection type and type dependent data.328 // returns collection ID354 // returns collection ID329 #[weight =355 #[weight = T::WeightInfo::create_collection()]330 (70_000_000 as Weight)331 .saturating_add(RocksDbWeight::get().reads(7 as Weight))332 .saturating_add(RocksDbWeight::get().writes(5 as Weight))]333 pub fn create_collection(origin,356 pub fn create_collection(origin,334 collection_name: Vec<u16>,357 collection_name: Vec<u16>,335 collection_description: Vec<u16>,358 collection_description: Vec<u16>,425 /// # Arguments448 /// # Arguments426 /// 449 /// 427 /// * collection_id: collection to destroy.450 /// * collection_id: collection to destroy.428 #[weight =451 #[weight = T::WeightInfo::destroy_collection()]429 (90_000_000 as Weight)430 .saturating_add(RocksDbWeight::get().reads(2 as Weight))431 .saturating_add(RocksDbWeight::get().writes(5 as Weight))]432 pub fn destroy_collection(origin, collection_id: u64) -> DispatchResult {452 pub fn destroy_collection(origin, collection_id: u64) -> DispatchResult {433453434 let sender = ensure_signed(origin)?;454 let sender = ensure_signed(origin)?;475 /// * collection_id.495 /// * collection_id.476 /// 496 /// 477 /// * address.497 /// * address.478 #[weight =498 #[weight = T::WeightInfo::add_to_white_list()]479 (30_000_000 as Weight)480 .saturating_add(RocksDbWeight::get().reads(3 as Weight))481 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]482 pub fn add_to_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{499 pub fn add_to_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{483500484 let sender = ensure_signed(origin)?;501 let sender = ensure_signed(origin)?;513 /// * collection_id.530 /// * collection_id.514 /// 531 /// 515 /// * address.532 /// * address.516 #[weight =533 #[weight = T::WeightInfo::remove_from_white_list()]517 (35_000_000 as Weight)518 .saturating_add(RocksDbWeight::get().reads(3 as Weight))519 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]520 pub fn remove_from_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{534 pub fn remove_from_white_list(origin, collection_id: u64, address: T::AccountId) -> DispatchResult{521535522 let sender = ensure_signed(origin)?;536 let sender = ensure_signed(origin)?;545 /// * collection_id.559 /// * collection_id.546 /// 560 /// 547 /// * mode: [AccessMode]561 /// * mode: [AccessMode]548 #[weight =562 #[weight = T::WeightInfo::set_public_access_mode()]549 (27_000_000 as Weight)550 .saturating_add(RocksDbWeight::get().reads(1 as Weight))551 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]552 pub fn set_public_access_mode(origin, collection_id: u64, mode: AccessMode) -> DispatchResult563 pub fn set_public_access_mode(origin, collection_id: u64, mode: AccessMode) -> DispatchResult553 {564 {554 let sender = ensure_signed(origin)?;565 let sender = ensure_signed(origin)?;574 /// * collection_id.585 /// * collection_id.575 /// 586 /// 576 /// * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.587 /// * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.577 #[weight =588 #[weight = T::WeightInfo::set_mint_permission()]578 (27_000_000 as Weight)579 .saturating_add(RocksDbWeight::get().reads(1 as Weight))580 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]581 pub fn set_mint_permission(origin, collection_id: u64, mint_permission: bool) -> DispatchResult589 pub fn set_mint_permission(origin, collection_id: u64, mint_permission: bool) -> DispatchResult582 {590 {583 let sender = ensure_signed(origin)?;591 let sender = ensure_signed(origin)?;601 /// * collection_id.609 /// * collection_id.602 /// 610 /// 603 /// * new_owner.611 /// * new_owner.604 #[weight =612 #[weight = T::WeightInfo::change_collection_owner()]605 (27_000_000 as Weight)606 .saturating_add(RocksDbWeight::get().reads(1 as Weight))607 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]608 pub fn change_collection_owner(origin, collection_id: u64, new_owner: T::AccountId) -> DispatchResult {613 pub fn change_collection_owner(origin, collection_id: u64, new_owner: T::AccountId) -> DispatchResult {609614610 let sender = ensure_signed(origin)?;615 let sender = ensure_signed(origin)?;629 /// * collection_id: ID of the Collection to add admin for.634 /// * collection_id: ID of the Collection to add admin for.630 /// 635 /// 631 /// * new_admin_id: Address of new admin to add.636 /// * new_admin_id: Address of new admin to add.632 #[weight =637 #[weight = T::WeightInfo::add_collection_admin()]633 (32_000_000 as Weight)634 .saturating_add(RocksDbWeight::get().reads(3 as Weight))635 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]636 pub fn add_collection_admin(origin, collection_id: u64, new_admin_id: T::AccountId) -> DispatchResult {638 pub fn add_collection_admin(origin, collection_id: u64, new_admin_id: T::AccountId) -> DispatchResult {637639638 let sender = ensure_signed(origin)?;640 let sender = ensure_signed(origin)?;666 /// * collection_id: ID of the Collection to remove admin for.668 /// * collection_id: ID of the Collection to remove admin for.667 /// 669 /// 668 /// * account_id: Address of admin to remove.670 /// * account_id: Address of admin to remove.669 #[weight =671 #[weight = T::WeightInfo::remove_collection_admin()]670 (50_000_000 as Weight)671 .saturating_add(RocksDbWeight::get().reads(2 as Weight))672 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]673 pub fn remove_collection_admin(origin, collection_id: u64, account_id: T::AccountId) -> DispatchResult {672 pub fn remove_collection_admin(origin, collection_id: u64, account_id: T::AccountId) -> DispatchResult {674673675 let sender = ensure_signed(origin)?;674 let sender = ensure_signed(origin)?;694 /// * collection_id.693 /// * collection_id.695 /// 694 /// 696 /// * new_sponsor.695 /// * new_sponsor.697 #[weight =696 #[weight = T::WeightInfo::set_collection_sponsor()]698 (32_000_000 as Weight)699 .saturating_add(RocksDbWeight::get().reads(2 as Weight))700 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]701 pub fn set_collection_sponsor(origin, collection_id: u64, new_sponsor: T::AccountId) -> DispatchResult {697 pub fn set_collection_sponsor(origin, collection_id: u64, new_sponsor: T::AccountId) -> DispatchResult {702698703 let sender = ensure_signed(origin)?;699 let sender = ensure_signed(origin)?;719 /// # Arguments715 /// # Arguments720 /// 716 /// 721 /// * collection_id.717 /// * collection_id.722 #[weight =718 #[weight = T::WeightInfo::confirm_sponsorship()]723 (22_000_000 as Weight)724 .saturating_add(RocksDbWeight::get().reads(1 as Weight))725 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]726 pub fn confirm_sponsorship(origin, collection_id: u64) -> DispatchResult {719 pub fn confirm_sponsorship(origin, collection_id: u64) -> DispatchResult {727720728 let sender = ensure_signed(origin)?;721 let sender = ensure_signed(origin)?;747 /// # Arguments740 /// # Arguments748 /// 741 /// 749 /// * collection_id.742 /// * collection_id.750 #[weight =743 #[weight = T::WeightInfo::remove_collection_sponsor()]751 (24_000_000 as Weight)752 .saturating_add(RocksDbWeight::get().reads(1 as Weight))753 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]754 pub fn remove_collection_sponsor(origin, collection_id: u64) -> DispatchResult {744 pub fn remove_collection_sponsor(origin, collection_id: u64) -> DispatchResult {755745756 let sender = ensure_signed(origin)?;746 let sender = ensure_signed(origin)?;783 /// * properties: Array of bytes that contains NFT properties. Since NFT Module is agnostic of properties meaning, it is treated purely as an array of bytes.773 /// * properties: Array of bytes that contains NFT properties. Since NFT Module is agnostic of properties meaning, it is treated purely as an array of bytes.784 /// 774 /// 785 /// * owner: Address, initial owner of the NFT.775 /// * owner: Address, initial owner of the NFT.776 // #[weight =777 // (130_000_000 as Weight)778 // .saturating_add((2135 as Weight).saturating_mul((properties.len() as u64) as Weight))779 // .saturating_add(RocksDbWeight::get().reads(10 as Weight))780 // .saturating_add(RocksDbWeight::get().writes(8 as Weight))]781786 #[weight =782 #[weight = T::WeightInfo::create_item(properties.len())]787 (130_000_000 as Weight)788 .saturating_add((2135 as Weight).saturating_mul((properties.len() as u64) as Weight))789 .saturating_add(RocksDbWeight::get().reads(10 as Weight))790 .saturating_add(RocksDbWeight::get().writes(8 as Weight))]791 pub fn create_item(origin, collection_id: u64, properties: Vec<u8>, owner: T::AccountId) -> DispatchResult {783 pub fn create_item(origin, collection_id: u64, properties: Vec<u8>, owner: T::AccountId) -> DispatchResult {792784793 let sender = ensure_signed(origin)?;785 let sender = ensure_signed(origin)?;870 /// * collection_id: ID of the collection.862 /// * collection_id: ID of the collection.871 /// 863 /// 872 /// * item_id: ID of NFT to burn.864 /// * item_id: ID of NFT to burn.873 #[weight =865 #[weight = T::WeightInfo::burn_item()]874 (170_000_000 as Weight)875 .saturating_add(RocksDbWeight::get().reads(9 as Weight))876 .saturating_add(RocksDbWeight::get().writes(7 as Weight))]877 pub fn burn_item(origin, collection_id: u64, item_id: u64) -> DispatchResult {866 pub fn burn_item(origin, collection_id: u64, item_id: u64) -> DispatchResult {878867879 let sender = ensure_signed(origin)?;868 let sender = ensure_signed(origin)?;926 /// * Non-Fungible Mode: Ignored915 /// * Non-Fungible Mode: Ignored927 /// * Fungible Mode: Must specify transferred amount916 /// * Fungible Mode: Must specify transferred amount928 /// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)917 /// * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)929 #[weight =918 #[weight = T::WeightInfo::transfer()]930 (125_000_000 as Weight)931 .saturating_add(RocksDbWeight::get().reads(7 as Weight))932 .saturating_add(RocksDbWeight::get().writes(7 as Weight))]933 pub fn transfer(origin, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64) -> DispatchResult {919 pub fn transfer(origin, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64) -> DispatchResult {934920935 let sender = ensure_signed(origin)?;921 let sender = ensure_signed(origin)?;971 /// * collection_id.957 /// * collection_id.972 /// 958 /// 973 /// * item_id: ID of the item.959 /// * item_id: ID of the item.974 #[weight =960 #[weight = T::WeightInfo::approve()]975 (45_000_000 as Weight)976 .saturating_add(RocksDbWeight::get().reads(3 as Weight))977 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]978 pub fn approve(origin, approved: T::AccountId, collection_id: u64, item_id: u64) -> DispatchResult {961 pub fn approve(origin, approved: T::AccountId, collection_id: u64, item_id: u64) -> DispatchResult {979962980 let sender = ensure_signed(origin)?;963 let sender = ensure_signed(origin)?;1032 /// * item_id: ID of the item.1015 /// * item_id: ID of the item.1033 /// 1016 /// 1034 /// * value: Amount to transfer.1017 /// * value: Amount to transfer.1035 #[weight =1018 #[weight = T::WeightInfo::transfer_from()]1036 (150_000_000 as Weight)1037 .saturating_add(RocksDbWeight::get().reads(9 as Weight))1038 .saturating_add(RocksDbWeight::get().writes(8 as Weight))]1039 pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64 ) -> DispatchResult {1019 pub fn transfer_from(origin, from: T::AccountId, recipient: T::AccountId, collection_id: u64, item_id: u64, value: u64 ) -> DispatchResult {104010201041 let sender = ensure_signed(origin)?;1021 let sender = ensure_signed(origin)?;1107 /// * collection_id.1087 /// * collection_id.1108 /// 1088 /// 1109 /// * schema: String representing the offchain data schema.1089 /// * schema: String representing the offchain data schema.1110 #[weight =1090 #[weight = T::WeightInfo::set_offchain_schema()]1111 (33_000_000 as Weight)1112 .saturating_add(RocksDbWeight::get().reads(2 as Weight))1113 .saturating_add(RocksDbWeight::get().writes(1 as Weight))]1114 pub fn set_offchain_schema(1091 pub fn set_offchain_schema(1115 origin,1092 origin,1116 collection_id: u64,1093 collection_id: u64,runtime/src/lib.rsdiffbeforeafterboth84/// Digest item type.84/// Digest item type.85pub type DigestItem = generic::DigestItem<Hash>;85pub type DigestItem = generic::DigestItem<Hash>;868687mod nft_weights;878888/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know89/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know89/// the specifics of the runtime. They can then be made to be agnostic over specific formats90/// the specifics of the runtime. They can then be made to be agnostic over specific formats144 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;145 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;145 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);146 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);146 /// Assume 10% of weight for average on_initialize calls.147 /// Assume 10% of weight for average on_initialize calls.148 // pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()149 // .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();150147 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()151 pub MaximumExtrinsicWeight: Weight = 4_294_967_295; 148 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();152 //pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;149 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;153 pub const MaximumBlockLength: u32 = 4_294_967_295;150 pub const Version: RuntimeVersion = VERSION;154 pub const Version: RuntimeVersion = VERSION;151}155}152156291}295}292296293parameter_types! {297parameter_types! {294 pub const TransactionByteFee: Balance = 1;298 pub const TransactionByteFee: Balance = 10 * MILLICENTS;295}299}296300297impl pallet_transaction_payment::Trait for Runtime {301impl pallet_transaction_payment::Trait for Runtime {310/// Used for the module nft in `./nft.rs`314/// Used for the module nft in `./nft.rs`311impl pallet_nft::Trait for Runtime {315impl pallet_nft::Trait for Runtime {312 type Event = Event;316 type Event = Event;317 type WeightInfo = nft_weights::WeightInfo;313}318}314319315construct_runtime!(320construct_runtime!(runtime/src/nft_weights.rsdiffbeforeafterbothno changes