pub use erc20::*;
#[allow(clippy::too_many_arguments, non_camel_case_types)]
pub mod erc20 {
#![allow(clippy::enum_variant_names)]
#![allow(dead_code)]
#![allow(clippy::type_complexity)]
#![allow(unused_imports)]
use ethers::contract::{
builders::{ContractCall, Event},
Contract, Lazy,
};
use ethers::core::{
abi::{Abi, Detokenize, InvalidOutputType, Token, Tokenizable},
types::*,
};
use ethers::providers::Middleware;
#[doc = "ERC20 was auto-generated with ethers-rs Abigen. More information at: https://github.com/gakonst/ethers-rs"]
use std::sync::Arc;
pub static ERC20_ABI: ethers::contract::Lazy<ethers::core::abi::Abi> =
ethers::contract::Lazy::new(|| {
ethers :: core :: utils :: __serde_json :: from_str ("[\n {\n \"constant\": true,\n \"inputs\": [],\n \"name\": \"name\",\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"string\"\n }\n ],\n \"payable\": false,\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"constant\": false,\n \"inputs\": [\n {\n \"name\": \"_spender\",\n \"type\": \"address\"\n },\n {\n \"name\": \"_value\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"approve\",\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"payable\": false,\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"constant\": true,\n \"inputs\": [],\n \"name\": \"totalSupply\",\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"payable\": false,\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"constant\": false,\n \"inputs\": [\n {\n \"name\": \"_from\",\n \"type\": \"address\"\n },\n {\n \"name\": \"_to\",\n \"type\": \"address\"\n },\n {\n \"name\": \"_value\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"transferFrom\",\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"payable\": false,\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"constant\": true,\n \"inputs\": [],\n \"name\": \"decimals\",\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"uint8\"\n }\n ],\n \"payable\": false,\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"constant\": true,\n \"inputs\": [\n {\n \"name\": \"_owner\",\n \"type\": \"address\"\n }\n ],\n \"name\": \"balanceOf\",\n \"outputs\": [\n {\n \"name\": \"balance\",\n \"type\": \"uint256\"\n }\n ],\n \"payable\": false,\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"constant\": true,\n \"inputs\": [],\n \"name\": \"symbol\",\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"string\"\n }\n ],\n \"payable\": false,\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"constant\": false,\n \"inputs\": [\n {\n \"name\": \"_to\",\n \"type\": \"address\"\n },\n {\n \"name\": \"_value\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"transfer\",\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"bool\"\n }\n ],\n \"payable\": false,\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\"\n },\n {\n \"constant\": true,\n \"inputs\": [\n {\n \"name\": \"_owner\",\n \"type\": \"address\"\n },\n {\n \"name\": \"_spender\",\n \"type\": \"address\"\n }\n ],\n \"name\": \"allowance\",\n \"outputs\": [\n {\n \"name\": \"\",\n \"type\": \"uint256\"\n }\n ],\n \"payable\": false,\n \"stateMutability\": \"view\",\n \"type\": \"function\"\n },\n {\n \"payable\": true,\n \"stateMutability\": \"payable\",\n \"type\": \"fallback\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"name\": \"owner\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"name\": \"spender\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"name\": \"value\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"Approval\",\n \"type\": \"event\"\n },\n {\n \"anonymous\": false,\n \"inputs\": [\n {\n \"indexed\": true,\n \"name\": \"from\",\n \"type\": \"address\"\n },\n {\n \"indexed\": true,\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"indexed\": false,\n \"name\": \"value\",\n \"type\": \"uint256\"\n }\n ],\n \"name\": \"Transfer\",\n \"type\": \"event\"\n }\n]") . expect ("invalid abi")
});
pub struct ERC20<M>(ethers::contract::Contract<M>);
impl<M> Clone for ERC20<M> {
fn clone(&self) -> Self {
ERC20(self.0.clone())
}
}
impl<M> std::ops::Deref for ERC20<M> {
type Target = ethers::contract::Contract<M>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<M: ethers::providers::Middleware> std::fmt::Debug for ERC20<M> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_tuple(stringify!(ERC20))
.field(&self.address())
.finish()
}
}
impl<M: ethers::providers::Middleware> ERC20<M> {
#[doc = r" Creates a new contract instance with the specified `ethers`"]
#[doc = r" client at the given `Address`. The contract derefs to a `ethers::Contract`"]
#[doc = r" object"]
pub fn new<T: Into<ethers::core::types::Address>>(
address: T,
client: ::std::sync::Arc<M>,
) -> Self {
ethers::contract::Contract::new(address.into(), ERC20_ABI.clone(), client).into()
}
#[doc = "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)")
}
#[doc = "Calls the contract's `approve` (0x095ea7b3) function"]
pub fn approve(
&self,
spender: ethers::core::types::Address,
value: ethers::core::types::U256,
) -> ethers::contract::builders::ContractCall<M, bool> {
self.0
.method_hash([9, 94, 167, 179], (spender, value))
.expect("method not found (this should never happen)")
}
#[doc = "Calls the contract's `balanceOf` (0x70a08231) function"]
pub fn balance_of(
&self,
owner: ethers::core::types::Address,
) -> ethers::contract::builders::ContractCall<M, ethers::core::types::U256> {
self.0
.method_hash([112, 160, 130, 49], owner)
.expect("method not found (this should never happen)")
}
#[doc = "Calls the contract's `decimals` (0x313ce567) function"]
pub fn decimals(&self) -> ethers::contract::builders::ContractCall<M, u8> {
self.0
.method_hash([49, 60, 229, 103], ())
.expect("method not found (this should never happen)")
}
#[doc = "Calls the contract's `name` (0x06fdde03) function"]
pub fn name(&self) -> ethers::contract::builders::ContractCall<M, String> {
self.0
.method_hash([6, 253, 222, 3], ())
.expect("method not found (this should never happen)")
}
#[doc = "Calls the contract's `symbol` (0x95d89b41) function"]
pub fn symbol(&self) -> ethers::contract::builders::ContractCall<M, String> {
self.0
.method_hash([149, 216, 155, 65], ())
.expect("method not found (this should never happen)")
}
#[doc = "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)")
}
#[doc = "Calls the contract's `transfer` (0xa9059cbb) function"]
pub fn transfer(
&self,
to: ethers::core::types::Address,
value: ethers::core::types::U256,
) -> ethers::contract::builders::ContractCall<M, bool> {
self.0
.method_hash([169, 5, 156, 187], (to, value))
.expect("method not found (this should never happen)")
}
#[doc = "Calls the contract's `transferFrom` (0x23b872dd) function"]
pub fn transfer_from(
&self,
from: ethers::core::types::Address,
to: ethers::core::types::Address,
value: ethers::core::types::U256,
) -> ethers::contract::builders::ContractCall<M, bool> {
self.0
.method_hash([35, 184, 114, 221], (from, to, value))
.expect("method not found (this should never happen)")
}
#[doc = "Gets the contract's `Approval` event"]
pub fn approval_filter(&self) -> ethers::contract::builders::Event<M, ApprovalFilter> {
self.0.event()
}
#[doc = "Gets the contract's `Transfer` event"]
pub fn transfer_filter(&self) -> ethers::contract::builders::Event<M, TransferFilter> {
self.0.event()
}
#[doc = r" Returns an [`Event`](#ethers_contract::builders::Event) builder for all events of this contract"]
pub fn events(&self) -> ethers::contract::builders::Event<M, ERC20Events> {
self.0.event_with_filter(Default::default())
}
}
impl<M: ethers::providers::Middleware> From<ethers::contract::Contract<M>> for ERC20<M> {
fn from(contract: ethers::contract::Contract<M>) -> Self {
Self(contract)
}
}
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthEvent,
ethers :: contract :: EthDisplay,
)]
#[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,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthEvent,
ethers :: contract :: EthDisplay,
)]
#[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,
}
#[derive(Debug, Clone, PartialEq, Eq, ethers :: contract :: EthAbiType)]
pub enum ERC20Events {
ApprovalFilter(ApprovalFilter),
TransferFilter(TransferFilter),
}
impl ethers::contract::EthLogDecode for ERC20Events {
fn decode_log(log: ðers::core::abi::RawLog) -> Result<Self, ethers::core::abi::Error>
where
Self: Sized,
{
if let Ok(decoded) = ApprovalFilter::decode_log(log) {
return Ok(ERC20Events::ApprovalFilter(decoded));
}
if let Ok(decoded) = TransferFilter::decode_log(log) {
return Ok(ERC20Events::TransferFilter(decoded));
}
Err(ethers::core::abi::Error::InvalidData)
}
}
impl ::std::fmt::Display for ERC20Events {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
ERC20Events::ApprovalFilter(element) => element.fmt(f),
ERC20Events::TransferFilter(element) => element.fmt(f),
}
}
}
#[doc = "Container type for all input parameters for the `allowance` function with signature `allowance(address,address)` and selector `[221, 98, 237, 62]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthCall,
ethers :: contract :: EthDisplay,
)]
#[ethcall(name = "allowance", abi = "allowance(address,address)")]
pub struct AllowanceCall {
pub owner: ethers::core::types::Address,
pub spender: ethers::core::types::Address,
}
#[doc = "Container type for all input parameters for the `approve` function with signature `approve(address,uint256)` and selector `[9, 94, 167, 179]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthCall,
ethers :: contract :: EthDisplay,
)]
#[ethcall(name = "approve", abi = "approve(address,uint256)")]
pub struct ApproveCall {
pub spender: ethers::core::types::Address,
pub value: ethers::core::types::U256,
}
#[doc = "Container type for all input parameters for the `balanceOf` function with signature `balanceOf(address)` and selector `[112, 160, 130, 49]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthCall,
ethers :: contract :: EthDisplay,
)]
#[ethcall(name = "balanceOf", abi = "balanceOf(address)")]
pub struct BalanceOfCall {
pub owner: ethers::core::types::Address,
}
#[doc = "Container type for all input parameters for the `decimals` function with signature `decimals()` and selector `[49, 60, 229, 103]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthCall,
ethers :: contract :: EthDisplay,
)]
#[ethcall(name = "decimals", abi = "decimals()")]
pub struct DecimalsCall;
#[doc = "Container type for all input parameters for the `name` function with signature `name()` and selector `[6, 253, 222, 3]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthCall,
ethers :: contract :: EthDisplay,
)]
#[ethcall(name = "name", abi = "name()")]
pub struct NameCall;
#[doc = "Container type for all input parameters for the `symbol` function with signature `symbol()` and selector `[149, 216, 155, 65]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthCall,
ethers :: contract :: EthDisplay,
)]
#[ethcall(name = "symbol", abi = "symbol()")]
pub struct SymbolCall;
#[doc = "Container type for all input parameters for the `totalSupply` function with signature `totalSupply()` and selector `[24, 22, 13, 221]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthCall,
ethers :: contract :: EthDisplay,
)]
#[ethcall(name = "totalSupply", abi = "totalSupply()")]
pub struct TotalSupplyCall;
#[doc = "Container type for all input parameters for the `transfer` function with signature `transfer(address,uint256)` and selector `[169, 5, 156, 187]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthCall,
ethers :: contract :: EthDisplay,
)]
#[ethcall(name = "transfer", abi = "transfer(address,uint256)")]
pub struct TransferCall {
pub to: ethers::core::types::Address,
pub value: ethers::core::types::U256,
}
#[doc = "Container type for all input parameters for the `transferFrom` function with signature `transferFrom(address,address,uint256)` and selector `[35, 184, 114, 221]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthCall,
ethers :: contract :: EthDisplay,
)]
#[ethcall(name = "transferFrom", abi = "transferFrom(address,address,uint256)")]
pub struct TransferFromCall {
pub from: ethers::core::types::Address,
pub to: ethers::core::types::Address,
pub value: ethers::core::types::U256,
}
#[derive(Debug, Clone, PartialEq, Eq, ethers :: contract :: EthAbiType)]
pub enum ERC20Calls {
Allowance(AllowanceCall),
Approve(ApproveCall),
BalanceOf(BalanceOfCall),
Decimals(DecimalsCall),
Name(NameCall),
Symbol(SymbolCall),
TotalSupply(TotalSupplyCall),
Transfer(TransferCall),
TransferFrom(TransferFromCall),
}
impl ethers::core::abi::AbiDecode for ERC20Calls {
fn decode(data: impl AsRef<[u8]>) -> Result<Self, ethers::core::abi::AbiError> {
if let Ok(decoded) =
<AllowanceCall as ethers::core::abi::AbiDecode>::decode(data.as_ref())
{
return Ok(ERC20Calls::Allowance(decoded));
}
if let Ok(decoded) =
<ApproveCall as ethers::core::abi::AbiDecode>::decode(data.as_ref())
{
return Ok(ERC20Calls::Approve(decoded));
}
if let Ok(decoded) =
<BalanceOfCall as ethers::core::abi::AbiDecode>::decode(data.as_ref())
{
return Ok(ERC20Calls::BalanceOf(decoded));
}
if let Ok(decoded) =
<DecimalsCall as ethers::core::abi::AbiDecode>::decode(data.as_ref())
{
return Ok(ERC20Calls::Decimals(decoded));
}
if let Ok(decoded) = <NameCall as ethers::core::abi::AbiDecode>::decode(data.as_ref()) {
return Ok(ERC20Calls::Name(decoded));
}
if let Ok(decoded) = <SymbolCall as ethers::core::abi::AbiDecode>::decode(data.as_ref())
{
return Ok(ERC20Calls::Symbol(decoded));
}
if let Ok(decoded) =
<TotalSupplyCall as ethers::core::abi::AbiDecode>::decode(data.as_ref())
{
return Ok(ERC20Calls::TotalSupply(decoded));
}
if let Ok(decoded) =
<TransferCall as ethers::core::abi::AbiDecode>::decode(data.as_ref())
{
return Ok(ERC20Calls::Transfer(decoded));
}
if let Ok(decoded) =
<TransferFromCall as ethers::core::abi::AbiDecode>::decode(data.as_ref())
{
return Ok(ERC20Calls::TransferFrom(decoded));
}
Err(ethers::core::abi::Error::InvalidData.into())
}
}
impl ethers::core::abi::AbiEncode for ERC20Calls {
fn encode(self) -> Vec<u8> {
match self {
ERC20Calls::Allowance(element) => element.encode(),
ERC20Calls::Approve(element) => element.encode(),
ERC20Calls::BalanceOf(element) => element.encode(),
ERC20Calls::Decimals(element) => element.encode(),
ERC20Calls::Name(element) => element.encode(),
ERC20Calls::Symbol(element) => element.encode(),
ERC20Calls::TotalSupply(element) => element.encode(),
ERC20Calls::Transfer(element) => element.encode(),
ERC20Calls::TransferFrom(element) => element.encode(),
}
}
}
impl ::std::fmt::Display for ERC20Calls {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
ERC20Calls::Allowance(element) => element.fmt(f),
ERC20Calls::Approve(element) => element.fmt(f),
ERC20Calls::BalanceOf(element) => element.fmt(f),
ERC20Calls::Decimals(element) => element.fmt(f),
ERC20Calls::Name(element) => element.fmt(f),
ERC20Calls::Symbol(element) => element.fmt(f),
ERC20Calls::TotalSupply(element) => element.fmt(f),
ERC20Calls::Transfer(element) => element.fmt(f),
ERC20Calls::TransferFrom(element) => element.fmt(f),
}
}
}
impl ::std::convert::From<AllowanceCall> for ERC20Calls {
fn from(var: AllowanceCall) -> Self {
ERC20Calls::Allowance(var)
}
}
impl ::std::convert::From<ApproveCall> for ERC20Calls {
fn from(var: ApproveCall) -> Self {
ERC20Calls::Approve(var)
}
}
impl ::std::convert::From<BalanceOfCall> for ERC20Calls {
fn from(var: BalanceOfCall) -> Self {
ERC20Calls::BalanceOf(var)
}
}
impl ::std::convert::From<DecimalsCall> for ERC20Calls {
fn from(var: DecimalsCall) -> Self {
ERC20Calls::Decimals(var)
}
}
impl ::std::convert::From<NameCall> for ERC20Calls {
fn from(var: NameCall) -> Self {
ERC20Calls::Name(var)
}
}
impl ::std::convert::From<SymbolCall> for ERC20Calls {
fn from(var: SymbolCall) -> Self {
ERC20Calls::Symbol(var)
}
}
impl ::std::convert::From<TotalSupplyCall> for ERC20Calls {
fn from(var: TotalSupplyCall) -> Self {
ERC20Calls::TotalSupply(var)
}
}
impl ::std::convert::From<TransferCall> for ERC20Calls {
fn from(var: TransferCall) -> Self {
ERC20Calls::Transfer(var)
}
}
impl ::std::convert::From<TransferFromCall> for ERC20Calls {
fn from(var: TransferFromCall) -> Self {
ERC20Calls::TransferFrom(var)
}
}
#[doc = "Container type for all return fields from the `allowance` function with signature `allowance(address,address)` and selector `[221, 98, 237, 62]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthAbiType,
ethers :: contract :: EthAbiCodec,
)]
pub struct AllowanceReturn(pub ethers::core::types::U256);
#[doc = "Container type for all return fields from the `approve` function with signature `approve(address,uint256)` and selector `[9, 94, 167, 179]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthAbiType,
ethers :: contract :: EthAbiCodec,
)]
pub struct ApproveReturn(pub bool);
#[doc = "Container type for all return fields from the `balanceOf` function with signature `balanceOf(address)` and selector `[112, 160, 130, 49]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthAbiType,
ethers :: contract :: EthAbiCodec,
)]
pub struct BalanceOfReturn {
pub balance: ethers::core::types::U256,
}
#[doc = "Container type for all return fields from the `decimals` function with signature `decimals()` and selector `[49, 60, 229, 103]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthAbiType,
ethers :: contract :: EthAbiCodec,
)]
pub struct DecimalsReturn(pub u8);
#[doc = "Container type for all return fields from the `name` function with signature `name()` and selector `[6, 253, 222, 3]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthAbiType,
ethers :: contract :: EthAbiCodec,
)]
pub struct NameReturn(pub String);
#[doc = "Container type for all return fields from the `symbol` function with signature `symbol()` and selector `[149, 216, 155, 65]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthAbiType,
ethers :: contract :: EthAbiCodec,
)]
pub struct SymbolReturn(pub String);
#[doc = "Container type for all return fields from the `totalSupply` function with signature `totalSupply()` and selector `[24, 22, 13, 221]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthAbiType,
ethers :: contract :: EthAbiCodec,
)]
pub struct TotalSupplyReturn(pub ethers::core::types::U256);
#[doc = "Container type for all return fields from the `transfer` function with signature `transfer(address,uint256)` and selector `[169, 5, 156, 187]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthAbiType,
ethers :: contract :: EthAbiCodec,
)]
pub struct TransferReturn(pub bool);
#[doc = "Container type for all return fields from the `transferFrom` function with signature `transferFrom(address,address,uint256)` and selector `[35, 184, 114, 221]`"]
#[derive(
Clone,
Debug,
Default,
Eq,
PartialEq,
ethers :: contract :: EthAbiType,
ethers :: contract :: EthAbiCodec,
)]
pub struct TransferFromReturn(pub bool);
}