Struct ethers_core::abi::AbiParser

source ·
pub struct AbiParser {
    pub structs: HashMap<String, SolStruct>,
    pub struct_tuples: HashMap<String, Vec<ParamType>>,
    pub function_params: HashMap<(String, String), String>,
    pub event_params: HashMap<(String, usize), String>,
    pub outputs: HashMap<String, Vec<String>>,
}
Expand description

A parser that turns a “human readable abi” into a Abi

Fields§

§structs: HashMap<String, SolStruct>

solidity structs

§struct_tuples: HashMap<String, Vec<ParamType>>

solidity structs as tuples

§function_params: HashMap<(String, String), String>

(function name, param name) -> struct which are the identifying properties we get the name from ethabi.

§event_params: HashMap<(String, usize), String>

(event name, idx) -> struct which are the identifying properties we get the name from ethabi.

Note: we need to map the index of the event here because events can contain nameless inputs

§outputs: HashMap<String, Vec<String>>

(function name) -> Vec<structs> all structs the function returns

Implementations§

Parses a “human readable abi” string

Example
let abi = AbiParser::default().parse_str(r#"[
        function setValue(string)
        function getValue() external view returns (string)
        event ValueChanged(address indexed author, string oldValue, string newValue)
    ]"#).unwrap();

Parses a “human readable abi” string vector

Example
use ethers_core::abi::AbiParser;

let abi = AbiParser::default().parse(&[
    "function x() external view returns (uint256)",
]).unwrap();

Link additional structs for parsing

Parses a solidity event declaration from event <name> (args*) anonymous?

Returns the parsed function from the input string

Example
use ethers_core::abi::AbiParser;
let f = AbiParser::default()
    .parse_function("bar(uint256 x, uint256 y, address addr)").unwrap();

Trait Implementations§

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.