Documentation ¶
Overview ¶
nolint
nolint
Index ¶
- Constants
- func MockContext(chain string, height uint64) sdk.Context
- func NewCheckTx(req []sdk.Actor) sdk.Tx
- func NewContext(chain string, height uint64, logger log.Logger) sdk.Context
- func NewFailTx() sdk.Tx
- func NewRawTx(d []byte) sdk.Tx
- func PrefixedKey(app string, key []byte) []byte
- func PrefixedStore(app string, store state.SimpleDB) state.SimpleDB
- type CheckHandler
- type CheckMiddleware
- func (p CheckMiddleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error)
- func (p CheckMiddleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error)
- func (_ CheckMiddleware) Name() string
- type CheckTx
- type CheckerMiddle
- type CheckerMiddleFunc
- type Checkpoint
- type DeliverMiddle
- type DeliverMiddleFunc
- type Dispatchable
- type Dispatcher
- func (d *Dispatcher) AddRoutes(routes ...Dispatchable)
- func (d *Dispatcher) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
- func (d *Dispatcher) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error)
- func (d *Dispatcher) InitState(l log.Logger, store state.SimpleDB, module, key, value string) (string, error)
- func (d *Dispatcher) InitValidate(log log.Logger, store state.SimpleDB, vals []*abci.Validator)
- func (d *Dispatcher) Name() string
- type EchoHandler
- type FailHandler
- type FailTx
- type GrantMiddleware
- func (g GrantMiddleware) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error)
- func (g GrantMiddleware) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error)
- func (_ GrantMiddleware) Name() string
- type InitStaterMiddle
- type InitStaterMiddleFunc
- type InitValidaterMiddle
- type InitValidaterMiddleFunc
- type Middleware
- type OKHandler
- type PanicHandler
- type PassCheck
- type PassDeliver
- type PassInitState
- type PassInitValidate
- type RawTx
- type Recovery
- func (Recovery) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error)
- func (Recovery) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error)
- func (Recovery) InitState(l log.Logger, store state.SimpleDB, module, key, value string, ...) (log string, err error)
- func (Recovery) InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, ...)
- func (Recovery) Name() string
- type Stack
Constants ¶
const ( NameOK = "ok" NameFail = "fail" NamePanic = "panic" NameEcho = "echo" )
nolint
const ( ByteRawTx = 0xF0 ByteCheckTx = 0xF1 ByteFailTx = 0xF2 TypeRawTx = NameOK + "/raw" // this will just say a-ok to RawTx TypeCheckTx = NameCheck + "/tx" TypeFailTx = NameFail + "/tx" )
nolint
const ( NameCheck = "check" NameGrant = "grant" )
const (
NameCheckpoint = "check"
)
nolint
const (
NameDispatcher = "disp"
)
nolint
const (
NameRecovery = "rcvr"
)
nolint
Variables ¶
This section is empty.
Functions ¶
func MockContext ¶
MockContext returns a simple, non-checking context for test cases.
Always use NewContext() for production code to sandbox malicious code better
func NewContext ¶
NewContext - create a new secureContext
func PrefixedKey ¶
PrefixedKey returns the absolute path to a given key in a particular app's state-space
This is useful for tests or utilities that have access to the global state to check individual app spaces. Individual apps should not be able to use this to read each other's space
func PrefixedStore ¶
PrefixedStore allows one to create an isolated state-space for a given app prefix, but it cannot easily be unwrapped
This is useful for tests or utilities that have access to the global state to check individual app spaces. Individual apps should not be able to use this to read each other's space
Types ¶
type CheckHandler ¶
type CheckHandler struct { sdk.NopInitState sdk.NopInitValidate }
CheckHandler accepts CheckTx and verifies the permissions
func (CheckHandler) CheckTx ¶
func (c CheckHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
CheckTx verifies the permissions
type CheckMiddleware ¶
type CheckMiddleware struct { Required sdk.Actor PassInitState PassInitValidate }
CheckMiddleware returns an error if the tx doesn't have auth of this Required Actor, otherwise passes along the call untouched
func (CheckMiddleware) Name ¶
func (_ CheckMiddleware) Name() string
type CheckerMiddle ¶
type CheckerMiddleFunc ¶
type Checkpoint ¶
type Checkpoint struct { OnCheck bool OnDeliver bool PassInitState PassInitValidate }
Checkpoint isolates all data store below this
func (Checkpoint) CheckTx ¶
func (c Checkpoint) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error)
CheckTx reverts all data changes if there was an error
func (Checkpoint) DeliverTx ¶
func (c Checkpoint) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error)
DeliverTx reverts all data changes if there was an error
func (Checkpoint) Name ¶
func (Checkpoint) Name() string
Name of the module - fulfills Middleware interface
type DeliverMiddle ¶
type DeliverMiddleFunc ¶
type Dispatchable ¶
type Dispatchable interface { Middleware AssertDispatcher() }
Dispatchable is like middleware, except the meaning of "next" is different. Whereas in the middleware, it is the next handler that we should pass the same tx into, for dispatchers, it is a dispatcher, which it can use to
func WrapHandler ¶
func WrapHandler(h sdk.Handler) Dispatchable
WrapHandler turns a sdk.Handler into a Dispatchable interface
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher grabs a bunch of Dispatchables and groups them into one Handler.
It will route tx to the proper locations and also allows them to call each other synchronously through the same tx methods.
Please note that iterating through a map is a non-deteministic operation and, as such, should never be done in the context of an ABCI app. Only use this map to look up an exact route by name.
func NewDispatcher ¶
func NewDispatcher(routes ...Dispatchable) *Dispatcher
NewDispatcher creates a dispatcher and adds the given routes. You can also add routes later with .AddRoutes()
func (*Dispatcher) AddRoutes ¶
func (d *Dispatcher) AddRoutes(routes ...Dispatchable)
AddRoutes registers all these dispatchable choices under their subdomains
Panics on attempt to double-register a route name, as this is a configuration error. Should I retrun an error instead?
func (*Dispatcher) CheckTx ¶
func (d *Dispatcher) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
CheckTx - implements Handler interface
Tries to find a registered module (Dispatchable) based on the name of the tx. The tx name (as registered with go-data) should be in the form `<module name>/XXXX`, where `module name` must match the name of a dispatchable and XXX can be any string.
func (*Dispatcher) DeliverTx ¶
func (d *Dispatcher) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error)
DeliverTx - implements Handler interface
Tries to find a registered module (Dispatchable) based on the name of the tx. The tx name (as registered with go-data) should be in the form `<module name>/XXXX`, where `module name` must match the name of a dispatchable and XXX can be any string.
func (*Dispatcher) InitState ¶
func (d *Dispatcher) InitState(l log.Logger, store state.SimpleDB, module, key, value string) (string, error)
InitState - implements Handler interface
Tries to find a registered module (Dispatchable) based on the module name from InitState of the tx.
func (*Dispatcher) InitValidate ¶
InitValidate makes sure all modules are informed
type EchoHandler ¶
type EchoHandler struct { sdk.NopInitState sdk.NopInitValidate }
EchoHandler returns success, echoing res.Data = tx bytes
func (EchoHandler) CheckTx ¶
func (EchoHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
CheckTx always returns an empty success tx
type FailHandler ¶
type FailHandler struct { Err error sdk.NopInitState sdk.NopInitValidate }
FailHandler always returns an error
func (FailHandler) CheckTx ¶
func (f FailHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
CheckTx always returns the given error
type GrantMiddleware ¶
type GrantMiddleware struct { Auth sdk.Actor PassInitState PassInitValidate }
GrantMiddleware tries to set the permission to this Actor, which may be prohibited
func (GrantMiddleware) Name ¶
func (_ GrantMiddleware) Name() string
type InitStaterMiddle ¶
type InitStaterMiddleFunc ¶
type InitValidaterMiddle ¶
type InitValidaterMiddleFunc ¶
func (InitValidaterMiddleFunc) InitValidate ¶
func (c InitValidaterMiddleFunc) InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, next sdk.InitValidater)
type Middleware ¶
type Middleware interface { CheckerMiddle DeliverMiddle InitStaterMiddle InitValidaterMiddle sdk.Named }
Middleware is anything that wraps another handler to enhance functionality.
You can use utilities in handlers to construct them, the interfaces are exposed in the top-level package to avoid import loops.
type OKHandler ¶
type OKHandler struct { Log string sdk.NopInitState sdk.NopInitValidate }
OKHandler just used to return okay to everything
func (OKHandler) CheckTx ¶
func (ok OKHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
CheckTx always returns an empty success tx
type PanicHandler ¶
type PanicHandler struct { Msg string Err error sdk.NopInitState sdk.NopInitValidate }
PanicHandler always panics, using the given error (first choice) or msg (fallback)
func (PanicHandler) CheckTx ¶
func (p PanicHandler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
CheckTx always panics
type PassDeliver ¶
type PassDeliver struct{}
type PassInitState ¶
type PassInitState struct{}
type PassInitValidate ¶
type PassInitValidate struct{}
func (PassInitValidate) InitValidate ¶
func (_ PassInitValidate) InitValidate(l log.Logger, store state.SimpleDB, vals []*abci.Validator, next sdk.InitValidater)
type Recovery ¶
type Recovery struct{}
Recovery catches any panics and returns them as errors instead
func (Recovery) CheckTx ¶
func (Recovery) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Checker) (res sdk.CheckResult, err error)
CheckTx catches any panic and converts to error - fulfills Middlware interface
func (Recovery) DeliverTx ¶
func (Recovery) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, next sdk.Deliver) (res sdk.DeliverResult, err error)
DeliverTx catches any panic and converts to error - fulfills Middlware interface
func (Recovery) InitState ¶
func (Recovery) InitState(l log.Logger, store state.SimpleDB, module, key, value string, next sdk.InitStater) (log string, err error)
InitState catches any panic and converts to error - fulfills Middlware interface
type Stack ¶
type Stack struct { sdk.Handler // the compiled version, which we expose // contains filtered or unexported fields }
Stack is the entire application stack
func New ¶
func New(middlewares ...Middleware) *Stack
New prepares a middleware stack, you must `.Use()` a Handler before you can execute it.
func (*Stack) Apps ¶
func (s *Stack) Apps(middlewares ...Middleware) *Stack
Apps adds the following Middlewares as typical application middleware to the stack (limit permission to one app)
func (*Stack) Dispatch ¶
func (s *Stack) Dispatch(routes ...Dispatchable) *Stack
Dispatch is like Use, but a convenience method to construct a dispatcher with a set of modules to route.
func (*Stack) IBC ¶
func (s *Stack) IBC(m Middleware) *Stack
IBC add the following middleware with permission to add cross-chain permissions