keeper

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// KeyPrefixHoldCoin is the prefix of a hold entry for an address and single denom.
	KeyPrefixHoldCoin = []byte{0x00}
)

Keys for store prefixes. Items are stored with the following keys:

Coin on hold: - 0x00<addr len (1 byte)><addr><denom> -> <amount>

Functions

func CreateHoldCoinKey

func CreateHoldCoinKey(addr sdk.AccAddress, denom string) []byte

CreateHoldCoinKey creates a hold coin key for the provided address and denom.

func CreateHoldCoinKeyAddrPrefix

func CreateHoldCoinKeyAddrPrefix(addr sdk.AccAddress) []byte

CreateHoldCoinKeyAddrPrefix creates a hold coin key prefix containing the provided address. It's useful for iterating over all funds on hold for an address.

func HoldAccountBalancesInvariant

func HoldAccountBalancesInvariant(keeper Keeper) sdk.Invariant

HoldAccountBalancesInvariant checks that all funds on hold are also otherwise unlocked in the account.

func ParseHoldCoinKey

func ParseHoldCoinKey(key []byte) (sdk.AccAddress, string)

ParseHoldCoinKey parses a full hold coin key into its address and denom.

func ParseHoldCoinKeyUnprefixed

func ParseHoldCoinKeyUnprefixed(key []byte) (sdk.AccAddress, string)

ParseHoldCoinKeyUnprefixed parses a hold coin key without the type prefix into its address and denom.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, keeper Keeper)

RegisterInvariants registers all quarantine invariants.

func UnmarshalHoldCoinValue

func UnmarshalHoldCoinValue(value []byte) (sdkmath.Int, error)

UnmarshalHoldCoinValue parses the store value of a hold coin entry back into it's Int form.

Types

type Keeper

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

func NewKeeper

func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, bankKeeper hold.BankKeeper) Keeper

func (Keeper) AddHold

func (k Keeper) AddHold(ctx sdk.Context, addr sdk.AccAddress, funds sdk.Coins, reason string) error

AddHold puts the provided funds on hold for the provided account.

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) *hold.GenesisState

ExportGenesis creates a GenesisState from the current state store.

func (Keeper) GetAllAccountHolds

func (k Keeper) GetAllAccountHolds(ctx sdk.Context) ([]*hold.AccountHold, error)

GetAllAccountHolds gets all the AccountHold entries currently in the state store.

func (Keeper) GetAllHolds

func (k Keeper) GetAllHolds(goCtx context.Context, req *hold.GetAllHoldsRequest) (*hold.GetAllHoldsResponse, error)

GetAllHolds returns all addresses with funds on hold, and the amount held.

func (Keeper) GetHoldCoin

func (k Keeper) GetHoldCoin(ctx sdk.Context, addr sdk.AccAddress, denom string) (sdk.Coin, error)

GetHoldCoin gets the amount of a denom on hold for a given account. Will return a zero Coin of the given denom if the store does not have an entry for it.

func (Keeper) GetHoldCoins

func (k Keeper) GetHoldCoins(ctx sdk.Context, addr sdk.AccAddress) (sdk.Coins, error)

GetHoldCoins gets all funds on hold for a given account.

func (Keeper) GetHolds

func (k Keeper) GetHolds(goCtx context.Context, req *hold.GetHoldsRequest) (*hold.GetHoldsResponse, error)

GetHolds looks up the funds that are on hold for an address.

func (Keeper) GetLockedCoins

func (k Keeper) GetLockedCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins

GetLockedCoins gets all the coins that are on hold for the given address.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(origCtx sdk.Context, genState *hold.GenesisState)

InitGenesis loads the provided GenesisState into the state store. Panics if there's an error.

func (Keeper) IterateAllHolds

func (k Keeper) IterateAllHolds(ctx sdk.Context, process func(sdk.AccAddress, sdk.Coin) bool) error

IterateAllHolds iterates over all hold coin entries for all accounts. The process function should return whether to stop: false = keep iterating, true = stop. If an error is encountered while reading from the store, that entry is skipped and an error is returned for it when iteration is completed.

func (Keeper) IterateHolds

func (k Keeper) IterateHolds(ctx sdk.Context, addr sdk.AccAddress, process func(sdk.Coin) bool) error

IterateHolds iterates over all funds on hold for a given account. The process function should return whether to stop: false = keep iterating, true = stop. If an error is encountered while reading from the store, that entry is skipped and an error is returned for it when iteration is completed.

func (Keeper) ReleaseHold

func (k Keeper) ReleaseHold(ctx sdk.Context, addr sdk.AccAddress, funds sdk.Coins) error

ReleaseHold releases the hold on the provided funds for the provided account.

func (Keeper) ValidateNewHold

func (k Keeper) ValidateNewHold(ctx sdk.Context, addr sdk.AccAddress, funds sdk.Coins) error

ValidateNewHold checks the account's spendable balance to make sure it has at least as much as the funds provided.

Jump to

Keyboard shortcuts

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