Skip to content

Remove transactional #800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions payments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ pub mod pallet {
weights::WeightInfo,
};
use frame_support::{
dispatch::DispatchResultWithPostInfo, fail, pallet_prelude::*, require_transactional,
storage::bounded_btree_map::BoundedBTreeMap, traits::tokens::BalanceStatus, transactional,
dispatch::DispatchResultWithPostInfo, fail, pallet_prelude::*, storage::bounded_btree_map::BoundedBTreeMap,
traits::tokens::BalanceStatus,
};
use frame_system::pallet_prelude::*;
use orml_traits::{MultiCurrency, MultiReservableCurrency};
Expand Down Expand Up @@ -279,7 +279,6 @@ pub mod pallet {
/// the option to add a remark, this remark can then be used to run
/// custom logic and trigger alternate payment flows. the specified
/// amount.
#[transactional]
#[pallet::weight(T::WeightInfo::pay(T::MaxRemarkLength::get()))]
pub fn pay(
origin: OriginFor<T>,
Expand Down Expand Up @@ -314,7 +313,6 @@ pub mod pallet {

/// Release any created payment, this will transfer the reserved amount
/// from the creator of the payment to the assigned recipient
#[transactional]
#[pallet::weight(T::WeightInfo::release())]
pub fn release(origin: OriginFor<T>, to: T::AccountId) -> DispatchResultWithPostInfo {
let from = ensure_signed(origin)?;
Expand All @@ -333,7 +331,6 @@ pub mod pallet {
/// Cancel a payment in created state, this will release the reserved
/// back to creator of the payment. This extrinsic can only be called by
/// the recipient of the payment
#[transactional]
#[pallet::weight(T::WeightInfo::cancel())]
pub fn cancel(origin: OriginFor<T>, creator: T::AccountId) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
Expand All @@ -356,7 +353,6 @@ pub mod pallet {
/// recipient of the payment.
/// This extrinsic allows the assigned judge to
/// cancel/release/partial_release the payment.
#[transactional]
#[pallet::weight(T::WeightInfo::resolve_payment())]
pub fn resolve_payment(
origin: OriginFor<T>,
Expand Down Expand Up @@ -392,7 +388,6 @@ pub mod pallet {
/// Allow the creator of a payment to initiate a refund that will return
/// the funds after a configured amount of time that the reveiver has to
/// react and opose the request
#[transactional]
#[pallet::weight(T::WeightInfo::request_refund())]
pub fn request_refund(origin: OriginFor<T>, recipient: T::AccountId) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
Expand Down Expand Up @@ -440,7 +435,6 @@ pub mod pallet {
/// payment creator This does not cancel the request, instead sends the
/// payment to a NeedsReview state The assigned resolver account can
/// then change the state of the payment after review.
#[transactional]
#[pallet::weight(T::WeightInfo::dispute_refund())]
pub fn dispute_refund(origin: OriginFor<T>, creator: T::AccountId) -> DispatchResultWithPostInfo {
use PaymentState::*;
Expand Down Expand Up @@ -487,7 +481,6 @@ pub mod pallet {
// using the `accept_and_pay` extrinsic. The payment will be in
// PaymentRequested State and can only be modified by the `accept_and_pay`
// extrinsic.
#[transactional]
#[pallet::weight(T::WeightInfo::request_payment())]
pub fn request_payment(
origin: OriginFor<T>,
Expand Down Expand Up @@ -516,7 +509,6 @@ pub mod pallet {
// This extrinsic allows the sender to fulfill a payment request created by a
// recipient. The amount will be transferred to the recipient and payment
// removed from storage
#[transactional]
#[pallet::weight(T::WeightInfo::accept_and_pay())]
pub fn accept_and_pay(origin: OriginFor<T>, to: T::AccountId) -> DispatchResultWithPostInfo {
let from = ensure_signed(origin)?;
Expand Down Expand Up @@ -544,7 +536,6 @@ pub mod pallet {
/// The function will create a new payment. The fee and incentive
/// amounts will be calculated and the `PaymentDetail` will be added to
/// storage.
#[require_transactional]
fn create_payment(
from: &T::AccountId,
recipient: &T::AccountId,
Expand Down Expand Up @@ -595,7 +586,6 @@ pub mod pallet {
/// The function will reserve the fees+transfer amount from the `from`
/// account. After reserving the payment.amount will be transferred to
/// the recipient but will stay in Reserve state.
#[require_transactional]
fn reserve_payment_amount(from: &T::AccountId, to: &T::AccountId, payment: PaymentDetail<T>) -> DispatchResult {
let fee_amount = payment.fee_detail.map(|(_, f)| f).unwrap_or_else(|| 0u32.into());

Expand Down
3 changes: 1 addition & 2 deletions tokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use frame_support::{
NamedReservableCurrency as PalletNamedReservableCurrency, ReservableCurrency as PalletReservableCurrency,
SignedImbalance, WithdrawReasons,
},
transactional, BoundedVec,
BoundedVec,
};
use frame_system::{ensure_signed, pallet_prelude::*};
use scale_info::TypeInfo;
Expand Down Expand Up @@ -2135,7 +2135,6 @@ where
}

impl<T: Config> TransferAll<T::AccountId> for Pallet<T> {
#[transactional]
fn transfer_all(source: &T::AccountId, dest: &T::AccountId) -> DispatchResult {
Accounts::<T>::iter_prefix(source).try_for_each(|(currency_id, account_data)| -> DispatchResult {
// allow death
Expand Down
6 changes: 1 addition & 5 deletions traits/src/currency.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use crate::arithmetic;
use codec::{Codec, FullCodec, MaxEncodedLen};
pub use frame_support::{
traits::{BalanceStatus, LockIdentifier},
transactional,
};
pub use frame_support::traits::{BalanceStatus, LockIdentifier};
use sp_runtime::{
traits::{AtLeast32BitUnsigned, MaybeSerializeDeserialize},
DispatchError, DispatchResult,
Expand Down Expand Up @@ -649,7 +646,6 @@ pub trait TransferAll<AccountId> {

#[impl_trait_for_tuples::impl_for_tuples(5)]
impl<AccountId> TransferAll<AccountId> for Tuple {
#[transactional]
fn transfer_all(source: &AccountId, dest: &AccountId) -> DispatchResult {
for_tuples!( #( {
Tuple::transfer_all(source, dest)?;
Expand Down
11 changes: 1 addition & 10 deletions xtokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
use frame_support::{
log,
pallet_prelude::*,
require_transactional,
traits::{Contains, Get},
transactional, Parameter,
Parameter,
};
use frame_system::{ensure_signed, pallet_prelude::*};
use sp_runtime::{
Expand Down Expand Up @@ -200,7 +199,6 @@ pub mod module {
/// by the network, and if the receiving chain would handle
/// messages correctly.
#[pallet::weight(Pallet::<T>::weight_of_transfer(currency_id.clone(), *amount, dest))]
#[transactional]
pub fn transfer(
origin: OriginFor<T>,
currency_id: T::CurrencyId,
Expand All @@ -226,7 +224,6 @@ pub mod module {
/// by the network, and if the receiving chain would handle
/// messages correctly.
#[pallet::weight(Pallet::<T>::weight_of_transfer_multiasset(asset, dest))]
#[transactional]
pub fn transfer_multiasset(
origin: OriginFor<T>,
asset: Box<VersionedMultiAsset>,
Expand Down Expand Up @@ -261,7 +258,6 @@ pub mod module {
/// by the network, and if the receiving chain would handle
/// messages correctly.
#[pallet::weight(Pallet::<T>::weight_of_transfer(currency_id.clone(), *amount, dest))]
#[transactional]
pub fn transfer_with_fee(
origin: OriginFor<T>,
currency_id: T::CurrencyId,
Expand Down Expand Up @@ -298,7 +294,6 @@ pub mod module {
/// by the network, and if the receiving chain would handle
/// messages correctly.
#[pallet::weight(Pallet::<T>::weight_of_transfer_multiasset(asset, dest))]
#[transactional]
pub fn transfer_multiasset_with_fee(
origin: OriginFor<T>,
asset: Box<VersionedMultiAsset>,
Expand Down Expand Up @@ -330,7 +325,6 @@ pub mod module {
/// by the network, and if the receiving chain would handle
/// messages correctly.
#[pallet::weight(Pallet::<T>::weight_of_transfer_multicurrencies(currencies, fee_item, dest))]
#[transactional]
pub fn transfer_multicurrencies(
origin: OriginFor<T>,
currencies: Vec<(T::CurrencyId, T::Balance)>,
Expand Down Expand Up @@ -360,7 +354,6 @@ pub mod module {
/// by the network, and if the receiving chain would handle
/// messages correctly.
#[pallet::weight(Pallet::<T>::weight_of_transfer_multiassets(assets, fee_item, dest))]
#[transactional]
pub fn transfer_multiassets(
origin: OriginFor<T>,
assets: Box<VersionedMultiAssets>,
Expand Down Expand Up @@ -931,7 +924,6 @@ pub mod module {
}

impl<T: Config> XcmTransfer<T::AccountId, T::Balance, T::CurrencyId> for Pallet<T> {
#[require_transactional]
fn transfer(
who: T::AccountId,
currency_id: T::CurrencyId,
Expand All @@ -942,7 +934,6 @@ pub mod module {
Self::do_transfer(who, currency_id, amount, dest, dest_weight)
}

#[require_transactional]
fn transfer_multi_asset(
who: T::AccountId,
asset: MultiAsset,
Expand Down