keeper

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: Apache-2.0 Imports: 14 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants runs all invariants of the X/precisebank module.

func BalancedFractionalTotalInvariant

func BalancedFractionalTotalInvariant(k Keeper) sdk.Invariant

BalancedFractionalTotalInvariant checks that the sum of fractional balances and the remainder amount is divisible by the conversion factor without any leftover amount.

func FractionalDenomNotInBankInvariant

func FractionalDenomNotInBankInvariant(k Keeper) sdk.Invariant

FractionalDenomNotInBankInvariant checks that the bank does not hold any fractional denoms. These assets, e.g. aatom, should only exist in the x/precisebank module as this is a decimal extension of uatom that shares the same total supply and is effectively the same asset. uatom held by this module in x/bank backs all fractional balances in x/precisebank. If aatom somehow ends up in x/bank, then it would both break all expectations of this module as well as be double-counted in the total supply.

func NewQueryServerImpl

func NewQueryServerImpl(k Keeper) types.QueryServer

NewQueryServerImpl creates a new server for handling gRPC queries.

func RegisterInvariants

func RegisterInvariants(
	ir sdk.InvariantRegistry,
	k Keeper,
)

RegisterInvariants registers the x/precisebank module invariants

func ReserveBacksFractionsInvariant

func ReserveBacksFractionsInvariant(k Keeper) sdk.Invariant

ReserveBacksFractionsInvariant checks that the total amount of backing coins in the reserve is equal to the total amount of fractional balances, such that the backing is always available to redeem all fractional balances and there are no extra coins in the reserve that are not backing any fractional balances.

func TotalSupplyInvariant

func TotalSupplyInvariant(k Keeper) sdk.Invariant

TotalSupplyInvariant checks that the total supply of the asset is equal to the sum of the fractional balances and the remainder amount.

func ValidFractionalAmountsInvariant

func ValidFractionalAmountsInvariant(k Keeper) sdk.Invariant

ValidFractionalAmountsInvariant checks that all individual fractional balances are valid.

func ValidRemainderAmountInvariant

func ValidRemainderAmountInvariant(k Keeper) sdk.Invariant

ValidRemainderAmountInvariant checks that the remainder amount is valid.

Types

type Keeper

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

Keeper defines the precisebank module's keeper

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey storetypes.StoreKey,
	bk types.BankKeeper,
	ak types.AccountKeeper,
) Keeper

NewKeeper creates a new keeper

func (Keeper) BurnCoins

func (k Keeper) BurnCoins(goCtx context.Context, moduleName string, amt sdk.Coins) error

BurnCoins burns coins deletes coins from the balance of the module account. It will panic if the module account does not exist or is unauthorized.

func (*Keeper) DeleteFractionalBalance

func (k *Keeper) DeleteFractionalBalance(
	ctx sdk.Context,
	address sdk.AccAddress,
)

DeleteFractionalBalance deletes the fractional balance for an address.

func (*Keeper) DeleteRemainderAmount

func (k *Keeper) DeleteRemainderAmount(
	ctx sdk.Context,
)

DeleteRemainderAmount deletes the internal remainder amount.

func (Keeper) GetBalance

func (k Keeper) GetBalance(
	goCtx context.Context,
	addr sdk.AccAddress,
	denom string,
) sdk.Coin

GetBalance returns the balance of a specific denom for an address. This will return the extended balance for the ExtendedCoinDenom, and the regular balance for all other denoms.

func (*Keeper) GetFractionalBalance

func (k *Keeper) GetFractionalBalance(ctx sdk.Context, address sdk.AccAddress) sdkmath.Int

GetFractionalBalance returns the fractional balance for an address.

func (*Keeper) GetRemainderAmount

func (k *Keeper) GetRemainderAmount(
	ctx sdk.Context,
) sdkmath.Int

GetRemainderAmount returns the internal remainder amount.

func (Keeper) GetSupply

func (k Keeper) GetSupply(ctx context.Context, denom string) sdk.Coin

func (*Keeper) GetTotalSumFractionalBalances

func (k *Keeper) GetTotalSumFractionalBalances(ctx sdk.Context) sdkmath.Int

GetTotalSumFractionalBalances returns the sum of all fractional balances.

func (Keeper) IsSendEnabledCoins

func (k Keeper) IsSendEnabledCoins(ctx context.Context, coins ...sdk.Coin) error

IsSendEnabledCoins uses the parent x/bank keeper to check the coins provided and returns an ErrSendDisabled if any of the coins are not configured for sending. Returns nil if sending is enabled for all provided coin. Note: This method is not used directly by x/evm, but is still required as part of authtypes.BankKeeper. x/evm uses auth methods that require this interface.

func (Keeper) IterateAccountBalances

func (k Keeper) IterateAccountBalances(ctx context.Context, account sdk.AccAddress, cb func(coin sdk.Coin) bool)

func (*Keeper) IterateFractionalBalances

func (k *Keeper) IterateFractionalBalances(
	ctx sdk.Context,
	cb func(address sdk.AccAddress, amount sdkmath.Int) (stop bool),
)

IterateFractionalBalances iterates over all fractional balances in the store and performs a callback function.

func (Keeper) IterateTotalSupply

func (k Keeper) IterateTotalSupply(ctx context.Context, cb func(coin sdk.Coin) bool)

func (Keeper) MintCoins

func (k Keeper) MintCoins(goCtx context.Context, moduleName string, amt sdk.Coins) error

MintCoins creates new coins from thin air and adds it to the module account. If ExtendedCoinDenom is provided, the corresponding fractional amount is added to the module state. It will panic if the module account does not exist or is unauthorized.

func (Keeper) SendCoins

func (k Keeper) SendCoins(
	goCtx context.Context,
	from, to sdk.AccAddress,
	amt sdk.Coins,
) error

SendCoins transfers amt coins from a sending account to a receiving account. An error is returned upon failure. This handles transfers including ExtendedCoinDenom and supports non-ExtendedCoinDenom transfers by passing through to x/bank.

func (Keeper) SendCoinsFromAccountToModule

func (k Keeper) SendCoinsFromAccountToModule(
	goCtx context.Context,
	senderAddr sdk.AccAddress,
	recipientModule string,
	amt sdk.Coins,
) error

SendCoinsFromModuleToModule transfers coins from a ModuleAccount to another. It will panic if either module account does not exist. An error is returned if the recipient module is the x/precisebank module account or if sending the tokens fails.

func (Keeper) SendCoinsFromModuleToAccount

func (k Keeper) SendCoinsFromModuleToAccount(
	goCtx context.Context,
	senderModule string,
	recipientAddr sdk.AccAddress,
	amt sdk.Coins,
) error

SendCoinsFromModuleToAccount transfers 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 blocked, if the sender is the x/precisebank module account, or if sending the tokens fails.

func (Keeper) SendCoinsFromModuleToModule

func (k Keeper) SendCoinsFromModuleToModule(
	goCtx context.Context,
	senderModule string,
	recipientModule string,
	amt sdk.Coins,
) error

SendCoinsFromModuleToModule transfers coins from a ModuleAccount to another. It will panic if either module account does not exist. An error is returned if the recipient module is the x/precisebank module account or if sending the tokens fails.

func (*Keeper) SetFractionalBalance

func (k *Keeper) SetFractionalBalance(
	ctx sdk.Context,
	address sdk.AccAddress,
	amount sdkmath.Int,
)

SetFractionalBalance sets the fractional balance for an address.

func (*Keeper) SetRemainderAmount

func (k *Keeper) SetRemainderAmount(
	ctx sdk.Context,
	amount sdkmath.Int,
)

SetRemainderAmount sets the internal remainder amount.

func (Keeper) SpendableCoin

func (k Keeper) SpendableCoin(
	goCtx context.Context,
	addr sdk.AccAddress,
	denom string,
) sdk.Coin

SpendableCoins returns the total balances of spendable coins for an account by address. If the account has no spendable coins, an empty Coins slice is returned.

Jump to

Keyboard shortcuts

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