Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Use transactional storage (paritytech#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeddes authored Mar 2, 2021
1 parent 09b49c5 commit 4779bc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions parachain/pallets/erc20-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use frame_support::{
decl_error, decl_event, decl_module, decl_storage,
dispatch::{DispatchError, DispatchResult},
traits::EnsureOrigin,
transactional,
};
use sp_runtime::traits::StaticLookup;
use sp_std::prelude::*;
Expand Down Expand Up @@ -81,6 +82,7 @@ decl_module! {

/// Burn an ERC20 token balance
#[weight = 0]
#[transactional]
pub fn burn(origin, channel_id: ChannelId, token: H160, recipient: H160, amount: U256) -> DispatchResult {
let who = ensure_signed(origin)?;

Expand All @@ -100,6 +102,7 @@ decl_module! {
}

#[weight = 0]
#[transactional]
pub fn mint(origin, token: H160, sender: H160, recipient: <T::Lookup as StaticLookup>::Source, amount: U256) -> DispatchResult {
let who = T::CallOrigin::ensure_origin(origin)?;
if who != Address::get() {
Expand Down
3 changes: 3 additions & 0 deletions parachain/pallets/eth-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use frame_support::{
decl_error, decl_event, decl_module, decl_storage,
dispatch::{DispatchError, DispatchResult},
traits::EnsureOrigin,
transactional,
};
use sp_runtime::traits::StaticLookup;
use sp_std::prelude::*;
Expand Down Expand Up @@ -82,6 +83,7 @@ decl_module! {
// Users should burn their holdings to release funds on the Ethereum side
// TODO: Calculate weights
#[weight = 0]
#[transactional]
pub fn burn(origin, channel_id: ChannelId, recipient: H160, amount: U256) -> DispatchResult {
let who = ensure_signed(origin)?;

Expand All @@ -100,6 +102,7 @@ decl_module! {
}

#[weight = 0]
#[transactional]
pub fn mint(origin, sender: H160, recipient: <T::Lookup as StaticLookup>::Source, amount: U256) -> DispatchResult {
let who = T::CallOrigin::ensure_origin(origin)?;
if who != Address::get() {
Expand Down

0 comments on commit 4779bc1

Please sign in to comment.