keeper

package
v0.0.0-...-1329066 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const ZETAMaxSupplyStr = "1850000000000000000000000000"

ZETAMaxSupplyStr is the maximum mintable ZETA in the fungible module 1.85 billion ZETA

Variables

View Source
var (
	BigIntZero                 = big.NewInt(0)
	ZEVMGasLimitDepositAndCall = big.NewInt(1_000_000)
	ZEVMGasLimitConnectorCall  = big.NewInt(1_000_000)
)

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.

Types

type EVMHooks

type EVMHooks struct {
	// contains filtered or unexported fields
}

func (EVMHooks) PostTxProcessing

func (h EVMHooks) PostTxProcessing(ctx sdk.Context, _ *core.Message, receipt *ethtypes.Receipt) error

PostTxProcessing is a wrapper for calling the EVM PostTxProcessing hook on the module keeper

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey,
	memKey storetypes.StoreKey,
	authKeeper types.AccountKeeper,
	evmKeeper types.EVMKeeper,
	bankKeeper types.BankKeeper,
	observerKeeper types.ObserverKeeper,
	authorityKeeper types.AuthorityKeeper,
) *Keeper

func (Keeper) BalanceOfZRC4

func (k Keeper) BalanceOfZRC4(
	ctx sdk.Context,
	contract, account common.Address,
) (*big.Int, error)

BalanceOfZRC4 queries an account's balance for a given ZRC4 contract

func (Keeper) CallDepositAndCallZRC20

func (k Keeper) CallDepositAndCallZRC20(
	ctx sdk.Context,
	context systemcontract.ZContext,
	zrc20 common.Address,
	amount *big.Int,
	target common.Address,
	message []byte,
) (*evmtypes.MsgEthereumTxResponse, error)

CallDepositAndCallZRC20 calls the depositAndCall (ZRC20 version) function on the gateway contract Callable only by the fungible module account returns directly CallEVM() function depositAndCall(

    zContext calldata context,
    address zrc20,
    uint256 amount,
    address target,
    bytes calldata message
)

func (Keeper) CallDepositAndRevert

func (k Keeper) CallDepositAndRevert(
	ctx sdk.Context,
	inboundSender string,
	zrc20 common.Address,
	amount *big.Int,
	target common.Address,
	message []byte,
) (*evmtypes.MsgEthereumTxResponse, error)

CallDepositAndRevert calls the depositAndRevert function on the gateway contract

function depositAndRevert(

address zrc20,
uint256 amount,
address target,
RevertContext revertContext

)

func (Keeper) CallEVM

func (k Keeper) CallEVM(
	ctx sdk.Context,
	abi abi.ABI,
	from, contract common.Address,
	value, gasLimit *big.Int,
	commit bool,
	noEthereumTxEvent bool,
	method string,
	args ...interface{},
) (*evmtypes.MsgEthereumTxResponse, error)

CallEVM performs a smart contract method call using given args returns (msg,err) the EVM execution result if there is any, even if error is non-nil due to contract reverts Furthermore, err!=nil && msg!=nil && msg.Failed() means the contract call reverted.

func (Keeper) CallEVMWithData

func (k Keeper) CallEVMWithData(
	ctx sdk.Context,
	from common.Address,
	contract *common.Address,
	data []byte,
	commit bool,
	noEthereumTxEvent bool,
	value *big.Int,
	gasLimit *big.Int,
) (*evmtypes.MsgEthereumTxResponse, error)

CallEVMWithData performs a smart contract method call using contract data value is the amount of wei to send; gaslimit is the custom gas limit, if nil EstimateGas is used to bisect the correct gas limit (this may sometimes result in insufficient gas limit; not sure why)

noEthereumTxEvent flag is used to control if ethereum_tx events should be emitted which will mean these txs are indexed and available in rpc methods

returns (msg,err) the EVM execution result if there is any, even if error is non-nil due to contract reverts Furthermore, err!=nil && msg!=nil && msg.Failed() means the contract call reverted; in which case msg.Ret gives the RET code if contract revert with REVERT opcode with parameters.

func (Keeper) CallExecute

func (k Keeper) CallExecute(
	ctx sdk.Context,
	context systemcontract.ZContext,
	zrc20 common.Address,
	amount *big.Int,
	target common.Address,
	message []byte,
) (*evmtypes.MsgEthereumTxResponse, error)

CallExecute calls the execute function on the gateway contract function execute(

zContext calldata context,
address zrc20,
uint256 amount,
address target,
bytes calldata message

)

func (Keeper) CallExecuteRevert

func (k Keeper) CallExecuteRevert(
	ctx sdk.Context,
	inboundSender string,
	zrc20 common.Address,
	amount *big.Int,
	target common.Address,
	message []byte,
) (*evmtypes.MsgEthereumTxResponse, error)

CallExecuteRevert calls the executeRevert function on the gateway contract

function executeRevert(
address target,
RevertContext revertContext,
)

func (Keeper) CallOnReceiveZevmConnector

func (k Keeper) CallOnReceiveZevmConnector(ctx sdk.Context,
	zetaTxSenderAddress []byte,
	sourceChainID *big.Int,
	destinationAddress common.Address,
	zetaValue *big.Int,
	message []byte,
	internalSendHash [32]byte,
) (*evmtypes.MsgEthereumTxResponse, error)

CallOnReceiveZevmConnector calls the onReceive function of the ZevmConnector contract Before calling it mints the zetaValue tokens to the fungible module , and this amount is then provided as value to the onReceive function The onReceive function will then wrap this native zeta into WZETA and call the onReceive function of the destination contract specified by the destinationAddress

func (Keeper) CallOnRevertZevmConnector

func (k Keeper) CallOnRevertZevmConnector(ctx sdk.Context,
	zetaTxSenderAddress common.Address,
	sourceChainID *big.Int,
	destinationAddress []byte,
	destinationChainID *big.Int,
	remainingZetaValue *big.Int,
	message []byte,
	internalSendHash [32]byte,
) (*evmtypes.MsgEthereumTxResponse, error)

CallOnRevertZevmConnector calls the onRevert function of the ZevmConnector contract Before calling it mints the remainingZetaValue tokens to the fungible module , and this amount is then provided as value to the onRevert function The onRevert function will then wrap this native zeta into WZETA and call the onRevert function of the contract specified by the zetaTxSenderAddress Note the destination address is the original destination address of the transaction and not the current destination .

func (*Keeper) CallUniswapV2RouterSwapEthForExactToken

func (k *Keeper) CallUniswapV2RouterSwapEthForExactToken(
	ctx sdk.Context,
	sender ethcommon.Address,
	to ethcommon.Address,
	maxAmountIn *big.Int,
	amountOut *big.Int,
	outZRC4 ethcommon.Address,
) ([]*big.Int, error)

CallUniswapV2RouterSwapEthForExactToken calls the swapETHForExactTokens method of the uniswapv2 router contract

func (*Keeper) CallUniswapV2RouterSwapExactETHForToken

func (k *Keeper) CallUniswapV2RouterSwapExactETHForToken(
	ctx sdk.Context,
	sender ethcommon.Address,
	to ethcommon.Address,
	amountIn *big.Int,
	outZRC4 ethcommon.Address,
	noEthereumTxEvent bool,
) ([]*big.Int, error)

CallUniswapV2RouterSwapExactETHForToken calls the swapExactETHForTokens method of the uniswapv2 router contract

func (*Keeper) CallUniswapV2RouterSwapExactTokensForETH

func (k *Keeper) CallUniswapV2RouterSwapExactTokensForETH(
	ctx sdk.Context,
	sender ethcommon.Address,
	to ethcommon.Address,
	amountIn *big.Int,
	inZRC4 ethcommon.Address,
	noEthereumTxEvent bool,
) (ret []*big.Int, err error)

CallUniswapV2RouterSwapExactTokensForETH calls the swapExactTokensForETH method of the uniswapv2 router contract

func (*Keeper) CallUniswapV2RouterSwapExactTokensForTokens

func (k *Keeper) CallUniswapV2RouterSwapExactTokensForTokens(
	ctx sdk.Context,
	sender ethcommon.Address,
	to ethcommon.Address,
	amountIn *big.Int,
	inZRC4,
	outZRC4 ethcommon.Address,
	noEthereumTxEvent bool,
) (ret []*big.Int, err error)

CallUniswapV2RouterSwapExactTokensForTokens calls the swapExactTokensForETH method of the uniswapv2 router contract to swap tokens to another tokens using wZeta as intermediary

func (Keeper) CallUpdateGatewayAddress

func (k Keeper) CallUpdateGatewayAddress(
	ctx sdk.Context,
	zrc20Address common.Address,
	newGatewayAddress common.Address,
) (*evmtypes.MsgEthereumTxResponse, error)

CallUpdateGatewayAddress calls the updateGatewayAddress function on the ZRC20 contract function updateGatewayAddress(address addr)

func (*Keeper) CallWZetaDeposit

func (k *Keeper) CallWZetaDeposit(ctx sdk.Context, sender ethcommon.Address, amount *big.Int) error

CallWZetaDeposit calls the deposit method of the wzeta contract

func (*Keeper) CallZRC20Approve

func (k *Keeper) CallZRC20Approve(
	ctx sdk.Context,
	owner ethcommon.Address,
	zrc20address ethcommon.Address,
	spender ethcommon.Address,
	amount *big.Int,
	noEthereumTxEvent bool,
) error

CallZRC20Approve calls the approve method of the zrc20 contract

func (*Keeper) CallZRC20Burn

func (k *Keeper) CallZRC20Burn(
	ctx sdk.Context,
	sender ethcommon.Address,
	zrc20address ethcommon.Address,
	amount *big.Int,
	noEthereumTxEvent bool,
) error

CallZRC20Burn calls the burn method of the zrc20 contract

func (*Keeper) CallZRC20Deposit

func (k *Keeper) CallZRC20Deposit(
	ctx sdk.Context,
	sender ethcommon.Address,
	zrc20address ethcommon.Address,
	to ethcommon.Address,
	amount *big.Int,
) error

CallZRC20Deposit calls the deposit method of the zrc20 contract

func (Keeper) CheckZRC20Allowance

func (k Keeper) CheckZRC20Allowance(
	ctx sdk.Context,
	owner, spender, zrc20Address common.Address,
	amount *big.Int,
) error

CheckZRC20Allowance checks if the allowance of ZRC20 tokens, is equal or greater than the provided amount.

func (Keeper) CheckZRC20Balance

func (k Keeper) CheckZRC20Balance(
	ctx sdk.Context,
	zrc20Address, owner common.Address,
	amount *big.Int,
) error

CheckZRC20Balance checks if the balance of ZRC20 tokens, is equal or greater than the provided amount.

func (Keeper) CodeHash

CodeHash returns the code hash of an account if it exists

func (Keeper) DeployConnectorZEVM

func (k Keeper) DeployConnectorZEVM(ctx sdk.Context, wzeta common.Address) (common.Address, error)

func (Keeper) DeployContract

func (k Keeper) DeployContract(
	ctx sdk.Context,
	metadata *bind.MetaData,
	constructorArguments ...interface{},
) (common.Address, error)

DeployContract deploys a new contract in the ZEVM

func (Keeper) DeploySystemContract

func (k Keeper) DeploySystemContract(
	ctx sdk.Context,
	wzeta common.Address,
	v2factory common.Address,
	router02 common.Address,
) (common.Address, error)

func (Keeper) DeployUniswapV2Factory

func (k Keeper) DeployUniswapV2Factory(ctx sdk.Context) (common.Address, error)

func (Keeper) DeployUniswapV2Router02

func (k Keeper) DeployUniswapV2Router02(
	ctx sdk.Context,
	factory common.Address,
	wzeta common.Address,
) (common.Address, error)

func (Keeper) DeployWZETA

func (k Keeper) DeployWZETA(ctx sdk.Context) (common.Address, error)

func (Keeper) DeployZRC20Contract

func (k Keeper) DeployZRC20Contract(
	ctx sdk.Context,
	name, symbol string,
	decimals uint8,
	chainID int64,
	coinType coin.CoinType,
	erc20Contract string,
	gasLimit *big.Int,
) (common.Address, error)

DeployZRC20Contract creates and deploys an ERC20 contract on the EVM with the erc20 module account as owner. Also adds itself to ForeignCoins fungible module state variable

func (Keeper) DepositCoinZeta

func (k Keeper) DepositCoinZeta(ctx sdk.Context, to eth.Address, amount *big.Int) error

DepositCoinZeta immediately mints ZETA to the EVM account

func (Keeper) DepositCoinsToFungibleModule

func (k Keeper) DepositCoinsToFungibleModule(ctx sdk.Context, amount *big.Int) error

func (Keeper) DepositZRC20

func (k Keeper) DepositZRC20(
	ctx sdk.Context,
	contract common.Address,
	to common.Address,
	amount *big.Int,
) (*evmtypes.MsgEthereumTxResponse, error)

DepositZRC20 deposits ZRC4 tokens into to account; Callable only by the fungible module account returns directly CallEVM()

func (Keeper) DepositZRC20AndCallContract

func (k Keeper) DepositZRC20AndCallContract(ctx sdk.Context,
	context systemcontract.ZContext,
	zrc20Addr common.Address,
	targetContract common.Address,
	amount *big.Int,
	message []byte,
) (*evmtypes.MsgEthereumTxResponse, error)

DepositZRC20AndCallContract deposits into ZRC4 and call contract function in a single tx callable from fungible module Returns directly results from CallEVM

func (Keeper) EVMHooks

func (k Keeper) EVMHooks() EVMHooks

func (Keeper) EnsureGasStabilityPoolAccountCreated

func (k Keeper) EnsureGasStabilityPoolAccountCreated(ctx sdk.Context)

EnsureGasStabilityPoolAccountCreated ensures the gas stability pool account exists

func (Keeper) FundGasStabilityPool

func (k Keeper) FundGasStabilityPool(
	ctx sdk.Context,
	chainID int64,
	amount *big.Int,
) error

FundGasStabilityPool mints the ZRC20 into a special address called gas stability pool for the chain

func (Keeper) GetAllForeignCoinMap

func (k Keeper) GetAllForeignCoinMap(ctx sdk.Context) map[int64]map[string]types.ForeignCoins

GetAllForeignCoinMap returns all foreign ERC20 coins in a map of chainID -> asset -> coin Note: DO NOT use this method outside of gRPC queries

func (Keeper) GetAllForeignCoins

func (k Keeper) GetAllForeignCoins(ctx sdk.Context) (list []types.ForeignCoins)

GetAllForeignCoins returns all foreignCoins

func (Keeper) GetAllForeignCoinsForChain

func (k Keeper) GetAllForeignCoinsForChain(ctx sdk.Context, foreignChainID int64) (list []types.ForeignCoins)

GetAllForeignCoinsForChain returns all foreignCoins on a given chain

func (Keeper) GetAuthKeeper

func (k Keeper) GetAuthKeeper() types.AccountKeeper

func (Keeper) GetAuthorityKeeper

func (k Keeper) GetAuthorityKeeper() types.AuthorityKeeper

func (Keeper) GetBankKeeper

func (k Keeper) GetBankKeeper() types.BankKeeper

func (Keeper) GetEVMKeeper

func (k Keeper) GetEVMKeeper() types.EVMKeeper

func (Keeper) GetForeignCoinFromAsset

func (k Keeper) GetForeignCoinFromAsset(ctx sdk.Context, asset string, chainID int64) (types.ForeignCoins, bool)

GetForeignCoinFromAsset returns the foreign coin for a given asset for a given chain

func (Keeper) GetForeignCoins

func (k Keeper) GetForeignCoins(
	ctx sdk.Context,
	zrc20Addr string,
) (val types.ForeignCoins, found bool)

GetForeignCoins returns a foreignCoins from its index

func (Keeper) GetGasCoinForForeignCoin

func (k Keeper) GetGasCoinForForeignCoin(ctx sdk.Context, chainID int64) (types.ForeignCoins, bool)

GetGasCoinForForeignCoin returns the gas coin for a given chain

func (Keeper) GetGasStabilityPoolBalance

func (k Keeper) GetGasStabilityPoolBalance(
	ctx sdk.Context,
	chainID int64,
) (*big.Int, error)

GetGasStabilityPoolBalance returns the balance of the gas stability pool

func (Keeper) GetObserverKeeper

func (k Keeper) GetObserverKeeper() types.ObserverKeeper

func (Keeper) GetSystemContract

func (k Keeper) GetSystemContract(ctx sdk.Context) (val types.SystemContract, found bool)

GetSystemContract returns system contract from the store

func (*Keeper) GetSystemContractAddress

func (k *Keeper) GetSystemContractAddress(ctx sdk.Context) (ethcommon.Address, error)

GetSystemContractAddress returns the system contract address TODO : wzetaContractAddress and other constant strings , can be declared as a constant string in types TODO Remove repetitive code

func (*Keeper) GetUniswapV2FactoryAddress

func (k *Keeper) GetUniswapV2FactoryAddress(ctx sdk.Context) (ethcommon.Address, error)

GetUniswapV2FactoryAddress returns the uniswapv2 factory contract address on ZetaChain

func (*Keeper) GetUniswapV2Router02Address

func (k *Keeper) GetUniswapV2Router02Address(ctx sdk.Context) (ethcommon.Address, error)

GetUniswapV2Router02Address returns the uniswapv2 router02 address on ZetaChain

func (*Keeper) GetWZetaContractAddress

func (k *Keeper) GetWZetaContractAddress(ctx sdk.Context) (ethcommon.Address, error)

GetWZetaContractAddress returns the wzeta contract address on ZetaChain

func (Keeper) IsValidDepositAmount

func (k Keeper) IsValidDepositAmount(totalSupply, alreadyLocked, amountToDeposit *big.Int) bool

IsValidDepositAmount checks "totalSupply >= amount_to_be_locked + amount_already_locked". A failure here means the user is trying to lock more than the available ZRC20 supply. This suggests that an actor is minting ZRC20 tokens out of thin air.

func (Keeper) IsValidZRC20

func (k Keeper) IsValidZRC20(ctx sdk.Context, zrc20Address common.Address) error

IsValidZRC20 returns an error whenever a ZRC20 is not whitelisted or paused.

func (Keeper) LockZRC20

func (k Keeper) LockZRC20(
	ctx sdk.Context,
	zrc20Address, spender, owner, locker common.Address,
	amount *big.Int,
) error

LockZRC20 locks ZRC20 tokens in the specified address The caller must have approved the locker contract to spend the amount of ZRC20 tokens. Warning: This function does not mint cosmos coins, if the depositor needs to be rewarded it has to be implemented by the caller of this function.

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

func (*Keeper) MintZetaToEVMAccount

func (k *Keeper) MintZetaToEVMAccount(ctx sdk.Context, to sdk.AccAddress, amount *big.Int) error

MintZetaToEVMAccount mints ZETA (gas token) to the given address NOTE: this method should be used with a temporary context, and it should not be committed if the method returns an error

func (*Keeper) MintZetaToFungibleModule

func (k *Keeper) MintZetaToFungibleModule(ctx sdk.Context, amount *big.Int) error

func (Keeper) ProcessV2Deposit

func (k Keeper) ProcessV2Deposit(
	ctx sdk.Context,
	from []byte,
	senderChainID int64,
	zrc20Addr ethcommon.Address,
	to ethcommon.Address,
	amount *big.Int,
	message []byte,
	coinType coin.CoinType,
	isCrossChainCall bool,
) (*evmtypes.MsgEthereumTxResponse, bool, error)

ProcessV2Deposit handles a deposit from an inbound tx with protocol version 2 returns [txResponse, isContractCall, error] isContractCall is true if the message is non empty

func (Keeper) ProcessV2RevertDeposit

func (k Keeper) ProcessV2RevertDeposit(
	ctx sdk.Context,
	inboundSender string,
	amount *big.Int,
	chainID int64,
	coinType coin.CoinType,
	asset string,
	revertAddress ethcommon.Address,
	callOnRevert bool,
	revertMessage []byte,
) error

ProcessV2RevertDeposit handles a revert deposit from an inbound tx with protocol version 2

func (Keeper) QueryChainIDFromContract

func (k Keeper) QueryChainIDFromContract(
	ctx sdk.Context,
	contract common.Address,
) (*big.Int, error)

QueryChainIDFromContract returns the chain id of the chain

func (Keeper) QueryGasLimit

func (k Keeper) QueryGasLimit(ctx sdk.Context, contract common.Address) (*big.Int, error)

QueryGasLimit returns the gas limit for a withdrawal transaction associated with a given zrc20

func (Keeper) QueryProtocolFlatFee

func (k Keeper) QueryProtocolFlatFee(ctx sdk.Context, contract common.Address) (*big.Int, error)

QueryProtocolFlatFee returns the protocol flat fee associated with a given zrc20

func (*Keeper) QuerySystemContractGasCoinZRC20

func (k *Keeper) QuerySystemContractGasCoinZRC20(ctx sdk.Context, chainid *big.Int) (ethcommon.Address, error)

QuerySystemContractGasCoinZRC20 returns the gas coin zrc20 address for the given chain id

func (*Keeper) QueryUniswapV2RouterGetZRC4AmountsIn

func (k *Keeper) QueryUniswapV2RouterGetZRC4AmountsIn(
	ctx sdk.Context,
	amountOut *big.Int,
	inZRC4 ethcommon.Address,
) (*big.Int, error)

QueryUniswapV2RouterGetZRC4AmountsIn returns the amount of ZRC4 tokens needed to buy the given amount of zeta

func (*Keeper) QueryUniswapV2RouterGetZRC4ToZRC4AmountsIn

func (k *Keeper) QueryUniswapV2RouterGetZRC4ToZRC4AmountsIn(
	ctx sdk.Context,
	amountOut *big.Int,
	inZRC4, outZRC4 ethcommon.Address,
) (*big.Int, error)

QueryUniswapV2RouterGetZRC4ToZRC4AmountsIn returns the amount of ZRC4 tokens needed to buy another ZRC4 token, it uses the WZeta contract as a bridge

func (*Keeper) QueryUniswapV2RouterGetZetaAmountsIn

func (k *Keeper) QueryUniswapV2RouterGetZetaAmountsIn(
	ctx sdk.Context,
	amountOut *big.Int,
	outZRC4 ethcommon.Address,
) (*big.Int, error)

QueryUniswapV2RouterGetZetaAmountsIn returns the amount of zeta needed to buy the given amount of ZRC4 tokens

func (*Keeper) QueryWZetaBalanceOf

func (k *Keeper) QueryWZetaBalanceOf(ctx sdk.Context, addr ethcommon.Address) (*big.Int, error)

QueryWZetaBalanceOf returns the balance of the given address in the wzeta contract

func (Keeper) QueryZRC20Data

func (k Keeper) QueryZRC20Data(
	ctx sdk.Context,
	contract common.Address,
) (types.ZRC20Data, error)

QueryZRC20Data returns the data of a deployed ZRC20 contract

func (Keeper) RemoveForeignCoins

func (k Keeper) RemoveForeignCoins(
	ctx sdk.Context,
	zrc20Addr string,
)

RemoveForeignCoins removes a foreignCoins from the store

func (Keeper) RemoveSystemContract

func (k Keeper) RemoveSystemContract(ctx sdk.Context)

RemoveSystemContract removes system contract from the store

func (Keeper) SetForeignCoins

func (k Keeper) SetForeignCoins(ctx sdk.Context, foreignCoins types.ForeignCoins)

SetForeignCoins set a specific foreignCoins in the store from its index

func (Keeper) SetGasCoin

func (k Keeper) SetGasCoin(ctx sdk.Context, chainid *big.Int, address ethcommon.Address) error

func (Keeper) SetGasPrice

func (k Keeper) SetGasPrice(ctx sdk.Context, chainid *big.Int, gasPrice *big.Int) (uint64, error)

SetGasPrice sets gas price on the system contract in zEVM; return the gasUsed and error code

func (Keeper) SetGasZetaPool

func (k Keeper) SetGasZetaPool(ctx sdk.Context, chainid *big.Int, pool ethcommon.Address) error

func (Keeper) SetSystemContract

func (k Keeper) SetSystemContract(ctx sdk.Context, sytemContract types.SystemContract)

SetSystemContract set system contract in the store

func (Keeper) SetupChainGasCoinAndPool

func (k Keeper) SetupChainGasCoinAndPool(
	ctx sdk.Context,
	chainID int64,
	gasAssetName string,
	symbol string,
	decimals uint8,
	gasLimit *big.Int,
) (ethcommon.Address, error)

SetupChainGasCoinAndPool setup gas ZRC20, and ZETA/gas pool for a chain add 0.1gas/0.1wzeta to the pool FIXME: add cointype and use proper gas limit based on cointype/chain

func (Keeper) TotalSupplyZRC4

func (k Keeper) TotalSupplyZRC4(
	ctx sdk.Context,
	contract common.Address,
) (*big.Int, error)

TotalSupplyZRC4 queries the total supply of a given ZRC4 contract

func (Keeper) UnlockZRC20

func (k Keeper) UnlockZRC20(
	ctx sdk.Context,
	zrc20Address, owner, locker common.Address,
	amount *big.Int,
) error

UnlockZRC20 unlocks ZRC20 tokens and sends them to the owner. Warning: Before unlocking ZRC20 tokens, the caller must check if the owner has enough collateral (cosmos coins) to be exchanged (burnt) for the ZRC20 tokens.

func (Keeper) UpdateZRC20GasLimit

func (k Keeper) UpdateZRC20GasLimit(
	ctx sdk.Context,
	zrc20Addr common.Address,
	newGasLimit *big.Int,
) (*evmtypes.MsgEthereumTxResponse, error)

UpdateZRC20GasLimit updates the gas limit for a given ZRC20 contract

func (Keeper) UpdateZRC20ProtocolFlatFee

func (k Keeper) UpdateZRC20ProtocolFlatFee(
	ctx sdk.Context,
	zrc20Addr common.Address,
	newFee *big.Int,
) (*evmtypes.MsgEthereumTxResponse, error)

UpdateZRC20ProtocolFlatFee updates the protocol flat fee for a given ZRC20 contract

func (Keeper) WithdrawFromGasStabilityPool

func (k Keeper) WithdrawFromGasStabilityPool(
	ctx sdk.Context,
	chainID int64,
	amount *big.Int,
) error

WithdrawFromGasStabilityPool burns the ZRC20 from the gas stability pool

func (Keeper) ZETADepositAndCallContract

func (k Keeper) ZETADepositAndCallContract(ctx sdk.Context,
	sender ethcommon.Address,
	to ethcommon.Address,
	inboundSenderChainID int64,
	inboundAmount *big.Int,
	data []byte,
	indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error)

ZETADepositAndCallContract deposits native ZETA to the to address if its an account or if the account does not exist yet If it's not an account it calls onReceive function of the connector contract and provides the address as the destinationAddress .The amount of tokens is minted to the fungible module account, wrapped and sent to the contract

func (Keeper) ZETARevertAndCallContract

func (k Keeper) ZETARevertAndCallContract(ctx sdk.Context,
	sender ethcommon.Address,
	to ethcommon.Address,
	inboundSenderChainID int64,
	destinationChainID int64,
	remainingAmount *big.Int,
	data []byte,
	indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error)

ZETARevertAndCallContract deposits native ZETA to the sender address if its account or if the account does not exist yet If it's not an account it calls onRevert function of the connector contract and provides the sender address as the zetaTxSenderAddress.The amount of tokens is minted to the fungible module account, wrapped and sent to the contract

func (Keeper) ZRC20Allowance

func (k Keeper) ZRC20Allowance(
	ctx sdk.Context,
	zrc20Address, owner, spender common.Address,
) (*big.Int, error)

ZRC20Allowance returns the ZRC20 allowance for a given spender. The allowance has to be previously approved by the ZRC20 tokens owner.

func (Keeper) ZRC20BalanceOf

func (k Keeper) ZRC20BalanceOf(
	ctx sdk.Context,
	zrc20Address, owner common.Address,
) (*big.Int, error)

ZRC20BalanceOf checks the ZRC20 balance of a given EOA.

func (Keeper) ZRC20DepositAndCallContract

func (k Keeper) ZRC20DepositAndCallContract(
	ctx sdk.Context,
	from []byte,
	to eth.Address,
	amount *big.Int,
	senderChainID int64,
	message []byte,
	coinType coin.CoinType,
	asset string,
	protocolContractVersion crosschaintypes.ProtocolContractVersion,
	isCrossChainCall bool,
) (*evmtypes.MsgEthereumTxResponse, bool, error)

ZRC20DepositAndCallContract deposits ZRC20 to the EVM account and calls the contract returns [txResponse, isContractCall, error]

func (Keeper) ZRC20TotalSupply

func (k Keeper) ZRC20TotalSupply(
	ctx sdk.Context,
	zrc20Address common.Address,
) (*big.Int, error)

ZRC20TotalSupply returns the total supply of a ZRC20 token.

func (Keeper) ZRC20Transfer

func (k Keeper) ZRC20Transfer(
	ctx sdk.Context,
	zrc20Address, from, to common.Address,
	amount *big.Int,
) (bool, error)

ZRC20Transfer transfers ZRC20 tokens from the sender to the recipient.

func (Keeper) ZRC20TransferFrom

func (k Keeper) ZRC20TransferFrom(
	ctx sdk.Context,
	zrc20Address, spender, from, to common.Address,
	amount *big.Int,
) (bool, error)

ZRC20TransferFrom transfers ZRC20 tokens "from" to the EOA "to". The transaction is started by the spender. Requisite: the original EOA must have approved the spender to spend the tokens.

Jump to

Keyboard shortcuts

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