Skip to main content

near_kit/types/
mod.rs

1//! Core types for NEAR Protocol.
2//!
3//! This module provides hand-rolled types based on NEAR RPC responses,
4//! designed for ergonomic use in client applications.
5//!
6//! # Primary Types
7//!
8//! | Type | Description |
9//! |------|-------------|
10//! | [`AccountId`] | Validated NEAR account identifier |
11//! | [`NearToken`] | Token amount with yoctoNEAR (10⁻²⁴) precision |
12//! | [`Gas`] | Gas units for transactions |
13//! | [`PublicKey`] | Ed25519 or Secp256k1 public key |
14//! | [`SecretKey`] | Ed25519 or Secp256k1 secret key |
15//! | [`CryptoHash`] | 32-byte SHA-256 hash (blocks, transactions) |
16//!
17//! # Amount Types
18//!
19//! [`NearToken`] and [`Gas`] support both typed constructors and string parsing:
20//!
21//! ```
22//! use near_kit::{NearToken, Gas};
23//!
24//! // Typed constructors (compile-time safe, zero-cost)
25//! let amount = NearToken::near(5);
26//! let gas = Gas::tgas(30);
27//!
28//! // String parsing (for runtime input)
29//! let amount: NearToken = "5 NEAR".parse().unwrap();
30//! let gas: Gas = "30 Tgas".parse().unwrap();
31//! ```
32//!
33//! # Block References
34//!
35//! [`BlockReference`] specifies which block state to query:
36//!
37//! - `BlockReference::Finality(Finality::Final)` — Fully finalized (default)
38//! - `BlockReference::Finality(Finality::Optimistic)` — Latest optimistic
39//! - `BlockReference::Height(12345)` — Specific block height
40//! - `BlockReference::Hash(hash)` — Specific block hash
41//!
42//! # RPC Response Types
43//!
44//! Types for RPC responses include [`AccountView`], [`BlockView`],
45//! [`FinalExecutionOutcome`], and others.
46
47mod account;
48mod action;
49mod block_reference;
50mod error;
51mod hash;
52mod key;
53pub mod nep413;
54mod network;
55mod rpc;
56mod rpc_extra;
57mod transaction;
58mod units;
59
60pub use account::AccountId;
61pub use action::{
62    AccessKey, AccessKeyPermission, Action, AddKeyAction, CreateAccountAction,
63    DELEGATE_ACTION_PREFIX, DecodeError as DelegateDecodeError, DelegateAction,
64    DeleteAccountAction, DeleteKeyAction, DeployContractAction, DeployGlobalContractAction,
65    DeterministicAccountStateInit, DeterministicAccountStateInitV1, DeterministicStateInitAction,
66    FunctionCallAction, FunctionCallPermission, GasKeyInfo, GlobalContractDeployMode,
67    GlobalContractIdentifier, NonDelegateAction, SignedDelegateAction, StakeAction, TransferAction,
68    TransferToGasKeyAction, UseGlobalContractAction, WithdrawFromGasKeyAction,
69};
70pub use block_reference::{BlockReference, Finality, SyncCheckpoint, TxExecutionStatus};
71pub use error::{
72    ActionError, ActionErrorKind, ActionsValidationError, CompilationError,
73    DepositCostFailureReason, FunctionCallError, HostError, InvalidAccessKeyError, InvalidTxError,
74    MethodResolveError, PrepareError, ReceiptValidationError, StorageError, TxExecutionError,
75    WasmTrap,
76};
77pub use hash::CryptoHash;
78pub use key::{
79    DEFAULT_HD_PATH, DEFAULT_WORD_COUNT, KeyPair, KeyType, PublicKey, SecretKey, Signature,
80    generate_seed_phrase,
81};
82pub use network::Network;
83pub use rpc::{
84    AccessKeyDetails, AccessKeyInfoView, AccessKeyListView, AccessKeyPermissionView, AccessKeyView,
85    AccountBalance, AccountView, ActionReceiptData, ActionView, BandwidthRequest,
86    BandwidthRequestBitmap, BandwidthRequests, BandwidthRequestsV1, BlockHeaderView, BlockView,
87    ChunkHeaderView, CongestionInfoView, DataReceiptData, DataReceiverView, DelegateActionView,
88    ExecutionMetadata, ExecutionOutcome, ExecutionOutcomeWithId, ExecutionStatus,
89    FinalExecutionOutcome, FinalExecutionOutcomeWithReceipts, FinalExecutionStatus, GasPrice,
90    GasProfileEntry, GlobalContractIdentifierView, MerkleDirection, MerklePathItem, NodeVersion,
91    Receipt, ReceiptContent, STORAGE_AMOUNT_PER_BYTE, SendTxResponse, SendTxWithReceiptsResponse,
92    SlashedValidator, StatusResponse, SyncInfo, TransactionView, TrieSplit, ValidatorInfo,
93    ValidatorStakeView, ValidatorStakeViewV1, ViewFunctionResult,
94};
95pub use rpc_extra::{
96    BlockHeaderInnerLiteView, CurrentEpochValidatorInfo, EpochValidatorInfo,
97    LightClientBlockLiteView, LightClientBlockView, NextEpochValidatorInfo, StateChangeCauseView,
98    StateChangeValueView, StateChangeWithCauseView, ValidatorKickoutReason, ValidatorKickoutView,
99};
100pub use transaction::{SignedTransaction, Transaction};
101pub use units::{Gas, IntoGas, IntoNearToken, NearToken};