keeper

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrappedOriginDenom

func WrappedOriginDenom(name, symbol string) (fxtypes.Contract, string, string)

Types

type Hooks

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

Hooks wrapper struct for erc20 keeper

func (Hooks) PostTxProcessing

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

PostTxProcessing implements EvmHooks.PostTxProcessing

type Keeper

type Keeper struct {
	Router *types.Router
	// contains filtered or unexported fields
}

Keeper of this module maintains collections of erc20.

func NewKeeper

func NewKeeper(
	storeKey sdk.StoreKey,
	cdc codec.BinaryCodec,
	ps paramtypes.Subspace,
	ak types.AccountKeeper,
	bk types.BankKeeper,
	evmKeeper types.EVMKeeper,
	ibcTransferKeeper types.IBCTransferKeeper,
	ibcChannelKeeper types.IBCChannelKeeper,
) Keeper

NewKeeper creates new instances of the erc20 Keeper

func (Keeper) AliasDenom added in v2.2.0

AliasDenom returns alias denom

func (Keeper) BalanceOf

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

BalanceOf returns the balance of an address for ERC20 contract

func (Keeper) CallEVM

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

CallEVM performs a smart contract method call using given args

func (Keeper) CallEVMWithData

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

CallEVMWithData performs a smart contract method call using contract data

func (Keeper) ConvertCoin

ConvertCoin converts Cosmos-native Coins into ERC20 tokens for both Cosmos-native and ERC20 TokenPair Owners

func (Keeper) ConvertCoinNativeCoin added in v2.3.0

func (k Keeper) ConvertCoinNativeCoin(ctx sdk.Context, pair types.TokenPair, msg *types.MsgConvertCoin, receiver common.Address, sender sdk.AccAddress) (*types.MsgConvertCoinResponse, error)

ConvertCoinNativeCoin handles the Coin conversion flow for a native coin token pair:

  • Escrow Coins on module account (Coins are not burned)
  • Mint Tokens and send to receiver
  • Check if token balance increased by amount

func (Keeper) ConvertCoinNativeERC20 added in v2.3.0

func (k Keeper) ConvertCoinNativeERC20(ctx sdk.Context, pair types.TokenPair, msg *types.MsgConvertCoin, receiver common.Address, sender sdk.AccAddress) (*types.MsgConvertCoinResponse, error)

ConvertCoinNativeERC20 handles the Coin conversion flow for a native ERC20 token pair:

  • Escrow Coins on module account
  • Unescrow Tokens that have been previously escrowed with ConvertERC20 and send to receiver
  • Burn escrowed Coins
  • Check if token balance increased by amount
  • Check for unexpected `appove` event in logs

func (Keeper) ConvertDenom added in v2.2.0

ConvertDenom converts coin into other coin, use for multiple chains in the same currency

func (Keeper) ConvertDenomToMany added in v2.3.0

func (k Keeper) ConvertDenomToMany(ctx sdk.Context, from sdk.AccAddress, coin sdk.Coin, target string) (sdk.Coin, error)

ConvertDenomToMany handles the Denom conversion flow for one to many token pair:

  • Escrow Coins on module account
  • Unescrow Tokens that have been previously escrowed with ConvertDenomToMany and send to receiver
  • Burn escrowed Coins
  • Check if token balance increased by amount

func (Keeper) ConvertDenomToOne added in v2.3.0

func (k Keeper) ConvertDenomToOne(ctx sdk.Context, from sdk.AccAddress, coin sdk.Coin) (sdk.Coin, error)

ConvertDenomToOne handles the Denom conversion flow for many to one token pair:

  • Escrow Coins on module account (Coins are not burned)
  • Mint Tokens and send to from address
  • Check if token balance increased by amount

func (Keeper) ConvertERC20

ConvertERC20 converts ERC20 tokens into Cosmos-native Coins for both Cosmos-native and ERC20 TokenPair Owners

func (Keeper) ConvertERC20NativeCoin added in v2.3.0

func (k Keeper) ConvertERC20NativeCoin(ctx sdk.Context, pair types.TokenPair, msg *types.MsgConvertERC20, receiver sdk.AccAddress, sender common.Address) (*types.MsgConvertERC20Response, error)

ConvertERC20NativeCoin handles the erc20 conversion flow for a native coin token pair:

  • Burn escrowed tokens
  • Unescrow coins that have been previously escrowed with ConvertCoin
  • Check if coin balance increased by amount
  • Check if token balance decreased by amount

func (Keeper) ConvertERC20NativeToken added in v2.3.0

func (k Keeper) ConvertERC20NativeToken(ctx sdk.Context, pair types.TokenPair, msg *types.MsgConvertERC20, receiver sdk.AccAddress, sender common.Address) (*types.MsgConvertERC20Response, error)

ConvertERC20NativeToken handles the erc20 conversion flow for a native erc20 token pair:

  • Escrow tokens on module account (Don't burn as module is not contract owner)
  • Mint coins on module
  • Send minted coins to the receiver
  • Check if coin balance increased by amount
  • Check if token balance decreased by amount
  • Check for unexpected `appove` event in logs

func (Keeper) CreateCoinMetadata

func (k Keeper) CreateCoinMetadata(ctx sdk.Context, contract common.Address) (*banktypes.Metadata, string, string, error)

CreateCoinMetadata generates the metadata to represent the ERC20 token on functionX.

func (Keeper) CreateContractWithCode

func (k Keeper) CreateContractWithCode(ctx sdk.Context, addr common.Address, code []byte) error

func (Keeper) DeleteAliasesDenom added in v2.3.0

func (k Keeper) DeleteAliasesDenom(ctx sdk.Context, aliases ...string)

DeleteAliasesDenom deletes the denom-alias for the given alias

func (Keeper) DeleteDenomMap added in v2.3.0

func (k Keeper) DeleteDenomMap(ctx sdk.Context, denom string)

DeleteDenomMap deletes the token pair id for the given denom

func (Keeper) DeleteERC20Map added in v2.3.0

func (k Keeper) DeleteERC20Map(ctx sdk.Context, erc20 common.Address)

DeleteERC20Map deletes the token pair id for the given address

func (Keeper) DeleteTokenPair

func (k Keeper) DeleteTokenPair(ctx sdk.Context, id []byte)

DeleteTokenPair deletes the token pair for the given id

func (Keeper) DenomAliases added in v2.2.0

DenomAliases returns denom aliases

func (Keeper) DeployContract

func (k Keeper) DeployContract(ctx sdk.Context, from common.Address, abi abi.ABI, bin []byte, constructorData ...interface{}) (common.Address, error)

func (Keeper) DeployERC1967Proxy

func (k Keeper) DeployERC1967Proxy(ctx sdk.Context, from, logicAddr common.Address, logicData ...byte) (common.Address, error)

func (Keeper) DeployERC20Contract

func (k Keeper) DeployERC20Contract(ctx sdk.Context, coinMetadata banktypes.Metadata) (common.Address, error)

DeployERC20Contract creates and deploys an ERC20 contract on the EVM with the erc20 module account as owner.

func (Keeper) DeployUpgradableToken

func (k Keeper) DeployUpgradableToken(ctx sdk.Context, from common.Address, name, symbol string, decimals uint8, origin bool) (common.Address, error)

func (Keeper) GetAliasDenom added in v2.2.0

func (k Keeper) GetAliasDenom(ctx sdk.Context, alias string) []byte

GetAliasDenom returns the denom for the given alias

func (Keeper) GetAllTokenPairs

func (k Keeper) GetAllTokenPairs(ctx sdk.Context) []types.TokenPair

GetAllTokenPairs - get all registered token tokenPairs

func (Keeper) GetDenomMap

func (k Keeper) GetDenomMap(ctx sdk.Context, denom string) []byte

GetDenomMap returns the token pair id for the given denomination

func (Keeper) GetERC20Map

func (k Keeper) GetERC20Map(ctx sdk.Context, erc20 common.Address) []byte

GetERC20Map returns the token pair id for the given address

func (Keeper) GetIBCTransferHash

func (k Keeper) GetIBCTransferHash(ctx sdk.Context, port, channel string, sequence uint64) (common.Hash, bool)

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams returns the total set of erc20 parameters.

func (Keeper) GetRouter

func (k Keeper) GetRouter() *types.Router

func (Keeper) GetTokenPair

func (k Keeper) GetTokenPair(ctx sdk.Context, id []byte) (types.TokenPair, bool)

GetTokenPair - get registered token pair from the identifier

func (Keeper) GetTokenPairByAddress

func (k Keeper) GetTokenPairByAddress(ctx sdk.Context, address common.Address) (types.TokenPair, bool)

func (Keeper) GetTokenPairID

func (k Keeper) GetTokenPairID(ctx sdk.Context, token string) []byte

GetTokenPairID returns the pair id from either of the registered tokens.

func (Keeper) HashIBCTransferHash

func (k Keeper) HashIBCTransferHash(ctx sdk.Context, port, channel string, sequence uint64) bool

func (*Keeper) Hooks

func (k *Keeper) Hooks() Hooks

Hooks Return the wrapper struct

func (Keeper) InitializeUpgradable

func (k Keeper) InitializeUpgradable(ctx sdk.Context, from, contract common.Address, abi abi.ABI, data ...interface{}) error

func (Keeper) IsAliasDenomRegistered added in v2.2.0

func (k Keeper) IsAliasDenomRegistered(ctx sdk.Context, alias string) bool

IsAliasDenomRegistered check if registered coin alias is registered

func (Keeper) IsDenomRegistered

func (k Keeper) IsDenomRegistered(ctx sdk.Context, denom string) bool

IsDenomRegistered check if registered coin denom is registered

func (Keeper) IsERC20Registered

func (k Keeper) IsERC20Registered(ctx sdk.Context, erc20 common.Address) bool

IsERC20Registered check if registered ERC20 token is registered

func (Keeper) IsManyToOneDenom added in v2.2.0

func (k Keeper) IsManyToOneDenom(ctx sdk.Context, denom string) (bool, error)

func (Keeper) IsTokenPairRegistered

func (k Keeper) IsTokenPairRegistered(ctx sdk.Context, id []byte) bool

IsTokenPairRegistered - check if registered token tokenPair is registered

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MintingEnabled

func (k Keeper) MintingEnabled(ctx sdk.Context, sender, receiver sdk.AccAddress, token string) (types.TokenPair, error)

MintingEnabled checks that:

  • the global parameter for intrarelaying is enabled
  • minting is enabled for the given (erc20,coin) token pair
  • recipient address is not on the blocked list
  • bank module transfers are enabled for the Cosmos coin

func (Keeper) Params

Params return hub contract param

func (Keeper) ProcessRelayToken

func (k Keeper) ProcessRelayToken(ctx sdk.Context, fip20ABI abi.ABI, txHash common.Hash, pair types.TokenPair, from common.Address, amount *big.Int) error

func (Keeper) QueryERC20

func (k Keeper) QueryERC20(ctx sdk.Context, contract common.Address) (types.ERC20Data, error)

QueryERC20 returns the data of a deployed ERC20 contract

func (Keeper) RefundAfter

func (k Keeper) RefundAfter(ctx sdk.Context, sourcePort, sourceChannel string, sequence uint64, sender sdk.AccAddress, receiver string, amount sdk.Coin) error

func (Keeper) RegisterCoin

func (k Keeper) RegisterCoin(ctx sdk.Context, coinMetadata banktypes.Metadata) (*types.TokenPair, error)

RegisterCoin deploys an erc20 contract and creates the token pair for the existing cosmos coin

func (Keeper) RegisterERC20

func (k Keeper) RegisterERC20(ctx sdk.Context, contract common.Address) (*types.TokenPair, error)

RegisterERC20 creates a cosmos coin and registers the token pair between the coin and the ERC20

func (Keeper) RelayConvertCoin

func (k Keeper) RelayConvertCoin(ctx sdk.Context, sender sdk.AccAddress, receiver common.Address, coin sdk.Coin) error

func (Keeper) RelayConvertDenomToMany added in v2.2.1

func (k Keeper) RelayConvertDenomToMany(ctx sdk.Context, from sdk.AccAddress, coin sdk.Coin, target string) (sdk.Coin, error)

func (Keeper) RelayConvertDenomToOne added in v2.2.1

func (k Keeper) RelayConvertDenomToOne(ctx sdk.Context, from sdk.AccAddress, coin sdk.Coin) (sdk.Coin, error)

func (Keeper) RelayTokenProcessing

func (k Keeper) RelayTokenProcessing(ctx sdk.Context, _ common.Address, _ *common.Address, receipt *ethtypes.Receipt) error

RelayTokenProcessing relay token from evm contract to chain address

func (Keeper) RelayTransferCrossChainProcessing

func (k Keeper) RelayTransferCrossChainProcessing(ctx sdk.Context, from common.Address, to *common.Address, receipt *ethtypes.Receipt) (err error)

func (Keeper) RemoveTokenPair added in v2.3.0

func (k Keeper) RemoveTokenPair(ctx sdk.Context, tokenPair types.TokenPair)

RemoveTokenPair removes a token pair.

func (Keeper) SendCoins added in v2.3.0

func (k Keeper) SendCoins(ctx sdk.Context, from, to sdk.AccAddress, coins sdk.Coins) error

func (Keeper) SetAliasesDenom added in v2.2.0

func (k Keeper) SetAliasesDenom(ctx sdk.Context, denom string, aliases ...string)

SetAliasesDenom sets the aliases for the denomination

func (Keeper) SetDenomMap

func (k Keeper) SetDenomMap(ctx sdk.Context, denom string, id []byte)

SetDenomMap sets the token pair id for the denomination

func (Keeper) SetERC20Map

func (k Keeper) SetERC20Map(ctx sdk.Context, erc20 common.Address, id []byte)

SetERC20Map sets the token pair id for the given address

func (*Keeper) SetIBCChannelKeeperForTest

func (k *Keeper) SetIBCChannelKeeperForTest(t types.IBCChannelKeeper)

func (Keeper) SetIBCTransferHash added in v2.3.0

func (k Keeper) SetIBCTransferHash(ctx sdk.Context, port, channel string, sequence uint64, hash common.Hash)

func (*Keeper) SetIBCTransferKeeperForTest

func (k *Keeper) SetIBCTransferKeeperForTest(t types.IBCTransferKeeper)

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams sets the erc20 parameters to the param space.

func (*Keeper) SetRouter

func (k *Keeper) SetRouter(rtr *types.Router)

SetRouter sets the Router in IBC Transfer Keeper and seals it. The method panics if there is an existing router that's already sealed.

func (Keeper) SetTokenPair

func (k Keeper) SetTokenPair(ctx sdk.Context, tokenPair types.TokenPair)

SetTokenPair stores a token pair

func (Keeper) SupportInfiniteGasMeter added in v2.2.1

func (k Keeper) SupportInfiniteGasMeter(ctx sdk.Context) (sdk.Context, sdk.GasMeter)

func (Keeper) SupportRefundGasWithGasMeter added in v2.2.1

func (k Keeper) SupportRefundGasWithGasMeter(ctx sdk.Context, gasMater sdk.GasMeter) sdk.Context

func (Keeper) ToggleRelay

func (k Keeper) ToggleRelay(ctx sdk.Context, token string) (types.TokenPair, error)

ToggleRelay toggles relaying for a given token pair

func (Keeper) TokenPair

TokenPair returns a given registered token pair

func (Keeper) TokenPairs

TokenPairs return registered pairs

func (Keeper) TransferAfter

func (k Keeper) TransferAfter(ctx sdk.Context, sender, receive string, coin, fee sdk.Coin) error

func (Keeper) TransferChainHandler

func (k Keeper) TransferChainHandler(ctx sdk.Context, from sdk.AccAddress, to string, amount, fee sdk.Coin, target string, _ *ethtypes.Receipt) error

func (Keeper) TransferIBCHandler

func (k Keeper) TransferIBCHandler(ctx sdk.Context, from sdk.AccAddress, to string, amount, fee sdk.Coin, target string, receipt *ethtypes.Receipt) error

func (Keeper) UpdateDenomAlias added in v2.2.0

func (k Keeper) UpdateDenomAlias(ctx sdk.Context, denom, alias string) (bool, error)

UpdateDenomAlias update denom alias if alias not registered, add to denom alias if alias registered with denom, remove from denom alias if alias registered, but not with denom, return error

type Migrator

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator

func NewMigrator(keeper Keeper) Migrator

NewMigrator returns a new Migrator.

Jump to

Keyboard shortcuts

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