tensora/
lib.rs

1//! # Tensora Rust SDK
2//!
3//! `tensora-rs` is the official Rust SDK for the Tensora L2 AI Network.
4//!
5//! Built on the OP Stack with BSC (BNB Chain) as L1 settlement layer.
6//!
7//! ## Features
8//!
9//! - **Typed contract bindings** for TORA token, staking, subnets, and bridge
10//! - **Wallet abstraction** supporting local keypairs and external signers
11//! - **Bridge helpers** for L1↔L2 WTORA deposits and withdrawals
12//! - **API clients** for off-chain services (indexer, explorer, coordinator)
13//! - **Async-safe** with retry logic and BSC reorg handling
14//!
15//! ## Quick Start
16//!
17//! ```no_run
18//! use tensora::prelude::*;
19//! use ethers::types::Address;
20//!
21//! #[tokio::main]
22//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
23//!     // Load configuration from environment
24//!     let config = TensoraConfig::from_env()?;
25//!     
26//!     // Create client
27//!     let client = TensoraClient::new(&config).await?;
28//!     
29//!     // Get balance
30//!     let addr: Address = "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb".parse()?;
31//!     let balance = client.get_balance(addr).await?;
32//!     println!("Balance: {} BNB", balance);
33//!     
34//!     Ok(())
35//! }
36//! ```
37//!
38//! ## Configuration
39//!
40//! Set these environment variables or use a `.env` file:
41//!
42//! ```env
43//! TENSORA_RPC=https://rpc.tensora.sh
44//! TENSORA_CHAIN_ID=44444444
45//! BSC_RPC=https://bsc-dataseed.binance.org
46//! PRIVATE_KEY=0x...  # Optional, for signing transactions
47//! ```
48
49pub mod client;
50pub mod config;
51pub mod wallet;
52pub mod types;
53pub mod errors;
54pub mod contracts;
55pub mod api;
56
57/// Re-export commonly used types
58pub mod prelude {
59    pub use crate::client::TensoraClient;
60    pub use crate::config::TensoraConfig;
61    pub use crate::wallet::WalletSigner;
62    pub use crate::types::*;
63    pub use crate::errors::{TensoraError, Result};
64    pub use ethers::types::{Address, U256, H256, TransactionReceipt};
65}
66
67// Re-export ethers for convenience
68pub use ethers;
69
70#[cfg(test)]
71mod tests {
72    use super::*;
73
74    #[test]
75    fn test_library_compiles() {
76        // Basic compilation test
77        assert_eq!(2 + 2, 4);
78    }
79}
80