bank

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

nolint

nolint

Index

Constants

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

	CodeInvalidInput      sdk.CodeType = 101
	CodeInvalidOutput     sdk.CodeType = 102
	CodeBurnEmptyCoins    sdk.CodeType = 103
	CodeInvalidMemo       sdk.CodeType = 104
	CodeInvalidMemoRegexp sdk.CodeType = 105
	CodeInvalidAccount    sdk.CodeType = 106
)

Bank errors reserve 100 ~ 199.

View Source
const (
	QueryAccount    = "account"
	QueryTokenStats = "tokenStats"
)

query endpoints supported by the auth Querier

Variables

This section is empty.

Functions

func ErrBurnEmptyCoins

func ErrBurnEmptyCoins(codespace sdk.CodespaceType) sdk.Error

func ErrInvalidAccount

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

func ErrInvalidInput

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

func ErrInvalidMemo

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

func ErrInvalidMemoRegexp

func ErrInvalidMemoRegexp(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 NewAnteHandler

func NewAnteHandler(ak auth.AccountKeeper) sdk.AnteHandler

NewAnteHandler returns an AnteHandler that checks if the memo of the tx satisfies the rule set by the recipient

func NewHandler

func NewHandler(k Keeper) sdk.Handler

NewHandler returns a handler for "bank" type messages.

func NewQuerier

func NewQuerier(keeper Keeper, cdc *codec.Codec) sdk.Querier

creates a querier for auth REST endpoints

func NonnegativeBalanceInvariant

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

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(cdc *codec.Codec, 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) BurnCoins

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

BurnCoins burns coins from the given account

func (BaseKeeper) DecreaseLoosenToken

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

SendCoins moves coins from one account to another

func (BaseKeeper) DecreaseTotalSupply

func (keeper BaseKeeper) DecreaseTotalSupply(ctx sdk.Context, coin sdk.Coin) sdk.Error

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

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

GetLoosenCoins returns the total loosen coins

func (BaseKeeper) GetTotalSupplies

func (keeper BaseKeeper) GetTotalSupplies(ctx sdk.Context) sdk.Iterator

func (BaseKeeper) GetTotalSupply

func (keeper BaseKeeper) GetTotalSupply(ctx sdk.Context, denom string) (coin sdk.Coin, found bool)

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

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

func (BaseKeeper) IncreaseTotalSupply

func (keeper BaseKeeper) IncreaseTotalSupply(ctx sdk.Context, coin sdk.Coin) sdk.Error

func (BaseKeeper) Init

func (keeper BaseKeeper) Init(ctx sdk.Context)

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

func (keeper BaseKeeper) SetMemoRegexp(ctx sdk.Context, fromAddr sdk.AccAddress, regexp string) (sdk.Tags, sdk.Error)

SetMemoRegexp sets memo regexp for sender account

func (BaseKeeper) SetTotalSupply

func (keeper BaseKeeper) SetTotalSupply(ctx sdk.Context, totalSupply sdk.Coin)

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

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

GetCoins returns the coins at the addr.

func (BaseSendKeeper) GetLoosenCoins

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

GetLoosenCoins returns the total loosen coins

func (BaseSendKeeper) GetTotalSupply

func (keeper BaseSendKeeper) GetTotalSupply(ctx sdk.Context, denom string) (coin sdk.Coin, found bool)

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

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

GetCoins returns the coins at the addr.

func (BaseViewKeeper) GetLoosenCoins

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

GetLoosenCoins returns the total loosen coins

func (BaseViewKeeper) GetTotalSupply

func (keeper BaseViewKeeper) GetTotalSupply(ctx sdk.Context, denom string) (coin sdk.Coin, found bool)

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
	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)
	BurnCoins(ctx sdk.Context, fromAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error)
	SetMemoRegexp(ctx sdk.Context, fromAddr sdk.AccAddress, regexp string) (sdk.Tags, sdk.Error)
	IncreaseLoosenToken(ctx sdk.Context, amt sdk.Coins)
	DecreaseLoosenToken(ctx sdk.Context, amt sdk.Coins)
	IncreaseTotalSupply(ctx sdk.Context, amt sdk.Coin) sdk.Error
	DecreaseTotalSupply(ctx sdk.Context, amt sdk.Coin) sdk.Error
	SetTotalSupply(ctx sdk.Context, totalSupply sdk.Coin)
}

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

type MsgBurn

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

MsgBurn - high level transaction of the coin module

func NewMsgBurn

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

NewMsgBurn - construct MsgBurn

func (MsgBurn) GetSignBytes

func (msg MsgBurn) GetSignBytes() []byte

Implements Msg.

func (MsgBurn) GetSigners

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

Implements Msg.

func (MsgBurn) Route

func (msg MsgBurn) Route() string

Implements Msg. nolint

func (MsgBurn) Type

func (msg MsgBurn) Type() string

func (MsgBurn) ValidateBasic

func (msg MsgBurn) 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 MsgSetMemoRegexp

type MsgSetMemoRegexp struct {
	Owner      sdk.AccAddress `json:"owner"`
	MemoRegexp string         `json:"memo_regexp"`
}

MsgSetMemoRegexp - set memo regexp

func NewMsgSetMemoRegexp

func NewMsgSetMemoRegexp(owner sdk.AccAddress, memoRegexp string) MsgSetMemoRegexp

NewMsgSetMemoRegexp - construct MsgSetMemoRegexp

func (MsgSetMemoRegexp) GetSignBytes

func (msg MsgSetMemoRegexp) GetSignBytes() []byte

Implements Msg.

func (MsgSetMemoRegexp) GetSigners

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

Implements Msg.

func (MsgSetMemoRegexp) Route

func (msg MsgSetMemoRegexp) Route() string

Implements Msg. nolint

func (MsgSetMemoRegexp) Type

func (msg MsgSetMemoRegexp) Type() string

func (MsgSetMemoRegexp) ValidateBasic

func (msg MsgSetMemoRegexp) 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 QueryAccountParams

type QueryAccountParams struct {
	Address sdk.AccAddress
}

defines the params for query: "custom/acc/account"

func NewQueryAccountParams

func NewQueryAccountParams(addr sdk.AccAddress) QueryAccountParams

type QueryTokenStatsParams

type QueryTokenStatsParams struct {
	TokenId string
}

defines the params for query: "custom/bank/token-stats"

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 TokenStats

type TokenStats struct {
	LooseTokens  sdk.Coins `json:"loose_tokens"`
	BondedTokens sdk.Coins `json:"bonded_tokens"`
	BurnedTokens sdk.Coins `json:"burned_tokens"`
	TotalSupply  sdk.Coins `json:"total_supply"`
}

func (TokenStats) HumanString

func (ts TokenStats) HumanString(converter sdk.CoinsConverter) string

func (TokenStats) String

func (ts TokenStats) String() string

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
	GetTotalSupply(ctx sdk.Context, denom string) (coin sdk.Coin, found 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