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

Commit

Permalink
Avoid duplicate evm transact fees (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aki Wu authored and jiguantong committed Jul 1, 2022
1 parent feaa9e3 commit 8b13160
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions modules/dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ use frame_support::{
dispatch::Dispatchable,
ensure,
traits::Get,
weights::{extract_actual_weight, GetDispatchInfo},
weights::GetDispatchInfo,
};
use frame_support::dispatch::{DispatchInfo, DispatchResultWithPostInfo, Weight};
use frame_support::pallet_prelude::Pays;
use frame_system::RawOrigin;
use sp_runtime::traits::{BadOrigin, Convert, IdentifyAccount, MaybeDisplay, Verify};
use sp_runtime::traits::{BadOrigin, Convert, IdentifyAccount, MaybeDisplay, Verify, Zero};
use sp_std::{fmt::Debug, prelude::*};

pub use pallet::*;
Expand Down Expand Up @@ -360,6 +362,17 @@ impl<T: Config<I>, I: 'static> MessageDispatch<T::AccountId, T::BridgeMessageId>
}
}

fn extract_actual_weight(result: &DispatchResultWithPostInfo, info: &DispatchInfo) -> Weight {
let post_info = match result {
Ok(post_info) => &post_info,
Err(err) => &err.post_info,
};
match post_info.pays_fee {
Pays::Yes => post_info.calc_actual_weight(info),
Pays::No => Weight::zero()
}
}

/// Check if the message is allowed to be dispatched on the target chain given the sender's origin
/// on the source chain.
///
Expand Down

0 comments on commit 8b13160

Please sign in to comment.