keeper

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// query balance path
	QueryBalance = "balances"
)

Variables

This section is empty.

Functions

func NewQuerier

func NewQuerier(k Keeper) sdk.Querier

NewQuerier returns a new sdk.Keeper instance.

func NonnegativeBalanceInvariant

func NonnegativeBalanceInvariant(ak types.AccountKeeper) sdk.Invariant

NonnegativeBalanceInvariant checks that all accounts in the application have non-negative balances

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, ak types.AccountKeeper)

RegisterInvariants registers the bank module invariants

Types

type BaseKeeper

type BaseKeeper struct {
	BaseSendKeeper
	// contains filtered or unexported fields
}

BaseKeeper manages transfers between accounts. It implements the Keeper interface.

func NewBaseKeeper

func NewBaseKeeper(ak types.AccountKeeper,
	paramSpace params.Subspace,
	codespace sdk.CodespaceType, blacklistedAddrs map[string]bool) BaseKeeper

NewBaseKeeper returns a new BaseKeeper

func (BaseKeeper) DelegateTokens

func (keeper BaseKeeper) DelegateTokens(ctx sdk.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Tokens) sdk.Error

DelegateTokens performs delegation by deducting amt tokens from an account with address addr. For vesting accounts, delegations amounts are tracked for both vesting and vested tokens. The tokens are then transferred from the delegator address to a ModuleAccount address. If any of the delegation amounts are negative, an error is returned.

func (BaseKeeper) UndelegateTokens

func (keeper BaseKeeper) UndelegateTokens(ctx sdk.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Tokens) sdk.Error

UndelegateTokens performs undelegation by crediting amt tokens to an account with address addr. For vesting accounts, undelegation amounts are tracked for both vesting and vested tokens. The tokens are then transferred from a ModuleAccount address to the delegator address. If any of the undelegation amounts are negative, an error is returned.

type BaseSendKeeper

type BaseSendKeeper struct {
	BaseViewKeeper
	// contains filtered or unexported fields
}

BaseSendKeeper only allows transfers between accounts without the possibility of creating tokens. It implements the SendKeeper interface.

func NewBaseSendKeeper

func NewBaseSendKeeper(ak types.AccountKeeper,
	paramSpace params.Subspace, codespace sdk.CodespaceType, blacklistedAddrs map[string]bool) BaseSendKeeper

NewBaseSendKeeper returns a new BaseSendKeeper.

func (BaseSendKeeper) AddTokens

func (keeper BaseSendKeeper) AddTokens(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Tokens) (sdk.Tokens, sdk.Error)

AddTokens adds amt to the tokens at the addr.

func (BaseSendKeeper) BlacklistedAddr

func (keeper BaseSendKeeper) BlacklistedAddr(addr sdk.AccAddress) bool

BlacklistedAddr checks if a given address is blacklisted (i.e restricted from receiving funds)

func (BaseSendKeeper) GetSendEnabled

func (keeper BaseSendKeeper) GetSendEnabled(ctx sdk.Context) bool

GetSendEnabled returns the current SendEnabled nolint: errcheck

func (BaseSendKeeper) InputOutputTokens

func (keeper BaseSendKeeper) InputOutputTokens(ctx sdk.Context, inputs []types.Input, outputs []types.Output) sdk.Error

InputOutputTokens handles a list of inputs and outputs

func (BaseSendKeeper) SendTokens

func (keeper BaseSendKeeper) SendTokens(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Tokens) sdk.Error

SendTokens moves tokens from one account to another

func (BaseSendKeeper) SetSendEnabled

func (keeper BaseSendKeeper) SetSendEnabled(ctx sdk.Context, enabled bool)

SetSendEnabled sets the send enabled

func (BaseSendKeeper) SetTokens

func (keeper BaseSendKeeper) SetTokens(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Tokens) sdk.Error

SetTokens sets the tokens at the addr.

func (BaseSendKeeper) SubtractTokens

func (keeper BaseSendKeeper) SubtractTokens(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Tokens) (sdk.Tokens, sdk.Error)

SubtractTokens subtracts amt from the tokens at the addr.

CONTRACT: If the account is a vesting account, the amount has to be spendable.

type BaseViewKeeper

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

BaseViewKeeper implements a read only keeper implementation of ViewKeeper.

func NewBaseViewKeeper

func NewBaseViewKeeper(ak types.AccountKeeper, codespace sdk.CodespaceType) BaseViewKeeper

NewBaseViewKeeper returns a new BaseViewKeeper.

func (BaseViewKeeper) Codespace

func (keeper BaseViewKeeper) Codespace() sdk.CodespaceType

Codespace returns the keeper's codespace.

func (BaseViewKeeper) GetTokens

func (keeper BaseViewKeeper) GetTokens(ctx sdk.Context, addr sdk.AccAddress) sdk.Tokens

GetTokens returns the tokens at the addr.

func (BaseViewKeeper) HasTokens

func (keeper BaseViewKeeper) HasTokens(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Tokens) bool

HasTokens returns whether or not an account has at least amt tokens.

func (BaseViewKeeper) Logger

func (keeper BaseViewKeeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

type Keeper

type Keeper interface {
	SendKeeper

	DelegateTokens(ctx sdk.Context, delegatorAddr, moduleAccAddr sdk.AccAddress, amt sdk.Tokens) sdk.Error
	UndelegateTokens(ctx sdk.Context, moduleAccAddr, delegatorAddr sdk.AccAddress, amt sdk.Tokens) sdk.Error
}

Keeper defines a module interface that facilitates the transfer of tokens between accounts.

type SendKeeper

type SendKeeper interface {
	ViewKeeper

	InputOutputTokens(ctx sdk.Context, inputs []types.Input, outputs []types.Output) sdk.Error
	SendTokens(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Tokens) sdk.Error

	SubtractTokens(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Tokens) (sdk.Tokens, sdk.Error)
	AddTokens(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Tokens) (sdk.Tokens, sdk.Error)
	SetTokens(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Tokens) sdk.Error

	GetSendEnabled(ctx sdk.Context) bool
	SetSendEnabled(ctx sdk.Context, enabled bool)

	BlacklistedAddr(addr sdk.AccAddress) bool
}

SendKeeper defines a module interface that facilitates the transfer of tokens between accounts without the possibility of creating tokens.

type ViewKeeper

type ViewKeeper interface {
	GetTokens(ctx sdk.Context, addr sdk.AccAddress) sdk.Tokens
	HasTokens(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Tokens) bool

	Codespace() sdk.CodespaceType
}

ViewKeeper defines a module interface that facilitates read only access to account balances.

Jump to

Keyboard shortcuts

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