domain_test_primitives/
lib.rs

1//! Test primitives crates that expose extensions for testing.
2
3#![cfg_attr(not(feature = "std"), no_std)]
4
5use domain_runtime_primitives::EthereumAccountId;
6use parity_scale_codec::{Decode, Encode};
7use sp_domains::PermissionedActionAllowedBy;
8use sp_messenger::messages::{ChainId, ChannelId};
9use subspace_runtime_primitives::Moment;
10
11sp_api::decl_runtime_apis! {
12    /// Api that returns the domain timestamp
13    pub trait TimestampApi {
14        /// Returns the current domain timestamp
15        fn domain_timestamp() -> Moment;
16    }
17}
18
19sp_api::decl_runtime_apis! {
20    /// Api for querying onchain state in tests
21    pub trait OnchainStateApi<AccountId, Balance>
22    where
23        AccountId: Encode + Decode,
24        Balance: Encode + Decode
25    {
26        /// Api to get the free balance of the given account
27        fn free_balance(account_id: AccountId) -> Balance;
28
29        /// Returns the last open channel for a given domain.
30        fn get_open_channel_for_chain(dst_chain_id: ChainId) -> Option<ChannelId>;
31
32        /// Api to get the current domain transaction byte fee
33        fn consensus_transaction_byte_fee() -> Balance;
34
35        /// Get the storage root
36        fn storage_root() -> [u8; 32];
37
38        /// Return the chain's total issuance
39        fn total_issuance() -> Balance;
40    }
41}
42
43sp_api::decl_runtime_apis! {
44    /// Api for querying onchain EVM state in tests
45    pub trait EvmOnchainStateApi
46    {
47        /// Returns the current EVM contract creation allow list.
48        /// Returns `None` if this is not an EVM domain.
49        fn evm_contract_creation_allowed_by() -> Option<PermissionedActionAllowedBy<EthereumAccountId>>;
50    }
51}