-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathlib.rs
More file actions
90 lines (84 loc) · 3.03 KB
/
lib.rs
File metadata and controls
90 lines (84 loc) · 3.03 KB
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
//! A Rust library for interacting with the NEAR Protocol blockchain
//!
//! This crate provides a high-level API for interacting with NEAR Protocol, including:
//! - [Account management and creation](Account)
//! - [Contract deployment and interaction with it](Contract)
//! - [Token operations](Tokens) ([`NEAR`](https://docs.near.org/concepts/basics/tokens), [`FT`](https://docs.near.org/build/primitives/ft), [`NFT`](https://docs.near.org/build/primitives/nft))
//! - [Storage management](StorageDeposit)
//! - [Staking operations](Staking)
//! - [Custom transaction building and signing](Transaction)
//! - [Querying the chain data](Chain)
//! - [Several ways to sign the transaction](signer)
//! - Account nonce caching and access-key pooling mechanisms to speed up the transaction processing.
//! - Support for backup RPC endpoints
//!
//! # Example
//! In this example, we use Bob account with a predefined seed phrase to create Alice account and pre-fund it with 1 `NEAR`.
//! ```rust,no_run
//! use near_api::{*, signer::generate_secret_key};
//! use std::str::FromStr;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Initialize network configuration
//! let bob = AccountId::from_str("bob.testnet")?;
//! let bob_seed_phrase = "lucky barrel fall come bottom can rib join rough around subway cloth ";
//!
//! // Fetch NEAR balance
//! let _bob_balance = Tokens::account(bob.clone())
//! .near_balance()
//! .fetch_from_testnet()
//! .await?;
//!
//! // Create an account instance
//! let signer = Signer::from_seed_phrase(bob_seed_phrase, None)?;
//! let alice_secret_key = generate_secret_key()?;
//! Account::create_account(AccountId::from_str("alice.testnet")?)
//! .fund_myself(bob.clone(), NearToken::from_near(1))
//! .with_public_key(alice_secret_key.public_key())
//! .with_signer(signer)
//! .send_to_testnet()
//! .await?;
//! # Ok(())
//! # }
//! ```
//!
//! # Features
//! - `ledger`: Enables hardware wallet support
//! - `keystore`: Enables system keychain integration
//! - `workspaces`: Enables integration with near-workspaces for testing
mod account;
mod chain;
mod config;
mod contract;
mod stake;
mod storage;
mod tokens;
mod transactions;
// TODO: to be honest, there is almost nothing in this file
// we should maybe integrate with them more tightly
// for now, i comment it out
// mod fastnear;
mod common;
pub use near_api_types as types;
pub mod errors;
pub mod signer;
pub use crate::{
account::Account,
chain::Chain,
config::{NetworkConfig, RPCEndpoint, RetryMethod},
contract::Contract,
signer::{Signer, SignerTrait},
stake::{Delegation, Staking},
storage::{StorageDeposit, StorageDepositBuilder, StorageUnregisterBuilder},
tokens::Tokens,
transactions::Transaction,
types::{
AccountId, CryptoHash, Data, EpochReference, NearGas, NearToken, PublicKey, Reference,
SecretKey,
tokens::{FTBalance, USDT_BALANCE, W_NEAR_BALANCE},
},
};
pub mod advanced {
pub use crate::common::query::*;
pub use crate::common::send::*;
}