bank

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 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

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

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

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

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

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 struct {
	// contains filtered or unexported fields
}

Keeper manages transfers between accounts

func NewKeeper

func NewKeeper(am auth.AccountMapper) Keeper

NewKeeper returns a new Keeper

func (Keeper) AddCoins

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

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

GetCoins returns the coins at the addr.

func (Keeper) HasCoins

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

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

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

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

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

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) Type

func (msg MsgIssue) Type() string

Implements Msg.

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) Type

func (msg MsgSend) Type() string

Implements Msg.

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 struct {
	// contains filtered or unexported fields
}

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

func NewSendKeeper

func NewSendKeeper(am auth.AccountMapper) SendKeeper

NewSendKeeper returns a new Keeper

func (SendKeeper) GetCoins

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

GetCoins returns the coins at the addr.

func (SendKeeper) HasCoins

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

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

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

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

ViewKeeper only allows reading of balances

func NewViewKeeper

func NewViewKeeper(am auth.AccountMapper) ViewKeeper

NewViewKeeper returns a new Keeper

func (ViewKeeper) GetCoins

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

GetCoins returns the coins at the addr.

func (ViewKeeper) HasCoins

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