bank

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName = "bank"
)
View Source
const QueryBalance = "balances"

query balance path

View Source
const RouterKey = ModuleName

RouterKey is they name of the bank module

Variables

View Source
var Package = amino.RegisterPackage(amino.NewPackage(
	"github.com/gnolang/gno/tm2/pkg/sdk/bank",
	"bank",
	amino.GetCallersDirname(),
).WithDependencies().WithTypes(
	NoInputsError{}, "NoInputsError",
	NoOutputsError{}, "NoOutputsError",
	InputOutputMismatchError{}, "InputOutputMismatchError",
	MsgSend{}, "MsgSend",
))

Functions

func ErrInputOutputMismatch

func ErrInputOutputMismatch() error

func ErrNoInputs

func ErrNoInputs() error

func ErrNoOutputs

func ErrNoOutputs() error

func NewHandler

func NewHandler(bank BankKeeper) bankHandler

NewHandler returns a handler for "bank" type messages.

func NonnegativeBalanceInvariant

func NonnegativeBalanceInvariant(acck auth.AccountKeeper) sdk.Invariant

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

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, acck auth.AccountKeeper)

RegisterInvariants registers the bank module invariants

func ValidateInputsOutputs

func ValidateInputsOutputs(inputs []Input, outputs []Output) error

ValidateInputsOutputs validates that each respective input and output is valid and that the sum of inputs is equal to the sum of outputs.

Types

type BankKeeper

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

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

func NewBankKeeper

func NewBankKeeper(acck auth.AccountKeeper) BankKeeper

NewBankKeeper returns a new BankKeeper.

func (BankKeeper) AddCoins

func (bank BankKeeper) AddCoins(ctx sdk.Context, addr crypto.Address, amt std.Coins) (std.Coins, error)

AddCoins adds amt to the coins at the addr.

func (BankKeeper) InputOutputCoins

func (bank BankKeeper) InputOutputCoins(ctx sdk.Context, inputs []Input, outputs []Output) error

InputOutputCoins handles a list of inputs and outputs

func (BankKeeper) SendCoins

func (bank BankKeeper) SendCoins(ctx sdk.Context, fromAddr crypto.Address, toAddr crypto.Address, amt std.Coins) error

SendCoins moves coins from one account to another

func (BankKeeper) SetCoins

func (bank BankKeeper) SetCoins(ctx sdk.Context, addr crypto.Address, amt std.Coins) error

SetCoins sets the coins at the addr.

func (BankKeeper) SubtractCoins

func (bank BankKeeper) SubtractCoins(ctx sdk.Context, addr crypto.Address, amt std.Coins) (std.Coins, error)

SubtractCoins subtracts amt from the coins at the addr.

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

type BankKeeperI

type BankKeeperI interface {
	ViewKeeperI

	InputOutputCoins(ctx sdk.Context, inputs []Input, outputs []Output) error
	SendCoins(ctx sdk.Context, fromAddr crypto.Address, toAddr crypto.Address, amt std.Coins) error

	SubtractCoins(ctx sdk.Context, addr crypto.Address, amt std.Coins) (std.Coins, error)
	AddCoins(ctx sdk.Context, addr crypto.Address, amt std.Coins) (std.Coins, error)
	SetCoins(ctx sdk.Context, addr crypto.Address, amt std.Coins) error
}

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

type Input

type Input struct {
	Address crypto.Address `json:"address" yaml:"address"`
	Coins   std.Coins      `json:"coins" yaml:"coins"`
}

Input models transaction input

func NewInput

func NewInput(addr crypto.Address, coins std.Coins) Input

NewInput - create a transaction input, used with MsgMultiSend

func (Input) ValidateBasic

func (in Input) ValidateBasic() error

ValidateBasic - validate transaction input

type InputOutputMismatchError

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

func (InputOutputMismatchError) AssertABCIError

func (InputOutputMismatchError) AssertABCIError()

func (InputOutputMismatchError) Error

func (e InputOutputMismatchError) Error() string

type MsgMultiSend

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

MsgMultiSend - high level transaction of the coin module

func NewMsgMultiSend

func NewMsgMultiSend(in []Input, out []Output) MsgMultiSend

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

func (MsgMultiSend) GetSignBytes

func (msg MsgMultiSend) GetSignBytes() []byte

GetSignBytes Implements Msg.

func (MsgMultiSend) GetSigners

func (msg MsgMultiSend) GetSigners() []crypto.Address

GetSigners Implements Msg.

func (MsgMultiSend) Route

func (msg MsgMultiSend) Route() string

Route Implements Msg

func (MsgMultiSend) Type

func (msg MsgMultiSend) Type() string

Type Implements Msg

func (MsgMultiSend) ValidateBasic

func (msg MsgMultiSend) ValidateBasic() error

ValidateBasic Implements Msg.

type MsgSend

type MsgSend struct {
	FromAddress crypto.Address `json:"from_address" yaml:"from_address"`
	ToAddress   crypto.Address `json:"to_address" yaml:"to_address"`
	Amount      std.Coins      `json:"amount" yaml:"amount"`
}

MsgSend - high level transaction of the coin module

func NewMsgSend

func NewMsgSend(fromAddr, toAddr crypto.Address, amount std.Coins) MsgSend

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

func (MsgSend) GetSignBytes

func (msg MsgSend) GetSignBytes() []byte

GetSignBytes Implements Msg.

func (MsgSend) GetSigners

func (msg MsgSend) GetSigners() []crypto.Address

GetSigners Implements Msg.

func (MsgSend) Route

func (msg MsgSend) Route() string

Route Implements Msg.

func (MsgSend) Type

func (msg MsgSend) Type() string

Type Implements Msg.

func (MsgSend) ValidateBasic

func (msg MsgSend) ValidateBasic() error

ValidateBasic Implements Msg.

type NoInputsError

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

declare all bank errors. NOTE: these are meant to be used in conjunction with pkgs/errors.

func (NoInputsError) AssertABCIError

func (NoInputsError) AssertABCIError()

func (NoInputsError) Error

func (e NoInputsError) Error() string

type NoOutputsError

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

func (NoOutputsError) AssertABCIError

func (NoOutputsError) AssertABCIError()

func (NoOutputsError) Error

func (e NoOutputsError) Error() string

type Output

type Output struct {
	Address crypto.Address `json:"address" yaml:"address"`
	Coins   std.Coins      `json:"coins" yaml:"coins"`
}

Output models transaction outputs

func NewOutput

func NewOutput(addr crypto.Address, coins std.Coins) Output

NewOutput - create a transaction output, used with MsgMultiSend

func (Output) ValidateBasic

func (out Output) ValidateBasic() error

ValidateBasic - validate transaction output

type ViewKeeper

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

ViewKeeper implements a read only keeper implementation of ViewKeeperI.

func NewViewKeeper

func NewViewKeeper(acck auth.AccountKeeper) ViewKeeper

NewViewKeeper returns a new ViewKeeper.

func (ViewKeeper) GetCoins

func (view ViewKeeper) GetCoins(ctx sdk.Context, addr crypto.Address) std.Coins

GetCoins returns the coins at the addr.

func (ViewKeeper) HasCoins

func (view ViewKeeper) HasCoins(ctx sdk.Context, addr crypto.Address, amt std.Coins) bool

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

func (ViewKeeper) Logger

func (view ViewKeeper) Logger(ctx sdk.Context) *slog.Logger

Logger returns a module-specific logger.

type ViewKeeperI

type ViewKeeperI interface {
	GetCoins(ctx sdk.Context, addr crypto.Address) std.Coins
	HasCoins(ctx sdk.Context, addr crypto.Address, amt std.Coins) bool
}

ViewKeeperI 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