Documentation ¶
Index ¶
- Constants
- Variables
- func AllInvariants(bankK types.BankKeeper, k Keeper) sdk.Invariant
- func BackedCoinsInvariant(_ types.BankKeeper, k Keeper) sdk.Invariant
- func FullyBackedInvariant(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)
- func SmallBalancesInvariant(_ types.BankKeeper, k Keeper) sdk.Invariant
- func SplitArotoCoins(coins sdk.Coins) (sdk.Coin, sdk.Int, error)
- func ValidateEvmCoins(coins sdk.Coins) error
- type EvmBankKeeper
- func (k EvmBankKeeper) BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
- func (k EvmBankKeeper) ConvertArotoToUroto(ctx sdk.Context, addr sdk.AccAddress) error
- func (k EvmBankKeeper) ConvertOneUrotoToArotoIfNeeded(ctx sdk.Context, addr sdk.AccAddress, arotoNeeded sdk.Int) error
- func (k EvmBankKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
- func (k EvmBankKeeper) GetModuleAddress(moduleName string) sdk.AccAddress
- func (k EvmBankKeeper) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
- func (k EvmBankKeeper) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, ...) error
- func (k EvmBankKeeper) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, ...) error
- type Keeper
- func (k Keeper) AddBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Int) error
- func (k Keeper) BurnConversionPairCoin(ctx sdk.Context, pair types.ConversionPair, coin sdk.Coin, ...) 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) ConvertERC20ToCoin(ctx sdk.Context, initiator types.InternalEVMAddress, receiver sdk.AccAddress, ...) 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) GetBalance(ctx sdk.Context, addr sdk.AccAddress) sdk.Int
- 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) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) IterateAllAccounts(ctx sdk.Context, cb func(types.Account) 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) RemoveBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.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 sdk.Int) 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
Constants ¶
const ( // EvmDenom is the gas denom used by the evm EvmDenom = "aroto" // CosmosDenom is the gas denom used by the roto app CosmosDenom = "uroto" )
Variables ¶
var ConversionMultiplier = sdk.NewInt(1_000_000_000_000)
ConversionMultiplier is the conversion multiplier between aroto and uroto
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 FullyBackedInvariant ¶
func FullyBackedInvariant(bankK types.BankKeeper, k Keeper) sdk.Invariant
FullyBackedInvariant ensures all minor balances are backed by the coins in the module account.
The module balance can be greater than the sum of all minor balances. This can happen in rare cases where the evm module burns tokens.
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
func SmallBalancesInvariant ¶
func SmallBalancesInvariant(_ types.BankKeeper, k Keeper) sdk.Invariant
SmallBalancesInvariant ensures all minor balances are less than the overflow amount, beyond this they should be converted to the major denom.
func SplitArotoCoins ¶
SplitArotoCoins splits aroto coins to the equivalent uroto coins and any remaining aroto balance. An error will be returned if the coins are not valid or if the coins are not the aroto denom.
func ValidateEvmCoins ¶
ValidateEvmCoins validates the coins from evm is valid and is the EvmDenom (aroto).
Types ¶
type EvmBankKeeper ¶
type EvmBankKeeper struct {
// contains filtered or unexported fields
}
EvmBankKeeper is a BankKeeper wrapper for the x/evm module to allow the use of the 18 decimal aroto coin on the evm. x/evm consumes gas and send coins by minting and burning aroto coins in its module account and then sending the funds to the target account. This keeper uses both the uroto coin and a separate aroto balance to manage the extra percision needed by the evm.
func NewEvmBankKeeper ¶
func NewEvmBankKeeper(arotoKeeper Keeper, bk types.BankKeeper, ak types.AccountKeeper) EvmBankKeeper
func (EvmBankKeeper) BurnCoins ¶
BurnCoins burns aroto coins by burning the equivalent uroto coins and any remaining aroto coins. It will panic if the module account does not exist or is unauthorized.
func (EvmBankKeeper) ConvertArotoToUroto ¶
func (k EvmBankKeeper) ConvertArotoToUroto(ctx sdk.Context, addr sdk.AccAddress) error
ConvertArotoToUroto converts all available aroto to uroto for a given AccAddress.
func (EvmBankKeeper) ConvertOneUrotoToArotoIfNeeded ¶
func (k EvmBankKeeper) ConvertOneUrotoToArotoIfNeeded(ctx sdk.Context, addr sdk.AccAddress, arotoNeeded sdk.Int) error
ConvertOneUrotoToArotoIfNeeded converts 1 uroto to aroto for an address if its aroto balance is smaller than the arotoNeeded amount.
func (EvmBankKeeper) GetBalance ¶
func (k EvmBankKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
GetBalance returns the total **spendable** balance of aroto for a given account by address.
func (EvmBankKeeper) GetModuleAddress ¶
func (k EvmBankKeeper) GetModuleAddress(moduleName string) sdk.AccAddress
func (EvmBankKeeper) MintCoins ¶
MintCoins mints aroto coins by minting the equivalent uroto coins and any remaining aroto coins. It will panic if the module account does not exist or is unauthorized.
func (EvmBankKeeper) SendCoinsFromAccountToModule ¶
func (k EvmBankKeeper) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
SendCoinsFromAccountToModule transfers aroto coins from an AccAddress to a ModuleAccount. It will panic if the module account does not exist.
func (EvmBankKeeper) SendCoinsFromModuleToAccount ¶
func (k EvmBankKeeper) SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromModuleToAccount transfers aroto coins from a ModuleAccount to an AccAddress. It will panic if the module account does not exist. An error is returned if the recipient address is black-listed or if sending the tokens fails.
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 sdk.StoreKey, params paramtypes.Subspace, bk types.BankKeeper, ak types.AccountKeeper, ) Keeper
NewKeeper creates an evmutil keeper.
func (Keeper) AddBalance ¶
AddBalance increments the aroto 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) 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) ConvertERC20ToCoin ¶
func (k Keeper) ConvertERC20ToCoin( ctx sdk.Context, initiator types.InternalEVMAddress, receiver sdk.AccAddress, contractAddr types.InternalEVMAddress, amount sdk.Int, ) error
ConvertERC20ToCoin converts an ERC20 coin from the originating account to an sdk.Coin to the receiver account.
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) GetBalance ¶
GetBalance returns the total balance of aroto for a given account by address.
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) IterateAllAccounts ¶
IterateAllAccounts iterates over all accounts. 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)
func (Keeper) RemoveBalance ¶
RemoveBalance decrements the aroto balance of an address.
func (Keeper) SendBalance ¶
func (k Keeper) SendBalance(ctx sdk.Context, senderAddr sdk.AccAddress, recipientAddr sdk.AccAddress, amt sdk.Int) error
SendBalance transfers the aroto 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 aroto for a given account by 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.