mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
move signed extension stuff from prolkadot-core primitives to bridge-hub-cumulus-primitives (#1968)
This commit is contained in:
committed by
Bastian Köcher
parent
74b0eca59c
commit
62480cf9db
@@ -37,7 +37,6 @@ use sp_runtime::{
|
||||
use sp_std::prelude::Vec;
|
||||
|
||||
// Re-export's to avoid extra substrate dependencies in chain-specific crates.
|
||||
use bp_runtime::extensions::*;
|
||||
pub use frame_support::{weights::constants::ExtrinsicBaseWeight, Parameter};
|
||||
pub use sp_runtime::{traits::Convert, Perbill};
|
||||
|
||||
@@ -252,142 +251,6 @@ impl Chain for PolkadotLike {
|
||||
}
|
||||
}
|
||||
|
||||
/// Some functionality associated with the default signed extension used by Polkadot and
|
||||
/// Polkadot-like chains.
|
||||
pub trait PolkadotSignedExtension {
|
||||
fn from_params(
|
||||
spec_version: u32,
|
||||
transaction_version: u32,
|
||||
era: bp_runtime::TransactionEraOf<PolkadotLike>,
|
||||
genesis_hash: Hash,
|
||||
nonce: Nonce,
|
||||
tip: Balance,
|
||||
) -> Self;
|
||||
|
||||
fn nonce(&self) -> Nonce;
|
||||
|
||||
fn tip(&self) -> Balance;
|
||||
}
|
||||
|
||||
type DefaultSignedExtra = (
|
||||
CheckNonZeroSender,
|
||||
CheckSpecVersion,
|
||||
CheckTxVersion,
|
||||
CheckGenesis<PolkadotLike>,
|
||||
CheckEra<PolkadotLike>,
|
||||
CheckNonce<Nonce>,
|
||||
CheckWeight,
|
||||
ChargeTransactionPayment<PolkadotLike>,
|
||||
);
|
||||
|
||||
/// The default signed extension used by Polkadot and Polkadot-like chains.
|
||||
pub type DefaultSignedExtension = GenericSignedExtension<DefaultSignedExtra>;
|
||||
|
||||
impl PolkadotSignedExtension for DefaultSignedExtension {
|
||||
fn from_params(
|
||||
spec_version: u32,
|
||||
transaction_version: u32,
|
||||
era: bp_runtime::TransactionEraOf<PolkadotLike>,
|
||||
genesis_hash: Hash,
|
||||
nonce: Nonce,
|
||||
tip: Balance,
|
||||
) -> Self {
|
||||
Self::new(
|
||||
(
|
||||
(), // non-zero sender
|
||||
(), // spec version
|
||||
(), // tx version
|
||||
(), // genesis
|
||||
era.frame_era(), // era
|
||||
nonce.into(), // nonce (compact encoding)
|
||||
(), // Check weight
|
||||
tip.into(), // transaction payment / tip (compact encoding)
|
||||
),
|
||||
Some((
|
||||
(),
|
||||
spec_version,
|
||||
transaction_version,
|
||||
genesis_hash,
|
||||
era.signed_payload(genesis_hash),
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
||||
/// Return signer nonce, used to craft transaction.
|
||||
fn nonce(&self) -> Nonce {
|
||||
self.payload.5.into()
|
||||
}
|
||||
|
||||
/// Return transaction tip.
|
||||
fn tip(&self) -> Balance {
|
||||
self.payload.7.into()
|
||||
}
|
||||
}
|
||||
|
||||
type BridgeSignedExtra = (
|
||||
CheckNonZeroSender,
|
||||
CheckSpecVersion,
|
||||
CheckTxVersion,
|
||||
CheckGenesis<PolkadotLike>,
|
||||
CheckEra<PolkadotLike>,
|
||||
CheckNonce<Nonce>,
|
||||
CheckWeight,
|
||||
ChargeTransactionPayment<PolkadotLike>,
|
||||
BridgeRejectObsoleteHeadersAndMessages,
|
||||
);
|
||||
|
||||
/// The default signed extension used by Polkadot and Polkadot-like chains with bridging.
|
||||
pub type BridgeSignedExtension = GenericSignedExtension<BridgeSignedExtra>;
|
||||
|
||||
impl PolkadotSignedExtension for BridgeSignedExtension {
|
||||
fn from_params(
|
||||
spec_version: u32,
|
||||
transaction_version: u32,
|
||||
era: bp_runtime::TransactionEraOf<PolkadotLike>,
|
||||
genesis_hash: Hash,
|
||||
nonce: Nonce,
|
||||
tip: Balance,
|
||||
) -> Self {
|
||||
Self::new(
|
||||
(
|
||||
(), // non-zero sender
|
||||
(), // spec version
|
||||
(), // tx version
|
||||
(), // genesis
|
||||
era.frame_era(), // era
|
||||
nonce.into(), // nonce (compact encoding)
|
||||
(), // Check weight
|
||||
tip.into(), // transaction payment / tip (compact encoding)
|
||||
(), // bridge reject obsolete headers and msgs
|
||||
),
|
||||
Some((
|
||||
(),
|
||||
spec_version,
|
||||
transaction_version,
|
||||
genesis_hash,
|
||||
era.signed_payload(genesis_hash),
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
(),
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
||||
/// Return signer nonce, used to craft transaction.
|
||||
fn nonce(&self) -> Nonce {
|
||||
self.payload.5.into()
|
||||
}
|
||||
|
||||
/// Return transaction tip.
|
||||
fn tip(&self) -> Balance {
|
||||
self.payload.7.into()
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides a storage key for account data.
|
||||
///
|
||||
/// We need to use this approach when we don't have access to the runtime.
|
||||
|
||||
Reference in New Issue
Block a user