werc20

package
v1.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventTypeDeposit defines the event type for the Deposit transaction.
	EventTypeDeposit = "Deposit"
	// EventTypeWithdrawal defines the event type for the Withdraw transaction.
	EventTypeWithdrawal = "Withdrawal"
)
View Source
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"
)
View Source
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) Run

func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error)

Run executes the precompiled contract WERC20 methods defined in the ABI.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL