bank

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
const (
	DefaultCodespace sdk.CodespaceType = 2

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

Bank errors reserve 100 ~ 199.

Variables

This section is empty.

Functions

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 ModuleInvariants added in v0.20.0

func ModuleInvariants(t *testing.T, app *mock.App, log string)

ModuleInvariants runs all invariants of the bank module. Currently runs non-negative balance invariant and TotalCoinsInvariant

func NewHandler

func NewHandler(k Keeper) sdk.Handler

NewHandler returns a handler for "bank" type messages.

func NonnegativeBalanceInvariant added in v0.20.0

func NonnegativeBalanceInvariant(t *testing.T, app *mock.App, log string)

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

func RegisterWire

func RegisterWire(cdc *wire.Codec)

Register concrete types on wire codec

func TestAndRunSingleInputMsgSend added in v0.20.0

func TestAndRunSingleInputMsgSend(t *testing.T, r *rand.Rand, app *mock.App, ctx sdk.Context, keys []crypto.PrivKey, log string) (action string, err sdk.Error)

TestAndRunSingleInputMsgSend tests and runs a single msg send, with one input and one output, where both accounts already exist.

func TotalCoinsInvariant added in v0.20.0

func TotalCoinsInvariant(t *testing.T, app *mock.App, log string)

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

Types

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 added in v0.19.0

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 added in v0.16.0

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

Keeper manages transfers between accounts

func NewKeeper added in v0.16.0

func NewKeeper(am auth.AccountMapper) Keeper

NewKeeper returns a new Keeper

func (Keeper) AddCoins added in v0.16.0

func (keeper Keeper) 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 (Keeper) GetCoins added in v0.16.0

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

GetCoins returns the coins at the addr.

func (Keeper) HasCoins added in v0.16.0

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

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

func (Keeper) InputOutputCoins added in v0.16.0

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

InputOutputCoins handles a list of inputs and outputs

func (Keeper) SendCoins added in v0.16.0

func (keeper Keeper) 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 (Keeper) SetCoins added in v0.16.0

func (keeper Keeper) SetCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) sdk.Error

SetCoins sets the coins at the addr.

func (Keeper) SubtractCoins added in v0.16.0

func (keeper Keeper) 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 MsgIssue added in v0.16.0

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

MsgIssue - high level transaction of the coin module

func NewMsgIssue added in v0.16.0

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

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

func (MsgIssue) GetSignBytes added in v0.16.0

func (msg MsgIssue) GetSignBytes() []byte

Implements Msg.

func (MsgIssue) GetSigners added in v0.16.0

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

Implements Msg.

func (MsgIssue) Type added in v0.16.0

func (msg MsgIssue) Type() string

Implements Msg.

func (MsgIssue) ValidateBasic added in v0.16.0

func (msg MsgIssue) ValidateBasic() sdk.Error

Implements Msg.

type MsgSend added in v0.16.0

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

MsgSend - high level transaction of the coin module

func NewMsgSend added in v0.16.0

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

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

func (MsgSend) GetSignBytes added in v0.16.0

func (msg MsgSend) GetSignBytes() []byte

Implements Msg.

func (MsgSend) GetSigners added in v0.16.0

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

Implements Msg.

func (MsgSend) Type added in v0.16.0

func (msg MsgSend) Type() string

Implements Msg.

func (MsgSend) ValidateBasic added in v0.16.0

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 added in v0.19.0

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 added in v0.16.0

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

SendKeeper only allows transfers between accounts, without the possibility of creating coins

func NewSendKeeper added in v0.16.0

func NewSendKeeper(am auth.AccountMapper) SendKeeper

NewSendKeeper returns a new Keeper

func (SendKeeper) GetCoins added in v0.16.0

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

GetCoins returns the coins at the addr.

func (SendKeeper) HasCoins added in v0.16.0

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

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

func (SendKeeper) InputOutputCoins added in v0.16.0

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

InputOutputCoins handles a list of inputs and outputs

func (SendKeeper) SendCoins added in v0.16.0

func (keeper SendKeeper) 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 ViewKeeper added in v0.16.0

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

ViewKeeper only allows reading of balances

func NewViewKeeper added in v0.16.0

func NewViewKeeper(am auth.AccountMapper) ViewKeeper

NewViewKeeper returns a new Keeper

func (ViewKeeper) GetCoins added in v0.16.0

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

GetCoins returns the coins at the addr.

func (ViewKeeper) HasCoins added in v0.16.0

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

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

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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