keeper

package
v6.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Keeper

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

Keeper of this module maintains collections of erc20.

func NewKeeper

func NewKeeper(
	storeKey storetypes.StoreKey,
	cdc codec.BinaryCodec,
	ak types.AccountKeeper,
	bk types.BankKeeper,
	evmKeeper types.EVMKeeper,
	ibcTransferKeeper types.IBCTransferKeeper,
	authority string,
) Keeper

NewKeeper creates new instances of the erc20 Keeper

func (Keeper) AckAfter

func (k Keeper) AckAfter(ctx sdk.Context, channel string, sequence uint64) error

func (Keeper) AddTokenPair

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

func (Keeper) AliasDenom

AliasDenom returns alias denom

func (Keeper) ConvertCoin

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

func (Keeper) ConvertCoinNativeCoin

func (k Keeper) ConvertCoinNativeCoin(ctx sdk.Context, pair types.TokenPair, sender sdk.AccAddress, receiver common.Address, coin sdk.Coin) 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

func (k Keeper) ConvertCoinNativeERC20(ctx sdk.Context, pair types.TokenPair, sender sdk.AccAddress, receiver common.Address, coin sdk.Coin) 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 `approve` event in logs

func (Keeper) ConvertDenom

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

func (Keeper) ConvertDenomToTarget

func (k Keeper) ConvertDenomToTarget(ctx sdk.Context, from sdk.AccAddress, coin sdk.Coin, fxTarget fxtypes.FxTarget) (sdk.Coin, error)

func (Keeper) ConvertERC20

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

func (Keeper) ConvertERC20NativeCoin

func (k Keeper) ConvertERC20NativeCoin(ctx sdk.Context, pair types.TokenPair, sender common.Address, receiver sdk.AccAddress, amount sdkmath.Int) 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

func (k Keeper) ConvertERC20NativeToken(ctx sdk.Context, pair types.TokenPair, sender common.Address, receiver sdk.AccAddress, amount sdkmath.Int) 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 `approve` event in logs

func (Keeper) DeleteAliasesDenom

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

DeleteAliasesDenom deletes the denom-alias for the given alias

func (Keeper) DeleteIBCTransferRelation

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

func (Keeper) DeleteOutgoingTransferRelation

func (k Keeper) DeleteOutgoingTransferRelation(ctx sdk.Context, moduleName string, txID uint64)

func (Keeper) DenomAliases

DenomAliases returns denom aliases

func (Keeper) DeployUpgradableToken

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

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState

ExportGenesis export module status

func (Keeper) GetAliasDenom

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

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) GetAuthority

func (k Keeper) GetAuthority() string

func (Keeper) GetEnableEVMHook

func (k Keeper) GetEnableEVMHook(ctx sdk.Context) bool

GetEnableEVMHook returns the EnableEVMHook parameter.

func (Keeper) GetEnableErc20

func (k Keeper) GetEnableErc20(ctx sdk.Context) bool

GetEnableErc20 returns the EnableErc20 parameter.

func (Keeper) GetIbcTimeout

func (k Keeper) GetIbcTimeout(ctx sdk.Context) time.Duration

GetIbcTimeout returns the IbcTimeout parameter.

func (Keeper) GetParams

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

GetParams returns the total set of erc20 parameters.

func (Keeper) GetTokenPair

func (k Keeper) GetTokenPair(ctx sdk.Context, tokenOrDenom string) (types.TokenPair, bool)

GetTokenPair - get registered token pair from the token or denom

func (Keeper) GetTokenPairByAddress

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

func (Keeper) GetValidMetadata

func (k Keeper) GetValidMetadata(ctx sdk.Context, denom string) (banktypes.Metadata, bool)

func (Keeper) HasDenomAlias

func (k Keeper) HasDenomAlias(ctx sdk.Context, denom string) (banktypes.Metadata, bool)

func (Keeper) HasOutgoingTransferRelation

func (k Keeper) HasOutgoingTransferRelation(ctx sdk.Context, moduleName string, txID uint64) bool

func (Keeper) HookOutgoingRefund

func (k Keeper) HookOutgoingRefund(ctx sdk.Context, moduleName string, txID uint64, sender sdk.AccAddress, totalCoin sdk.Coin) error

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState)

InitGenesis import module genesis

func (Keeper) IsAliasDenomRegistered

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

IsAliasDenomRegistered check if registered coin alias is registered

func (Keeper) IsConvertedAlias

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

func (Keeper) IsConvertedMetadata

func (k Keeper) IsConvertedMetadata(md banktypes.Metadata) bool

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) IsOriginDenom

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

IsOriginDenom check denom origin denom must be eth0x...|bsc0x...|tronTL...|ibc/ABC... origin: FX, fxUSD(fxevm-ERC20) cross: PUNDIX, PURSE, Other(usdt,usdc)

func (Keeper) IsOriginOrConvertedDenom

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

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, 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) ModuleAddress

func (k Keeper) ModuleAddress() common.Address

ModuleAddress return erc20 module address

func (Keeper) Params

Params return hub contract param

func (Keeper) PrecompileCancelSendToExternal

func (k Keeper) PrecompileCancelSendToExternal(_ sdk.Context, _ uint64, _ sdk.AccAddress) (sdk.Coin, error)

func (Keeper) PrecompileIncreaseBridgeFee

func (k Keeper) PrecompileIncreaseBridgeFee(_ sdk.Context, _ uint64, _ sdk.AccAddress, _ sdk.Coin) 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, channel string, sequence uint64, sender sdk.AccAddress, amount sdk.Coin) error

func (Keeper) RegisterCoin

func (Keeper) RegisterERC20

func (Keeper) RegisterNativeCoin

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

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

func (Keeper) RegisterNativeERC20

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

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

func (Keeper) RemoveTokenPair

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

RemoveTokenPair removes a token pair.

func (Keeper) SetAliasesDenom

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

SetAliasesDenom sets the aliases for the denomination

func (Keeper) SetIBCTransferRelation

func (k Keeper) SetIBCTransferRelation(ctx sdk.Context, channel string, sequence uint64)

func (Keeper) SetOutgoingTransferRelation

func (k Keeper) SetOutgoingTransferRelation(ctx sdk.Context, moduleName string, txID uint64)

func (Keeper) SetParams

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

SetParams sets the parameters in the store

func (Keeper) SetTokenPair

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

func (Keeper) ToTargetDenom

func (k Keeper) ToTargetDenom(ctx sdk.Context, denom, base string, aliases []string, fxTarget fxtypes.FxTarget) string

func (Keeper) ToggleTokenConvert

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

ToggleTokenConvert 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 sdk.AccAddress, receive string, coin, fee sdk.Coin, _ bool) error

TransferAfter ibc transfer after

func (Keeper) UpdateDenomAliases

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

UpdateDenomAliases 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

func (Keeper) UpdateParams

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, ss types.Subspace) Migrator

NewMigrator returns a new Migrator.

func (Migrator) Migrate3to4

func (k Migrator) Migrate3to4(ctx sdk.Context) error

Migrate3to4 migrates the x/erc20 module state from the consensus version 3 to version 4. Specifically, it takes the parameters that are currently stored and managed by the x/params modules and stores them directly into the x/erc20 module state.

Jump to

Keyboard shortcuts

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