sdk

package
v0.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ParseGasPrice  = std.ParseGasPrice
	ParseGasPrices = std.ParseGasPrices
)
View Source
var Package = amino.RegisterPackage(amino.NewPackage(
	"github.com/gnolang/gno/tm2/pkg/sdk",
	"tm",
	amino.GetCallersDirname(),
).
	WithDependencies(
		abci.Package,
	).
	WithTypes(
		Result{},
	))

Functions

func ABCIError

func ABCIError(err error) abci.Error

TODO: replace with abci.ABCIErrorOrStringError().

func ABCIResponseQueryFromError

func ABCIResponseQueryFromError(err error) (res abci.ResponseQuery)

func FormatInvariant

func FormatInvariant(module, name, msg string) string

FormatInvariant returns a standardized invariant message.

func NewRouter

func NewRouter() *router

NewRouter returns a reference to a new router.

func SetHaltHeight

func SetHaltHeight(blockHeight uint64) func(*BaseApp)

SetHaltHeight returns a BaseApp option function that sets the halt block height.

func SetHaltTime

func SetHaltTime(haltTime uint64) func(*BaseApp)

SetHaltTime returns a BaseApp option function that sets the halt block time.

func SetMinGasPrices

func SetMinGasPrices(gasPricesStr string) func(*BaseApp)

SetMinGasPrices returns an option that sets the minimum gas prices on the app.

func SetPruningOptions

func SetPruningOptions(opts store.PruningOptions) func(*BaseApp)

SetPruningOptions sets pruning options on the multistore associated with the app

func SetStoreOptions

func SetStoreOptions(opts store.StoreOptions) func(*BaseApp)

SetStoreOptions sets store options on the multistore associated with the app

Types

type AnteHandler

type AnteHandler func(ctx Context, tx Tx, simulate bool) (newCtx Context, result Result, abort bool)

AnteHandler authenticates transactions, before their internal messages are handled.

type BaseApp

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

BaseApp reflects the ABCI application implementation.

func NewBaseApp

func NewBaseApp(
	name string,
	logger *slog.Logger,
	db dbm.DB,
	baseKey store.StoreKey,
	mainKey store.StoreKey,
	options ...func(*BaseApp),
) *BaseApp

NewBaseApp returns a reference to an initialized BaseApp. It accepts a variadic number of option functions, which act on the BaseApp to set configuration choices.

NOTE: The db is used to store the version number for now.

func (*BaseApp) AppVersion

func (app *BaseApp) AppVersion() string

AppVersion returns the application's version string.

func (*BaseApp) BeginBlock

func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeginBlock)

BeginBlock implements the ABCI application interface.

func (*BaseApp) Check

func (app *BaseApp) Check(tx Tx) (result Result)

func (*BaseApp) CheckTx

func (app *BaseApp) CheckTx(req abci.RequestCheckTx) (res abci.ResponseCheckTx)

CheckTx implements the ABCI interface. It runs the "basic checks" to see whether or not a transaction can possibly be executed, first decoding and then the ante handler (which checks signatures/fees/ValidateBasic).

NOTE:CheckTx does not run the actual Msg handler function(s).

func (*BaseApp) Close

func (app *BaseApp) Close() error

TODO implement cleanup

func (*BaseApp) Commit

func (app *BaseApp) Commit() (res abci.ResponseCommit)

Commit implements the ABCI interface. It will commit all state that exists in the deliver state's multi-store and includes the resulting commit ID in the returned abci.ResponseCommit. Commit will set the check state based on the latest header and reset the deliver state. Also, if a non-zero halt height is defined in config, Commit will execute a deferred function call to check against that height and gracefully halt if it matches the latest committed height.

func (*BaseApp) Deliver

func (app *BaseApp) Deliver(tx Tx) (result Result)

func (*BaseApp) DeliverTx

func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliverTx)

DeliverTx implements the ABCI interface.

func (*BaseApp) EndBlock

func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBlock)

EndBlock implements the ABCI interface.

func (*BaseApp) GetCacheMultiStore

func (app *BaseApp) GetCacheMultiStore() store.MultiStore

Returns a read-only (cache) MultiStore. This may be used by keepers for initialization upon restart.

func (*BaseApp) Info

func (app *BaseApp) Info(req abci.RequestInfo) (res abci.ResponseInfo)

Info implements the ABCI interface.

func (*BaseApp) InitChain

func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain)

InitChain implements the ABCI interface. It runs the initialization logic directly on the CommitMultiStore.

func (*BaseApp) IsSealed

func (app *BaseApp) IsSealed() bool

IsSealed returns true if the BaseApp is sealed and false otherwise.

func (*BaseApp) LastBlockHeight

func (app *BaseApp) LastBlockHeight() int64

LastBlockHeight returns the last committed block height.

func (*BaseApp) LastCommitID

func (app *BaseApp) LastCommitID() store.CommitID

LastCommitID returns the last CommitID of the multistore.

func (*BaseApp) LoadLatestVersion

func (app *BaseApp) LoadLatestVersion() error

LoadLatestVersion loads the latest application version. It will panic if called more than once on a running BaseApp. This, or LoadVersion() MUST be called even after first init.

func (*BaseApp) LoadVersion

func (app *BaseApp) LoadVersion(version int64) error

LoadVersion loads the BaseApp application version. It will panic if called more than once on a running baseapp. This, or LoadLatestVersion() MUST be called even after first init.

func (*BaseApp) Logger

func (app *BaseApp) Logger() *slog.Logger

Logger returns the logger of the BaseApp.

func (*BaseApp) MountStore

func (app *BaseApp) MountStore(key store.StoreKey, cons store.CommitStoreConstructor)

MountStore mounts a store to the provided key in the BaseApp multistore, using the default DB.

func (*BaseApp) MountStoreWithDB

func (app *BaseApp) MountStoreWithDB(key store.StoreKey, cons store.CommitStoreConstructor, db dbm.DB)

MountStoreWithDB mounts a store to the provided key in the BaseApp multistore, using a specified DB.

func (*BaseApp) Name

func (app *BaseApp) Name() string

Name returns the name of the BaseApp.

func (*BaseApp) NewContext

func (app *BaseApp) NewContext(mode RunTxMode, header abci.Header) Context

Context with current {check, deliver}State of the app used by tests

func (*BaseApp) Query

func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery)

Query implements the ABCI interface. It delegates to CommitMultiStore if it implements Queryable.

func (*BaseApp) Router

func (app *BaseApp) Router() Router

Router returns the router of the BaseApp.

func (*BaseApp) Seal

func (app *BaseApp) Seal()

Seal seals a BaseApp. It prohibits any further modifications to a BaseApp.

func (*BaseApp) SetAnteHandler

func (app *BaseApp) SetAnteHandler(ah AnteHandler)

func (*BaseApp) SetAppVersion

func (app *BaseApp) SetAppVersion(v string)

SetAppVersion sets the application's version string.

func (*BaseApp) SetBeginBlocker

func (app *BaseApp) SetBeginBlocker(beginBlocker BeginBlocker)

func (*BaseApp) SetCMS

func (app *BaseApp) SetCMS(cms store.CommitMultiStore)

func (*BaseApp) SetDB

func (app *BaseApp) SetDB(db dbm.DB)

func (*BaseApp) SetEndBlocker

func (app *BaseApp) SetEndBlocker(endBlocker EndBlocker)

func (*BaseApp) SetInitChainer

func (app *BaseApp) SetInitChainer(initChainer InitChainer)

func (*BaseApp) SetName

func (app *BaseApp) SetName(name string)

func (*BaseApp) SetOption

func (app *BaseApp) SetOption(req abci.RequestSetOption) (res abci.ResponseSetOption)

SetOption implements the ABCI interface.

func (*BaseApp) Simulate

func (app *BaseApp) Simulate(txBytes []byte, tx Tx) (result Result)

type BeginBlocker

type BeginBlocker func(ctx Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock

BeginBlocker runs code before the transactions in a block

Note: applications which set create_empty_blocks=false will not have regular block timing and should use e.g. BFT timestamps rather than block height for any periodic BeginBlock logic

type Coin

type Coin = std.Coin

type Coins

type Coins = std.Coins

type Context

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

Context is a mostly immutable object contains all information needed to process a request.

It contains a context.Context object inside if you want to use that, but please do not over-use it. We try to keep all data structured and standard additions here would be better just to add to the Context struct

func NewContext

func NewContext(mode RunTxMode, ms store.MultiStore, header abci.Header, logger *slog.Logger) Context

create a new context

func (Context) BlockGasMeter

func (c Context) BlockGasMeter() store.GasMeter

func (Context) BlockHeader

func (c Context) BlockHeader() abci.Header

clone the header before returning

func (Context) BlockHeight

func (c Context) BlockHeight() int64

func (Context) BlockTime

func (c Context) BlockTime() time.Time

func (Context) CacheContext

func (c Context) CacheContext() (cc Context, writeCache func())

CacheContext returns a new Context with the multi-store cached and a new EventLogger . The cached context is written to the context when writeCache is called. XXX remove?

func (Context) ChainID

func (c Context) ChainID() string

func (Context) ConsensusParams

func (c Context) ConsensusParams() *abci.ConsensusParams

func (Context) Context

func (c Context) Context() context.Context

Read-only accessors

func (Context) EventLogger

func (c Context) EventLogger() *EventLogger

func (Context) GasMeter

func (c Context) GasMeter() store.GasMeter

func (Context) IsCheckTx

func (c Context) IsCheckTx() bool

func (Context) IsZero

func (c Context) IsZero() bool

func (Context) Logger

func (c Context) Logger() *slog.Logger

func (Context) MinGasPrices

func (c Context) MinGasPrices() []GasPrice

func (Context) Mode

func (c Context) Mode() RunTxMode

func (Context) MultiStore

func (c Context) MultiStore() store.MultiStore

func (Context) Store

func (c Context) Store(key store.StoreKey) store.Store

Store fetches a Store from the MultiStore, but wrapped for gas calculation.

func (Context) TxBytes

func (c Context) TxBytes() []byte

func (Context) Value

func (c Context) Value(key interface{}) interface{}

Value is deprecated, provided for backwards compatibility Please use

ctx.Context().Value(key)

instead of

ctx.Value(key)

NOTE: why?

func (Context) VoteInfos

func (c Context) VoteInfos() []abci.VoteInfo

func (Context) WithBlockGasMeter

func (c Context) WithBlockGasMeter(meter store.GasMeter) Context

func (Context) WithBlockHeader

func (c Context) WithBlockHeader(header abci.Header) Context

func (Context) WithChainID

func (c Context) WithChainID(chainID string) Context

func (Context) WithConsensusParams

func (c Context) WithConsensusParams(params *abci.ConsensusParams) Context

func (Context) WithContext

func (c Context) WithContext(ctx context.Context) Context

func (Context) WithEventLogger

func (c Context) WithEventLogger(em *EventLogger) Context

func (Context) WithGasMeter

func (c Context) WithGasMeter(meter store.GasMeter) Context

func (Context) WithLogger

func (c Context) WithLogger(logger *slog.Logger) Context

func (Context) WithMinGasPrices

func (c Context) WithMinGasPrices(gasPrices []GasPrice) Context

func (Context) WithMode

func (c Context) WithMode(mode RunTxMode) Context

func (Context) WithMultiStore

func (c Context) WithMultiStore(ms store.MultiStore) Context

func (Context) WithTxBytes

func (c Context) WithTxBytes(txBytes []byte) Context

func (Context) WithValue

func (c Context) WithValue(key, value interface{}) Context

WithValue is deprecated, provided for backwards compatibility Please use

ctx = ctx.WithContext(context.WithValue(ctx.Context(), key, false))

instead of

ctx = ctx.WithValue(key, false)

NOTE: why?

func (Context) WithVoteInfos

func (c Context) WithVoteInfos(voteInfo []abci.VoteInfo) Context

type EndBlocker

type EndBlocker func(ctx Context, req abci.RequestEndBlock) abci.ResponseEndBlock

EndBlocker runs code after the transactions in a block and return updates to the validator set

Note: applications which set create_empty_blocks=false will not have regular block timing and should use e.g. BFT timestamps rather than block height for any periodic EndBlock logic

type Event

type Event = abci.Event

type EventLogger

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

EventLogger implements a simple wrapper around a slice of Event objects that can be emitted from.

func NewEventLogger

func NewEventLogger() *EventLogger

func (*EventLogger) EmitEvent

func (em *EventLogger) EmitEvent(event Event)

EmitEvent stores a single Event object.

func (*EventLogger) EmitEvents

func (em *EventLogger) EmitEvents(events []Event)

EmitEvents stores a series of Event objects.

func (*EventLogger) Events

func (em *EventLogger) Events() []Event

type GasPrice

type GasPrice = std.GasPrice

type Handler

type Handler interface {
	// Process defines the core of the state transition function of an application.
	Process(ctx Context, msg Msg) Result
	// Query allows the state to be queried.
	Query(ctx Context, req abci.RequestQuery) abci.ResponseQuery
}

A Handler handles processing messages and answering queries for a particular application concern.

type InitChainer

type InitChainer func(ctx Context, req abci.RequestInitChain) abci.ResponseInitChain

InitChainer initializes application state at genesis

type Invariant

type Invariant func(ctx Context) (string, bool)

An Invariant is a function which tests a particular invariant. The invariant returns a descriptive message about what happened and a boolean indicating whether the invariant has been broken. The simulator will then halt and print the logs.

type InvariantRegistry

type InvariantRegistry interface {
	RegisterRoute(moduleName, route string, invar Invariant)
}

expected interface for registering invariants

type Invariants

type Invariants []Invariant

Invariants defines a group of invariants

type Msg

type Msg = std.Msg

Exports from std.

type Request

type Request = Context

Proposed rename, not done to avoid API breakage

type Result

type Result struct {
	abci.ResponseBase
	GasWanted int64
	GasUsed   int64
}

Result is the union of ResponseDeliverTx and ResponseCheckTx plus events.

func ABCIResultFromError

func ABCIResultFromError(err error) (res Result)

type Router

type Router interface {
	AddRoute(r string, h Handler) Router
	Route(path string) Handler
}

Router provides handlers for each transaction type.

type RunTxMode

type RunTxMode uint8

Enum mode for app.runTx

const (
	// Check a transaction
	RunTxModeCheck RunTxMode = iota
	// Simulate a transaction
	RunTxModeSimulate RunTxMode = iota
	// Deliver a transaction
	RunTxModeDeliver RunTxMode = iota
)

type Tx

type Tx = std.Tx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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