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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// This file is part of Astar.

// Copyright (C) Stake Technologies Pte.Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later

// Astar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Astar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Astar. If not, see <http://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]

//! Core Astar types.
//!
//! These core Astar types are used by the Shiden, Shibuya, Astar and Local runtime.
pub mod xcm;

/// Checked Ethereum transaction primitives.
pub mod ethereum_checked;

/// EVM primitives.
pub mod evm;

/// Precompiles
pub mod precompiles;

/// dApp staking & inflation primitives.
pub mod dapp_staking;

/// Useful primitives for testing.
pub mod testing;

/// Oracle & price primitives.
pub mod oracle;

/// Governance primitives.
pub mod governance;

/// Genesis generation helpers & primitives.
pub mod genesis;

/// Parachain related constants.
pub mod parachain;

/// Benchmark primitives
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarks;

use frame_support::migrations::{FailedMigrationHandler, FailedMigrationHandling};
use sp_runtime::{
    generic,
    traits::{BlakeTwo256, IdentifyAccount, Verify},
};

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = sp_runtime::MultiSignature;
/// 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 = sp_runtime::MultiAddress<AccountId, ()>;

/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Balance of an account.
pub type Balance = u128;
/// An index to a block.
pub type BlockNumber = u32;
/// A hash of some data used by the chain.
pub type Hash = sp_core::H256;
/// Id used for identifying assets.
///
/// AssetId allocation:
/// [1; 2^32-1]     Custom user assets (permissionless)
/// [2^32; 2^64-1]  Statemine assets (simple map)
/// [2^64; 2^128-1] Ecosystem assets
/// 2^128-1         Relay chain token (KSM)
pub type AssetId = u128;
/// Block type.
pub type Block = sp_runtime::generic::Block<Header, sp_runtime::OpaqueExtrinsic>;
/// Index of a transaction in the chain.
pub type Nonce = u32;

/// Unfreeze chain on failed migration and continue with extrinsic execution.
/// Migration must be tested and make sure it doesn't fail. If it happens, we don't have other
/// choices but unfreeze chain and continue with extrinsic execution.
pub struct UnfreezeChainOnFailedMigration;
impl FailedMigrationHandler for UnfreezeChainOnFailedMigration {
    fn failed(migration: Option<u32>) -> FailedMigrationHandling {
        log::error!(target: "mbm", "Migration failed at cursor: {migration:?}");
        FailedMigrationHandling::ForceUnstuck
    }
}