bank

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 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 ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis performs basic validation of genesis data returning an error for any failed validation criteria.

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, pk params.ParamsKeeperI) 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) ExportGenesis

func (bank BankKeeper) ExportGenesis(ctx sdk.Context) GenesisState

ExportGenesis returns a GenesisState for a given context and keeper

func (BankKeeper) GetParams

func (bank BankKeeper) GetParams(ctx sdk.Context) Params

func (BankKeeper) InitGenesis

func (bank BankKeeper) InitGenesis(ctx sdk.Context, data GenesisState)

InitGenesis - Init store state from genesis data

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

func (bank BankKeeper) RestrictedDenoms(ctx sdk.Context) []string

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, restrction could be applied

func (BankKeeper) SendCoinsUnrestricted

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

SendCoinsUnrestricted is used for paying gas.

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

func (bank BankKeeper) SetParams(ctx sdk.Context, params Params) error

func (BankKeeper) SetRestrictedDenoms

func (bank BankKeeper) SetRestrictedDenoms(ctx sdk.Context, restrictedDenoms []string)

This is a convenience function for manually setting the restricted denoms. Useful for testing and initchain setup. The ParamKeeper will call WillSetRestrictedDenoms() before writing.

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.

func (BankKeeper) WillSetParam

func (bank BankKeeper) WillSetParam(ctx sdk.Context, key string, value any)

func (BankKeeper) WillSetRestrictedDenoms

func (bank BankKeeper) WillSetRestrictedDenoms(ctx sdk.Context, restrictedDenoms []string)

This will get called whenever the restricted denoms parameter is changed.

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
	SendCoinsUnrestricted(ctx sdk.Context, fromAddr crypto.Address, toAddr crypto.Address, amt std.Coins) error

	InitGenesis(ctx sdk.Context, data GenesisState)
	GetParams(ctx sdk.Context) Params
}

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

type BankParamsContextKey

type BankParamsContextKey struct{}

type GenesisState

type GenesisState struct {
	Params Params `json:"params" yaml:"params"`
}

GenesisState - all state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState - Return a default genesis state

func NewGenesisState

func NewGenesisState(params Params) GenesisState

NewGenesisState - Create a new genesis state

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 Params

type Params struct {
	RestrictedDenoms []string `json:"restricted_denoms" yaml:"restricted_denoms"`
}

Params defines the parameters for the bank module.

func DefaultParams

func DefaultParams() Params

DefaultParams returns a default set of parameters.

func NewParams

func NewParams(restDenoms []string) Params

NewParams creates a new Params object

func (Params) String

func (p Params) String() string

String implements the stringer interface.

func (*Params) Validate

func (p *Params) Validate() error

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