transaction-decoder 0.1.13

A CLI tool for decoding EVM transactions
Documentation
use serde::Deserialize;
use std::collections::HashMap;

/// The response structure from function signature API.
#[derive(Deserialize, Debug)]
pub struct FunctionResponse {
    /// Whether the lookup was successful.
    pub ok: bool,
    /// The actual result containing decoded function data.
    pub result: FunctionResult,
}

/// Decoded function result returned from the API.
#[derive(Deserialize, Debug)]
pub struct FunctionResult {
    /// Placeholder for event info.
    pub event: serde_json::Value,
    /// Mapping from function selector to function details.
    pub function: HashMap<String, Vec<FunctionDetails>>,
}

/// Contains information about a single function signature.
#[derive(Deserialize, Debug, Clone)]
pub struct FunctionDetails {
    /// Function name like `transfer(address,uint256)`.
    pub name: String,
    /// Whether the function was filtered in API.
    pub filtered: bool,
}

/// Contains information about a single event signature.
#[derive(Deserialize, Debug)]
pub struct EventDetails {
    /// Event name like `Transfer(address,address,uint256)`.
    pub name: String,
    /// Whether the event was filtered in API.
    pub filtered: bool,
}

/// Container for all decoded events returned from API.
#[derive(Deserialize, Debug)]
pub struct EventResult {
    /// Placeholder for function info.
    pub function: serde_json::Value,
    /// Mapping from event topic0 to event details.
    pub event: HashMap<String, Vec<EventDetails>>,
}

/// The response structure from event signature API.
#[derive(Deserialize, Debug)]
pub struct EventResponse {
    /// Whether the lookup was successful.
    pub ok: bool,
    /// The actual result containing decoded event data.
    pub result: EventResult,
}