sdk

package
v0.0.0-...-dcdbaa1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSDKHandleRelay                   = sdkerrors.Register(codespace, 1, "internal error handling relay request")
	ErrSDKInvalidRelayResponseSignature = sdkerrors.Register(codespace, 2, "invalid relay response signature")
	ErrSDKEmptyRelayResponseSignature   = sdkerrors.Register(codespace, 3, "empty relay response signature")
	ErrSDKVerifyResponseSignature       = sdkerrors.Register(codespace, 4, "error verifying relay response signature")
	ErrSDKGetApplications               = sdkerrors.Register(codespace, 5, "error querying on-chain applications")
	ErrSDKEmptySupplierPubKey           = sdkerrors.Register(codespace, 6, "empty supplier public key")
)

TODO_TECHDEBT: Do a source code wise find-replace using regex pattern match of `sdkerrors\.Wrapf\(([a-zA-Z]+), ` with `$1.Wrapf(`

Functions

func RPCToWebsocketURL

func RPCToWebsocketURL(hostUrl *url.URL) string

RPCToWebsocketURL converts the provided URL into a websocket URL string that can be used to subscribe to onchain events and query the chain via a client context or send transactions via a tx client context.

Types

type GetApplicationsOptions

type GetApplicationsOptions struct {
	// If non-empty, only return applications that have delegated to this gateway address
	DelegatedGatewayAddress string
}

GetApplicationsOptions defines the options for the GetApplications SDK method

type POKTRollSDK

type POKTRollSDK interface {
	// GetApplications queries a list of all on-chain applications, optionally filtered by
	// delegated gateway
	GetApplications(ctx context.Context, options GetApplicationsOptions) ([]apptypes.Application, error)

	// GetSessionSupplierEndpoints returns the suppliers endpoints of the current session for
	// the given application and service.
	GetSessionSupplierEndpoints(
		ctx context.Context,
		appAddress string,
		serviceId string,
	) (session *SessionSuppliers, err error)

	// SendRelay sends a relay request to the given supplier's endpoint.
	SendRelay(
		ctx context.Context,
		sessionSupplierEndpoint *SingleSupplierEndpoint,
		request http.Request,
	) (response *servicetypes.RelayResponse, err error)
}

POKTRollSDK is the interface for the POKTRoll SDK. It is used by gateways and/or applications to interact with the Pocket protocol.

func NewPOKTRollSDK

func NewPOKTRollSDK(ctx context.Context, config *POKTRollSDKConfig) (POKTRollSDK, error)

NewPOKTRollSDK creates a new POKTRollSDK instance with the given configuration.

type POKTRollSDKConfig

type POKTRollSDKConfig struct {
	QueryNodeGRPCUrl *url.URL
	QueryNodeUrl     *url.URL
	PrivateKey       cryptotypes.PrivKey
	Deps             depinject.Config
}

POKTRollSDKConfig is the configuration for the POKTRollSDK. It contains the Pocket Node URL to be used by the queriers and the private key to be used for signing relay requests. Deps is an optional field that can be used to provide the needed dependencies for the SDK. If it is not provided, the SDK will build the dependencies itself.

type SessionSuppliers

type SessionSuppliers struct {
	// Session is the fully hydrated session object returned by the query.
	Session *sessiontypes.Session

	// SuppliersEndpoints is a slice of the session's suppliers endpoints each
	// item representing a single supplier endpoint augmented with the session
	// header and the supplier's address.
	// An item from this slice is what needs to be passed to the `SendRelay`
	// function so it has all the information needed to send the relay request.
	SuppliersEndpoints []*SingleSupplierEndpoint
}

SessionSuppliers is the structure that represents a session's end block height and its matching suppliers.

type SingleSupplierEndpoint

type SingleSupplierEndpoint struct {
	Url             *url.URL
	RpcType         sharedtypes.RPCType
	SupplierAddress string
	Header          *sessiontypes.SessionHeader
}

SingleSupplierEndpoint is the structure that represents a supplier's endpoint augmented with the session's header and the supplier's address for easy access to the needed information when sending a relay request.

Jump to

Keyboard shortcuts

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