mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
@@ -14,7 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::HeaderIdProvider;
|
||||
use crate::{ChainId, HeaderIdProvider};
|
||||
|
||||
use codec::{Codec, Decode, Encode, MaxEncodedLen};
|
||||
use frame_support::{weights::Weight, Parameter};
|
||||
use num_traits::{AsPrimitive, Bounded, CheckedSub, Saturating, SaturatingAdd, Zero};
|
||||
@@ -99,6 +100,9 @@ impl<ChainCall: Encode> Encode for EncodedOrDecodedCall<ChainCall> {
|
||||
|
||||
/// Minimal Substrate-based chain representation that may be used from no_std environment.
|
||||
pub trait Chain: Send + Sync + 'static {
|
||||
/// Chain id.
|
||||
const ID: ChainId;
|
||||
|
||||
/// A type that fulfills the abstract idea of what a Substrate block number is.
|
||||
// Constraits come from the associated Number type of `sp_runtime::traits::Header`
|
||||
// See here for more info:
|
||||
@@ -208,6 +212,8 @@ impl<T> Chain for T
|
||||
where
|
||||
T: Send + Sync + 'static + UnderlyingChainProvider,
|
||||
{
|
||||
const ID: ChainId = <T::Chain as Chain>::ID;
|
||||
|
||||
type BlockNumber = <T::Chain as Chain>::BlockNumber;
|
||||
type Hash = <T::Chain as Chain>::Hash;
|
||||
type Hasher = <T::Chain as Chain>::Hasher;
|
||||
|
||||
@@ -102,6 +102,7 @@ impl SignedExtensionSchema for Tuple {
|
||||
/// and signed payloads in the client code.
|
||||
#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
|
||||
pub struct GenericSignedExtension<S: SignedExtensionSchema> {
|
||||
/// A payload that is included in the transaction.
|
||||
pub payload: S::Payload,
|
||||
#[codec(skip)]
|
||||
// It may be set to `None` if extensions are decoded. We are never reconstructing transactions
|
||||
@@ -112,6 +113,7 @@ pub struct GenericSignedExtension<S: SignedExtensionSchema> {
|
||||
}
|
||||
|
||||
impl<S: SignedExtensionSchema> GenericSignedExtension<S> {
|
||||
/// Create new `GenericSignedExtension` object.
|
||||
pub fn new(payload: S::Payload, additional_signed: Option<S::AdditionalSigned>) -> Self {
|
||||
Self { payload, additional_signed }
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
//! Primitives that may be used at (bridges) runtime level.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use codec::{Decode, Encode, FullCodec, MaxEncodedLen};
|
||||
@@ -61,36 +62,6 @@ pub use sp_runtime::paste;
|
||||
/// Use this when something must be shared among all instances.
|
||||
pub const NO_INSTANCE_ID: ChainId = [0, 0, 0, 0];
|
||||
|
||||
/// Polkadot chain id.
|
||||
pub const POLKADOT_CHAIN_ID: ChainId = *b"pdot";
|
||||
|
||||
/// Polkadot Bulletin chain id.
|
||||
pub const POLKADOT_BULLETIN_CHAIN_ID: ChainId = *b"pdbc";
|
||||
|
||||
/// Kusama chain id.
|
||||
pub const KUSAMA_CHAIN_ID: ChainId = *b"ksma";
|
||||
|
||||
/// Westend chain id.
|
||||
pub const WESTEND_CHAIN_ID: ChainId = *b"wend";
|
||||
|
||||
/// `AssetHubWestmint` chain id.
|
||||
pub const ASSET_HUB_WESTEND_CHAIN_ID: ChainId = *b"ahwe";
|
||||
|
||||
/// Rococo chain id.
|
||||
pub const ROCOCO_CHAIN_ID: ChainId = *b"roco";
|
||||
|
||||
/// BridgeHubRococo chain id.
|
||||
pub const BRIDGE_HUB_ROCOCO_CHAIN_ID: ChainId = *b"bhro";
|
||||
|
||||
/// BridgeHubWestend chain id.
|
||||
pub const BRIDGE_HUB_WESTEND_CHAIN_ID: ChainId = *b"bhwd";
|
||||
|
||||
/// BridgeHubKusama chain id.
|
||||
pub const BRIDGE_HUB_KUSAMA_CHAIN_ID: ChainId = *b"bhks";
|
||||
|
||||
/// BridgeHubPolkadot chain id.
|
||||
pub const BRIDGE_HUB_POLKADOT_CHAIN_ID: ChainId = *b"bhpd";
|
||||
|
||||
/// Generic header Id.
|
||||
#[derive(
|
||||
RuntimeDebug,
|
||||
@@ -126,10 +97,10 @@ pub type HeaderIdOf<C> = HeaderId<HashOf<C>, BlockNumberOf<C>>;
|
||||
|
||||
/// Generic header id provider.
|
||||
pub trait HeaderIdProvider<Header: HeaderT> {
|
||||
// Get the header id.
|
||||
/// Get the header id.
|
||||
fn id(&self) -> HeaderId<Header::Hash, Header::Number>;
|
||||
|
||||
// Get the header id for the parent block.
|
||||
/// Get the header id for the parent block.
|
||||
fn parent_id(&self) -> Option<HeaderId<Header::Hash, Header::Number>>;
|
||||
}
|
||||
|
||||
@@ -342,7 +313,7 @@ pub trait StorageDoubleMapKeyProvider {
|
||||
}
|
||||
|
||||
/// Error generated by the `OwnedBridgeModule` trait.
|
||||
#[derive(Encode, Decode, TypeInfo, PalletError)]
|
||||
#[derive(Encode, Decode, PartialEq, Eq, TypeInfo, PalletError)]
|
||||
pub enum OwnedBridgeModuleError {
|
||||
/// All pallet operations are halted.
|
||||
Halted,
|
||||
@@ -350,7 +321,7 @@ pub enum OwnedBridgeModuleError {
|
||||
|
||||
/// Operating mode for a bridge module.
|
||||
pub trait OperatingMode: Send + Copy + Debug + FullCodec {
|
||||
// Returns true if the bridge module is halted.
|
||||
/// Returns true if the bridge module is halted.
|
||||
fn is_halted(&self) -> bool;
|
||||
}
|
||||
|
||||
@@ -392,8 +363,11 @@ pub trait OwnedBridgeModule<T: frame_system::Config> {
|
||||
/// The target that will be used when publishing logs related to this module.
|
||||
const LOG_TARGET: &'static str;
|
||||
|
||||
/// A storage entry that holds the module `Owner` account.
|
||||
type OwnerStorage: StorageValue<T::AccountId, Query = Option<T::AccountId>>;
|
||||
/// Operating mode type of the pallet.
|
||||
type OperatingMode: OperatingMode;
|
||||
/// A storage value that holds the pallet operating mode.
|
||||
type OperatingModeStorage: StorageValue<Self::OperatingMode, Query = Self::OperatingMode>;
|
||||
|
||||
/// Check if the module is halted.
|
||||
@@ -469,9 +443,11 @@ impl WeightExtraOps for Weight {
|
||||
|
||||
/// Trait that provides a static `str`.
|
||||
pub trait StaticStrProvider {
|
||||
/// Static string.
|
||||
const STR: &'static str;
|
||||
}
|
||||
|
||||
/// A macro that generates `StaticStrProvider` with the string set to its stringified argument.
|
||||
#[macro_export]
|
||||
macro_rules! generate_static_str_provider {
|
||||
($str:expr) => {
|
||||
@@ -485,6 +461,7 @@ macro_rules! generate_static_str_provider {
|
||||
};
|
||||
}
|
||||
|
||||
/// Error message that is only dispayable in `std` environment.
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq, PalletError, TypeInfo)]
|
||||
#[scale_info(skip_type_params(T))]
|
||||
pub struct StrippableError<T> {
|
||||
|
||||
Reference in New Issue
Block a user