mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 19:51:02 +00:00
84cd93f936
* Move chain primitives to a sub-folder. * Update workspace members. * Extract core parts of polkadot. * cargo fmt --all * Remove TODO. * cargo fmt --all * Fix crate names. * Add to the latest API. * cargo fmt --all * Add nested lock files to ignore (generated during cargo fmt) * Fix compilation. * cargo fmt --all * Fix ignore pattern. * Address review comments.
97 lines
3.3 KiB
Rust
97 lines
3.3 KiB
Rust
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
|
// This file is part of Parity Bridges Common.
|
|
|
|
// Parity Bridges Common is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Parity Bridges Common is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// 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/>.
|
|
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
|
|
|
use bp_message_lane::MessageNonce;
|
|
use bp_runtime::Chain;
|
|
use frame_support::RuntimeDebug;
|
|
use sp_core::Hasher as HasherT;
|
|
use sp_runtime::{
|
|
generic,
|
|
traits::{BlakeTwo256, IdentifyAccount, Verify},
|
|
MultiSignature, OpaqueExtrinsic as UncheckedExtrinsic,
|
|
};
|
|
|
|
// Re-export's to avoid extra substrate dependencies in chain-specific crates.
|
|
pub use frame_support::Parameter;
|
|
pub use sp_runtime::traits::Convert;
|
|
|
|
// TODO [#78] may need to be updated after https://github.com/paritytech/parity-bridges-common/issues/78
|
|
/// Maximal number of messages in single delivery transaction.
|
|
pub const MAX_MESSAGES_IN_DELIVERY_TRANSACTION: MessageNonce = 128;
|
|
|
|
/// Maximal number of unrewarded relayer entries at inbound lane.
|
|
pub const MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE: MessageNonce = 128;
|
|
|
|
// TODO [#438] should be selected keeping in mind:
|
|
// finality delay on both chains + reward payout cost + messages throughput.
|
|
/// Maximal number of unconfirmed messages at inbound lane.
|
|
pub const MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE: MessageNonce = 8192;
|
|
|
|
/// Block number type used in Polkadot-like chains.
|
|
pub type BlockNumber = u32;
|
|
|
|
/// Hash type used in Polkadot-like chains.
|
|
pub type Hash = <BlakeTwo256 as HasherT>::Out;
|
|
|
|
/// The type of an object that can produce hashes on Polkadot-like chains.
|
|
pub type Hasher = BlakeTwo256;
|
|
|
|
/// The header type used by Polkadot-like chains.
|
|
pub type Header = generic::Header<BlockNumber, Hasher>;
|
|
|
|
/// Signature type used by Polkadot-like chains.
|
|
pub type Signature = MultiSignature;
|
|
|
|
/// Public key of account on Polkadot-like chains.
|
|
pub type AccountPublic = <Signature as Verify>::Signer;
|
|
|
|
/// Id of account on Polkadot-like chains.
|
|
pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId;
|
|
|
|
/// Index of a transaction on the Polkadot-like chains.
|
|
pub type Nonce = u32;
|
|
|
|
/// Block type of Polkadot-like chains.
|
|
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
|
|
|
/// Polkadot-like block signed with a Justification.
|
|
pub type SignedBlock = generic::SignedBlock<Block>;
|
|
|
|
/// The balance of an account on Polkadot-like chain.
|
|
pub type Balance = u128;
|
|
|
|
/// Polkadot-like chain.
|
|
#[derive(RuntimeDebug)]
|
|
pub struct PolkadotLike;
|
|
|
|
impl Chain for PolkadotLike {
|
|
type BlockNumber = BlockNumber;
|
|
type Hash = Hash;
|
|
type Hasher = Hasher;
|
|
type Header = Header;
|
|
}
|
|
|
|
/// Convert a 256-bit hash into an AccountId.
|
|
pub struct AccountIdConverter;
|
|
|
|
impl Convert<sp_core::H256, AccountId> for AccountIdConverter {
|
|
fn convert(hash: sp_core::H256) -> AccountId {
|
|
hash.to_fixed_bytes().into()
|
|
}
|
|
}
|