common_primitives/
node.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2pub use sp_runtime::{
3	generic,
4	traits::{BlakeTwo256, IdentifyAccount, Verify},
5	DispatchError, MultiAddress, MultiSignature, OpaqueExtrinsic,
6};
7
8extern crate alloc;
9use alloc::{boxed::Box, vec::Vec};
10
11use crate::signatures::UnifiedSignature;
12use frame_support::dispatch::DispatchResultWithPostInfo;
13
14/// Some way of identifying an account on the chain. We intentionally make it equivalent
15/// to the public key of our transaction signing scheme.
16pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
17
18/// The address format for describing accounts.
19pub type Address = MultiAddress<AccountId, ()>;
20
21/// Balance is a generic type for the balance of an account.
22pub type Balance = u128;
23
24/// Block type as expected by this runtime.
25pub type Block = generic::Block<Header, OpaqueExtrinsic>;
26
27/// BlockId type as expected by this runtime.
28pub type BlockId = generic::BlockId<Block>;
29
30/// An index to a block.
31pub type BlockNumber = u32;
32
33/// Block header type as expected by this runtime.
34pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
35
36/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
37pub type Signature = UnifiedSignature;
38
39/// Index of a transaction in the chain.
40pub type Index = u32;
41
42/// A hash of some data used by the chain.
43pub type Hash = sp_core::H256;
44/// The provider of a collective action interface, for example an instance of `pallet-collective`.
45pub trait ProposalProvider<AccountId, Proposal> {
46	/// Add a new proposal with a threshold number of council votes.
47	/// Returns a proposal length and active proposals count if successful.
48	fn propose(
49		who: AccountId,
50		threshold: u32,
51		proposal: Box<Proposal>,
52	) -> Result<(u32, u32), DispatchError>;
53
54	/// Add a new proposal with a simple majority (>50%) of council votes.
55	/// Returns a proposal length and active proposals count if successful.
56	fn propose_with_simple_majority(
57		who: AccountId,
58		proposal: Box<Proposal>,
59	) -> Result<(u32, u32), DispatchError>;
60
61	/// Get the number of proposals
62	#[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
63	fn proposal_count() -> u32;
64}
65
66/// The provider for interfacing into the Utility pallet.
67pub trait UtilityProvider<Origin, RuntimeCall> {
68	/// Passthrough into the Utility::batch_all call
69	fn batch_all(origin: Origin, calls: Vec<RuntimeCall>) -> DispatchResultWithPostInfo;
70}
71
72/// Trait that must be implemented to be able to encode the payload to eip-712 compatible signatures
73pub trait EIP712Encode {
74	/// encodes the type without hashing it
75	fn encode_eip_712(&self, chain_id: u32) -> Box<[u8]>;
76}