gear_runtime_primitives/lib.rs
1// This file is part of Gear.
2
3// Copyright (C) 2021-2025 Gear Technologies Inc.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program 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// This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Low-level types used throughout the Substrate code.
20
21#![warn(missing_docs)]
22#![cfg_attr(not(feature = "std"), no_std)]
23
24use sp_runtime::{
25 generic,
26 traits::{BlakeTwo256, IdentifyAccount, Verify},
27 MultiSignature, OpaqueExtrinsic,
28};
29
30/// An index to a block.
31pub type BlockNumber = u32;
32
33/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
34pub type Signature = MultiSignature;
35
36/// Alias to the public key used for this chain.
37pub type AccountPublic = <Signature as Verify>::Signer;
38
39/// Some way of identifying an account on the chain. We intentionally make it equivalent
40/// to the public key of our transaction signing scheme.
41pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId;
42
43/// The type for looking up accounts. We don't expect more than 4 billion of them.
44pub type AccountIndex = u32;
45
46/// Balance of an account.
47pub type Balance = u128;
48
49/// Type used for expressing timestamp.
50pub type Moment = u64;
51
52/// Nonce of a transaction in the chain.
53pub type Nonce = u32;
54
55/// A hash of some data used by the chain.
56pub type Hash = sp_core::H256;
57
58/// A timestamp: milliseconds since the unix epoch.
59/// `u64` is enough to represent a duration of half a billion years, when the
60/// time scale is milliseconds.
61pub type Timestamp = u64;
62
63/// Digest item type.
64pub type DigestItem = generic::DigestItem;
65/// Header type.
66pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
67/// Block type.
68pub type Block = generic::Block<Header, OpaqueExtrinsic>;
69/// Block ID.
70pub type BlockId = generic::BlockId<Block>;
71
72/// SS58 prefix of VARA.
73pub const VARA_SS58_PREFIX: u8 = 137;