estimate transaction fee (#1015)

This commit is contained in:
Svyatoslav Nikolsky
2021-06-28 12:13:53 +03:00
committed by Bastian Köcher
parent 165730a2c2
commit db0216dabb
20 changed files with 294 additions and 72 deletions
+22 -4
View File
@@ -17,14 +17,15 @@
use bp_runtime::Chain as ChainBase;
use frame_support::Parameter;
use jsonrpsee_ws_client::{DeserializeOwned, Serialize};
use num_traits::{CheckedSub, SaturatingAdd, Zero};
use num_traits::{Bounded, CheckedSub, SaturatingAdd, Zero};
use sp_core::{storage::StorageKey, Pair};
use sp_runtime::{
generic::SignedBlock,
traits::{
AtLeast32Bit, Block as BlockT, Dispatchable, MaybeDisplay, MaybeSerialize, MaybeSerializeDeserialize, Member,
AtLeast32Bit, AtLeast32BitUnsigned, Block as BlockT, Dispatchable, MaybeDisplay, MaybeSerialize,
MaybeSerializeDeserialize, Member,
},
EncodedJustification,
EncodedJustification, FixedPointOperand,
};
use std::{fmt::Debug, time::Duration};
@@ -37,6 +38,10 @@ pub trait Chain: ChainBase + Clone {
/// How often blocks are produced on that chain. It's suggested to set this value
/// to match the block time of the chain.
const AVERAGE_BLOCK_INTERVAL: Duration;
/// Maximal expected storage proof overhead (in bytes).
const STORAGE_PROOF_OVERHEAD: u32;
/// Maximal size (in bytes) of SCALE-encoded account id on this chain.
const MAXIMAL_ENCODED_ACCOUNT_ID_SIZE: u32;
/// The user account identifier type for the runtime.
type AccountId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + Default;
@@ -58,7 +63,20 @@ pub trait Chain: ChainBase + Clone {
///
/// The chain may suport multiple tokens, but this particular type is for token that is used
/// to pay for transaction dispatch, to reward different relayers (headers, messages), etc.
type Balance: Parameter + Member + DeserializeOwned + Clone + Copy + CheckedSub + PartialOrd + SaturatingAdd + Zero;
type Balance: AtLeast32BitUnsigned
+ FixedPointOperand
+ Parameter
+ Parameter
+ Member
+ DeserializeOwned
+ Clone
+ Copy
+ Bounded
+ CheckedSub
+ PartialOrd
+ SaturatingAdd
+ Zero
+ std::convert::TryFrom<sp_core::U256>;
}
/// Substrate-based chain with `frame_system::Config::AccountData` set to