1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#![cfg_attr(not(feature = "std"), no_std)]
pub use sp_runtime::{
	generic,
	traits::{BlakeTwo256, IdentifyAccount, Verify},
	DispatchError, MultiAddress, MultiSignature, OpaqueExtrinsic,
};
use sp_std::{boxed::Box, vec::Vec};

use frame_support::dispatch::DispatchResultWithPostInfo;

/// Some way of identifying an account on the chain. We intentionally make it equivalent
/// to the public key of our transaction signing scheme.
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;

/// The address format for describing accounts.
pub type Address = MultiAddress<AccountId, ()>;

/// Balance is a generic type for the balance of an account.
pub type Balance = u128;

/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, OpaqueExtrinsic>;

/// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;

/// An index to a block.
pub type BlockNumber = u32;

/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = MultiSignature;

/// Index of a transaction in the chain.
pub type Index = u32;

/// A hash of some data used by the chain.
pub type Hash = sp_core::H256;
/// The provider of a collective action interface, for example an instance of `pallet-collective`.
pub trait ProposalProvider<AccountId, Proposal> {
	/// Add a new proposal with a threshold number of council votes.
	/// Returns a proposal length and active proposals count if successful.
	fn propose(
		who: AccountId,
		threshold: u32,
		proposal: Box<Proposal>,
	) -> Result<(u32, u32), DispatchError>;

	/// Add a new proposal with a simple majority (>50%) of council votes.
	/// Returns a proposal length and active proposals count if successful.
	fn propose_with_simple_majority(
		who: AccountId,
		proposal: Box<Proposal>,
	) -> Result<(u32, u32), DispatchError>;

	/// Get the number of proposals
	#[cfg(any(feature = "runtime-benchmarks", feature = "test"))]
	fn proposal_count() -> u32;
}

/// The provider for interfacing into the Utility pallet.
pub trait UtilityProvider<Origin, RuntimeCall> {
	/// Passthrough into the Utility::batch_all call
	fn batch_all(origin: Origin, calls: Vec<RuntimeCall>) -> DispatchResultWithPostInfo;
}