mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 14:01:06 +00:00
Refactor primitives.
This commit is contained in:
@@ -43,7 +43,7 @@ extern crate uint as uint_crate;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
extern crate core;
|
||||
extern crate polkadot_runtime_codec as codec;
|
||||
extern crate polkadot_codec as codec;
|
||||
#[cfg(test)]
|
||||
extern crate polkadot_serializer;
|
||||
#[cfg(test)]
|
||||
@@ -80,38 +80,7 @@ mod tests;
|
||||
pub mod hashing;
|
||||
|
||||
pub use self::hash::{H160, H256};
|
||||
pub use self::relay::BlockNumber;
|
||||
pub use self::uint::{U256, U512};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use hashing::{blake2_256, twox_128, twox_256};
|
||||
|
||||
/// Virtual account ID that represents the idea of a dispatch/statement being signed by everybody
|
||||
/// (who matters). Essentially this means that a majority of validators have decided it is
|
||||
/// "correct".
|
||||
pub const EVERYBODY: AccountId = [255u8; 32];
|
||||
|
||||
/// Alias to Ed25519 pubkey that identifies an account.
|
||||
pub type AccountId = [u8; 32];
|
||||
|
||||
/// The Ed25519 pub key of an session that belongs to an authority. This is used as what the
|
||||
/// external environment/consensus algorithm calls an "authority".
|
||||
pub type SessionKey = AccountId;
|
||||
|
||||
/// Indentifier for a chain.
|
||||
pub type ChainID = u64;
|
||||
|
||||
/// Index of a transaction.
|
||||
pub type TxOrder = u64;
|
||||
|
||||
/// A hash of some data.
|
||||
pub type Hash = hash::H256;
|
||||
|
||||
/// Alias to 520-bit hash when used in the context of a signature.
|
||||
pub type Signature = hash::H512;
|
||||
|
||||
/// A balance in the staking subsystem.
|
||||
pub type Balance = u64;
|
||||
|
||||
/// A timestamp.
|
||||
pub type Timestamp = u64;
|
||||
|
||||
@@ -54,7 +54,7 @@ pub struct Candidate {
|
||||
/// The ID of the parachain this is a proposal for.
|
||||
pub parachain_index: Id,
|
||||
/// Collator's signature
|
||||
pub collator_signature: ::Signature,
|
||||
pub collator_signature: ::relay::Signature,
|
||||
/// Unprocessed ingress queue.
|
||||
///
|
||||
/// Ordered by parachain ID and block number.
|
||||
@@ -71,12 +71,12 @@ pub struct Candidate {
|
||||
pub struct CandidateReceipt {
|
||||
/// The ID of the parachain this is a candidate for.
|
||||
pub parachain_index: Id,
|
||||
/// The collator's account ID
|
||||
pub collator: ::AccountId,
|
||||
/// The collator's relay-chain account ID
|
||||
pub collator: ::relay::AccountId,
|
||||
/// The head-data
|
||||
pub head_data: HeadData,
|
||||
/// Balance uploads to the relay chain.
|
||||
pub balance_uploads: Vec<(::AccountId, ::uint::U256)>,
|
||||
pub balance_uploads: Vec<(::relay::AccountId, ::uint::U256)>,
|
||||
/// Egress queue roots.
|
||||
pub egress_queue_roots: Vec<(Id, ::hash::H256)>,
|
||||
/// Fees paid from the chain to the relay chain validators
|
||||
|
||||
@@ -7,3 +7,27 @@ pub use self::block::*;
|
||||
pub use self::transaction::*;
|
||||
|
||||
pub use self::block::Number as BlockNumber;
|
||||
|
||||
/// Virtual account ID that represents the idea of a dispatch/statement being signed by everybody
|
||||
/// (who matters). Essentially this means that a majority of validators have decided it is
|
||||
/// "correct".
|
||||
pub const EVERYBODY: AccountId = [255u8; 32];
|
||||
|
||||
/// Alias to Ed25519 pubkey that identifies an account on the relay chain.
|
||||
pub type AccountId = [u8; 32];
|
||||
|
||||
/// The Ed25519 pub key of an session that belongs to an authority of the relay chain. This is
|
||||
/// used as what the external environment/consensus algorithm calls an "authority".
|
||||
pub type SessionKey = AccountId;
|
||||
|
||||
/// Indentifier for a chain.
|
||||
pub type ChainID = u64;
|
||||
|
||||
/// Index of a transaction in the relay chain.
|
||||
pub type TxOrder = u64;
|
||||
|
||||
/// A hash of some data used by the relay chain.
|
||||
pub type Hash = ::hash::H256;
|
||||
|
||||
/// Alias to 520-bit hash when used in the context of a signature on the relay chain.
|
||||
pub type Signature = ::hash::H512;
|
||||
|
||||
@@ -205,15 +205,15 @@ impl FunctionId {
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub enum Function {
|
||||
/// Set the timestamp.
|
||||
TimestampSet(::Timestamp),
|
||||
TimestampSet(u64),
|
||||
/// Set temporary session key as a validator.
|
||||
SessionSetKey(::SessionKey),
|
||||
SessionSetKey(::relay::SessionKey),
|
||||
/// Staking subsystem: begin staking.
|
||||
StakingStake,
|
||||
/// Staking subsystem: stop staking.
|
||||
StakingUnstake,
|
||||
/// Staking subsystem: transfer stake.
|
||||
StakingTransfer(::AccountId, ::Balance),
|
||||
StakingTransfer(::relay::AccountId, u64),
|
||||
/// Make a proposal for the governance system.
|
||||
GovernancePropose(Proposal),
|
||||
/// Approve a proposal for the governance system.
|
||||
@@ -288,9 +288,9 @@ impl Slicable for Function {
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub struct Transaction {
|
||||
/// Who signed it (note this is not a signature).
|
||||
pub signed: ::AccountId,
|
||||
pub signed: super::AccountId,
|
||||
/// The number of transactions have come before from the same signer.
|
||||
pub nonce: ::TxOrder,
|
||||
pub nonce: super::TxOrder,
|
||||
/// The function that should be called.
|
||||
pub function: Function,
|
||||
}
|
||||
@@ -326,7 +326,7 @@ pub struct UncheckedTransaction {
|
||||
/// The actual transaction information.
|
||||
pub transaction: Transaction,
|
||||
/// The signature; should be an Ed25519 signature applied to the serialised `transaction` field.
|
||||
pub signature: ::Signature,
|
||||
pub signature: super::Signature,
|
||||
}
|
||||
|
||||
impl Slicable for UncheckedTransaction {
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
//! Tests.
|
||||
|
||||
use codec::Slicable;
|
||||
|
||||
use ::AccountId;
|
||||
use relay::block::{Block, Header, Digest, Log};
|
||||
use relay::transaction::{UncheckedTransaction, Transaction, Function};
|
||||
use relay::{AccountId, Block, Header, Digest, Log, UncheckedTransaction, Transaction, Function};
|
||||
|
||||
#[test]
|
||||
fn serialise_transaction_works() {
|
||||
|
||||
Reference in New Issue
Block a user