From 9a7c1e41d09f421912f5c451646971e64bcbcfbc Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Fri, 30 Dec 2022 08:59:31 +0100 Subject: [PATCH] use abigen macro to generate multicall --- .../src/multicall/multicall_abi.json | 1 + .../src/multicall/multicall_contract.rs | 926 +----------------- 2 files changed, 2 insertions(+), 925 deletions(-) create mode 100644 ethers-contract/src/multicall/multicall_abi.json diff --git a/ethers-contract/src/multicall/multicall_abi.json b/ethers-contract/src/multicall/multicall_abi.json new file mode 100644 index 00000000..75da07c0 --- /dev/null +++ b/ethers-contract/src/multicall/multicall_abi.json @@ -0,0 +1 @@ +[{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call[]","name":"calls","type":"tuple[]"}],"name":"aggregate","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes[]","name":"returnData","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bool","name":"allowFailure","type":"bool"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call3[]","name":"calls","type":"tuple[]"}],"name":"aggregate3","outputs":[{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bool","name":"allowFailure","type":"bool"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call3Value[]","name":"calls","type":"tuple[]"}],"name":"aggregate3Value","outputs":[{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call[]","name":"calls","type":"tuple[]"}],"name":"blockAndAggregate","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes32","name":"blockHash","type":"bytes32"},{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getBasefee","outputs":[{"internalType":"uint256","name":"basefee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockNumber","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getChainId","outputs":[{"internalType":"uint256","name":"chainid","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockCoinbase","outputs":[{"internalType":"address","name":"coinbase","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockDifficulty","outputs":[{"internalType":"uint256","name":"difficulty","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockGasLimit","outputs":[{"internalType":"uint256","name":"gaslimit","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockTimestamp","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getEthBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"requireSuccess","type":"bool"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call[]","name":"calls","type":"tuple[]"}],"name":"tryAggregate","outputs":[{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bool","name":"requireSuccess","type":"bool"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call[]","name":"calls","type":"tuple[]"}],"name":"tryBlockAndAggregate","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes32","name":"blockHash","type":"bytes32"},{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"}] \ No newline at end of file diff --git a/ethers-contract/src/multicall/multicall_contract.rs b/ethers-contract/src/multicall/multicall_contract.rs index 9ddd2b95..82878124 100644 --- a/ethers-contract/src/multicall/multicall_contract.rs +++ b/ethers-contract/src/multicall/multicall_contract.rs @@ -1,925 +1 @@ -#[allow(clippy::too_many_arguments, non_camel_case_types)] -pub mod multicall_3 { - #![allow(clippy::enum_variant_names)] - #![allow(dead_code)] - #![allow(clippy::type_complexity)] - #![allow(unused_imports)] - - // This is a hack to guarantee all ethers-derive macros can find the types. - // See [`ethers_core::macros::determine_ethers_crates`]. - #[doc(hidden)] - mod ethers_contract { - pub use crate::*; - } - - use self::ethers_contract::{ - builders::{ContractCall, Event}, - Contract, Lazy, - }; - use ethers_core::{ - abi::{Abi, Detokenize, InvalidOutputType, Token, Tokenizable}, - types::{Address, Bytes, U256}, - }; - use ethers_providers::Middleware; - use std::sync::Arc; - - #[doc = "Multicall3 was auto-generated with ethers-rs Abigen. More information at: https://github.com/gakonst/ethers-rs"] - # [rustfmt :: skip] const __ABI : & str = "[{\"type\":\"function\",\"name\":\"aggregate\",\"inputs\":[{\"internalType\":\"struct Multicall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"address\"},{\"type\":\"bytes\"}]}],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes[]\",\"name\":\"returnData\",\"type\":\"bytes[]\"}],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"aggregate3\",\"inputs\":[{\"internalType\":\"struct Multicall3.Call3[]\",\"name\":\"calls\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"address\"},{\"type\":\"bool\"},{\"type\":\"bytes\"}]}],\"outputs\":[{\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"bool\"},{\"type\":\"bytes\"}]}],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"aggregate3Value\",\"inputs\":[{\"internalType\":\"struct Multicall3.Call3Value[]\",\"name\":\"calls\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"address\"},{\"type\":\"bool\"},{\"type\":\"uint256\"},{\"type\":\"bytes\"}]}],\"outputs\":[{\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"bool\"},{\"type\":\"bytes\"}]}],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"blockAndAggregate\",\"inputs\":[{\"internalType\":\"struct Multicall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"address\"},{\"type\":\"bytes\"}]}],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"bool\"},{\"type\":\"bytes\"}]}],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"getBasefee\",\"inputs\":[],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"basefee\",\"type\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBlockHash\",\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getBlockNumber\",\"inputs\":[],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getChainId\",\"inputs\":[],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"chainid\",\"type\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getCurrentBlockCoinbase\",\"inputs\":[],\"outputs\":[{\"internalType\":\"address\",\"name\":\"coinbase\",\"type\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getCurrentBlockDifficulty\",\"inputs\":[],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"difficulty\",\"type\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getCurrentBlockGasLimit\",\"inputs\":[],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"gaslimit\",\"type\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getCurrentBlockTimestamp\",\"inputs\":[],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getEthBalance\",\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"getLastBlockHash\",\"inputs\":[],\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"tryAggregate\",\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"internalType\":\"struct Multicall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"address\"},{\"type\":\"bytes\"}]}],\"outputs\":[{\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"bool\"},{\"type\":\"bytes\"}]}],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"tryBlockAndAggregate\",\"inputs\":[{\"internalType\":\"bool\",\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"internalType\":\"struct Multicall3.Call[]\",\"name\":\"calls\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"address\"},{\"type\":\"bytes\"}]}],\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"blockHash\",\"type\":\"bytes32\"},{\"internalType\":\"struct Multicall3.Result[]\",\"name\":\"returnData\",\"type\":\"tuple[]\",\"components\":[{\"type\":\"bool\"},{\"type\":\"bytes\"}]}],\"stateMutability\":\"payable\"}]" ; - #[doc = r" The parsed JSON-ABI of the contract."] - pub static MULTICALL3_ABI: ethers_contract::Lazy = - ethers_contract::Lazy::new(|| { - ethers_core::utils::__serde_json::from_str(__ABI).expect("invalid abi") - }); - pub struct Multicall3(ethers_contract::Contract); - impl Clone for Multicall3 { - fn clone(&self) -> Self { - Multicall3(self.0.clone()) - } - } - impl std::ops::Deref for Multicall3 { - type Target = ethers_contract::Contract; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - impl std::fmt::Debug for Multicall3 { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_tuple(stringify!(Multicall3)).field(&self.address()).finish() - } - } - impl Multicall3 { - #[doc = r" Creates a new contract instance with the specified `ethers`"] - #[doc = r" client at the given `Address`. The contract derefs to a `crate`"] - #[doc = r" object"] - pub fn new>( - address: T, - client: ::std::sync::Arc, - ) -> Self { - ethers_contract::Contract::new(address.into(), MULTICALL3_ABI.clone(), client).into() - } - #[doc = "Calls the contract's `aggregate` (0x252dba42) function"] - pub fn aggregate( - &self, - calls: ::std::vec::Vec, - ) -> ethers_contract::builders::ContractCall< - M, - (ethers_core::types::U256, ::std::vec::Vec), - > { - self.0 - .method_hash([37, 45, 186, 66], calls) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `aggregate3` (0x82ad56cb) function"] - pub fn aggregate_3( - &self, - calls: ::std::vec::Vec, - ) -> ethers_contract::builders::ContractCall> { - self.0 - .method_hash([130, 173, 86, 203], calls) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `aggregate3Value` (0x174dea71) function"] - pub fn aggregate_3_value( - &self, - calls: ::std::vec::Vec, - ) -> ethers_contract::builders::ContractCall> { - self.0 - .method_hash([23, 77, 234, 113], calls) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `blockAndAggregate` (0xc3077fa9) function"] - pub fn block_and_aggregate( - &self, - calls: ::std::vec::Vec, - ) -> ethers_contract::builders::ContractCall< - M, - (ethers_core::types::U256, [u8; 32], ::std::vec::Vec), - > { - self.0 - .method_hash([195, 7, 127, 169], calls) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getBasefee` (0x3e64a696) function"] - pub fn get_basefee( - &self, - ) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([62, 100, 166, 150], ()) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getBlockHash` (0xee82ac5e) function"] - pub fn get_block_hash( - &self, - block_number: ethers_core::types::U256, - ) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([238, 130, 172, 94], block_number) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getBlockNumber` (0x42cbb15c) function"] - pub fn get_block_number( - &self, - ) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([66, 203, 177, 92], ()) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getChainId` (0x3408e470) function"] - pub fn get_chain_id( - &self, - ) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([52, 8, 228, 112], ()) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getCurrentBlockCoinbase` (0xa8b0574e) function"] - pub fn get_current_block_coinbase( - &self, - ) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([168, 176, 87, 78], ()) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getCurrentBlockDifficulty` (0x72425d9d) function"] - pub fn get_current_block_difficulty( - &self, - ) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([114, 66, 93, 157], ()) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getCurrentBlockGasLimit` (0x86d516e8) function"] - pub fn get_current_block_gas_limit( - &self, - ) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([134, 213, 22, 232], ()) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getCurrentBlockTimestamp` (0x0f28c97d) function"] - pub fn get_current_block_timestamp( - &self, - ) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([15, 40, 201, 125], ()) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getEthBalance` (0x4d2301cc) function"] - pub fn get_eth_balance( - &self, - addr: ethers_core::types::Address, - ) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([77, 35, 1, 204], addr) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `getLastBlockHash` (0x27e86d6e) function"] - pub fn get_last_block_hash(&self) -> ethers_contract::builders::ContractCall { - self.0 - .method_hash([39, 232, 109, 110], ()) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `tryAggregate` (0xbce38bd7) function"] - pub fn try_aggregate( - &self, - require_success: bool, - calls: ::std::vec::Vec, - ) -> ethers_contract::builders::ContractCall> { - self.0 - .method_hash([188, 227, 139, 215], (require_success, calls)) - .expect("method not found (this should never happen)") - } - #[doc = "Calls the contract's `tryBlockAndAggregate` (0x399542e9) function"] - pub fn try_block_and_aggregate( - &self, - require_success: bool, - calls: ::std::vec::Vec, - ) -> ethers_contract::builders::ContractCall< - M, - (ethers_core::types::U256, [u8; 32], ::std::vec::Vec), - > { - self.0 - .method_hash([57, 149, 66, 233], (require_success, calls)) - .expect("method not found (this should never happen)") - } - } - impl From> for Multicall3 { - fn from(contract: ethers_contract::Contract) -> Self { - Self(contract) - } - } - #[doc = "Container type for all input parameters for the `aggregate` function with signature `aggregate((address,bytes)[])` and selector `[37, 45, 186, 66]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "aggregate", abi = "aggregate((address,bytes)[])")] - pub struct AggregateCall { - pub calls: ::std::vec::Vec, - } - #[doc = "Container type for all input parameters for the `aggregate3` function with signature `aggregate3((address,bool,bytes)[])` and selector `[130, 173, 86, 203]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "aggregate3", abi = "aggregate3((address,bool,bytes)[])")] - pub struct Aggregate3Call { - pub calls: ::std::vec::Vec, - } - #[doc = "Container type for all input parameters for the `aggregate3Value` function with signature `aggregate3Value((address,bool,uint256,bytes)[])` and selector `[23, 77, 234, 113]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "aggregate3Value", abi = "aggregate3Value((address,bool,uint256,bytes)[])")] - pub struct Aggregate3ValueCall { - pub calls: ::std::vec::Vec, - } - #[doc = "Container type for all input parameters for the `blockAndAggregate` function with signature `blockAndAggregate((address,bytes)[])` and selector `[195, 7, 127, 169]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "blockAndAggregate", abi = "blockAndAggregate((address,bytes)[])")] - pub struct BlockAndAggregateCall { - pub calls: ::std::vec::Vec, - } - #[doc = "Container type for all input parameters for the `getBasefee` function with signature `getBasefee()` and selector `[62, 100, 166, 150]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getBasefee", abi = "getBasefee()")] - pub struct GetBasefeeCall; - #[doc = "Container type for all input parameters for the `getBlockHash` function with signature `getBlockHash(uint256)` and selector `[238, 130, 172, 94]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getBlockHash", abi = "getBlockHash(uint256)")] - pub struct GetBlockHashCall { - pub block_number: ethers_core::types::U256, - } - #[doc = "Container type for all input parameters for the `getBlockNumber` function with signature `getBlockNumber()` and selector `[66, 203, 177, 92]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getBlockNumber", abi = "getBlockNumber()")] - pub struct GetBlockNumberCall; - #[doc = "Container type for all input parameters for the `getChainId` function with signature `getChainId()` and selector `[52, 8, 228, 112]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getChainId", abi = "getChainId()")] - pub struct GetChainIdCall; - #[doc = "Container type for all input parameters for the `getCurrentBlockCoinbase` function with signature `getCurrentBlockCoinbase()` and selector `[168, 176, 87, 78]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getCurrentBlockCoinbase", abi = "getCurrentBlockCoinbase()")] - pub struct GetCurrentBlockCoinbaseCall; - #[doc = "Container type for all input parameters for the `getCurrentBlockDifficulty` function with signature `getCurrentBlockDifficulty()` and selector `[114, 66, 93, 157]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getCurrentBlockDifficulty", abi = "getCurrentBlockDifficulty()")] - pub struct GetCurrentBlockDifficultyCall; - #[doc = "Container type for all input parameters for the `getCurrentBlockGasLimit` function with signature `getCurrentBlockGasLimit()` and selector `[134, 213, 22, 232]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getCurrentBlockGasLimit", abi = "getCurrentBlockGasLimit()")] - pub struct GetCurrentBlockGasLimitCall; - #[doc = "Container type for all input parameters for the `getCurrentBlockTimestamp` function with signature `getCurrentBlockTimestamp()` and selector `[15, 40, 201, 125]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getCurrentBlockTimestamp", abi = "getCurrentBlockTimestamp()")] - pub struct GetCurrentBlockTimestampCall; - #[doc = "Container type for all input parameters for the `getEthBalance` function with signature `getEthBalance(address)` and selector `[77, 35, 1, 204]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getEthBalance", abi = "getEthBalance(address)")] - pub struct GetEthBalanceCall { - pub addr: ethers_core::types::Address, - } - #[doc = "Container type for all input parameters for the `getLastBlockHash` function with signature `getLastBlockHash()` and selector `[39, 232, 109, 110]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "getLastBlockHash", abi = "getLastBlockHash()")] - pub struct GetLastBlockHashCall; - #[doc = "Container type for all input parameters for the `tryAggregate` function with signature `tryAggregate(bool,(address,bytes)[])` and selector `[188, 227, 139, 215]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "tryAggregate", abi = "tryAggregate(bool,(address,bytes)[])")] - pub struct TryAggregateCall { - pub require_success: bool, - pub calls: ::std::vec::Vec, - } - #[doc = "Container type for all input parameters for the `tryBlockAndAggregate` function with signature `tryBlockAndAggregate(bool,(address,bytes)[])` and selector `[57, 149, 66, 233]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthCall, - ethers_contract :: EthDisplay, - )] - #[ethcall(name = "tryBlockAndAggregate", abi = "tryBlockAndAggregate(bool,(address,bytes)[])")] - pub struct TryBlockAndAggregateCall { - pub require_success: bool, - pub calls: ::std::vec::Vec, - } - #[derive(Debug, Clone, PartialEq, Eq, ethers_contract :: EthAbiType)] - pub enum Multicall3Calls { - Aggregate(AggregateCall), - Aggregate3(Aggregate3Call), - Aggregate3Value(Aggregate3ValueCall), - BlockAndAggregate(BlockAndAggregateCall), - GetBasefee(GetBasefeeCall), - GetBlockHash(GetBlockHashCall), - GetBlockNumber(GetBlockNumberCall), - GetChainId(GetChainIdCall), - GetCurrentBlockCoinbase(GetCurrentBlockCoinbaseCall), - GetCurrentBlockDifficulty(GetCurrentBlockDifficultyCall), - GetCurrentBlockGasLimit(GetCurrentBlockGasLimitCall), - GetCurrentBlockTimestamp(GetCurrentBlockTimestampCall), - GetEthBalance(GetEthBalanceCall), - GetLastBlockHash(GetLastBlockHashCall), - TryAggregate(TryAggregateCall), - TryBlockAndAggregate(TryBlockAndAggregateCall), - } - impl ethers_core::abi::AbiDecode for Multicall3Calls { - fn decode( - data: impl AsRef<[u8]>, - ) -> ::std::result::Result { - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::Aggregate(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::Aggregate3(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::Aggregate3Value(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::BlockAndAggregate(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::GetBasefee(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::GetBlockHash(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::GetBlockNumber(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::GetChainId(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::GetCurrentBlockCoinbase(decoded)) - } - if let Ok(decoded) = - ::decode( - data.as_ref(), - ) - { - return Ok(Multicall3Calls::GetCurrentBlockDifficulty(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::GetCurrentBlockGasLimit(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::GetCurrentBlockTimestamp(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::GetEthBalance(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::GetLastBlockHash(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::TryAggregate(decoded)) - } - if let Ok(decoded) = - ::decode(data.as_ref()) - { - return Ok(Multicall3Calls::TryBlockAndAggregate(decoded)) - } - Err(ethers_core::abi::Error::InvalidData.into()) - } - } - impl ethers_core::abi::AbiEncode for Multicall3Calls { - fn encode(self) -> Vec { - match self { - Multicall3Calls::Aggregate(element) => element.encode(), - Multicall3Calls::Aggregate3(element) => element.encode(), - Multicall3Calls::Aggregate3Value(element) => element.encode(), - Multicall3Calls::BlockAndAggregate(element) => element.encode(), - Multicall3Calls::GetBasefee(element) => element.encode(), - Multicall3Calls::GetBlockHash(element) => element.encode(), - Multicall3Calls::GetBlockNumber(element) => element.encode(), - Multicall3Calls::GetChainId(element) => element.encode(), - Multicall3Calls::GetCurrentBlockCoinbase(element) => element.encode(), - Multicall3Calls::GetCurrentBlockDifficulty(element) => element.encode(), - Multicall3Calls::GetCurrentBlockGasLimit(element) => element.encode(), - Multicall3Calls::GetCurrentBlockTimestamp(element) => element.encode(), - Multicall3Calls::GetEthBalance(element) => element.encode(), - Multicall3Calls::GetLastBlockHash(element) => element.encode(), - Multicall3Calls::TryAggregate(element) => element.encode(), - Multicall3Calls::TryBlockAndAggregate(element) => element.encode(), - } - } - } - impl ::std::fmt::Display for Multicall3Calls { - fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { - match self { - Multicall3Calls::Aggregate(element) => element.fmt(f), - Multicall3Calls::Aggregate3(element) => element.fmt(f), - Multicall3Calls::Aggregate3Value(element) => element.fmt(f), - Multicall3Calls::BlockAndAggregate(element) => element.fmt(f), - Multicall3Calls::GetBasefee(element) => element.fmt(f), - Multicall3Calls::GetBlockHash(element) => element.fmt(f), - Multicall3Calls::GetBlockNumber(element) => element.fmt(f), - Multicall3Calls::GetChainId(element) => element.fmt(f), - Multicall3Calls::GetCurrentBlockCoinbase(element) => element.fmt(f), - Multicall3Calls::GetCurrentBlockDifficulty(element) => element.fmt(f), - Multicall3Calls::GetCurrentBlockGasLimit(element) => element.fmt(f), - Multicall3Calls::GetCurrentBlockTimestamp(element) => element.fmt(f), - Multicall3Calls::GetEthBalance(element) => element.fmt(f), - Multicall3Calls::GetLastBlockHash(element) => element.fmt(f), - Multicall3Calls::TryAggregate(element) => element.fmt(f), - Multicall3Calls::TryBlockAndAggregate(element) => element.fmt(f), - } - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: AggregateCall) -> Self { - Multicall3Calls::Aggregate(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: Aggregate3Call) -> Self { - Multicall3Calls::Aggregate3(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: Aggregate3ValueCall) -> Self { - Multicall3Calls::Aggregate3Value(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: BlockAndAggregateCall) -> Self { - Multicall3Calls::BlockAndAggregate(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetBasefeeCall) -> Self { - Multicall3Calls::GetBasefee(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetBlockHashCall) -> Self { - Multicall3Calls::GetBlockHash(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetBlockNumberCall) -> Self { - Multicall3Calls::GetBlockNumber(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetChainIdCall) -> Self { - Multicall3Calls::GetChainId(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetCurrentBlockCoinbaseCall) -> Self { - Multicall3Calls::GetCurrentBlockCoinbase(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetCurrentBlockDifficultyCall) -> Self { - Multicall3Calls::GetCurrentBlockDifficulty(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetCurrentBlockGasLimitCall) -> Self { - Multicall3Calls::GetCurrentBlockGasLimit(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetCurrentBlockTimestampCall) -> Self { - Multicall3Calls::GetCurrentBlockTimestamp(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetEthBalanceCall) -> Self { - Multicall3Calls::GetEthBalance(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: GetLastBlockHashCall) -> Self { - Multicall3Calls::GetLastBlockHash(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: TryAggregateCall) -> Self { - Multicall3Calls::TryAggregate(var) - } - } - impl ::std::convert::From for Multicall3Calls { - fn from(var: TryBlockAndAggregateCall) -> Self { - Multicall3Calls::TryBlockAndAggregate(var) - } - } - #[doc = "Container type for all return fields from the `aggregate` function with signature `aggregate((address,bytes)[])` and selector `[37, 45, 186, 66]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct AggregateReturn { - pub block_number: ethers_core::types::U256, - pub return_data: ::std::vec::Vec, - } - #[doc = "Container type for all return fields from the `aggregate3` function with signature `aggregate3((address,bool,bytes)[])` and selector `[130, 173, 86, 203]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct Aggregate3Return { - pub return_data: ::std::vec::Vec, - } - #[doc = "Container type for all return fields from the `aggregate3Value` function with signature `aggregate3Value((address,bool,uint256,bytes)[])` and selector `[23, 77, 234, 113]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct Aggregate3ValueReturn { - pub return_data: ::std::vec::Vec, - } - #[doc = "Container type for all return fields from the `blockAndAggregate` function with signature `blockAndAggregate((address,bytes)[])` and selector `[195, 7, 127, 169]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct BlockAndAggregateReturn { - pub block_number: ethers_core::types::U256, - pub block_hash: [u8; 32], - pub return_data: ::std::vec::Vec, - } - #[doc = "Container type for all return fields from the `getBasefee` function with signature `getBasefee()` and selector `[62, 100, 166, 150]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetBasefeeReturn { - pub basefee: ethers_core::types::U256, - } - #[doc = "Container type for all return fields from the `getBlockHash` function with signature `getBlockHash(uint256)` and selector `[238, 130, 172, 94]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetBlockHashReturn { - pub block_hash: [u8; 32], - } - #[doc = "Container type for all return fields from the `getBlockNumber` function with signature `getBlockNumber()` and selector `[66, 203, 177, 92]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetBlockNumberReturn { - pub block_number: ethers_core::types::U256, - } - #[doc = "Container type for all return fields from the `getChainId` function with signature `getChainId()` and selector `[52, 8, 228, 112]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetChainIdReturn { - pub chainid: ethers_core::types::U256, - } - #[doc = "Container type for all return fields from the `getCurrentBlockCoinbase` function with signature `getCurrentBlockCoinbase()` and selector `[168, 176, 87, 78]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetCurrentBlockCoinbaseReturn { - pub coinbase: ethers_core::types::Address, - } - #[doc = "Container type for all return fields from the `getCurrentBlockDifficulty` function with signature `getCurrentBlockDifficulty()` and selector `[114, 66, 93, 157]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetCurrentBlockDifficultyReturn { - pub difficulty: ethers_core::types::U256, - } - #[doc = "Container type for all return fields from the `getCurrentBlockGasLimit` function with signature `getCurrentBlockGasLimit()` and selector `[134, 213, 22, 232]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetCurrentBlockGasLimitReturn { - pub gaslimit: ethers_core::types::U256, - } - #[doc = "Container type for all return fields from the `getCurrentBlockTimestamp` function with signature `getCurrentBlockTimestamp()` and selector `[15, 40, 201, 125]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetCurrentBlockTimestampReturn { - pub timestamp: ethers_core::types::U256, - } - #[doc = "Container type for all return fields from the `getEthBalance` function with signature `getEthBalance(address)` and selector `[77, 35, 1, 204]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetEthBalanceReturn { - pub balance: ethers_core::types::U256, - } - #[doc = "Container type for all return fields from the `getLastBlockHash` function with signature `getLastBlockHash()` and selector `[39, 232, 109, 110]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct GetLastBlockHashReturn { - pub block_hash: [u8; 32], - } - #[doc = "Container type for all return fields from the `tryAggregate` function with signature `tryAggregate(bool,(address,bytes)[])` and selector `[188, 227, 139, 215]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct TryAggregateReturn { - pub return_data: ::std::vec::Vec, - } - #[doc = "Container type for all return fields from the `tryBlockAndAggregate` function with signature `tryBlockAndAggregate(bool,(address,bytes)[])` and selector `[57, 149, 66, 233]`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct TryBlockAndAggregateReturn { - pub block_number: ethers_core::types::U256, - pub block_hash: [u8; 32], - pub return_data: ::std::vec::Vec, - } - #[doc = "`Call(address,bytes)`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct Call { - pub target: ethers_core::types::Address, - pub call_data: ethers_core::types::Bytes, - } - #[doc = "`Call3(address,bool,bytes)`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct Call3 { - pub target: ethers_core::types::Address, - pub allow_failure: bool, - pub call_data: ethers_core::types::Bytes, - } - #[doc = "`Call3Value(address,bool,uint256,bytes)`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct Call3Value { - pub target: ethers_core::types::Address, - pub allow_failure: bool, - pub value: ethers_core::types::U256, - pub call_data: ethers_core::types::Bytes, - } - #[doc = "`Result(bool,bytes)`"] - #[derive( - Clone, - Debug, - Default, - Eq, - PartialEq, - ethers_contract :: EthAbiType, - ethers_contract :: EthAbiCodec, - )] - pub struct Result { - pub success: bool, - pub return_data: ethers_core::types::Bytes, - } -} +ethers_contract_derive::abigen!(Multicall3, "src/multicall/multicall_abi.json");