Documentation ¶
Index ¶
- func DeployContract(ctx sdk.Context, evmKeeper types.EVMKeeper, ...) (common.Address, error)
- func DeployERC20Contract(ctx sdk.Context, k Keeper, ak types.AccountKeeper, ...) (common.Address, error)
- type Hooks
- type Keeper
- func (k Keeper) BalanceOf(ctx sdk.Context, abi abi.ABI, contract, account common.Address) *big.Int
- func (k Keeper) CallEVM(ctx sdk.Context, abi abi.ABI, from, contract common.Address, commit bool, ...) (*evmtypes.MsgEthereumTxResponse, error)
- func (k Keeper) CallEVMWithData(ctx sdk.Context, from common.Address, contract *common.Address, data []byte, ...) (*evmtypes.MsgEthereumTxResponse, error)
- func (k Keeper) ConvertCoin(goCtx context.Context, msg *types.MsgConvertCoin) (*types.MsgConvertCoinResponse, error)
- func (k Keeper) ConvertERC20(goCtx context.Context, msg *types.MsgConvertERC20) (*types.MsgConvertERC20Response, error)
- func (k Keeper) CreateCoinMetadata(ctx sdk.Context, contract common.Address) (*banktypes.Metadata, error)
- func (k Keeper) DeleteTokenPair(ctx sdk.Context, tokenPair types.TokenPair)
- func (k Keeper) DeployERC20Contract(ctx sdk.Context, coinMetadata banktypes.Metadata) (common.Address, error)
- func (k Keeper) GetAllTokenPairDenomIndexes(ctx sdk.Context) []types.TokenPairDenomIndex
- func (k Keeper) GetAllTokenPairERC20AddressIndexes(ctx sdk.Context) []types.TokenPairERC20AddressIndex
- func (k Keeper) GetAuthority() string
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetTokenPair(ctx sdk.Context, id []byte) (types.TokenPair, bool)
- func (k Keeper) GetTokenPairID(ctx sdk.Context, token string) []byte
- func (k Keeper) GetTokenPairIdByDenom(ctx sdk.Context, denom string) []byte
- func (k Keeper) GetTokenPairIdByERC20Addr(ctx sdk.Context, erc20 common.Address) []byte
- func (k Keeper) GetTokenPairs(ctx sdk.Context) []types.TokenPair
- func (k Keeper) Hooks() Hooks
- func (k Keeper) IsDenomRegistered(ctx sdk.Context, denom string) bool
- func (k Keeper) IsERC20Registered(ctx sdk.Context, erc20 common.Address) bool
- func (k Keeper) IsTokenPairRegistered(ctx sdk.Context, id []byte) bool
- func (k Keeper) IterateTokenPairDenomIndex(ctx sdk.Context, cb func(denom string, id []byte) (stop bool))
- func (k Keeper) IterateTokenPairERC20AddressIndex(ctx sdk.Context, cb func(erc20Addr common.Address, id []byte) (stop bool))
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) MintingEnabled(ctx sdk.Context, sender, receiver sdk.AccAddress, token string) (types.TokenPair, error)
- func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) QueryERC20(ctx sdk.Context, contract common.Address) (types.ERC20Data, error)
- func (k Keeper) RegisterCoin(ctx sdk.Context, coinMetadata banktypes.Metadata) (*types.TokenPair, error)
- func (k Keeper) RegisterCoinProposal(goCtx context.Context, req *types.MsgRegisterCoin) (*types.MsgRegisterCoinResponse, error)
- func (k Keeper) RegisterERC20(ctx sdk.Context, contract common.Address) (*types.TokenPair, error)
- func (k Keeper) RegisterERC20Proposal(goCtx context.Context, req *types.MsgRegisterERC20) (*types.MsgRegisterERC20Response, error)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetTokenPair(ctx sdk.Context, tokenPair types.TokenPair)
- func (k Keeper) SetTokenPairIdByDenom(ctx sdk.Context, denom string, id []byte)
- func (k Keeper) SetTokenPairIdByERC20Addr(ctx sdk.Context, erc20 common.Address, id []byte)
- func (k Keeper) ToggleConversion(ctx sdk.Context, token string) (types.TokenPair, error)
- func (k Keeper) ToggleTokenConversionProposal(goCtx context.Context, req *types.MsgToggleTokenConversion) (*types.MsgToggleTokenConversionResponse, error)
- func (k Keeper) TokenPair(c context.Context, req *types.QueryTokenPairRequest) (*types.QueryTokenPairResponse, error)
- func (k Keeper) TokenPairs(c context.Context, req *types.QueryTokenPairsRequest) (*types.QueryTokenPairsResponse, error)
- func (k Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error)
- type Migrator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeployContract ¶
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. 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`.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper of this module maintains collections of erc20.
func NewKeeper ¶
func NewKeeper( storeService store.KVStoreService, cdc codec.BinaryCodec, ps paramtypes.Subspace, ak types.AccountKeeper, bk types.BankKeeper, evmKeeper types.EVMKeeper, authority string, ) Keeper
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) 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 lyfebloc.
func (Keeper) DeleteTokenPair ¶
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) GetAllTokenPairDenomIndexes ¶
func (k Keeper) GetAllTokenPairDenomIndexes(ctx sdk.Context) []types.TokenPairDenomIndex
GetAllTokenPairDenomIndexes returns all token pair denom indexes
func (Keeper) GetAllTokenPairERC20AddressIndexes ¶
func (k Keeper) GetAllTokenPairERC20AddressIndexes(ctx sdk.Context) []types.TokenPairERC20AddressIndex
GetAllTokenPairERC20AddressIndexes returns all token pair ERC20 address indexes
func (Keeper) GetAuthority ¶
GetAuthority returns the x/erc20 module's authority.
func (Keeper) GetTokenPair ¶
GetTokenPair - get registered token pair from the identifier
func (Keeper) GetTokenPairID ¶
GetTokenPairID returns the pair id from either of the registered tokens.
func (Keeper) GetTokenPairIdByDenom ¶
GetTokenPairIdByDenom returns the token pair id for the given denomination
func (Keeper) GetTokenPairIdByERC20Addr ¶
GetTokenPairIdByERC20Addr returns the token pair id for the given address
func (Keeper) GetTokenPairs ¶
GetTokenPairs - get all registered token tokenPairs
func (Keeper) IsDenomRegistered ¶
IsDenomRegistered check if registered coin denom is registered
func (Keeper) IsERC20Registered ¶
IsERC20Registered check if registered ERC20 token is registered
func (Keeper) IsTokenPairRegistered ¶
IsTokenPairRegistered - check if registered token tokenPair is registered
func (Keeper) IterateTokenPairDenomIndex ¶
func (k Keeper) IterateTokenPairDenomIndex(ctx sdk.Context, cb func(denom string, id []byte) (stop bool))
IterateTokenPairDenomIndex iterates over all token pair denom indexes
func (Keeper) IterateTokenPairERC20AddressIndex ¶
func (k Keeper) IterateTokenPairERC20AddressIndex(ctx sdk.Context, cb func(erc20Addr common.Address, id []byte) (stop bool))
IterateTokenPairERC20AddressIndex iterates over all token pair ERC20 address indexes
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) Params ¶
func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
Params returns the params of the erc20 module
func (Keeper) QueryERC20 ¶
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) RegisterCoinProposal ¶
func (k Keeper) RegisterCoinProposal(goCtx context.Context, req *types.MsgRegisterCoin) (*types.MsgRegisterCoinResponse, error)
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) RegisterERC20Proposal ¶
func (k Keeper) RegisterERC20Proposal(goCtx context.Context, req *types.MsgRegisterERC20) (*types.MsgRegisterERC20Response, error)
func (Keeper) SetTokenPair ¶
SetTokenPair stores a token pair
func (Keeper) SetTokenPairIdByDenom ¶
SetTokenPairIdByDenom sets the token pair id for the denomination
func (Keeper) SetTokenPairIdByERC20Addr ¶
SetTokenPairIdByERC20Addr sets the token pair id for the given address
func (Keeper) ToggleConversion ¶
ToggleConversion toggles conversion for a given token pair
func (Keeper) ToggleTokenConversionProposal ¶
func (k Keeper) ToggleTokenConversionProposal(goCtx context.Context, req *types.MsgToggleTokenConversion) (*types.MsgToggleTokenConversionResponse, error)
func (Keeper) TokenPair ¶
func (k Keeper) TokenPair(c context.Context, req *types.QueryTokenPairRequest) (*types.QueryTokenPairResponse, error)
TokenPair returns a given registered token pair
func (Keeper) TokenPairs ¶
func (k Keeper) TokenPairs(c context.Context, req *types.QueryTokenPairsRequest) (*types.QueryTokenPairsResponse, error)
TokenPairs returns all registered pairs
func (Keeper) UpdateParams ¶
func (k Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error)