proto

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

sessions v0.0.1 b96502864e03f0bea75f41cafaf2178946a9e3b7 -- Code generated by webrpc-gen@v0.10.x-dev with golang generator. DO NOT EDIT.

webrpc-gen -schema=sessions.ridl -target=golang -pkg=proto -server -client -out=./sessions.gen.go

Index

Constants

View Source
const SessionsPathPrefix = "/rpc/Sessions/"

Variables

View Source
var (
	// For Client
	HTTPClientRequestHeadersCtxKey = &contextKey{"HTTPClientRequestHeaders"}

	// For Server
	HTTPResponseWriterCtxKey = &contextKey{"HTTPResponseWriter"}

	HTTPRequestCtxKey = &contextKey{"HTTPRequest"}

	ServiceNameCtxKey = &contextKey{"ServiceName"}

	MethodNameCtxKey = &contextKey{"MethodName"}
)
View Source
var SignatureType_name = map[int32]string{
	0: "EIP712",
	1: "EthSign",
	2: "EIP1271",
}
View Source
var SignatureType_value = map[string]int32{
	"EIP712":  0,
	"EthSign": 1,
	"EIP1271": 2,
}
View Source
var WebRPCServices = map[string][]string{
	"Sessions": {
		"Ping",
		"Config",
		"Wallets",
		"DeployHash",
		"ConfigUpdates",
		"Migrations",
		"SaveConfig",
		"SaveWallet",
		"SaveSignature",
		"SaveSignerSignatures",
		"SaveMigration",
	},
}

Functions

func HTTPRequestHeaders

func HTTPRequestHeaders(ctx context.Context) (http.Header, bool)

func HTTPStatusFromErrorCode

func HTTPStatusFromErrorCode(code ErrorCode) int

func IsErrorCode

func IsErrorCode(err error, code ErrorCode) bool

func IsValidErrorCode

func IsValidErrorCode(code ErrorCode) bool

func RespondWithError

func RespondWithError(w http.ResponseWriter, err error)

func WebRPCSchemaHash

func WebRPCSchemaHash() string

Schema hash generated from your RIDL schema

func WebRPCSchemaVersion

func WebRPCSchemaVersion() string

Schema version of your RIDL schema

func WebRPCVersion

func WebRPCVersion() string

WebRPC description and code-gen version

func WithHTTPRequestHeaders

func WithHTTPRequestHeaders(ctx context.Context, h http.Header) (context.Context, error)

Types

type ConfigUpdate

type ConfigUpdate struct {
	ToImageHash prototyp.Hash `json:"toImageHash"`
	Signature   prototyp.Hash `json:"signature"`
}

type Context

type Context struct {
	Version              int           `json:"version"`
	Factory              prototyp.Hash `json:"factory"`
	MainModule           prototyp.Hash `json:"mainModule"`
	MainModuleUpgradable prototyp.Hash `json:"mainModuleUpgradable"`
	GuestModule          prototyp.Hash `json:"guestModule"`
	WalletCreationCode   prototyp.Hash `json:"walletCreationCode"`
}

type Error

type Error interface {
	// Code is of the valid error codes
	Code() ErrorCode

	// Msg returns a human-readable, unstructured messages describing the error
	Msg() string

	// Cause is reason for the error
	Cause() error

	// Error returns a string of the form "webrpc error <Code>: <Msg>"
	Error() string

	// Error response payload
	Payload() ErrorPayload
}

func ErrorInternal

func ErrorInternal(format string, args ...interface{}) Error

func ErrorInvalidArgument

func ErrorInvalidArgument(argument string, validationMsg string) Error

func ErrorNotFound

func ErrorNotFound(format string, args ...interface{}) Error

func ErrorRequiredArgument

func ErrorRequiredArgument(argument string) Error

func Errorf

func Errorf(code ErrorCode, msgf string, args ...interface{}) Error

func Failf

func Failf(format string, args ...interface{}) Error

func WrapError

func WrapError(code ErrorCode, cause error, format string, args ...interface{}) Error

func WrapFailf

func WrapFailf(cause error, format string, args ...interface{}) Error

type ErrorCode

type ErrorCode string
const (
	// Unknown error. For example when handling errors raised by APIs that do not
	// return enough error information.
	ErrUnknown ErrorCode = "unknown"

	// Fail error. General failure error type.
	ErrFail ErrorCode = "fail"

	// Canceled indicates the operation was cancelled (typically by the caller).
	ErrCanceled ErrorCode = "canceled"

	// InvalidArgument indicates client specified an invalid argument. It
	// indicates arguments that are problematic regardless of the state of the
	// system (i.e. a malformed file name, required argument, number out of range,
	// etc.).
	ErrInvalidArgument ErrorCode = "invalid argument"

	// DeadlineExceeded means operation expired before completion. For operations
	// that change the state of the system, this error may be returned even if the
	// operation has completed successfully (timeout).
	ErrDeadlineExceeded ErrorCode = "deadline exceeded"

	// NotFound means some requested entity was not found.
	ErrNotFound ErrorCode = "not found"

	// BadRoute means that the requested URL path wasn't routable to a webrpc
	// service and method. This is returned by the generated server, and usually
	// shouldn't be returned by applications. Instead, applications should use
	// NotFound or Unimplemented.
	ErrBadRoute ErrorCode = "bad route"

	// AlreadyExists means an attempt to create an entity failed because one
	// already exists.
	ErrAlreadyExists ErrorCode = "already exists"

	// PermissionDenied indicates the caller does not have permission to execute
	// the specified operation. It must not be used if the caller cannot be
	// identified (Unauthenticated).
	ErrPermissionDenied ErrorCode = "permission denied"

	// Unauthenticated indicates the request does not have valid authentication
	// credentials for the operation.
	ErrUnauthenticated ErrorCode = "unauthenticated"

	// ResourceExhausted indicates some resource has been exhausted, perhaps a
	// per-user quota, or perhaps the entire file system is out of space.
	ErrResourceExhausted ErrorCode = "resource exhausted"

	// FailedPrecondition indicates operation was rejected because the system is
	// not in a state required for the operation's execution. For example, doing
	// an rmdir operation on a directory that is non-empty, or on a non-directory
	// object, or when having conflicting read-modify-write on the same resource.
	ErrFailedPrecondition ErrorCode = "failed precondition"

	// Aborted indicates the operation was aborted, typically due to a concurrency
	// issue like sequencer check failures, transaction aborts, etc.
	ErrAborted ErrorCode = "aborted"

	// OutOfRange means operation was attempted past the valid range. For example,
	// seeking or reading past end of a paginated collection.
	//
	// Unlike InvalidArgument, this error indicates a problem that may be fixed if
	// the system state changes (i.e. adding more items to the collection).
	//
	// There is a fair bit of overlap between FailedPrecondition and OutOfRange.
	// We recommend using OutOfRange (the more specific error) when it applies so
	// that callers who are iterating through a space can easily look for an
	// OutOfRange error to detect when they are done.
	ErrOutOfRange ErrorCode = "out of range"

	// Unimplemented indicates operation is not implemented or not
	// supported/enabled in this service.
	ErrUnimplemented ErrorCode = "unimplemented"

	// Internal errors. When some invariants expected by the underlying system
	// have been broken. In other words, something bad happened in the library or
	// backend service. Do not confuse with HTTP Internal Server Error; an
	// Internal error could also happen on the client code, i.e. when parsing a
	// server response.
	ErrInternal ErrorCode = "internal"

	// Unavailable indicates the service is currently unavailable. This is a most
	// likely a transient condition and may be corrected by retrying with a
	// backoff.
	ErrUnavailable ErrorCode = "unavailable"

	// DataLoss indicates unrecoverable data loss or corruption.
	ErrDataLoss ErrorCode = "data loss"

	// ErrNone is the zero-value, is considered an empty error and should not be
	// used.
	ErrNone ErrorCode = ""
)

type ErrorPayload

type ErrorPayload struct {
	Status int    `json:"status"`
	Code   string `json:"code"`
	Cause  string `json:"cause,omitempty"`
	Msg    string `json:"msg"`
	Error  string `json:"error"`
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.

type Sessions

type Sessions interface {
	Ping(ctx context.Context) error
	Config(ctx context.Context, imageHash string) (int, interface{}, error)
	Wallets(ctx context.Context, signer string) (map[string]*Signature, error)
	DeployHash(ctx context.Context, wallet string) (string, *Context, error)
	ConfigUpdates(ctx context.Context, wallet string, fromImageHash string, allUpdates *bool) ([]*ConfigUpdate, error)
	Migrations(ctx context.Context, wallet string, fromVersion int, fromImageHash string, chainID *string) (map[string]map[int]map[string]*TransactionBundle, error)
	SaveConfig(ctx context.Context, version int, config interface{}) error
	SaveWallet(ctx context.Context, version int, deployConfig interface{}) error
	SaveSignature(ctx context.Context, wallet string, digest string, chainID string, signature string, toConfig *interface{}) error
	SaveSignerSignatures(ctx context.Context, wallet string, digest string, chainID string, signatures []string, toConfig *interface{}) error
	SaveMigration(ctx context.Context, wallet string, fromVersion int, toVersion int, toConfig interface{}, executor string, transactions []*Transaction, nonce string, signature string, chainID *string) error
}

func NewSessionsClient

func NewSessionsClient(addr string, client HTTPClient) Sessions

type Signature

type Signature struct {
	Digest      prototyp.Hash      `json:"digest"`
	ToImageHash prototyp.HashMaybe `json:"toImageHash,omitempty"`
	ChainID     prototyp.BigInt    `json:"chainID"`
	Type        SignatureType      `json:"type"`
	Signature   prototyp.Hash      `json:"signature"`
}

type SignatureType

type SignatureType int32
const (
	SignatureType_EIP712  SignatureType = 0
	SignatureType_EthSign SignatureType = 1
	SignatureType_EIP1271 SignatureType = 2
)

func (SignatureType) MarshalJSON

func (x SignatureType) MarshalJSON() ([]byte, error)

func (SignatureType) String

func (x SignatureType) String() string

func (*SignatureType) UnmarshalJSON

func (x *SignatureType) UnmarshalJSON(b []byte) error

type Transaction

type Transaction struct {
	To            prototyp.Hash      `json:"to"`
	Value         prototyp.BigInt    `json:"value,omitempty"`
	Data          prototyp.HashMaybe `json:"data,omitempty"`
	GasLimit      prototyp.BigInt    `json:"gasLimit,omitempty"`
	DelegateCall  *bool              `json:"delegateCall,omitempty"`
	RevertOnError *bool              `json:"revertOnError,omitempty"`
}

type TransactionBundle

type TransactionBundle struct {
	Executor     prototyp.Hash   `json:"executor"`
	Transactions []*Transaction  `json:"transactions"`
	Nonce        prototyp.BigInt `json:"nonce"`
	Signature    prototyp.Hash   `json:"signature"`
}

type WebRPCServer

type WebRPCServer interface {
	http.Handler
}

func NewSessionsServer

func NewSessionsServer(svc Sessions) WebRPCServer

Jump to

Keyboard shortcuts

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