Documentation ¶
Index ¶
- Constants
- type EventDepositWithdraw
- type Precompile
- func (p Precompile) Address() common.Address
- func (p Precompile) Deposit(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, _ *abi.Method, ...) ([]byte, error)
- func (p Precompile) EmitDepositEvent(ctx sdk.Context, stateDB vm.StateDB, dst 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) IsTransaction(methodName string) bool
- func (p Precompile) RequiredGas(input []byte) uint64
- func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error)
- func (p Precompile) Withdraw(ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, _ *abi.Method, ...) ([]byte, error)
Constants ¶
const ( // EventTypeDeposit defines the event type for the Deposit transaction. EventTypeDeposit = "Deposit" // EventTypeWithdrawal defines 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 ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventDepositWithdraw ¶
type EventDepositWithdraw struct { // source or destination address Address common.Address // amount deposited or withdrawn Amount *big.Int }
EventDepositWithdraw defines the common event data for the WERC20 Deposit and Withdraw events.
type Precompile ¶
type Precompile struct {
*erc20.Precompile
}
Precompile defines the precompiled contract for WERC20.
func NewPrecompile ¶
func NewPrecompile( tokenPair erc20types.TokenPair, bankKeeper bankkeeper.Keeper, authzKeeper authzkeeper.Keeper, transferKeeper transferkeeper.Keeper, ) (*Precompile, error)
NewPrecompile creates a new WERC20 Precompile instance as a PrecompiledContract interface.
func (Precompile) Address ¶
func (p Precompile) Address() common.Address
Address defines the address of the ERC20 precompile contract.
func (Precompile) Deposit ¶
func (p Precompile) Deposit( ctx sdk.Context, contract *vm.Contract, stateDB vm.StateDB, _ *abi.Method, _ []interface{}, ) ([]byte, error)
Deposit 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 (eg. ISLM and WISLM). It only emits the Deposit event.
func (Precompile) EmitDepositEvent ¶
func (p Precompile) EmitDepositEvent(ctx sdk.Context, stateDB vm.StateDB, dst common.Address, amount *big.Int) error
EmitDepositEvent creates a new Deposit event emitted on 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 on Withdraw transaction.
func (Precompile) IsTransaction ¶
func (p Precompile) IsTransaction(methodName string) bool
IsTransaction checks if the given method name corresponds to a transaction or query.
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, _ *abi.Method, 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 (eg. ISLM and WISLM). It only emits the Withdraw event.