astar_primitives/
lib.rs

1// This file is part of Astar.
2
3// Copyright (C) Stake Technologies Pte.Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later
5
6// Astar is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// Astar is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with Astar. If not, see <http://www.gnu.org/licenses/>.
18
19#![cfg_attr(not(feature = "std"), no_std)]
20
21//! Core Astar types.
22//!
23//! These core Astar types are used by the Shiden, Shibuya, Astar and Local runtime.
24pub mod xcm;
25
26/// Checked Ethereum transaction primitives.
27pub mod ethereum_checked;
28
29/// EVM primitives.
30pub mod evm;
31
32/// Precompiles
33pub mod precompiles;
34
35/// dApp staking & inflation primitives.
36pub mod dapp_staking;
37
38/// Useful primitives for testing.
39pub mod testing;
40
41/// Oracle & price primitives.
42pub mod oracle;
43
44/// Governance primitives.
45pub mod governance;
46
47/// Genesis generation helpers & primitives.
48pub mod genesis;
49
50/// Parachain related constants.
51pub mod parachain;
52
53/// Benchmark primitives
54#[cfg(feature = "runtime-benchmarks")]
55pub mod benchmarks;
56
57use frame_support::migrations::{FailedMigrationHandler, FailedMigrationHandling};
58use sp_runtime::{
59    generic,
60    traits::{BlakeTwo256, IdentifyAccount, Verify},
61};
62
63/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
64pub type Signature = sp_runtime::MultiSignature;
65/// Some way of identifying an account on the chain. We intentionally make it equivalent
66/// to the public key of our transaction signing scheme.
67pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;
68/// The address format for describing accounts.
69pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
70
71/// Block header type as expected by this runtime.
72pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
73/// Balance of an account.
74pub type Balance = u128;
75/// An index to a block.
76pub type BlockNumber = u32;
77/// A hash of some data used by the chain.
78pub type Hash = sp_core::H256;
79/// Id used for identifying assets.
80///
81/// AssetId allocation:
82/// [1; 2^32-1]     Custom user assets (permissionless)
83/// [2^32; 2^64-1]  Statemine assets (simple map)
84/// [2^64; 2^128-1] Ecosystem assets
85/// 2^128-1         Relay chain token (KSM)
86pub type AssetId = u128;
87/// Block type.
88pub type Block = sp_runtime::generic::Block<Header, sp_runtime::OpaqueExtrinsic>;
89/// Index of a transaction in the chain.
90pub type Nonce = u32;
91
92/// Unfreeze chain on failed migration and continue with extrinsic execution.
93/// Migration must be tested and make sure it doesn't fail. If it happens, we don't have other
94/// choices but unfreeze chain and continue with extrinsic execution.
95pub struct UnfreezeChainOnFailedMigration;
96impl FailedMigrationHandler for UnfreezeChainOnFailedMigration {
97    fn failed(migration: Option<u32>) -> FailedMigrationHandling {
98        log::error!(target: "mbm", "Migration failed at cursor: {migration:?}");
99        FailedMigrationHandling::ForceUnstuck
100    }
101}