keeper

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EvmDenom is the gas denom used by the evm
	EvmDenom = "agert"

	// CosmosDenom is the gas denom used by the gert app
	CosmosDenom = "ugert"
)

Variables

View Source
var ConversionMultiplier = sdk.NewInt(1_000_000_000_000)

ConversionMultiplier is the conversion multiplier between agert and ugert

Functions

func AllInvariants

func AllInvariants(bankK types.BankKeeper, k Keeper) sdk.Invariant

AllInvariants runs all invariants of the swap module

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 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 SplitAgertCoins

func SplitAgertCoins(coins sdk.Coins) (sdk.Coin, sdk.Int, error)

SplitAgertCoins splits agert coins to the equivalent ugert coins and any remaining agert balance. An error will be returned if the coins are not valid or if the coins are not the agert denom.

func ValidateEvmCoins

func ValidateEvmCoins(coins sdk.Coins) error

ValidateEvmCoins validates the coins from evm is valid and is the EvmDenom (agert).

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 agert coin on the evm. x/evm consumes gas and send coins by minting and burning agert coins in its module account and then sending the funds to the target account. This keeper uses both the ugert coin and a separate agert balance to manage the extra percision needed by the evm.

func NewEvmBankKeeper

func NewEvmBankKeeper(agertKeeper Keeper, bk types.BankKeeper, ak types.AccountKeeper) EvmBankKeeper

func (EvmBankKeeper) BurnCoins

func (k EvmBankKeeper) BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error

BurnCoins burns agert coins by burning the equivalent ugert coins and any remaining agert coins. It will panic if the module account does not exist or is unauthorized.

func (EvmBankKeeper) ConvertAgertToUgert

func (k EvmBankKeeper) ConvertAgertToUgert(ctx sdk.Context, addr sdk.AccAddress) error

ConvertAgertToUgert converts all available agert to ugert for a given AccAddress.

func (EvmBankKeeper) ConvertOneUgertToAgertIfNeeded

func (k EvmBankKeeper) ConvertOneUgertToAgertIfNeeded(ctx sdk.Context, addr sdk.AccAddress, agertNeeded sdk.Int) error

ConvertOneUgertToAgertIfNeeded converts 1 ugert to agert for an address if its agert balance is smaller than the agertNeeded 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 agert for a given account by address.

func (EvmBankKeeper) GetModuleAddress

func (k EvmBankKeeper) GetModuleAddress(moduleName string) sdk.AccAddress

func (EvmBankKeeper) MintCoins

func (k EvmBankKeeper) MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error

MintCoins mints agert coins by minting the equivalent ugert coins and any remaining agert 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 agert 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 agert 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) Keeper

NewKeeper creates an evmutil keeper.

func (Keeper) AddBalance

func (k Keeper) AddBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Int) error

AddBalance increments the agert balance of an address.

func (Keeper) GetAccount

func (k Keeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) *types.Account

GetAccount returns the account for a given address.

func (Keeper) GetAllAccounts

func (k Keeper) GetAllAccounts(ctx sdk.Context) (accounts []types.Account)

GetAllAccounts returns all accounts.

func (Keeper) GetBalance

func (k Keeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress) sdk.Int

GetBalance returns the total balance of agert for a given account by address.

func (Keeper) IterateAllAccounts

func (k Keeper) IterateAllAccounts(ctx sdk.Context, cb func(types.Account) bool)

IterateAllAccounts iterates over all accounts. If true is returned from the callback, iteration is halted.

func (Keeper) RemoveBalance

func (k Keeper) RemoveBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Int) error

RemoveBalance decrements the agert 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 agert balance from sender addr to recipient addr.

func (Keeper) SetAccount

func (k Keeper) SetAccount(ctx sdk.Context, account types.Account) error

SetAccount sets the account for a given address.

func (Keeper) SetBalance

func (k Keeper) SetBalance(ctx sdk.Context, addr sdk.AccAddress, bal sdk.Int) error

SetBalance sets the total balance of agert for a given account by address.

Jump to

Keyboard shortcuts

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