pub use ierc20::*;
/// This module was auto-generated with ethers-rs Abigen.
/// More information at: <https://github.com/gakonst/ethers-rs>
#[allow(
clippy::enum_variant_names,
clippy::too_many_arguments,
clippy::upper_case_acronyms,
clippy::type_complexity,
dead_code,
non_camel_case_types
)]
pub mod ierc20 {
#[rustfmt::skip]
const __ABI: &str = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\",\"components\":[],\"indexed\":true},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\",\"components\":[],\"indexed\":true},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\",\"components\":[],\"indexed\":false}],\"type\":\"event\",\"name\":\"Approval\",\"outputs\":[],\"anonymous\":false},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\",\"components\":[],\"indexed\":true},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\",\"components\":[],\"indexed\":true},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\",\"components\":[],\"indexed\":false}],\"type\":\"event\",\"name\":\"Transfer\",\"outputs\":[],\"anonymous\":false},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\",\"components\":[]}],\"stateMutability\":\"view\",\"type\":\"function\",\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\",\"components\":[]}]},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\",\"components\":[]}],\"stateMutability\":\"nonpayable\",\"type\":\"function\",\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\",\"components\":[]}]},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\",\"components\":[]}],\"stateMutability\":\"view\",\"type\":\"function\",\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\",\"components\":[]}]},{\"inputs\":[],\"stateMutability\":\"view\",\"type\":\"function\",\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\",\"components\":[]}]},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\",\"components\":[]}],\"stateMutability\":\"nonpayable\",\"type\":\"function\",\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\",\"components\":[]}]},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\",\"components\":[]},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\",\"components\":[]}],\"stateMutability\":\"nonpayable\",\"type\":\"function\",\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\",\"components\":[]}]}]";
///The parsed JSON ABI of the contract.
pub static IERC20_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> =
::ethers::contract::Lazy::new(|| {
::ethers::core::utils::__serde_json::from_str(__ABI).expect("ABI is always valid")
});
pub struct IERC20<M>(::ethers::contract::Contract<M>);
impl<M> ::core::clone::Clone for IERC20<M> {
fn clone(&self) -> Self {
Self(::core::clone::Clone::clone(&self.0))
}
}
impl<M> ::core::ops::Deref for IERC20<M> {
type Target = ::ethers::contract::Contract<M>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<M> ::core::ops::DerefMut for IERC20<M> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl<M> ::core::fmt::Debug for IERC20<M> {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_tuple(stringify!(IERC20))
.field(&self.address())
.finish()
}
}
impl<M: ::ethers::providers::Middleware> IERC20<M> {
/// Creates a new contract instance with the specified `ethers` client at
/// `address`. The contract derefs to a `ethers::Contract` object.
pub fn new<T: Into<::ethers::core::types::Address>>(
address: T,
client: ::std::sync::Arc<M>,
) -> Self {
Self(::ethers::contract::Contract::new(
address.into(),
IERC20_ABI.clone(),
client,
))
}
///Calls the contract's `allowance` (0xdd62ed3e) function
pub fn allowance(
&self,
owner: ::ethers::core::types::Address,
spender: ::ethers::core::types::Address,
) -> ::ethers::contract::builders::ContractCall<M, ::ethers::core::types::U256> {
self.0
.method_hash([221, 98, 237, 62], (owner, spender))
.expect("method not found (this should never happen)")
}
///Calls the contract's `approve` (0x095ea7b3) function
pub fn approve(
&self,
spender: ::ethers::core::types::Address,
amount: ::ethers::core::types::U256,
) -> ::ethers::contract::builders::ContractCall<M, bool> {
self.0
.method_hash([9, 94, 167, 179], (spender, amount))
.expect("method not found (this should never happen)")
}
///Calls the contract's `balanceOf` (0x70a08231) function
pub fn balance_of(
&self,
account: ::ethers::core::types::Address,
) -> ::ethers::contract::builders::ContractCall<M, ::ethers::core::types::U256> {
self.0
.method_hash([112, 160, 130, 49], account)
.expect("method not found (this should never happen)")
}
///Calls the contract's `totalSupply` (0x18160ddd) function
pub fn total_supply(
&self,
) -> ::ethers::contract::builders::ContractCall<M, ::ethers::core::types::U256> {
self.0
.method_hash([24, 22, 13, 221], ())
.expect("method not found (this should never happen)")
}
///Calls the contract's `transfer` (0xa9059cbb) function
pub fn transfer(
&self,
recipient: ::ethers::core::types::Address,
amount: ::ethers::core::types::U256,
) -> ::ethers::contract::builders::ContractCall<M, bool> {
self.0
.method_hash([169, 5, 156, 187], (recipient, amount))
.expect("method not found (this should never happen)")
}
///Calls the contract's `transferFrom` (0x23b872dd) function
pub fn transfer_from(
&self,
sender: ::ethers::core::types::Address,
recipient: ::ethers::core::types::Address,
amount: ::ethers::core::types::U256,
) -> ::ethers::contract::builders::ContractCall<M, bool> {
self.0
.method_hash([35, 184, 114, 221], (sender, recipient, amount))
.expect("method not found (this should never happen)")
}
///Gets the contract's `Approval` event
pub fn approval_filter(
&self,
) -> ::ethers::contract::builders::Event<::std::sync::Arc<M>, M, ApprovalFilter> {
self.0.event()
}
///Gets the contract's `Transfer` event
pub fn transfer_filter(
&self,
) -> ::ethers::contract::builders::Event<::std::sync::Arc<M>, M, TransferFilter> {
self.0.event()
}
/// Returns an `Event` builder for all the events of this contract.
pub fn events(
&self,
) -> ::ethers::contract::builders::Event<::std::sync::Arc<M>, M, IERC20Events> {
self.0
.event_with_filter(::core::default::Default::default())
}
}
impl<M: ::ethers::providers::Middleware> From<::ethers::contract::Contract<M>> for IERC20<M> {
fn from(contract: ::ethers::contract::Contract<M>) -> Self {
Self::new(contract.address(), contract.client())
}
}
#[derive(
Clone,
::ethers::contract::EthEvent,
::ethers::contract::EthDisplay,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
#[ethevent(name = "Approval", abi = "Approval(address,address,uint256)")]
pub struct ApprovalFilter {
#[ethevent(indexed)]
pub owner: ::ethers::core::types::Address,
#[ethevent(indexed)]
pub spender: ::ethers::core::types::Address,
pub value: ::ethers::core::types::U256,
}
#[derive(
Clone,
::ethers::contract::EthEvent,
::ethers::contract::EthDisplay,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
#[ethevent(name = "Transfer", abi = "Transfer(address,address,uint256)")]
pub struct TransferFilter {
#[ethevent(indexed)]
pub from: ::ethers::core::types::Address,
#[ethevent(indexed)]
pub to: ::ethers::core::types::Address,
pub value: ::ethers::core::types::U256,
}
///Container type for all of the contract's events
#[derive(Clone, ::ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)]
pub enum IERC20Events {
ApprovalFilter(ApprovalFilter),
TransferFilter(TransferFilter),
}
impl ::ethers::contract::EthLogDecode for IERC20Events {
fn decode_log(
log: &::ethers::core::abi::RawLog,
) -> ::core::result::Result<Self, ::ethers::core::abi::Error> {
if let Ok(decoded) = ApprovalFilter::decode_log(log) {
return Ok(IERC20Events::ApprovalFilter(decoded));
}
if let Ok(decoded) = TransferFilter::decode_log(log) {
return Ok(IERC20Events::TransferFilter(decoded));
}
Err(::ethers::core::abi::Error::InvalidData)
}
}
impl ::core::fmt::Display for IERC20Events {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
match self {
Self::ApprovalFilter(element) => ::core::fmt::Display::fmt(element, f),
Self::TransferFilter(element) => ::core::fmt::Display::fmt(element, f),
}
}
}
impl ::core::convert::From<ApprovalFilter> for IERC20Events {
fn from(value: ApprovalFilter) -> Self {
Self::ApprovalFilter(value)
}
}
impl ::core::convert::From<TransferFilter> for IERC20Events {
fn from(value: TransferFilter) -> Self {
Self::TransferFilter(value)
}
}
///Container type for all input parameters for the `allowance` function with signature `allowance(address,address)` and selector `0xdd62ed3e`
#[derive(
Clone,
::ethers::contract::EthCall,
::ethers::contract::EthDisplay,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
#[ethcall(name = "allowance", abi = "allowance(address,address)")]
pub struct AllowanceCall {
pub owner: ::ethers::core::types::Address,
pub spender: ::ethers::core::types::Address,
}
///Container type for all input parameters for the `approve` function with signature `approve(address,uint256)` and selector `0x095ea7b3`
#[derive(
Clone,
::ethers::contract::EthCall,
::ethers::contract::EthDisplay,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
#[ethcall(name = "approve", abi = "approve(address,uint256)")]
pub struct ApproveCall {
pub spender: ::ethers::core::types::Address,
pub amount: ::ethers::core::types::U256,
}
///Container type for all input parameters for the `balanceOf` function with signature `balanceOf(address)` and selector `0x70a08231`
#[derive(
Clone,
::ethers::contract::EthCall,
::ethers::contract::EthDisplay,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
#[ethcall(name = "balanceOf", abi = "balanceOf(address)")]
pub struct BalanceOfCall {
pub account: ::ethers::core::types::Address,
}
///Container type for all input parameters for the `totalSupply` function with signature `totalSupply()` and selector `0x18160ddd`
#[derive(
Clone,
::ethers::contract::EthCall,
::ethers::contract::EthDisplay,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
#[ethcall(name = "totalSupply", abi = "totalSupply()")]
pub struct TotalSupplyCall;
///Container type for all input parameters for the `transfer` function with signature `transfer(address,uint256)` and selector `0xa9059cbb`
#[derive(
Clone,
::ethers::contract::EthCall,
::ethers::contract::EthDisplay,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
#[ethcall(name = "transfer", abi = "transfer(address,uint256)")]
pub struct TransferCall {
pub recipient: ::ethers::core::types::Address,
pub amount: ::ethers::core::types::U256,
}
///Container type for all input parameters for the `transferFrom` function with signature `transferFrom(address,address,uint256)` and selector `0x23b872dd`
#[derive(
Clone,
::ethers::contract::EthCall,
::ethers::contract::EthDisplay,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
#[ethcall(name = "transferFrom", abi = "transferFrom(address,address,uint256)")]
pub struct TransferFromCall {
pub sender: ::ethers::core::types::Address,
pub recipient: ::ethers::core::types::Address,
pub amount: ::ethers::core::types::U256,
}
///Container type for all of the contract's call
#[derive(Clone, ::ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)]
pub enum IERC20Calls {
Allowance(AllowanceCall),
Approve(ApproveCall),
BalanceOf(BalanceOfCall),
TotalSupply(TotalSupplyCall),
Transfer(TransferCall),
TransferFrom(TransferFromCall),
}
impl ::ethers::core::abi::AbiDecode for IERC20Calls {
fn decode(
data: impl AsRef<[u8]>,
) -> ::core::result::Result<Self, ::ethers::core::abi::AbiError> {
let data = data.as_ref();
if let Ok(decoded) = <AllowanceCall as ::ethers::core::abi::AbiDecode>::decode(data) {
return Ok(Self::Allowance(decoded));
}
if let Ok(decoded) = <ApproveCall as ::ethers::core::abi::AbiDecode>::decode(data) {
return Ok(Self::Approve(decoded));
}
if let Ok(decoded) = <BalanceOfCall as ::ethers::core::abi::AbiDecode>::decode(data) {
return Ok(Self::BalanceOf(decoded));
}
if let Ok(decoded) = <TotalSupplyCall as ::ethers::core::abi::AbiDecode>::decode(data) {
return Ok(Self::TotalSupply(decoded));
}
if let Ok(decoded) = <TransferCall as ::ethers::core::abi::AbiDecode>::decode(data) {
return Ok(Self::Transfer(decoded));
}
if let Ok(decoded) = <TransferFromCall as ::ethers::core::abi::AbiDecode>::decode(data)
{
return Ok(Self::TransferFrom(decoded));
}
Err(::ethers::core::abi::Error::InvalidData.into())
}
}
impl ::ethers::core::abi::AbiEncode for IERC20Calls {
fn encode(self) -> Vec<u8> {
match self {
Self::Allowance(element) => ::ethers::core::abi::AbiEncode::encode(element),
Self::Approve(element) => ::ethers::core::abi::AbiEncode::encode(element),
Self::BalanceOf(element) => ::ethers::core::abi::AbiEncode::encode(element),
Self::TotalSupply(element) => ::ethers::core::abi::AbiEncode::encode(element),
Self::Transfer(element) => ::ethers::core::abi::AbiEncode::encode(element),
Self::TransferFrom(element) => ::ethers::core::abi::AbiEncode::encode(element),
}
}
}
impl ::core::fmt::Display for IERC20Calls {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
match self {
Self::Allowance(element) => ::core::fmt::Display::fmt(element, f),
Self::Approve(element) => ::core::fmt::Display::fmt(element, f),
Self::BalanceOf(element) => ::core::fmt::Display::fmt(element, f),
Self::TotalSupply(element) => ::core::fmt::Display::fmt(element, f),
Self::Transfer(element) => ::core::fmt::Display::fmt(element, f),
Self::TransferFrom(element) => ::core::fmt::Display::fmt(element, f),
}
}
}
impl ::core::convert::From<AllowanceCall> for IERC20Calls {
fn from(value: AllowanceCall) -> Self {
Self::Allowance(value)
}
}
impl ::core::convert::From<ApproveCall> for IERC20Calls {
fn from(value: ApproveCall) -> Self {
Self::Approve(value)
}
}
impl ::core::convert::From<BalanceOfCall> for IERC20Calls {
fn from(value: BalanceOfCall) -> Self {
Self::BalanceOf(value)
}
}
impl ::core::convert::From<TotalSupplyCall> for IERC20Calls {
fn from(value: TotalSupplyCall) -> Self {
Self::TotalSupply(value)
}
}
impl ::core::convert::From<TransferCall> for IERC20Calls {
fn from(value: TransferCall) -> Self {
Self::Transfer(value)
}
}
impl ::core::convert::From<TransferFromCall> for IERC20Calls {
fn from(value: TransferFromCall) -> Self {
Self::TransferFrom(value)
}
}
///Container type for all return fields from the `allowance` function with signature `allowance(address,address)` and selector `0xdd62ed3e`
#[derive(
Clone,
::ethers::contract::EthAbiType,
::ethers::contract::EthAbiCodec,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
pub struct AllowanceReturn(pub ::ethers::core::types::U256);
///Container type for all return fields from the `approve` function with signature `approve(address,uint256)` and selector `0x095ea7b3`
#[derive(
Clone,
::ethers::contract::EthAbiType,
::ethers::contract::EthAbiCodec,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
pub struct ApproveReturn(pub bool);
///Container type for all return fields from the `balanceOf` function with signature `balanceOf(address)` and selector `0x70a08231`
#[derive(
Clone,
::ethers::contract::EthAbiType,
::ethers::contract::EthAbiCodec,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
pub struct BalanceOfReturn(pub ::ethers::core::types::U256);
///Container type for all return fields from the `totalSupply` function with signature `totalSupply()` and selector `0x18160ddd`
#[derive(
Clone,
::ethers::contract::EthAbiType,
::ethers::contract::EthAbiCodec,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
pub struct TotalSupplyReturn(pub ::ethers::core::types::U256);
///Container type for all return fields from the `transfer` function with signature `transfer(address,uint256)` and selector `0xa9059cbb`
#[derive(
Clone,
::ethers::contract::EthAbiType,
::ethers::contract::EthAbiCodec,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
pub struct TransferReturn(pub bool);
///Container type for all return fields from the `transferFrom` function with signature `transferFrom(address,address,uint256)` and selector `0x23b872dd`
#[derive(
Clone,
::ethers::contract::EthAbiType,
::ethers::contract::EthAbiCodec,
Default,
Debug,
PartialEq,
Eq,
Hash,
)]
pub struct TransferFromReturn(pub bool);
}