walletsuite_tx_compiler/lib.rs
1//! Deterministic transaction compilation for Ethereum (EVM) and Tron.
2//!
3//! This crate converts `WalletSuite` canonical prepared transaction payloads
4//! into signer-ready unsigned artifacts and human-reviewable representations.
5//!
6//! # Example
7//!
8//! ```
9//! use walletsuite_tx_compiler::{compile, review, validate};
10//!
11//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
12//! let raw: serde_json::Value = serde_json::from_str(r#"{
13//! "chain": "ethereum",
14//! "chainId": 1,
15//! "txType": "TRANSFER_NATIVE",
16//! "from": "0x1111111111111111111111111111111111111111",
17//! "to": "0x2222222222222222222222222222222222222222",
18//! "valueWei": "1000000000000000000",
19//! "nonce": "0",
20//! "fee": {
21//! "mode": "EIP1559",
22//! "gasLimit": "21000",
23//! "maxFeePerGas": "30000000000",
24//! "maxPriorityFeePerGas": "1500000000"
25//! }
26//! }"#)?;
27//!
28//! let prepared = validate(&raw)?;
29//! let _review = review(&prepared)?;
30//! let result = compile(&prepared, Default::default())?;
31//!
32//! assert!(result.unsigned_tx.starts_with("0x02")); // EIP-1559 envelope
33//! # Ok(())
34//! # }
35//! # example().unwrap();
36//! ```
37//!
38//! # Determinism
39//!
40//! The compiler is byte-exact against the pinned canonical fixture set
41//! in `tests/fixtures/canonical.json`. Any change that alters compiled
42//! bytes must update that fixture and is treated as a hard-failing
43//! regression by the CI determinism suite.
44#![doc(html_root_url = "https://docs.rs/walletsuite-tx-compiler/0.1.0")]
45
46mod compile;
47pub mod constants;
48mod error;
49mod evm;
50mod review;
51mod tron;
52mod tron_address;
53mod tron_proto;
54mod types;
55mod validate;
56
57pub use crate::compile::compile;
58pub use crate::error::{TxCompilerError, TxCompilerErrorCode};
59pub use crate::review::review;
60pub use crate::tron_address::tron_address_to_bytes;
61pub use crate::types::{
62 Chain, CompilationMetadata, CompilationResult, CompileOptions, FeeMode, FeeParams, FeeReview,
63 PreparedTransaction, TransactionReview, TronBlockHeader, TxType,
64};
65pub use crate::validate::validate;