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§

source§

impl AbiParser

source

pub fn parse_str(&mut self, s: &str) -> Result<Abi, ParseError>

Parses a “human readable abi” string

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

pub fn parse(&mut self, input: &[&str]) -> Result<Abi, ParseError>

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();
source

pub fn with_structs(structs: Vec<SolStruct>) -> Self

Link additional structs for parsing

source

pub fn parse_event(&mut self, s: &str) -> Result<Event, ParseError>

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

source

pub fn parse_function(&mut self, s: &str) -> Result<Function, ParseError>

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();
source

pub fn parse_constructor(&self, s: &str) -> Result<Constructor, ParseError>

Trait Implementations§

source§

impl Default for AbiParser

source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> JsonSchemaMaybe for T