types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: Apache-2.0 Imports: 5 Imported by: 22

Documentation

Index

Constants

View Source
const (
	// SubModuleName defines the IBC port name
	SubModuleName = "routing"

	// StoreKey is the store key string for IBC ports
	StoreKey = SubModuleName

	// RouterKey is the message route for IBC ports
	RouterKey = SubModuleName

	// QuerierRoute is the querier route for IBC ports
	QuerierRoute = SubModuleName
)
View Source
const RulePattern = "^([^.]{1,50}\\.){2}[^.]{1,50}$"

Variables

View Source
var (
	ErrInvalidRoute     = sdkerrors.Register(moduleName, 2, "route not found")
	ErrInvalidRule      = sdkerrors.Register(moduleName, 3, "invalid rule")
	ErrFailMarshalRules = sdkerrors.Register(moduleName, 4, "ailed to marshal rules")
)

TIBC routing sentinel errors

Functions

func GetModuleOwner

func GetModuleOwner(modules []string) string

GetModuleOwner enforces that only IBC and the module bound to port can own the capability while future implementations may allow multiple modules to bind to a port, currently we only allow one module to be bound to a port at any given time

Types

type Port

type Port string
const (
	FT       Port = "FT"
	NFT      Port = "NFT"
	CONTRACT Port = "CONTRACT"
	SERVICE  Port = "SERVICE"
)

type Router

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

The router is a map from module name to the TIBCModule which contains all the module-defined callbacks required by TICS-26

func NewRouter

func NewRouter() *Router

func (*Router) AddRoute

func (rtr *Router) AddRoute(port Port, cbs TIBCModule) *Router

AddRoute adds TIBCModule for a given module name. It returns the Router so AddRoute calls can be linked. It will panic if the Router is sealed.

func (*Router) GetRoute

func (rtr *Router) GetRoute(port Port) (TIBCModule, bool)

GetRoute returns a IBCModule for a given module.

func (*Router) HasRoute

func (rtr *Router) HasRoute(port Port) bool

HasRoute returns true if the Router has a module registered or false otherwise.

func (*Router) Seal

func (rtr *Router) Seal()

Seal prevents the Router from any subsequent route handlers to be registered. Seal will panic if called more than once.

func (Router) Sealed

func (rtr Router) Sealed() bool

Sealed returns a boolean signifying if the Router is sealed or not.

type TIBCModule

type TIBCModule interface {
	// OnRecvPacket must return the acknowledgement bytes
	// In the case of an asynchronous acknowledgement, nil should be returned.
	OnRecvPacket(
		ctx sdk.Context,
		packet packettypes.Packet,
	) (*sdk.Result, []byte, error)

	OnAcknowledgementPacket(
		ctx sdk.Context,
		packet packettypes.Packet,
		acknowledgement []byte,
	) (*sdk.Result, error)
}

TIBCModule defines an interface that implements all the callbacks that modules must define as specified in TICS-26

Jump to

Keyboard shortcuts

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