Skip to main content

veiron_sdk_rust/
lib.rs

1//! # veiron-sdk-rust
2//!
3//! **Standalone** Rust client SDK for **Veiron Network Mainnet Candidate**
4//! (prototype — not Mainnet Live).
5//!
6//! Protocol primitives (address, amount, keys, transactions) are **vendored**
7//! inside this crate — there is **no** dependency on `veiron-core`.
8//!
9//! Coexists with the public TypeScript package `@veiron/sdk` at monorepo path `veiron-sdk/`.
10//!
11//! ## Essential surface
12//! - [`NetworkConfig`] — network + RPC (+ public pool) base URLs
13//! - [`WalletAccount`] — in-memory mnemonic / key account
14//! - [`TransferBuilder`] — build and sign transfers
15//! - [`RpcClient`] — async HTTP RPC + public pool (feature `native`, default)
16//! - [`pool_block_maturity`] — pure maturity helper
17//!
18//! ## Non-goals
19//! pool admin mutations, contracts, browser store extension.
20
21#![cfg_attr(docsrs, feature(doc_cfg))]
22
23pub mod config;
24pub mod error;
25pub mod maturity;
26pub mod protocol;
27pub mod tx;
28pub mod wallet;
29
30#[cfg(feature = "native")]
31pub mod rpc;
32
33pub use config::{
34    NetworkConfig, DEFAULT_LOCAL_MAINNET_CANDIDATE_RPC, DEFAULT_MAINNET_CANDIDATE_POOL,
35    DEFAULT_MAINNET_CANDIDATE_RPC,
36};
37pub use error::{Result, SdkError};
38pub use maturity::{
39    pool_block_maturity, MaturityProgress, MaturityStatus, DEFAULT_BLOCK_MATURITY_CONFIRMATIONS,
40};
41pub use tx::{SignedTransfer, TransferBuilder};
42pub use wallet::{GeneratedMnemonic, WalletAccount};
43
44#[cfg(feature = "native")]
45pub use rpc::{
46    AddressAccountResponse, AddressBalanceResponse, AtomicValue, BlockResponse,
47    ChainHeightResponse, ChainTipResponse, HealthResponse, IndexSummary, IndexedAddressResponse,
48    IndexedBlockResponse, IndexedTransactionResponse, IndexerStatusResponse,
49    IndexerSummaryResponse, MempoolStatusResponse, NetworkResponse, P2pStatusResponse, PoolBlock,
50    PoolBlockWithMaturity, PoolHistoryResponse, PoolStatusResponse, PoolWorker, RpcClient,
51    StatusResponse, SubmitTransactionResponse, SupplyResponse, SupplySummary, SyncStatusResponse,
52    TransactionResponse,
53};
54
55#[cfg(all(feature = "native", feature = "blocking"))]
56pub use rpc::BlockingRpcClient;
57
58// Protocol surface (standalone — not re-exported from veiron-core).
59pub use protocol::{
60    generate_mnemonic, hash_to_hex, Address, Amount, MnemonicWordCount, Network, PrivateKey,
61    PublicKey, Signature, Transaction, UnsignedTransaction, VeironError, WalletDerivationPath,
62    ATOMIC_UNITS_PER_VIRE, BLOCK_TIME_SECONDS, CURRENT_STATUS, DECIMALS, INITIAL_BASE_FEE_ATOMIC,
63    INITIAL_BLOCK_REWARD_ATOMIC, MAX_SUPPLY_ATOMIC, TICKER,
64};
65
66/// Compile-time marker used by wasm feature checks and docs.
67#[cfg(feature = "wasm")]
68pub const WASM_LOGIC_FEATURE: bool = true;
69
70#[cfg(feature = "wasm")]
71/// Pure helpers safe to call from wasm hosts (no filesystem, no native TLS RPC in v0).
72pub mod wasm_logic {
73    use crate::error::Result;
74    use crate::protocol::{Address, Amount, Transaction};
75
76    pub fn parse_address(value: &str) -> Result<Address> {
77        Ok(Address::parse(value)?)
78    }
79
80    pub fn format_vire(amount: Amount) -> String {
81        amount.format_vire()
82    }
83
84    pub fn parse_vire(value: &str) -> Result<Amount> {
85        Ok(Amount::parse_vire(value)?)
86    }
87
88    pub fn verify_transaction(tx: &Transaction) -> Result<()> {
89        Ok(tx.verify()?)
90    }
91}