Skip to main content

Crate walletsuite_tx_compiler

Crate walletsuite_tx_compiler 

Source
Expand description

Deterministic transaction compilation for Ethereum (EVM) and Tron.

This crate converts WalletSuite canonical prepared transaction payloads into signer-ready unsigned artifacts and human-reviewable representations.

§Example

use walletsuite_tx_compiler::{compile, review, validate};

let raw: serde_json::Value = serde_json::from_str(r#"{
    "chain": "ethereum",
    "chainId": 1,
    "txType": "TRANSFER_NATIVE",
    "from": "0x1111111111111111111111111111111111111111",
    "to":   "0x2222222222222222222222222222222222222222",
    "valueWei": "1000000000000000000",
    "nonce": "0",
    "fee": {
        "mode": "EIP1559",
        "gasLimit": "21000",
        "maxFeePerGas": "30000000000",
        "maxPriorityFeePerGas": "1500000000"
    }
}"#)?;

let prepared = validate(&raw)?;
let _review = review(&prepared)?;
let result = compile(&prepared, Default::default())?;

assert!(result.unsigned_tx.starts_with("0x02")); // EIP-1559 envelope

§Determinism

The compiler is byte-exact against the pinned canonical fixture set in tests/fixtures/canonical.json. Any change that alters compiled bytes must update that fixture and is treated as a hard-failing regression by the CI determinism suite.

Modules§

constants
Shared on-chain constants used across validation, review, and compilation.

Structs§

CompilationMetadata
Metadata describing how a transaction was compiled.
CompilationResult
Result of compiling a prepared transaction.
CompileOptions
Options for crate::compile.
FeeParams
Mode-discriminated fee parameters. Exactly one of the three mode-specific subsets is populated; the others are None.
FeeReview
Fee summary sized for display to a human reviewer.
PreparedTransaction
Canonical prepared transaction payload from the WalletSuite prepare-sign API.
TransactionReview
Human-reviewable representation of a transaction.
TronBlockHeader
Tron block-header reference used for replay protection and Transaction.raw_data construction.
TxCompilerError
Structured error returned by every public operation.

Enums§

Chain
Supported chain families.
FeeMode
Fee calculation mode carried by a prepared transaction.
TxCompilerErrorCode
Discriminator for the class of error raised by the compiler.
TxType
Intent expressed by the prepared payload.

Functions§

compile
Compile a validated prepared transaction into unsigned signer-ready artifacts.
review
Produce a human-reviewable summary of prepared.
tron_address_to_bytes
Decode a Tron address into its raw 21-byte representation.
validate
Validate an arbitrary JSON payload into a PreparedTransaction.