bank

package
v0.11.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
const (
	DefaultCodespace sdk.CodespaceType = "bank"

	CodeInvalidInput   sdk.CodeType = 101
	CodeInvalidOutput  sdk.CodeType = 102
	CodeBurnEmptyCoins sdk.CodeType = 103
)

Bank errors reserve 100 ~ 199.

Variables

This section is empty.

Functions

func ErrBurnEmptyCoins added in v0.10.0

func ErrBurnEmptyCoins(codespace sdk.CodespaceType) sdk.Error

func ErrInvalidInput

func ErrInvalidInput(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidOutput

func ErrInvalidOutput(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrNoInputs

func ErrNoInputs(codespace sdk.CodespaceType) sdk.Error

func ErrNoOutputs

func ErrNoOutputs(codespace sdk.CodespaceType) sdk.Error

func NewHandler

func NewHandler(k Keeper) sdk.Handler

NewHandler returns a handler for "bank" type messages.

func NonnegativeBalanceInvariant added in v0.11.0

func NonnegativeBalanceInvariant(mapper auth.AccountKeeper) sdk.Invariant

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

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec

func TotalCoinsInvariant added in v0.11.0

func TotalCoinsInvariant(mapper auth.AccountKeeper, totalSupplyFn func() sdk.Coins) sdk.Invariant

TotalCoinsInvariant checks that the sum of the coins across all accounts is what is expected

Types

type BaseKeeper

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

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

func NewBaseKeeper

func NewBaseKeeper(am auth.AccountKeeper) BaseKeeper

NewBaseKeeper returns a new BaseKeeper

func (BaseKeeper) AddCoins

func (keeper BaseKeeper) AddCoins(
	ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins,
) (sdk.Coins, sdk.Tags, sdk.Error)

AddCoins adds amt to the coins at the addr.

func (BaseKeeper) BurnCoinsFromAddr added in v0.10.0

func (keeper BaseKeeper) BurnCoinsFromAddr(
	ctx sdk.Context, fromAddr sdk.AccAddress, amt sdk.Coins,
) (sdk.Tags, sdk.Error)

BurnCoins burns coins from one account

func (BaseKeeper) BurnCoinsFromPool added in v0.10.0

func (keeper BaseKeeper) BurnCoinsFromPool(
	ctx sdk.Context, pool string, amt sdk.Coins,
) (sdk.Tags, sdk.Error)

BurnCoins burns coins from one account

func (BaseKeeper) DecreaseLoosenToken added in v0.10.0

func (keeper BaseKeeper) DecreaseLoosenToken(
	ctx sdk.Context, amt sdk.Coins)

SendCoins moves coins from one account to another

func (BaseKeeper) GetBurnedCoins added in v0.10.0

func (keeper BaseKeeper) GetBurnedCoins(ctx sdk.Context) sdk.Coins

GetLoosenCoins returns the burned coins

func (BaseKeeper) GetCoins

func (keeper BaseKeeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins

GetCoins returns the coins at the addr.

func (BaseKeeper) GetLoosenCoins added in v0.10.0

func (keeper BaseKeeper) GetLoosenCoins(ctx sdk.Context) sdk.Coins

GetLoosenCoins returns the total loosen coins

func (BaseKeeper) HasCoins

func (keeper BaseKeeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool

HasCoins returns whether or not an account has at least amt coins.

func (BaseKeeper) IncreaseLoosenToken added in v0.10.0

func (keeper BaseKeeper) IncreaseLoosenToken(
	ctx sdk.Context, amt sdk.Coins)

func (BaseKeeper) InputOutputCoins

func (keeper BaseKeeper) InputOutputCoins(ctx sdk.Context, inputs []Input, outputs []Output) (sdk.Tags, sdk.Error)

InputOutputCoins handles a list of inputs and outputs

func (BaseKeeper) SendCoins

func (keeper BaseKeeper) SendCoins(
	ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins,
) (sdk.Tags, sdk.Error)

SendCoins moves coins from one account to another

func (BaseKeeper) SubtractCoins

func (keeper BaseKeeper) SubtractCoins(
	ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins,
) (sdk.Coins, sdk.Tags, sdk.Error)

SubtractCoins subtracts amt from the coins at the addr.

type BaseSendKeeper

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

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

func NewBaseSendKeeper

func NewBaseSendKeeper(am auth.AccountKeeper) BaseSendKeeper

NewBaseSendKeeper returns a new BaseSendKeeper.

func (BaseSendKeeper) GetBurnedCoins added in v0.10.0

func (keeper BaseSendKeeper) GetBurnedCoins(ctx sdk.Context) sdk.Coins

GetLoosenCoins returns the burned coins

func (BaseSendKeeper) GetCoins

func (keeper BaseSendKeeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins

GetCoins returns the coins at the addr.

func (BaseSendKeeper) GetLoosenCoins added in v0.10.0

func (keeper BaseSendKeeper) GetLoosenCoins(ctx sdk.Context) sdk.Coins

GetLoosenCoins returns the total loosen coins

func (BaseSendKeeper) HasCoins

func (keeper BaseSendKeeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool

HasCoins returns whether or not an account has at least amt coins.

func (BaseSendKeeper) InputOutputCoins

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

InputOutputCoins handles a list of inputs and outputs

func (BaseSendKeeper) SendCoins

func (keeper BaseSendKeeper) SendCoins(
	ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins,
) (sdk.Tags, sdk.Error)

SendCoins moves coins from one account to another

type BaseViewKeeper

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

BaseViewKeeper implements a read only keeper implementation of ViewKeeper.

func NewBaseViewKeeper

func NewBaseViewKeeper(am auth.AccountKeeper) BaseViewKeeper

NewBaseViewKeeper returns a new BaseViewKeeper.

func (BaseViewKeeper) GetBurnedCoins added in v0.10.0

func (keeper BaseViewKeeper) GetBurnedCoins(ctx sdk.Context) sdk.Coins

GetLoosenCoins returns the burned coins

func (BaseViewKeeper) GetCoins

func (keeper BaseViewKeeper) GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins

GetCoins returns the coins at the addr.

func (BaseViewKeeper) GetLoosenCoins added in v0.10.0

func (keeper BaseViewKeeper) GetLoosenCoins(ctx sdk.Context) sdk.Coins

GetLoosenCoins returns the total loosen coins

func (BaseViewKeeper) HasCoins

func (keeper BaseViewKeeper) HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool

HasCoins returns whether or not an account has at least amt coins.

type Input

type Input struct {
	Address sdk.AccAddress `json:"address"`
	Coins   sdk.Coins      `json:"coins"`
}

Transaction Input

func NewInput

func NewInput(addr sdk.AccAddress, coins sdk.Coins) Input

NewInput - create a transaction input, used with MsgSend

func (Input) GetSignBytes

func (in Input) GetSignBytes() []byte

Return bytes to sign for Input

func (Input) ValidateBasic

func (in Input) ValidateBasic() sdk.Error

ValidateBasic - validate transaction input

type Keeper

type Keeper interface {
	SendKeeper
	IncreaseLoosenToken(ctx sdk.Context, amt sdk.Coins)
	DecreaseLoosenToken(ctx sdk.Context, amt sdk.Coins)
	SubtractCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error)
	AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error)
	BurnCoinsFromAddr(ctx sdk.Context, fromAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error)
	BurnCoinsFromPool(ctx sdk.Context, pool string, amt sdk.Coins) (sdk.Tags, sdk.Error)
}

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

type MsgBurn added in v0.10.0

type MsgBurn struct {
	Owner sdk.AccAddress `json:"owner"`
	Coins sdk.Coins      `json:"coins"`
}

MsgBurn - high level transaction of the coin module

func NewMsgBurn added in v0.10.0

func NewMsgBurn(owner sdk.AccAddress, coins sdk.Coins) MsgBurn

NewMsgIssue - construct arbitrary multi-in, multi-out send msg.

func (MsgBurn) GetSignBytes added in v0.10.0

func (msg MsgBurn) GetSignBytes() []byte

Implements Msg.

func (MsgBurn) GetSigners added in v0.10.0

func (msg MsgBurn) GetSigners() []sdk.AccAddress

Implements Msg.

func (MsgBurn) Route added in v0.10.0

func (msg MsgBurn) Route() string

Implements Msg. nolint

func (MsgBurn) Type added in v0.10.0

func (msg MsgBurn) Type() string

func (MsgBurn) ValidateBasic added in v0.10.0

func (msg MsgBurn) ValidateBasic() sdk.Error

Implements Msg.

type MsgIssue

type MsgIssue struct {
	Banker  sdk.AccAddress `json:"banker"`
	Outputs []Output       `json:"outputs"`
}

MsgIssue - high level transaction of the coin module

func NewMsgIssue

func NewMsgIssue(banker sdk.AccAddress, out []Output) MsgIssue

NewMsgIssue - construct arbitrary multi-in, multi-out send msg.

func (MsgIssue) GetSignBytes

func (msg MsgIssue) GetSignBytes() []byte

Implements Msg.

func (MsgIssue) GetSigners

func (msg MsgIssue) GetSigners() []sdk.AccAddress

Implements Msg.

func (MsgIssue) Route

func (msg MsgIssue) Route() string

Implements Msg. nolint

func (MsgIssue) Type

func (msg MsgIssue) Type() string

func (MsgIssue) ValidateBasic

func (msg MsgIssue) ValidateBasic() sdk.Error

Implements Msg.

type MsgSend

type MsgSend struct {
	Inputs  []Input  `json:"inputs"`
	Outputs []Output `json:"outputs"`
}

MsgSend - high level transaction of the coin module

func NewMsgSend

func NewMsgSend(in []Input, out []Output) MsgSend

NewMsgSend - construct arbitrary multi-in, multi-out send msg.

func (MsgSend) GetSignBytes

func (msg MsgSend) GetSignBytes() []byte

Implements Msg.

func (MsgSend) GetSigners

func (msg MsgSend) GetSigners() []sdk.AccAddress

Implements Msg.

func (MsgSend) Route

func (msg MsgSend) Route() string

Implements Msg. nolint

func (MsgSend) Type

func (msg MsgSend) Type() string

func (MsgSend) ValidateBasic

func (msg MsgSend) ValidateBasic() sdk.Error

Implements Msg.

type Output

type Output struct {
	Address sdk.AccAddress `json:"address"`
	Coins   sdk.Coins      `json:"coins"`
}

Transaction Output

func NewOutput

func NewOutput(addr sdk.AccAddress, coins sdk.Coins) Output

NewOutput - create a transaction output, used with MsgSend

func (Output) GetSignBytes

func (out Output) GetSignBytes() []byte

Return bytes to sign for Output

func (Output) ValidateBasic

func (out Output) ValidateBasic() sdk.Error

ValidateBasic - validate transaction output

type SendKeeper

type SendKeeper interface {
	ViewKeeper
	SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error)
	InputOutputCoins(ctx sdk.Context, inputs []Input, outputs []Output) (sdk.Tags, sdk.Error)
}

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

type ViewKeeper

type ViewKeeper interface {
	GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
	GetLoosenCoins(ctx sdk.Context) sdk.Coins
	GetBurnedCoins(ctx sdk.Context) sdk.Coins
	HasCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) bool
}

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