Expand description
§txgate-core
Core types, traits, and error definitions for the TxGate signing service.
§Internal Crate Warning
This crate is an internal implementation detail of txgate.
It is published to crates.io only because Cargo requires all dependencies to be published. The API is unstable and may change without notice between any versions, including patch releases.
Do not depend on this crate directly. Instead:
- For the signing server binary:
cargo install txgate - For programmatic access: Open an issue at https://github.com/luisjpf/txgate to discuss a stable public API.
This crate provides the foundational types shared across all TxGate crates:
§Modules
error- Error types and result aliasestypes- Core data types (ParsedTx,TxType,PolicyResult)traits- Core trait definitions (planned)chain- Chain identifier types (planned)
§Error Handling
The crate provides comprehensive error types for all failure modes:
use txgate_core::error::{TxGateError, ParseError, RpcErrorCode};
fn example() -> Result<(), TxGateError> {
// Parse errors automatically convert to TxGateError
let err = ParseError::unsupported_chain("cosmos");
// Get the RPC error code for JSON-RPC responses
let txgate_err: TxGateError = err.into();
let code = RpcErrorCode::from(&txgate_err);
assert_eq!(code, RpcErrorCode::ChainNotSupported);
Ok(())
}§Core Types
The types module provides the foundational data structures:
use txgate_core::{ParsedTx, TxType, PolicyResult, U256};
use std::collections::HashMap;
// Create a parsed transaction
let tx = ParsedTx {
hash: [0u8; 32],
recipient: Some("0x742d35Cc...".to_string()),
amount: Some(U256::from(1_500_000_000_000_000_000u64)),
token: Some("ETH".to_string()),
token_address: None,
tx_type: TxType::Transfer,
chain: "ethereum".to_string(),
nonce: Some(42),
chain_id: Some(1),
metadata: HashMap::new(),
};
// Check transaction type
assert!(tx.is_native_transfer());
// Evaluate policy result
let result = PolicyResult::Allowed;
assert!(result.is_allowed());§Features
serde- Enable serde serialization/deserializationstd- Enable standard library features (enabled by default)
Re-exports§
pub use error::ConfigError;pub use error::ParseError;pub use error::PolicyError;pub use error::Result;pub use error::RpcErrorCode;pub use error::SignError;pub use error::StoreError;pub use error::TxGateError;pub use config::Config;pub use config::ConfigBuilder;pub use config::KeysConfig;pub use config::PolicyConfig;pub use config::ServerConfig;pub use config_loader::expand_path;pub use config_loader::load_config;pub use config_loader::ConfigLoader;pub use types::ParsedTx;pub use types::PolicyResult;pub use types::TxType;pub use signing::ChainParser;pub use signing::PolicyCheckResult;pub use signing::PolicyEngineExt;pub use signing::SignatureBytes;pub use signing::SignerExt;pub use signing::SigningError;pub use signing::SigningResult;pub use signing::SigningService;
Modules§
- config
- Configuration types for the
TxGatesigning service. - config_
loader - Configuration loader for the
TxGatesigning service. - error
- Error types for the
TxGatesigning service. - signing
- Signing flow orchestration for the
TxGatesigning service. - types
- Core types for the
TxGatesigning service.
Type Aliases§
- U256
- 256-bit unsigned integer type, consisting of 4, 64-bit limbs.