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
impl AbiParser
Sourcepub fn parse_str(&mut self, s: &str) -> Result<Abi, ParseError>
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();
Sourcepub fn parse(&mut self, input: &[&str]) -> Result<Abi, ParseError>
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();
Sourcepub fn with_structs(structs: Vec<SolStruct>) -> Self
pub fn with_structs(structs: Vec<SolStruct>) -> Self
Link additional structs for parsing
Sourcepub fn parse_event(&mut self, s: &str) -> Result<Event, ParseError>
pub fn parse_event(&mut self, s: &str) -> Result<Event, ParseError>
Parses a solidity event declaration from event <name> (args*) anonymous?
Sourcepub fn parse_function(&mut self, s: &str) -> Result<Function, ParseError>
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();
pub fn parse_constructor(&self, s: &str) -> Result<Constructor, ParseError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AbiParser
impl RefUnwindSafe for AbiParser
impl Send for AbiParser
impl Sync for AbiParser
impl Unpin for AbiParser
impl UnwindSafe for AbiParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more