keeper

package
v0.0.0-...-bd096cc Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: LGPL-3.0 Imports: 36 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 is a wrapper for calling the EVM PostTxProcessing hook on the module keeper

type Keeper

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

Keeper of this module maintains collections of erc20.

func NewKeeper

NewKeeper creates new instances of the erc20 Keeper

func (Keeper) BalanceOf

func (k Keeper) BalanceOf(
	ctx sdk.Context,
	abi abi.ABI,
	contract, account common.Address,
) *big.Int

BalanceOf queries an account's balance for a given 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

func (k Keeper) ConvertCoin(
	goCtx context.Context,
	msg *types.MsgConvertCoin,
) (*types.MsgConvertCoinResponse, error)

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

func (Keeper) ConvertCoinToERC20FromPacket

func (k Keeper) ConvertCoinToERC20FromPacket(ctx sdk.Context, data transfertypes.FungibleTokenPacketData) error

ConvertCoinToERC20FromPacket converts the IBC coin to ERC20 after refunding the sender

func (Keeper) ConvertERC20

func (k Keeper) ConvertERC20(
	goCtx context.Context,
	msg *types.MsgConvertERC20,
) (*types.MsgConvertERC20Response, error)

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

func (Keeper) CreateCoinMetadata

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

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

func (Keeper) DeleteTokenPair

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

DeleteTokenPair removes a token pair.

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

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

GetEnableEVMHook returns true if the EVM hooks are enabled

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, id []byte) (types.TokenPair, bool)

GetTokenPair gets a registered token pair from the identifier.

func (Keeper) GetTokenPairID

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

GetTokenPairID returns the pair id from either of the registered tokens. Hex address or Denom can be used as token argument.

func (Keeper) GetTokenPairs

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

GetTokenPairs - get all registered token tokenPairs

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Return the wrapper struct

func (Keeper) IsDenomRegistered

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

IsDenomRegistered check if registered coin denom is registered

func (Keeper) IsERC20Enabled

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

IsERC20Enabled returns true if the module logic is enabled

func (Keeper) IsERC20Registered

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

IsERC20Registered check if registered ERC20 token is registered

func (Keeper) IsTokenPairRegistered

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

IsTokenPairRegistered - check if registered token tokenPair is registered

func (Keeper) IterateTokenPairs

func (k Keeper) IterateTokenPairs(ctx sdk.Context, cb func(tokenPair types.TokenPair) (stop bool))

IterateTokenPairs iterates over all the stored token pairs

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 erc20 conversion 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) OnAcknowledgementPacket

OnAcknowledgementPacket responds to the the success or failure of a packet acknowledgement written on the receiving chain. If the acknowledgement was a success then nothing occurs. If the acknowledgement failed, then the sender is refunded and then the IBC Coins are converted to ERC20.

func (Keeper) OnRecvPacket

OnRecvPacket performs the ICS20 middleware receive callback for automatically converting an IBC Coin to their ERC20 representation. For the conversion to succeed, the IBC denomination must have previously been registered via governance. Note that the native staking denomination (e.g. "aevmos"), is excluded from the conversion.

CONTRACT: This middleware MUST be executed transfer after the ICS20 OnRecvPacket Return acknowledgement and continue with the next layer of the IBC middleware stack if: - ERC20s are disabled - Denomination is native staking token - The base denomination is not registered as ERC20

func (Keeper) OnTimeoutPacket

OnTimeoutPacket converts the IBC coin to ERC20 after refunding the sender since the original packet sent was never received and has been timed out.

func (Keeper) Params

Params returns the params of the erc20 module

func (Keeper) PostTxProcessing

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

PostTxProcessing implements EvmHooks.PostTxProcessing. The EVM hooks allows users to convert ERC20s to Cosmos Coins by sending an Ethereum tx transfer to the module account address. This hook applies to both token pairs that have been registered through a native Cosmos coin or an ERC20 token. If token pair has been registered with:

  • coin -> burn tokens and transfer escrowed coins on module to sender
  • token -> escrow tokens on module account and mint & transfer coins to sender

Note that the PostTxProcessing hook is only called by sending an EVM transaction that triggers `ApplyTransaction`. A cosmos tx with a `ConvertERC20` msg does not trigger the hook as it only calls `ApplyMessage`.

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

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

SetParams sets the erc20 parameters to the param space.

func (Keeper) SetTokenPair

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

SetTokenPair stores a token pair

func (Keeper) ToggleConversion

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

ToggleConversion toggles conversion for a given token pair

func (Keeper) TokenPair

TokenPair returns a given registered token pair

func (Keeper) TokenPairs

TokenPairs returns all registered pairs

func (*Keeper) UpdateParams

func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error)

UpdateParams implements the gRPC MsgServer interface. After a successful governance vote it updates the parameters in the keeper only if the requested authority is the Cosmos SDK governance module account

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

NewMigrator returns a new Migrator.

func (Migrator) Migrate2to3

func (m Migrator) Migrate2to3(ctx sdk.Context) error

Jump to

Keyboard shortcuts

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