Documentation
¶
Index ¶
- Constants
- Variables
- type Erc20Keeper
- type Precompile
- func (p Precompile) Deposit(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB) ([]byte, error)
- func (p Precompile) EmitDepositEvent(ctx sdk.Context, stateDB vm.StateDB, caller common.Address, amount *big.Int) error
- func (p Precompile) EmitWithdrawalEvent(ctx sdk.Context, stateDB vm.StateDB, src common.Address, amount *big.Int) error
- func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error)
- func (p Precompile) IsTransaction(method *abi.Method) bool
- func (p Precompile) RequiredGas(input []byte) uint64
- func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (p Precompile) Withdraw(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, args []interface{}) ([]byte, error)
Constants ¶
const ( // EventTypeDeposit is the key of the event type for the Deposit transaction. EventTypeDeposit = "Deposit" // EventTypeWithdrawal is the key of the event type for the Withdraw transaction. EventTypeWithdrawal = "Withdrawal" )
const ( // DepositMethod defines the ABI method name for the IWERC20 deposit // transaction. DepositMethod = "deposit" // WithdrawMethod defines the ABI method name for the IWERC20 withdraw // transaction. WithdrawMethod = "withdraw" )
const ( // DepositRequiredGas defines the gas required for the Deposit transaction. DepositRequiredGas uint64 = 23_878 // WithdrawRequiredGas defines the gas required for the Withdraw transaction. WithdrawRequiredGas uint64 = 9207 )
Variables ¶
var (
ABI abi.ABI
)
Functions ¶
This section is empty.
Types ¶
type Erc20Keeper ¶ added in v0.2.0
type Erc20Keeper interface {
GetAllowance(ctx sdk.Context, erc20 common.Address, owner common.Address, spender common.Address) (*big.Int, error)
SetAllowance(ctx sdk.Context, erc20 common.Address, owner common.Address, spender common.Address, value *big.Int) error
DeleteAllowance(ctx sdk.Context, erc20 common.Address, owner common.Address, spender common.Address) error
}
type Precompile ¶
type Precompile struct {
*erc20.Precompile
}
Precompile defines the precompiled contract for WERC20.
func NewPrecompile ¶
func NewPrecompile( tokenPair erc20types.TokenPair, bankKeeper cmn.BankKeeper, erc20Keeper Erc20Keeper, transferKeeper ibcutils.TransferKeeper, ) *Precompile
NewPrecompile creates a new WERC20 Precompile instance implementing the PrecompiledContract interface. This type wraps around the ERC20 Precompile instance to provide additional methods.
func (Precompile) Deposit ¶
func (p Precompile) Deposit( ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, ) ([]byte, error)
Deposit handles the payable deposit function. It retrieves the deposited amount and sends it back to the sender using the bank keeper.
func (Precompile) EmitDepositEvent ¶
func (p Precompile) EmitDepositEvent( ctx sdk.Context, stateDB vm.StateDB, caller common.Address, amount *big.Int, ) error
EmitDepositEvent creates a new Deposit event emitted after a Deposit transaction.
func (Precompile) EmitWithdrawalEvent ¶
func (p Precompile) EmitWithdrawalEvent( ctx sdk.Context, stateDB vm.StateDB, src common.Address, amount *big.Int, ) error
EmitWithdrawalEvent creates a new Withdrawal event emitted after a Withdraw transaction.
func (Precompile) IsTransaction ¶
func (p Precompile) IsTransaction(method *abi.Method) bool
IsTransaction returns true if the given method name correspond to a transaction. Returns false otherwise.
func (Precompile) RequiredGas ¶
func (p Precompile) RequiredGas(input []byte) uint64
RequiredGas calculates the contract gas use.
func (Precompile) Withdraw ¶
func (p Precompile) Withdraw(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, args []interface{}) ([]byte, error)
Withdraw is a no-op and mock function that provides the same interface as the WETH contract to support equality between the native coin and its wrapped ERC-20 (e.g. ATOM and WEVMOS).