Skip to content

Commit

Permalink
refactor: remove #[transactional] from extrinsics
Browse files Browse the repository at this point in the history
Every extrinsic now runs in transaction implicitly, and
`#[transactional]` on pallet dispatchable is now meaningless

Upstream-Change: paritytech/substrate#10806
Signed-off-by: Yaroslav Bolyukin <iam@lach.pw>
  • Loading branch information
CertainLach committed Jul 21, 2022
1 parent 03cdd4a commit 460acb3
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 53 deletions.
3 changes: 1 addition & 2 deletions pallets/evm-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub mod weights;

#[frame_support::pallet]
pub mod pallet {
use frame_support::{pallet_prelude::*, transactional};
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_core::{H160, H256};
use sp_std::vec::Vec;
Expand Down Expand Up @@ -84,7 +84,6 @@ pub mod pallet {
}

#[pallet::weight(<SelfWeightOf<T>>::finish(code.len() as u32))]
#[transactional]
pub fn finish(origin: OriginFor<T>, address: H160, code: Vec<u8>) -> DispatchResult {
ensure_root(origin)?;
ensure!(
Expand Down
19 changes: 1 addition & 18 deletions pallets/proxy-rmrk-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::{pallet_prelude::*, transactional, BoundedVec, dispatch::DispatchResult};
use frame_support::{pallet_prelude::*, BoundedVec, dispatch::DispatchResult};
use frame_system::{pallet_prelude::*, ensure_signed};
use sp_runtime::{DispatchError, Permill, traits::StaticLookup};
use sp_std::{
Expand Down Expand Up @@ -187,7 +187,6 @@ pub mod pallet {
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Create a collection
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::create_collection())]
pub fn create_collection(
origin: OriginFor<T>,
Expand Down Expand Up @@ -252,7 +251,6 @@ pub mod pallet {
}

/// destroy collection
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::destroy_collection())]
pub fn destroy_collection(
origin: OriginFor<T>,
Expand Down Expand Up @@ -284,7 +282,6 @@ pub mod pallet {
/// - `origin`: sender of the transaction
/// - `collection_id`: collection id of the nft to change issuer of
/// - `new_issuer`: Collection's new issuer
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::change_collection_issuer())]
pub fn change_collection_issuer(
origin: OriginFor<T>,
Expand Down Expand Up @@ -315,7 +312,6 @@ pub mod pallet {
}

/// lock collection
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::lock_collection())]
pub fn lock_collection(
origin: OriginFor<T>,
Expand Down Expand Up @@ -356,7 +352,6 @@ pub mod pallet {
/// - `royalty`: Permillage reward from each trade for the Recipient
/// - `metadata`: Arbitrary data about an nft, e.g. IPFS hash
/// - `transferable`: Ability to transfer this NFT
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::mint_nft(resources.as_ref().map(|r| r.len() as u32).unwrap_or(0)))]
pub fn mint_nft(
origin: OriginFor<T>,
Expand Down Expand Up @@ -424,7 +419,6 @@ pub mod pallet {
}

/// burn nft
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::burn_nft(*max_burns))]
pub fn burn_nft(
origin: OriginFor<T>,
Expand Down Expand Up @@ -465,7 +459,6 @@ pub mod pallet {
/// - `rmrk_collection_id`: collection id of the nft to be transferred
/// - `rmrk_nft_id`: nft id of the nft to be transferred
/// - `new_owner`: new owner of the nft which can be either an account or a NFT
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::send())]
pub fn send(
origin: OriginFor<T>,
Expand Down Expand Up @@ -586,7 +579,6 @@ pub mod pallet {
/// - `rmrk_nft_id`: nft id of the nft to be accepted
/// - `new_owner`: either origin's account ID or origin-owned NFT, whichever the NFT was
/// sent to
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::accept_nft())]
pub fn accept_nft(
origin: OriginFor<T>,
Expand Down Expand Up @@ -671,7 +663,6 @@ pub mod pallet {
/// - `origin`: sender of the transaction
/// - `rmrk_collection_id`: collection id of the nft to be accepted
/// - `rmrk_nft_id`: nft id of the nft to be accepted
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::reject_nft())]
pub fn reject_nft(
origin: OriginFor<T>,
Expand Down Expand Up @@ -725,7 +716,6 @@ pub mod pallet {
}

/// accept the addition of a new resource to an existing NFT
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::accept_resource())]
pub fn accept_resource(
origin: OriginFor<T>,
Expand Down Expand Up @@ -768,7 +758,6 @@ pub mod pallet {
}

/// accept the removal of a resource of an existing NFT
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::accept_resource_removal())]
pub fn accept_resource_removal(
origin: OriginFor<T>,
Expand Down Expand Up @@ -834,7 +823,6 @@ pub mod pallet {
}

/// set a custom value on an NFT
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::set_property())]
pub fn set_property(
origin: OriginFor<T>,
Expand Down Expand Up @@ -894,7 +882,6 @@ pub mod pallet {
}

/// set a different order of resource priority
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::set_priority())]
pub fn set_priority(
origin: OriginFor<T>,
Expand Down Expand Up @@ -933,7 +920,6 @@ pub mod pallet {
}

/// Create basic resource
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::add_basic_resource())]
pub fn add_basic_resource(
origin: OriginFor<T>,
Expand Down Expand Up @@ -963,7 +949,6 @@ pub mod pallet {
}

/// Create composable resource
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::add_composable_resource())]
pub fn add_composable_resource(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1013,7 +998,6 @@ pub mod pallet {
}

/// Create slot resource
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::add_slot_resource())]
pub fn add_slot_resource(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1043,7 +1027,6 @@ pub mod pallet {
}

/// remove resource
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::remove_resource())]
pub fn remove_resource(
origin: OriginFor<T>,
Expand Down
5 changes: 1 addition & 4 deletions pallets/proxy-rmrk-equip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::{pallet_prelude::*, transactional, BoundedVec, dispatch::DispatchResult};
use frame_support::{pallet_prelude::*, BoundedVec, dispatch::DispatchResult};
use frame_system::{pallet_prelude::*, ensure_signed};
use sp_runtime::DispatchError;
use up_data_structs::*;
Expand Down Expand Up @@ -98,7 +98,6 @@ pub mod pallet {
/// - symbol: arbitrary client-chosen symbol
/// - parts: array of Fixed and Slot parts composing the base, confined in length by
/// RmrkPartsLimit
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::create_base(parts.len() as u32))]
pub fn create_base(
origin: OriginFor<T>,
Expand Down Expand Up @@ -164,7 +163,6 @@ pub mod pallet {
/// - key: arbitrary BoundedString, defined by client
/// - value: arbitrary BoundedString, defined by client
/// - inherit: optional bool
#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::theme_add(theme.properties.len() as u32))]
pub fn theme_add(
origin: OriginFor<T>,
Expand Down Expand Up @@ -214,7 +212,6 @@ pub mod pallet {
Ok(())
}

#[transactional]
#[pallet::weight(<SelfWeightOf<T>>::equippable())]
pub fn equippable(
origin: OriginFor<T>,
Expand Down
Loading

0 comments on commit 460acb3

Please sign in to comment.