mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 22:51:13 +00:00
Estimate call fee (#9395)
* Estimate call fee * More fix * Fix * Update frame/support/src/traits/misc.rs Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com> * try and fix fmt stuff * fmt aain Co-authored-by: Parity Benchmarking Bot <admin@parity.io> Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
This commit is contained in:
@@ -52,7 +52,7 @@ use codec::{Decode, Encode};
|
||||
use sp_runtime::{
|
||||
traits::{
|
||||
Convert, DispatchInfoOf, Dispatchable, PostDispatchInfoOf, SaturatedConversion, Saturating,
|
||||
SignedExtension,
|
||||
SignedExtension, Zero,
|
||||
},
|
||||
transaction_validity::{
|
||||
TransactionPriority, TransactionValidity, TransactionValidityError, ValidTransaction,
|
||||
@@ -63,7 +63,7 @@ use sp_std::prelude::*;
|
||||
|
||||
use frame_support::{
|
||||
dispatch::DispatchResult,
|
||||
traits::Get,
|
||||
traits::{EstimateCallFee, Get},
|
||||
weights::{
|
||||
DispatchClass, DispatchInfo, GetDispatchInfo, Pays, PostDispatchInfo, Weight,
|
||||
WeightToFeeCoefficient, WeightToFeePolynomial,
|
||||
@@ -656,6 +656,19 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config, AnyCall: GetDispatchInfo + Encode> EstimateCallFee<AnyCall, BalanceOf<T>>
|
||||
for Pallet<T>
|
||||
where
|
||||
BalanceOf<T>: FixedPointOperand,
|
||||
T::Call: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
|
||||
{
|
||||
fn estimate_call_fee(call: &AnyCall, post_info: PostDispatchInfo) -> BalanceOf<T> {
|
||||
let len = call.encoded_size() as u32;
|
||||
let info = call.get_dispatch_info();
|
||||
Self::compute_actual_fee(len, &info, &post_info, Zero::zero())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user