bank

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: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrecompileAddress defines the bank precompile address in Hex format
	PrecompileAddress string = "0x0000000000000000000000000000000000000804"

	// GasBalanceOf defines the gas cost for a single ERC-20 balanceOf query
	GasBalanceOf = 2_851

	// GasTotalSupply defines the gas cost for a single ERC-20 totalSupply query
	GasTotalSupply = 2_477

	// GasSupplyOf defines the gas cost for a single ERC-20 supplyOf query, taken from totalSupply of ERC20
	GasSupplyOf = 2_477
)
View Source
const (
	// BalancesMethod defines the ABI method name for the bank Balances
	// query.
	BalancesMethod = "balances"
	// TotalSupplyMethod defines the ABI method name for the bank TotalSupply
	// query.
	TotalSupplyMethod = "totalSupply"
	// SupplyOfMethod defines the ABI method name for the bank SupplyOf
	// query.
	SupplyOfMethod = "supplyOf"
)

Variables

This section is empty.

Functions

func ParseBalancesArgs

func ParseBalancesArgs(args []interface{}) (sdk.AccAddress, error)

ParseBalancesArgs parses the call arguments for the bank Balances query.

func ParseSupplyOfArgs

func ParseSupplyOfArgs(args []interface{}) (common.Address, error)

ParseSupplyOfArgs parses the call arguments for the bank SupplyOf query.

Types

type Balance

type Balance struct {
	ContractAddress common.Address
	Amount          *big.Int
}

Balance contains the amount for a corresponding ERC-20 contract address

type Precompile

type Precompile struct {
	cmn.Precompile
	// contains filtered or unexported fields
}

Precompile defines the bank precompile

func NewPrecompile

func NewPrecompile(
	bankKeeper bankkeeper.Keeper,
	erc20Keeper erc20keeper.Keeper,
) (*Precompile, error)

NewPrecompile creates a new bank Precompile instance as a PrecompiledContract interface.

func (Precompile) Address

func (Precompile) Address() common.Address

Address defines the address of the bank compile contract. address: 0x0000000000000000000000000000000000000804

func (Precompile) Balances

func (p Precompile) Balances(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Balances returns all the native token balances (address, amount) for a given account. This method charges the account the corresponding value of an ERC-20 balanceOf call for each token returned.

func (Precompile) IsTransaction

func (Precompile) IsTransaction(_ string) bool

IsTransaction checks if the given method name corresponds to a transaction or query. It returns false since all bank methods are queries.

func (Precompile) RequiredGas

func (p Precompile) RequiredGas(input []byte) uint64

RequiredGas calculates the precompiled contract's base gas rate.

func (Precompile) Run

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

Run executes the precompiled contract bank query methods defined in the ABI.

func (Precompile) SupplyOf

func (p Precompile) SupplyOf(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

SupplyOf returns the total native supply of a given registered erc20 token.

func (Precompile) TotalSupply

func (p Precompile) TotalSupply(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	_ []interface{},
) ([]byte, error)

TotalSupply returns the total supply of all the native tokens. This method charges the account the corresponding value of a ERC-20 totalSupply call for each token returned.

Jump to

Keyboard shortcuts

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