Skip to main content

Module abi

Module abi 

Source
Expand description

Abi Module

§Abi

A module containing ABI type definitions for ethereum contracts.

§Usage

Let’s say you have a Contract<'a> generated from the huff_parser, representing an AST. This crate lets you easily convert the Contract into an Abi instance like so:

use std::sync::{Arc, Mutex};
use indexmap::IndexMap;
use huff_neo_utils::ast::abi::FunctionType;
use huff_neo_utils::ast::span::AstSpan;
use huff_neo_utils::prelude::*;

// Generate a default contract for demonstrative purposes.
// Realistically, contract generation would be done as shown in [huff_parser](./huff_parser)
let contract = Contract {
    macros: IndexMap::new(),
    invocations: vec![],
    imports: vec![],
    constants: Arc::new(Mutex::new(vec![])),
    errors: vec![],
    functions: vec![huff_neo_utils::ast::abi::FunctionDefinition {
        name: "CONSTRUCTOR".to_string(),
        signature: [0u8, 0u8, 0u8, 0u8],
        inputs: vec![],
        fn_type: FunctionType::NonPayable,
        outputs: vec![],
        span: AstSpan(vec![]),
    }],
    events: vec![],
    tables: vec![],
    labels: Default::default(),
    flattened_source: None,
    source_files: vec![],
    source_map: vec![],
    runtime_size: None,
};

// Create an ABI using that generate contract
let abi: Abi = contract.into();

Structs§

Abi
Abi
Constructor
Constructor
Error
Error
Event
Event
EventParam
EventParam
Function
Function
FunctionParam
FunctionParam

Enums§

FunctionParamType
FunctionParamType

Functions§

split_tuple_components 🔒
Splits the components of a tuple type at its top-level commas