git.delta.rocks / unique-network / refs/commits / 7fd36cea2f6e

difftreelog

refactor remove `#[transactional]` from extrinsics

Yaroslav Bolyukin2022-07-21parent: #e198017.patch.diff
in: master
Every extrinsic now runs in transaction implicitly, and
`#[transactional]` on pallet dispatchable is now meaningless

4 files changed

modifiedpallets/evm-migration/src/lib.rsdiffbeforeafterboth
2323
24#[frame_support::pallet]24#[frame_support::pallet]
25pub mod pallet {25pub mod pallet {
26 use frame_support::{pallet_prelude::*, transactional};26 use frame_support::pallet_prelude::*;
27 use frame_system::pallet_prelude::*;27 use frame_system::pallet_prelude::*;
28 use sp_core::{H160, H256};28 use sp_core::{H160, H256};
29 use sp_std::vec::Vec;29 use sp_std::vec::Vec;
84 }84 }
8585
86 #[pallet::weight(<SelfWeightOf<T>>::finish(code.len() as u32))]86 #[pallet::weight(<SelfWeightOf<T>>::finish(code.len() as u32))]
87 #[transactional]
88 pub fn finish(origin: OriginFor<T>, address: H160, code: Vec<u8>) -> DispatchResult {87 pub fn finish(origin: OriginFor<T>, address: H160, code: Vec<u8>) -> DispatchResult {
89 ensure_root(origin)?;88 ensure_root(origin)?;
90 ensure!(89 ensure!(
modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
145145
146#![cfg_attr(not(feature = "std"), no_std)]146#![cfg_attr(not(feature = "std"), no_std)]
147147
148use frame_support::{pallet_prelude::*, transactional, BoundedVec, dispatch::DispatchResult};148use frame_support::{pallet_prelude::*, BoundedVec, dispatch::DispatchResult};
149use frame_system::{pallet_prelude::*, ensure_signed};149use frame_system::{pallet_prelude::*, ensure_signed};
150use sp_runtime::{DispatchError, Permill, traits::StaticLookup};150use sp_runtime::{DispatchError, Permill, traits::StaticLookup};
151use sp_std::{151use sp_std::{
350 /// * Anyone - will be assigned as the issuer of the collection.350 /// * Anyone - will be assigned as the issuer of the collection.
351 ///351 ///
352 /// # Arguments:352 /// # Arguments:
353 /// - `origin`: sender of the transaction
353 /// - `metadata`: Metadata describing the collection, e.g. IPFS hash. Cannot be changed.354 /// - `metadata`: Metadata describing the collection, e.g. IPFS hash. Cannot be changed.
354 /// - `max`: Optional maximum number of tokens.355 /// - `max`: Optional maximum number of tokens.
355 /// - `symbol`: UTF-8 string with token prefix, by which to represent the token in wallets and UIs.356 /// - `symbol`: UTF-8 string with token prefix, by which to represent the token in wallets and UIs.
356 /// Analogous to Unique's [`token_prefix`](up_data_structs::Collection). Cannot be changed.357 /// Analogous to Unique's [`token_prefix`](up_data_structs::Collection). Cannot be changed.
357 #[transactional]
358 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]358 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]
359 pub fn create_collection(359 pub fn create_collection(
360 origin: OriginFor<T>,360 origin: OriginFor<T>,
426 /// * Collection issuer426 /// * Collection issuer
427 ///427 ///
428 /// # Arguments:428 /// # Arguments:
429 /// - `origin`: sender of the transaction
429 /// - `collection_id`: RMRK ID of the collection to destroy.430 /// - `collection_id`: RMRK ID of the collection to destroy.
430 #[transactional]
431 #[pallet::weight(<SelfWeightOf<T>>::destroy_collection())]431 #[pallet::weight(<SelfWeightOf<T>>::destroy_collection())]
432 pub fn destroy_collection(432 pub fn destroy_collection(
433 origin: OriginFor<T>,433 origin: OriginFor<T>,
459 /// * Collection issuer459 /// * Collection issuer
460 ///460 ///
461 /// # Arguments:461 /// # Arguments:
462 /// - `origin`: sender of the transaction
462 /// - `collection_id`: RMRK collection ID to change the issuer of.463 /// - `collection_id`: RMRK collection ID to change the issuer of.
463 /// - `new_issuer`: Collection's new issuer.464 /// - `new_issuer`: Collection's new issuer.
464 #[transactional]
465 #[pallet::weight(<SelfWeightOf<T>>::change_collection_issuer())]465 #[pallet::weight(<SelfWeightOf<T>>::change_collection_issuer())]
466 pub fn change_collection_issuer(466 pub fn change_collection_issuer(
467 origin: OriginFor<T>,467 origin: OriginFor<T>,
497 /// * Collection issuer497 /// * Collection issuer
498 ///498 ///
499 /// # Arguments:499 /// # Arguments:
500 /// - `origin`: sender of the transaction
500 /// - `collection_id`: RMRK ID of the collection to lock.501 /// - `collection_id`: RMRK ID of the collection to lock.
501 #[transactional]
502 #[pallet::weight(<SelfWeightOf<T>>::lock_collection())]502 #[pallet::weight(<SelfWeightOf<T>>::lock_collection())]
503 pub fn lock_collection(503 pub fn lock_collection(
504 origin: OriginFor<T>,504 origin: OriginFor<T>,
535 /// * Collection issuer535 /// * Collection issuer
536 ///536 ///
537 /// # Arguments:537 /// # Arguments:
538 /// - `origin`: sender of the transaction
538 /// - `owner`: Owner account of the NFT. If set to None, defaults to the sender (collection issuer).539 /// - `owner`: Owner account of the NFT. If set to None, defaults to the sender (collection issuer).
539 /// - `collection_id`: RMRK collection ID for the NFT to be minted within. Cannot be changed.540 /// - `collection_id`: RMRK collection ID for the NFT to be minted within. Cannot be changed.
540 /// - `recipient`: Receiver account of the royalty. Has no effect if the `royalty_amount` is not set. Cannot be changed.541 /// - `recipient`: Receiver account of the royalty. Has no effect if the `royalty_amount` is not set. Cannot be changed.
541 /// - `royalty_amount`: Optional permillage reward from each trade for the `recipient`. Cannot be changed.542 /// - `royalty_amount`: Optional permillage reward from each trade for the `recipient`. Cannot be changed.
542 /// - `metadata`: Arbitrary data about an NFT, e.g. IPFS hash. Cannot be changed.543 /// - `metadata`: Arbitrary data about an NFT, e.g. IPFS hash. Cannot be changed.
543 /// - `transferable`: Can this NFT be transferred? Cannot be changed.544 /// - `transferable`: Can this NFT be transferred? Cannot be changed.
544 /// - `resources`: Resource data to be added to the NFT immediately after minting.545 /// - `resources`: Resource data to be added to the NFT immediately after minting.
545 #[transactional]
546 #[pallet::weight(<SelfWeightOf<T>>::mint_nft(resources.as_ref().map(|r| r.len() as u32).unwrap_or(0)))]546 #[pallet::weight(<SelfWeightOf<T>>::mint_nft(resources.as_ref().map(|r| r.len() as u32).unwrap_or(0)))]
547 pub fn mint_nft(547 pub fn mint_nft(
548 origin: OriginFor<T>,548 origin: OriginFor<T>,
620 /// * Token owner620 /// * Token owner
621 ///621 ///
622 /// # Arguments:622 /// # Arguments:
623 /// - `origin`: sender of the transaction
623 /// - `collection_id`: RMRK ID of the collection in which the NFT to burn belongs to.624 /// - `collection_id`: RMRK ID of the collection in which the NFT to burn belongs to.
624 /// - `nft_id`: ID of the NFT to be destroyed.625 /// - `nft_id`: ID of the NFT to be destroyed.
625 /// - `max_burns`: Maximum number of tokens to burn, assuming nesting. The transaction626 /// - `max_burns`: Maximum number of tokens to burn, assuming nesting. The transaction
626 /// is reverted if there are more tokens to burn in the nesting tree than this number.627 /// is reverted if there are more tokens to burn in the nesting tree than this number.
627 /// This is primarily a mechanism of transaction weight control.628 /// This is primarily a mechanism of transaction weight control.
628 #[transactional]
629 #[pallet::weight(<SelfWeightOf<T>>::burn_nft(*max_burns))]629 #[pallet::weight(<SelfWeightOf<T>>::burn_nft(*max_burns))]
630 pub fn burn_nft(630 pub fn burn_nft(
631 origin: OriginFor<T>,631 origin: OriginFor<T>,
669 /// - Token owner669 /// - Token owner
670 ///670 ///
671 /// # Arguments:671 /// # Arguments:
672 /// - `origin`: sender of the transaction
672 /// - `collection_id`: RMRK ID of the collection of the NFT to be transferred.673 /// - `rmrk_collection_id`: RMRK ID of the collection of the NFT to be transferred.
673 /// - `nft_id`: ID of the NFT to be transferred.674 /// - `rmrk_nft_id`: ID of the NFT to be transferred.
674 /// - `new_owner`: New owner of the nft which can be either an account or a NFT.675 /// - `new_owner`: New owner of the nft which can be either an account or a NFT.
675 #[transactional]
676 #[pallet::weight(<SelfWeightOf<T>>::send())]676 #[pallet::weight(<SelfWeightOf<T>>::send())]
677 pub fn send(677 pub fn send(
678 origin: OriginFor<T>,678 origin: OriginFor<T>,
793 /// - Token-owner-to-be793 /// - Token-owner-to-be
794 ///794 ///
795 /// # Arguments:795 /// # Arguments:
796 /// - `origin`: sender of the transaction
796 /// - `rmrk_collection_id`: RMRK collection ID of the NFT to be accepted.797 /// - `rmrk_collection_id`: RMRK collection ID of the NFT to be accepted.
797 /// - `rmrk_nft_id`: ID of the NFT to be accepted.798 /// - `rmrk_nft_id`: ID of the NFT to be accepted.
798 /// - `new_owner`: Either the sender's account ID or a sender-owned NFT,799 /// - `new_owner`: Either the sender's account ID or a sender-owned NFT,
799 /// whichever the accepted NFT was sent to.800 /// whichever the accepted NFT was sent to.
800 #[transactional]
801 #[pallet::weight(<SelfWeightOf<T>>::accept_nft())]801 #[pallet::weight(<SelfWeightOf<T>>::accept_nft())]
802 pub fn accept_nft(802 pub fn accept_nft(
803 origin: OriginFor<T>,803 origin: OriginFor<T>,
885 /// - Token-owner-to-be-not885 /// - Token-owner-to-be-not
886 ///886 ///
887 /// # Arguments:887 /// # Arguments:
888 /// - `origin`: sender of the transaction
888 /// - `rmrk_collection_id`: RMRK ID of the NFT to be rejected.889 /// - `rmrk_collection_id`: RMRK ID of the NFT to be rejected.
889 /// - `rmrk_nft_id`: ID of the NFT to be rejected.890 /// - `rmrk_nft_id`: ID of the NFT to be rejected.
890 #[transactional]
891 #[pallet::weight(<SelfWeightOf<T>>::reject_nft())]891 #[pallet::weight(<SelfWeightOf<T>>::reject_nft())]
892 pub fn reject_nft(892 pub fn reject_nft(
893 origin: OriginFor<T>,893 origin: OriginFor<T>,
950 /// - Token owner950 /// - Token owner
951 ///951 ///
952 /// # Arguments:952 /// # Arguments:
953 /// - `origin`: sender of the transaction
953 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.954 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.
954 /// - `rmrk_nft_id`: ID of the NFT with a pending resource to be accepted.955 /// - `rmrk_nft_id`: ID of the NFT with a pending resource to be accepted.
955 /// - `resource_id`: ID of the newly created pending resource.956 /// - `resource_id`: ID of the newly created pending resource.
956 #[transactional]957 /// accept the addition of a new resource to an existing NFT
957 #[pallet::weight(<SelfWeightOf<T>>::accept_resource())]958 #[pallet::weight(<SelfWeightOf<T>>::accept_resource())]
958 pub fn accept_resource(959 pub fn accept_resource(
959 origin: OriginFor<T>,960 origin: OriginFor<T>,
1004 /// - Token owner1005 /// - Token owner
1005 ///1006 ///
1006 /// # Arguments:1007 /// # Arguments:
1008 /// - `origin`: sender of the transaction
1007 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.1009 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.
1008 /// - `rmrk_nft_id`: ID of the NFT with a resource to be removed.1010 /// - `rmrk_nft_id`: ID of the NFT with a resource to be removed.
1009 /// - `resource_id`: ID of the removal-pending resource.1011 /// - `resource_id`: ID of the removal-pending resource.
1010 #[transactional]
1011 #[pallet::weight(<SelfWeightOf<T>>::accept_resource_removal())]1012 #[pallet::weight(<SelfWeightOf<T>>::accept_resource_removal())]
1012 pub fn accept_resource_removal(1013 pub fn accept_resource_removal(
1013 origin: OriginFor<T>,1014 origin: OriginFor<T>,
1084 /// - Token owner - in case of NFT property1085 /// - Token owner - in case of NFT property
1085 ///1086 ///
1086 /// # Arguments:1087 /// # Arguments:
1088 /// - `origin`: sender of the transaction
1087 /// - `rmrk_collection_id`: RMRK collection ID.1089 /// - `rmrk_collection_id`: RMRK collection ID.
1088 /// - `maybe_nft_id`: Optional ID of the NFT. If left empty, then the property is set for the collection.1090 /// - `maybe_nft_id`: Optional ID of the NFT. If left empty, then the property is set for the collection.
1089 /// - `key`: Key of the custom property to be referenced by.1091 /// - `key`: Key of the custom property to be referenced by.
1090 /// - `value`: Value of the custom property to be stored.1092 /// - `value`: Value of the custom property to be stored.
1091 #[transactional]
1092 #[pallet::weight(<SelfWeightOf<T>>::set_property())]1093 #[pallet::weight(<SelfWeightOf<T>>::set_property())]
1093 pub fn set_property(1094 pub fn set_property(
1094 origin: OriginFor<T>,1095 origin: OriginFor<T>,
1158 /// - Token owner1159 /// - Token owner
1159 ///1160 ///
1160 /// # Arguments:1161 /// # Arguments:
1162 /// - `origin`: sender of the transaction
1161 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.1163 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.
1162 /// - `rmrk_nft_id`: ID of the NFT to rearrange resource priorities for.1164 /// - `rmrk_nft_id`: ID of the NFT to rearrange resource priorities for.
1163 /// - `priorities`: Ordered vector of resource IDs.1165 /// - `priorities`: Ordered vector of resource IDs.
1164 #[transactional]
1165 #[pallet::weight(<SelfWeightOf<T>>::set_priority())]1166 #[pallet::weight(<SelfWeightOf<T>>::set_priority())]
1166 pub fn set_priority(1167 pub fn set_priority(
1167 origin: OriginFor<T>,1168 origin: OriginFor<T>,
1209 /// the owner's [acceptance](Pallet::accept_resource).1210 /// the owner's [acceptance](Pallet::accept_resource).
1210 ///1211 ///
1211 /// # Arguments:1212 /// # Arguments:
1213 /// - `origin`: sender of the transaction
1212 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.1214 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.
1213 /// - `nft_id`: ID of the NFT to assign a resource to.1215 /// - `nft_id`: ID of the NFT to assign a resource to.
1214 /// - `resource`: Data of the resource to be created.1216 /// - `resource`: Data of the resource to be created.
1215 #[transactional]
1216 #[pallet::weight(<SelfWeightOf<T>>::add_basic_resource())]1217 #[pallet::weight(<SelfWeightOf<T>>::add_basic_resource())]
1217 pub fn add_basic_resource(1218 pub fn add_basic_resource(
1218 origin: OriginFor<T>,1219 origin: OriginFor<T>,
1251 /// the owner's [acceptance](Pallet::accept_resource).1252 /// the owner's [acceptance](Pallet::accept_resource).
1252 ///1253 ///
1253 /// # Arguments:1254 /// # Arguments:
1255 /// - `origin`: sender of the transaction
1254 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.1256 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.
1255 /// - `nft_id`: ID of the NFT to assign a resource to.1257 /// - `nft_id`: ID of the NFT to assign a resource to.
1256 /// - `resource`: Data of the resource to be created.1258 /// - `resource`: Data of the resource to be created.
1257 #[transactional]
1258 #[pallet::weight(<SelfWeightOf<T>>::add_composable_resource())]1259 #[pallet::weight(<SelfWeightOf<T>>::add_composable_resource())]
1259 pub fn add_composable_resource(1260 pub fn add_composable_resource(
1260 origin: OriginFor<T>,1261 origin: OriginFor<T>,
1313 /// the owner's [acceptance](Pallet::accept_resource).1314 /// the owner's [acceptance](Pallet::accept_resource).
1314 ///1315 ///
1315 /// # Arguments:1316 /// # Arguments:
1317 /// - `origin`: sender of the transaction
1316 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.1318 /// - `rmrk_collection_id`: RMRK collection ID of the NFT.
1317 /// - `nft_id`: ID of the NFT to assign a resource to.1319 /// - `nft_id`: ID of the NFT to assign a resource to.
1318 /// - `resource`: Data of the resource to be created.1320 /// - `resource`: Data of the resource to be created.
1319 #[transactional]
1320 #[pallet::weight(<SelfWeightOf<T>>::add_slot_resource())]1321 #[pallet::weight(<SelfWeightOf<T>>::add_slot_resource())]
1321 pub fn add_slot_resource(1322 pub fn add_slot_resource(
1322 origin: OriginFor<T>,1323 origin: OriginFor<T>,
1354 /// - Collection issuer1355 /// - Collection issuer
1355 ///1356 ///
1356 /// # Arguments1357 /// # Arguments
1358 /// - `origin`: sender of the transaction
1357 /// - `collection_id`: RMRK ID of a collection to which the NFT making use of the resource belongs to.1359 /// - `rmrk_collection_id`: RMRK ID of a collection to which the NFT making use of the resource belongs to.
1358 /// - `nft_id`: ID of the NFT with a resource to be removed.1360 /// - `nft_id`: ID of the NFT with a resource to be removed.
1359 /// - `resource_id`: ID of the resource to be removed.1361 /// - `resource_id`: ID of the resource to be removed.
1360 #[transactional]
1361 #[pallet::weight(<SelfWeightOf<T>>::remove_resource())]1362 #[pallet::weight(<SelfWeightOf<T>>::remove_resource())]
1362 pub fn remove_resource(1363 pub fn remove_resource(
1363 origin: OriginFor<T>,1364 origin: OriginFor<T>,
modifiedpallets/proxy-rmrk-equip/src/lib.rsdiffbeforeafterboth
133133
134#![cfg_attr(not(feature = "std"), no_std)]134#![cfg_attr(not(feature = "std"), no_std)]
135135
136use frame_support::{pallet_prelude::*, transactional, BoundedVec, dispatch::DispatchResult};136use frame_support::{pallet_prelude::*, BoundedVec, dispatch::DispatchResult};
137use frame_system::{pallet_prelude::*, ensure_signed};137use frame_system::{pallet_prelude::*, ensure_signed};
138use sp_runtime::DispatchError;138use sp_runtime::DispatchError;
139use up_data_structs::*;139use up_data_structs::*;
226 /// - Anyone - will be assigned as the issuer of the Base.226 /// - Anyone - will be assigned as the issuer of the Base.
227 ///227 ///
228 /// # Arguments:228 /// # Arguments:
229 /// - `origin`: Caller, will be assigned as the issuer of the Base
229 /// - `base_type`: Arbitrary media type, e.g. "svg".230 /// - `base_type`: Arbitrary media type, e.g. "svg".
230 /// - `symbol`: Arbitrary client-chosen symbol.231 /// - `symbol`: Arbitrary client-chosen symbol.
231 /// - `parts`: Array of Fixed and Slot Parts composing the Base,232 /// - `parts`: Array of Fixed and Slot Parts composing the Base,
232 /// confined in length by [`RmrkPartsLimit`](up_data_structs::RmrkPartsLimit).233 /// confined in length by [`RmrkPartsLimit`](up_data_structs::RmrkPartsLimit).
233 #[transactional]
234 #[pallet::weight(<SelfWeightOf<T>>::create_base(parts.len() as u32))]234 #[pallet::weight(<SelfWeightOf<T>>::create_base(parts.len() as u32))]
235 pub fn create_base(235 pub fn create_base(
236 origin: OriginFor<T>,236 origin: OriginFor<T>,
295 /// - Base issuer295 /// - Base issuer
296 ///296 ///
297 /// # Arguments:297 /// # Arguments:
298 /// - `origin`: sender of the transaction
298 /// - `base_id`: Base ID containing the Theme to be updated.299 /// - `base_id`: Base ID containing the Theme to be updated.
299 /// - `theme`: Theme to add to the Base. A Theme has a name and properties, which are an300 /// - `theme`: Theme to add to the Base. A Theme has a name and properties, which are an
300 /// array of [key, value, inherit].301 /// array of [key, value, inherit].
301 /// - `key`: Arbitrary BoundedString, defined by client.302 /// - `key`: Arbitrary BoundedString, defined by client.
302 /// - `value`: Arbitrary BoundedString, defined by client.303 /// - `value`: Arbitrary BoundedString, defined by client.
303 /// - `inherit`: Optional bool.304 /// - `inherit`: Optional bool.
304 #[transactional]
305 #[pallet::weight(<SelfWeightOf<T>>::theme_add(theme.properties.len() as u32))]305 #[pallet::weight(<SelfWeightOf<T>>::theme_add(theme.properties.len() as u32))]
306 pub fn theme_add(306 pub fn theme_add(
307 origin: OriginFor<T>,307 origin: OriginFor<T>,
359 /// - Base issuer359 /// - Base issuer
360 ///360 ///
361 /// # Arguments:361 /// # Arguments:
362 /// - `origin`: sender of the transaction
362 /// - `base_id`: Base containing the Slot Part to be updated.363 /// - `base_id`: Base containing the Slot Part to be updated.
363 /// - `part_id`: Slot Part whose Equippable List is being updated.364 /// - `slot_id`: Slot Part whose Equippable List is being updated .
364 /// - `equippables`: List of equippables that will override the current Equippables list.365 /// - `equippables`: List of equippables that will override the current Equippables list.
365 #[transactional]
366 #[pallet::weight(<SelfWeightOf<T>>::equippable())]366 #[pallet::weight(<SelfWeightOf<T>>::equippable())]
367 pub fn equippable(367 pub fn equippable(
368 origin: OriginFor<T>,368 origin: OriginFor<T>,
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
78 dispatch::DispatchResult,78 dispatch::DispatchResult,
79 ensure, fail,79 ensure, fail,
80 weights::{Weight},80 weights::{Weight},
81 transactional,
82 pallet_prelude::{DispatchResultWithPostInfo, ConstU32},81 pallet_prelude::{DispatchResultWithPostInfo, ConstU32},
83 BoundedVec,82 BoundedVec,
84};83};
311 /// * `mode`: Type of items stored in the collection and type dependent data.310 /// * `mode`: Type of items stored in the collection and type dependent data.
312 // returns collection ID311 // returns collection ID
313 #[weight = <SelfWeightOf<T>>::create_collection()]312 #[weight = <SelfWeightOf<T>>::create_collection()]
314 #[transactional]
315 #[deprecated(note = "`create_collection_ex` is more up-to-date and advanced, prefer it instead")]313 #[deprecated(note = "`create_collection_ex` is more up-to-date and advanced, prefer it instead")]
316 pub fn create_collection(314 pub fn create_collection(
317 origin,315 origin,
342 ///340 ///
343 /// * `data`: Explicit data of a collection used for its creation.341 /// * `data`: Explicit data of a collection used for its creation.
344 #[weight = <SelfWeightOf<T>>::create_collection()]342 #[weight = <SelfWeightOf<T>>::create_collection()]
345 #[transactional]
346 pub fn create_collection_ex(origin, data: CreateCollectionData<T::AccountId>) -> DispatchResult {343 pub fn create_collection_ex(origin, data: CreateCollectionData<T::AccountId>) -> DispatchResult {
347 let sender = ensure_signed(origin)?;344 let sender = ensure_signed(origin)?;
348345
363 ///360 ///
364 /// * `collection_id`: Collection to destroy.361 /// * `collection_id`: Collection to destroy.
365 #[weight = <SelfWeightOf<T>>::destroy_collection()]362 #[weight = <SelfWeightOf<T>>::destroy_collection()]
366 #[transactional]
367 pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {363 pub fn destroy_collection(origin, collection_id: CollectionId) -> DispatchResult {
368 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);364 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
369 let collection = <CollectionHandle<T>>::try_get(collection_id)?;365 let collection = <CollectionHandle<T>>::try_get(collection_id)?;
399 /// * `collection_id`: ID of the modified collection.395 /// * `collection_id`: ID of the modified collection.
400 /// * `address`: ID of the address to be added to the allowlist.396 /// * `address`: ID of the address to be added to the allowlist.
401 #[weight = <SelfWeightOf<T>>::add_to_allow_list()]397 #[weight = <SelfWeightOf<T>>::add_to_allow_list()]
402 #[transactional]
403 pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{398 pub fn add_to_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
404399
405 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);400 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
433 /// * `collection_id`: ID of the modified collection.428 /// * `collection_id`: ID of the modified collection.
434 /// * `address`: ID of the address to be removed from the allowlist.429 /// * `address`: ID of the address to be removed from the allowlist.
435 #[weight = <SelfWeightOf<T>>::remove_from_allow_list()]430 #[weight = <SelfWeightOf<T>>::remove_from_allow_list()]
436 #[transactional]
437 pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{431 pub fn remove_from_allow_list(origin, collection_id: CollectionId, address: T::CrossAccountId) -> DispatchResult{
438432
439 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);433 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
466 /// * `collection_id`: ID of the modified collection.460 /// * `collection_id`: ID of the modified collection.
467 /// * `new_owner`: ID of the account that will become the owner.461 /// * `new_owner`: ID of the account that will become the owner.
468 #[weight = <SelfWeightOf<T>>::change_collection_owner()]462 #[weight = <SelfWeightOf<T>>::change_collection_owner()]
469 #[transactional]
470 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {463 pub fn change_collection_owner(origin, collection_id: CollectionId, new_owner: T::AccountId) -> DispatchResult {
471464
472 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);465 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
501 /// * `collection_id`: ID of the Collection to add an admin for.494 /// * `collection_id`: ID of the Collection to add an admin for.
502 /// * `new_admin`: Address of new admin to add.495 /// * `new_admin`: Address of new admin to add.
503 #[weight = <SelfWeightOf<T>>::add_collection_admin()]496 #[weight = <SelfWeightOf<T>>::add_collection_admin()]
504 #[transactional]
505 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin: T::CrossAccountId) -> DispatchResult {497 pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::CrossAccountId) -> DispatchResult {
506 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);498 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
507 let collection = <CollectionHandle<T>>::try_get(collection_id)?;499 let collection = <CollectionHandle<T>>::try_get(collection_id)?;
508 collection.check_is_internal()?;500 collection.check_is_internal()?;
530 /// * `collection_id`: ID of the collection to remove the admin for.522 /// * `collection_id`: ID of the collection to remove the admin for.
531 /// * `account_id`: Address of the admin to remove.523 /// * `account_id`: Address of the admin to remove.
532 #[weight = <SelfWeightOf<T>>::remove_collection_admin()]524 #[weight = <SelfWeightOf<T>>::remove_collection_admin()]
533 #[transactional]
534 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::CrossAccountId) -> DispatchResult {525 pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::CrossAccountId) -> DispatchResult {
535 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);526 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
536 let collection = <CollectionHandle<T>>::try_get(collection_id)?;527 let collection = <CollectionHandle<T>>::try_get(collection_id)?;
558 /// * `collection_id`: ID of the modified collection.549 /// * `collection_id`: ID of the modified collection.
559 /// * `new_sponsor`: ID of the account of the sponsor-to-be.550 /// * `new_sponsor`: ID of the account of the sponsor-to-be.
560 #[weight = <SelfWeightOf<T>>::set_collection_sponsor()]551 #[weight = <SelfWeightOf<T>>::set_collection_sponsor()]
561 #[transactional]
562 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {552 pub fn set_collection_sponsor(origin, collection_id: CollectionId, new_sponsor: T::AccountId) -> DispatchResult {
563 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);553 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
564554
590 ///580 ///
591 /// * `collection_id`: ID of the collection with the pending sponsor.581 /// * `collection_id`: ID of the collection with the pending sponsor.
592 #[weight = <SelfWeightOf<T>>::confirm_sponsorship()]582 #[weight = <SelfWeightOf<T>>::confirm_sponsorship()]
593 #[transactional]
594 pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult {583 pub fn confirm_sponsorship(origin, collection_id: CollectionId) -> DispatchResult {
595 let sender = ensure_signed(origin)?;584 let sender = ensure_signed(origin)?;
596585
619 ///608 ///
620 /// * `collection_id`: ID of the collection with the sponsor to remove.609 /// * `collection_id`: ID of the collection with the sponsor to remove.
621 #[weight = <SelfWeightOf<T>>::remove_collection_sponsor()]610 #[weight = <SelfWeightOf<T>>::remove_collection_sponsor()]
622 #[transactional]
623 pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult {611 pub fn remove_collection_sponsor(origin, collection_id: CollectionId) -> DispatchResult {
624 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);612 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
625613
654 /// * `owner`: Address of the initial owner of the item.642 /// * `owner`: Address of the initial owner of the item.
655 /// * `data`: Token data describing the item to store on chain.643 /// * `data`: Token data describing the item to store on chain.
656 #[weight = T::CommonWeightInfo::create_item()]644 #[weight = T::CommonWeightInfo::create_item()]
657 #[transactional]
658 pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {645 pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {
659 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);646 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
660 let budget = budget::Value::new(NESTING_BUDGET);647 let budget = budget::Value::new(NESTING_BUDGET);
681 /// * `owner`: Address of the initial owner of the tokens.668 /// * `owner`: Address of the initial owner of the tokens.
682 /// * `items_data`: Vector of data describing each item to be created.669 /// * `items_data`: Vector of data describing each item to be created.
683 #[weight = T::CommonWeightInfo::create_multiple_items(&items_data)]670 #[weight = T::CommonWeightInfo::create_multiple_items(&items_data)]
684 #[transactional]
685 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {671 pub fn create_multiple_items(origin, collection_id: CollectionId, owner: T::CrossAccountId, items_data: Vec<CreateItemData>) -> DispatchResultWithPostInfo {
686 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);672 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);
687 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);673 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
703 /// * `properties`: Vector of key-value pairs stored as the collection's metadata.689 /// * `properties`: Vector of key-value pairs stored as the collection's metadata.
704 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.690 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
705 #[weight = T::CommonWeightInfo::set_collection_properties(properties.len() as u32)]691 #[weight = T::CommonWeightInfo::set_collection_properties(properties.len() as u32)]
706 #[transactional]
707 pub fn set_collection_properties(692 pub fn set_collection_properties(
708 origin,693 origin,
709 collection_id: CollectionId,694 collection_id: CollectionId,
729 /// * `property_keys`: Vector of keys of the properties to be deleted.714 /// * `property_keys`: Vector of keys of the properties to be deleted.
730 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.715 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
731 #[weight = T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32)]716 #[weight = T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32)]
732 #[transactional]
733 pub fn delete_collection_properties(717 pub fn delete_collection_properties(
734 origin,718 origin,
735 collection_id: CollectionId,719 collection_id: CollectionId,
761 /// * `properties`: Vector of key-value pairs stored as the token's metadata.745 /// * `properties`: Vector of key-value pairs stored as the token's metadata.
762 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.746 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
763 #[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]747 #[weight = T::CommonWeightInfo::set_token_properties(properties.len() as u32)]
764 #[transactional]
765 pub fn set_token_properties(748 pub fn set_token_properties(
766 origin,749 origin,
767 collection_id: CollectionId,750 collection_id: CollectionId,
792 /// * `property_keys`: Vector of keys of the properties to be deleted.775 /// * `property_keys`: Vector of keys of the properties to be deleted.
793 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.776 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
794 #[weight = T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32)]777 #[weight = T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32)]
795 #[transactional]
796 pub fn delete_token_properties(778 pub fn delete_token_properties(
797 origin,779 origin,
798 collection_id: CollectionId,780 collection_id: CollectionId,
823 /// * `property_permissions`: Vector of permissions for property keys.805 /// * `property_permissions`: Vector of permissions for property keys.
824 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.806 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
825 #[weight = T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32)]807 #[weight = T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32)]
826 #[transactional]
827 pub fn set_token_property_permissions(808 pub fn set_token_property_permissions(
828 origin,809 origin,
829 collection_id: CollectionId,810 collection_id: CollectionId,
852 /// * `collection_id`: ID of the collection to which the tokens would belong.833 /// * `collection_id`: ID of the collection to which the tokens would belong.
853 /// * `data`: Explicit item creation data.834 /// * `data`: Explicit item creation data.
854 #[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]835 #[weight = T::CommonWeightInfo::create_multiple_items_ex(&data)]
855 #[transactional]
856 pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {836 pub fn create_multiple_items_ex(origin, collection_id: CollectionId, data: CreateItemExData<T::CrossAccountId>) -> DispatchResultWithPostInfo {
857 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);837 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
858 let budget = budget::Value::new(NESTING_BUDGET);838 let budget = budget::Value::new(NESTING_BUDGET);
871 /// * `collection_id`: ID of the collection.851 /// * `collection_id`: ID of the collection.
872 /// * `value`: New value of the flag, are transfers allowed?852 /// * `value`: New value of the flag, are transfers allowed?
873 #[weight = <SelfWeightOf<T>>::set_transfers_enabled_flag()]853 #[weight = <SelfWeightOf<T>>::set_transfers_enabled_flag()]
874 #[transactional]
875 pub fn set_transfers_enabled_flag(origin, collection_id: CollectionId, value: bool) -> DispatchResult {854 pub fn set_transfers_enabled_flag(origin, collection_id: CollectionId, value: bool) -> DispatchResult {
876 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);855 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
877 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;856 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
901 /// * Fungible Mode: The desired number of pieces to burn.880 /// * Fungible Mode: The desired number of pieces to burn.
902 /// * Re-Fungible Mode: The desired number of pieces to burn.881 /// * Re-Fungible Mode: The desired number of pieces to burn.
903 #[weight = T::CommonWeightInfo::burn_item()]882 #[weight = T::CommonWeightInfo::burn_item()]
904 #[transactional]
905 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {883 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
906 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);884 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
907885
940 /// * Fungible Mode: The desired number of pieces to burn.918 /// * Fungible Mode: The desired number of pieces to burn.
941 /// * Re-Fungible Mode: The desired number of pieces to burn.919 /// * Re-Fungible Mode: The desired number of pieces to burn.
942 #[weight = T::CommonWeightInfo::burn_from()]920 #[weight = T::CommonWeightInfo::burn_from()]
943 #[transactional]
944 pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {921 pub fn burn_from(origin, collection_id: CollectionId, from: T::CrossAccountId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
945 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);922 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
946 let budget = budget::Value::new(NESTING_BUDGET);923 let budget = budget::Value::new(NESTING_BUDGET);
970 /// * Fungible Mode: The desired number of pieces to transfer.947 /// * Fungible Mode: The desired number of pieces to transfer.
971 /// * Re-Fungible Mode: The desired number of pieces to transfer.948 /// * Re-Fungible Mode: The desired number of pieces to transfer.
972 #[weight = T::CommonWeightInfo::transfer()]949 #[weight = T::CommonWeightInfo::transfer()]
973 #[transactional]
974 pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {950 pub fn transfer(origin, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {
975 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);951 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
976 let budget = budget::Value::new(NESTING_BUDGET);952 let budget = budget::Value::new(NESTING_BUDGET);
994 /// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).970 /// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).
995 /// Set to 0 to revoke the approval.971 /// Set to 0 to revoke the approval.
996 #[weight = T::CommonWeightInfo::approve()]972 #[weight = T::CommonWeightInfo::approve()]
997 #[transactional]
998 pub fn approve(origin, spender: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResultWithPostInfo {973 pub fn approve(origin, spender: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, amount: u128) -> DispatchResultWithPostInfo {
999 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);974 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
1000975
1026 /// * Fungible Mode: The desired number of pieces to transfer.1001 /// * Fungible Mode: The desired number of pieces to transfer.
1027 /// * Re-Fungible Mode: The desired number of pieces to transfer.1002 /// * Re-Fungible Mode: The desired number of pieces to transfer.
1028 #[weight = T::CommonWeightInfo::transfer_from()]1003 #[weight = T::CommonWeightInfo::transfer_from()]
1029 #[transactional]
1030 pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {1004 pub fn transfer_from(origin, from: T::CrossAccountId, recipient: T::CrossAccountId, collection_id: CollectionId, item_id: TokenId, value: u128 ) -> DispatchResultWithPostInfo {
1031 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1005 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
1032 let budget = budget::Value::new(NESTING_BUDGET);1006 let budget = budget::Value::new(NESTING_BUDGET);
1047 /// * `new_limit`: New limits of the collection. Fields that are not set (None)1021 /// * `new_limit`: New limits of the collection. Fields that are not set (None)
1048 /// will not overwrite the old ones.1022 /// will not overwrite the old ones.
1049 #[weight = <SelfWeightOf<T>>::set_collection_limits()]1023 #[weight = <SelfWeightOf<T>>::set_collection_limits()]
1050 #[transactional]
1051 pub fn set_collection_limits(1024 pub fn set_collection_limits(
1052 origin,1025 origin,
1053 collection_id: CollectionId,1026 collection_id: CollectionId,
1081 /// * `new_permission`: New permissions of the collection. Fields that are not set (None)1054 /// * `new_permission`: New permissions of the collection. Fields that are not set (None)
1082 /// will not overwrite the old ones.1055 /// will not overwrite the old ones.
1083 #[weight = <SelfWeightOf<T>>::set_collection_limits()]1056 #[weight = <SelfWeightOf<T>>::set_collection_limits()]
1084 #[transactional]
1085 pub fn set_collection_permissions(1057 pub fn set_collection_permissions(
1086 origin,1058 origin,
1087 collection_id: CollectionId,1059 collection_id: CollectionId,
1114 /// * `token_id`: ID of the RFT.1086 /// * `token_id`: ID of the RFT.
1115 /// * `amount`: New number of parts/pieces into which the token shall be partitioned.1087 /// * `amount`: New number of parts/pieces into which the token shall be partitioned.
1116 #[weight = T::RefungibleExtensionsWeightInfo::repartition()]1088 #[weight = T::RefungibleExtensionsWeightInfo::repartition()]
1117 #[transactional]
1118 pub fn repartition(1089 pub fn repartition(
1119 origin,1090 origin,
1120 collection_id: CollectionId,1091 collection_id: CollectionId,