Documentation
¶
Index ¶
- func AllInvariants(bankK types.BankKeeper, k Keeper) sdk.Invariant
- func BackedCoinsInvariant(_ types.BankKeeper, k Keeper) sdk.Invariant
- func CosmosCoinsFullyBackedInvariant(bankK types.BankKeeper, k Keeper) sdk.Invariant
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NewQueryServerImpl(k Keeper) types.QueryServer
- func RegisterInvariants(ir sdk.InvariantRegistry, bankK types.BankKeeper, k Keeper)
- type Keeper
- func (k Keeper) AddBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdkmath.Int) error
- func (k Keeper) BurnConversionPairCoin(ctx sdk.Context, pair types.ConversionPair, coin sdk.Coin, ...) error
- func (k Keeper) BurnERC20(ctx sdk.Context, contractAddr types.InternalEVMAddress, ...) error
- func (k Keeper) CallEVM(ctx sdk.Context, abi abi.ABI, from common.Address, ...) (*evmtypes.MsgEthereumTxResponse, error)
- func (k Keeper) CallEVMWithData(ctx sdk.Context, from common.Address, contract *types.InternalEVMAddress, ...) (*evmtypes.MsgEthereumTxResponse, error)
- func (k Keeper) ConvertCoinToERC20(ctx sdk.Context, initiatorAccount sdk.AccAddress, ...) error
- func (k *Keeper) ConvertCosmosCoinFromERC20(ctx sdk.Context, initiator types.InternalEVMAddress, receiver sdk.AccAddress, ...) error
- func (k *Keeper) ConvertCosmosCoinToERC20(ctx sdk.Context, initiator sdk.AccAddress, receiver types.InternalEVMAddress, ...) error
- func (k Keeper) ConvertERC20ToCoin(ctx sdk.Context, initiator types.InternalEVMAddress, receiver sdk.AccAddress, ...) error
- func (k Keeper) DeployKavaWrappedCosmosCoinERC20Contract(ctx sdk.Context, token types.AllowedCosmosCoinERC20Token) (types.InternalEVMAddress, error)
- func (k Keeper) DeployTestMintableERC20Contract(ctx sdk.Context, name string, symbol string, decimals uint8) (types.InternalEVMAddress, error)
- func (k Keeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) *types.Account
- func (k Keeper) GetAllAccounts(ctx sdk.Context) (accounts []types.Account)
- func (k Keeper) GetAllowedTokenMetadata(ctx sdk.Context, cosmosDenom string) (types.AllowedCosmosCoinERC20Token, bool)
- func (k Keeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress) sdkmath.Int
- func (k *Keeper) GetDeployedCosmosCoinContract(ctx sdk.Context, cosmosDenom string) (types.InternalEVMAddress, bool)
- func (k Keeper) GetEnabledConversionPairFromDenom(ctx sdk.Context, denom string) (types.ConversionPair, error)
- func (k Keeper) GetEnabledConversionPairFromERC20Address(ctx sdk.Context, address types.InternalEVMAddress) (types.ConversionPair, error)
- func (k *Keeper) GetOrDeployCosmosCoinERC20Contract(ctx sdk.Context, tokenInfo types.AllowedCosmosCoinERC20Token) (types.InternalEVMAddress, error)
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) IterateAllAccounts(ctx sdk.Context, cb func(types.Account) bool)
- func (k Keeper) IterateAllDeployedCosmosCoinContracts(ctx sdk.Context, cb func(types.DeployedCosmosCoinContract) bool)
- func (k Keeper) LockERC20Tokens(ctx sdk.Context, pair types.ConversionPair, amount *big.Int, ...) error
- func (k Keeper) MintConversionPairCoin(ctx sdk.Context, pair types.ConversionPair, amount *big.Int, ...) (sdk.Coin, error)
- func (k Keeper) MintERC20(ctx sdk.Context, contractAddr types.InternalEVMAddress, ...) error
- func (k Keeper) QueryERC20BalanceOf(ctx sdk.Context, contractAddr types.InternalEVMAddress, ...) (*big.Int, error)
- func (k Keeper) QueryERC20TotalSupply(ctx sdk.Context, contractAddr types.InternalEVMAddress) (*big.Int, error)
- func (k Keeper) RemoveBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdkmath.Int) error
- func (k Keeper) SendBalance(ctx sdk.Context, senderAddr sdk.AccAddress, recipientAddr sdk.AccAddress, ...) error
- func (k Keeper) SetAccount(ctx sdk.Context, account types.Account) error
- func (k Keeper) SetBalance(ctx sdk.Context, addr sdk.AccAddress, bal sdkmath.Int) error
- func (k *Keeper) SetDeployedCosmosCoinContract(ctx sdk.Context, cosmosDenom string, contractAddress types.InternalEVMAddress) error
- func (k *Keeper) SetEvmKeeper(evmKeeper types.EvmKeeper)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) UnlockERC20Tokens(ctx sdk.Context, pair types.ConversionPair, amount *big.Int, ...) error
- type Migrator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllInvariants ¶
func AllInvariants(bankK types.BankKeeper, k Keeper) sdk.Invariant
AllInvariants runs all invariants of the swap module
func BackedCoinsInvariant ¶
func BackedCoinsInvariant(_ types.BankKeeper, k Keeper) sdk.Invariant
BackedCoinsInvariant iterates all conversion pairs and asserts that the sdk.Coin balances are less than the module ERC20 balance. **Note:** This compares <= and not == as anyone can send tokens to the ERC20 contract address and break the invariant if a strict equal check.
func CosmosCoinsFullyBackedInvariant ¶
func CosmosCoinsFullyBackedInvariant(bankK types.BankKeeper, k Keeper) sdk.Invariant
CosmosCoinsFullyBackedInvariant ensures the total supply of ERC20 representations of sdk.Coins match the balances in the module account.
This invariant depends on the fact that coins can only become part of the balance through conversion to ERC20s. If in the future sdk.Coins can be sent directly to the module account, or the module account balance can be increased in any other way, this invariant should be changed from checking that the balance equals the total supply, to check that the balance is greater than or equal to the total supply.
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the evmutil MsgServer interface for the provided Keeper.
func NewQueryServerImpl ¶
func NewQueryServerImpl(k Keeper) types.QueryServer
NewQueryServerImpl creates a new server for handling gRPC queries.
func RegisterInvariants ¶
func RegisterInvariants(ir sdk.InvariantRegistry, bankK types.BankKeeper, k Keeper)
RegisterInvariants registers the swap module invariants
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper of the evmutil store. This keeper stores additional data related to evm accounts.
func NewKeeper ¶
func NewKeeper( cdc codec.Codec, storeKey storetypes.StoreKey, params paramtypes.Subspace, bk types.BankKeeper, ak types.AccountKeeper, ) Keeper
NewKeeper creates an evmutil keeper.
func (Keeper) AddBalance ¶
AddBalance increments the agrbc balance of an address.
func (Keeper) BurnConversionPairCoin ¶
func (k Keeper) BurnConversionPairCoin( ctx sdk.Context, pair types.ConversionPair, coin sdk.Coin, account sdk.AccAddress, ) error
BurnConversionPairCoin transfers the provided amount to the module account then burns it.
func (Keeper) BurnERC20 ¶
func (k Keeper) BurnERC20( ctx sdk.Context, contractAddr types.InternalEVMAddress, initiator types.InternalEVMAddress, amount *big.Int, ) error
BurnERC20 burns the token amount from the initiator's balance.
func (Keeper) CallEVM ¶
func (k Keeper) CallEVM( ctx sdk.Context, abi abi.ABI, from common.Address, contract types.InternalEVMAddress, 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 *types.InternalEVMAddress, data []byte, ) (*evmtypes.MsgEthereumTxResponse, error)
CallEVMWithData performs a smart contract method call using contract data Derived from tharsis/evmos https://github.com/tharsis/evmos/blob/ee54f496551df937915ff6f74a94732a35abc505/x/erc20/keeper/evm.go
func (Keeper) ConvertCoinToERC20 ¶
func (k Keeper) ConvertCoinToERC20( ctx sdk.Context, initiatorAccount sdk.AccAddress, receiverAccount types.InternalEVMAddress, coin sdk.Coin, ) error
ConvertCoinToERC20 converts an sdk.Coin from the originating account to an ERC20 to the receiver account.
func (*Keeper) ConvertCosmosCoinFromERC20 ¶
func (k *Keeper) ConvertCosmosCoinFromERC20( ctx sdk.Context, initiator types.InternalEVMAddress, receiver sdk.AccAddress, coin sdk.Coin, ) error
ConvertCosmosCoinFromERC20 burns the ERC20 wrapper of the cosmos coin and sends the underlying sdk coin form the module account to the receiver.
func (*Keeper) ConvertCosmosCoinToERC20 ¶
func (k *Keeper) ConvertCosmosCoinToERC20( ctx sdk.Context, initiator sdk.AccAddress, receiver types.InternalEVMAddress, amount sdk.Coin, ) error
ConvertCosmosCoinToERC20 locks the initiator's sdk.Coin in the module account and mints the receiver a corresponding amount of an ERC20 representing the Coin. If a conversion has never been made before and no contract exists, one will be deployed. Only denoms registered to the AllowedCosmosDenoms param may be converted.
func (Keeper) ConvertERC20ToCoin ¶
func (k Keeper) ConvertERC20ToCoin( ctx sdk.Context, initiator types.InternalEVMAddress, receiver sdk.AccAddress, contractAddr types.InternalEVMAddress, amount sdkmath.Int, ) error
ConvertERC20ToCoin converts an ERC20 coin from the originating account to an sdk.Coin to the receiver account.
func (Keeper) DeployKavaWrappedCosmosCoinERC20Contract ¶
func (k Keeper) DeployKavaWrappedCosmosCoinERC20Contract( ctx sdk.Context, token types.AllowedCosmosCoinERC20Token, ) (types.InternalEVMAddress, error)
DeployKavaWrappedCosmosCoinERC20Contract validates token details and then deploys an ERC20 contract with the token metadata. This method does NOT check if a token for the provided SdkDenom has already been deployed.
func (Keeper) DeployTestMintableERC20Contract ¶
func (k Keeper) DeployTestMintableERC20Contract( ctx sdk.Context, name string, symbol string, decimals uint8, ) (types.InternalEVMAddress, error)
DeployTestMintableERC20Contract deploys an ERC20 contract on the EVM as the module account and returns the address of the contract. This contract has minting permissions for the module account. Derived from tharsis/evmos https://github.com/tharsis/evmos/blob/ee54f496551df937915ff6f74a94732a35abc505/x/erc20/keeper/evm.go
func (Keeper) GetAccount ¶
GetAccount returns the account for a given address.
func (Keeper) GetAllAccounts ¶
GetAllAccounts returns all accounts.
func (Keeper) GetAllowedTokenMetadata ¶
func (k Keeper) GetAllowedTokenMetadata(ctx sdk.Context, cosmosDenom string) (types.AllowedCosmosCoinERC20Token, bool)
GetAllowedTokenMetadata gets the token metadata for the given cosmosDenom if it is allowed. Returns the metadata if allowed, and a bool indicating if the denom was in the allow list or not.
func (Keeper) GetBalance ¶
GetBalance returns the total balance of agrbc for a given account by address.
func (*Keeper) GetDeployedCosmosCoinContract ¶
func (k *Keeper) GetDeployedCosmosCoinContract(ctx sdk.Context, cosmosDenom string) (types.InternalEVMAddress, bool)
SetDeployedCosmosCoinContract gets a deployed ERC20KavaWrappedCosmosCoin contract address by cosmos denom Returns the stored address and a bool indicating if it was found or not
func (Keeper) GetEnabledConversionPairFromDenom ¶
func (k Keeper) GetEnabledConversionPairFromDenom( ctx sdk.Context, denom string, ) (types.ConversionPair, error)
GetEnabledConversionPairFromDenom returns an ConversionPair from the sdk.Coin denom.
func (Keeper) GetEnabledConversionPairFromERC20Address ¶
func (k Keeper) GetEnabledConversionPairFromERC20Address( ctx sdk.Context, address types.InternalEVMAddress, ) (types.ConversionPair, error)
GetEnabledConversionPairFromERC20Address returns an ConversionPair from the internal contract address.
func (*Keeper) GetOrDeployCosmosCoinERC20Contract ¶
func (k *Keeper) GetOrDeployCosmosCoinERC20Contract( ctx sdk.Context, tokenInfo types.AllowedCosmosCoinERC20Token, ) (types.InternalEVMAddress, error)
GetOrDeployCosmosCoinERC20Contract checks the module store for a deployed contract for the given token info and returns it if preset. Otherwise, it deploys and registers the contract.
func (Keeper) IterateAllAccounts ¶
IterateAllAccounts iterates over all accounts. If true is returned from the callback, iteration is halted.
func (Keeper) IterateAllDeployedCosmosCoinContracts ¶
func (k Keeper) IterateAllDeployedCosmosCoinContracts(ctx sdk.Context, cb func(types.DeployedCosmosCoinContract) bool)
IterateAllDeployedCosmosCoinContracts iterates through all the deployed ERC20 contracts representing cosmos-sdk coins. If true is returned from the callback, iteration is halted.
func (Keeper) LockERC20Tokens ¶
func (k Keeper) LockERC20Tokens( ctx sdk.Context, pair types.ConversionPair, amount *big.Int, initiator types.InternalEVMAddress, ) error
LockERC20Tokens transfers the given amount of a conversion pair ERC20 token from the initiator account to the module account.
func (Keeper) MintConversionPairCoin ¶
func (k Keeper) MintConversionPairCoin( ctx sdk.Context, pair types.ConversionPair, amount *big.Int, recipient sdk.AccAddress, ) (sdk.Coin, error)
MintConversionPairCoin mints the given amount of a ConversionPair denom and sends it to the provided address.
func (Keeper) MintERC20 ¶
func (k Keeper) MintERC20( ctx sdk.Context, contractAddr types.InternalEVMAddress, receiver types.InternalEVMAddress, amount *big.Int, ) error
MintERC20 mints the given amount of an ERC20 token to an address. This is unchecked and should only be called after permission and enabled ERC20 checks.
func (Keeper) QueryERC20BalanceOf ¶
func (k Keeper) QueryERC20BalanceOf( ctx sdk.Context, contractAddr types.InternalEVMAddress, account types.InternalEVMAddress, ) (*big.Int, error)
QueryERC20BalanceOf makes a contract call to the balanceOf method of the ERC20 contract to get the ERC20 balance of the given account.
func (Keeper) QueryERC20TotalSupply ¶
func (k Keeper) QueryERC20TotalSupply( ctx sdk.Context, contractAddr types.InternalEVMAddress, ) (*big.Int, error)
QueryERC20TotalSupply makes a contract call to the totalSupply method of the ERC20 contract to get the total supply of the token.
func (Keeper) RemoveBalance ¶
RemoveBalance decrements the agrbc balance of an address.
func (Keeper) SendBalance ¶
func (k Keeper) SendBalance(ctx sdk.Context, senderAddr sdk.AccAddress, recipientAddr sdk.AccAddress, amt sdkmath.Int) error
SendBalance transfers the agrbc balance from sender addr to recipient addr.
func (Keeper) SetAccount ¶
SetAccount sets the account for a given address.
func (Keeper) SetBalance ¶
SetBalance sets the total balance of agrbc for a given account by address.
func (*Keeper) SetDeployedCosmosCoinContract ¶
func (k *Keeper) SetDeployedCosmosCoinContract(ctx sdk.Context, cosmosDenom string, contractAddress types.InternalEVMAddress) error
SetDeployedCosmosCoinContract stores a single deployed ERC20KavaWrappedCosmosCoin contract address
func (*Keeper) SetEvmKeeper ¶
func (Keeper) UnlockERC20Tokens ¶
func (k Keeper) UnlockERC20Tokens( ctx sdk.Context, pair types.ConversionPair, amount *big.Int, receiver types.InternalEVMAddress, ) error
UnlockERC20Tokens transfers the given amount of a conversion pair ERC20 token to the provided account.