metadata

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

sequence-metadata v0.4.0 3ca0743a5a28609d8befcd56350d0654d671a66e -- This file has been generated by https://github.com/webrpc/webrpc using gen/golang Do not edit by hand. Update your webrpc schema and re-generate.

Index

Constants

View Source
const MetadataPathPrefix = "/rpc/Metadata/"

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 SwapType_name = map[uint32]string{
	0: "UNKNOWN",
	1: "BUY",
	2: "SELL",
}
View Source
var SwapType_value = map[string]uint32{
	"UNKNOWN": 0,
	"BUY":     1,
	"SELL":    2,
}
View Source
var WebRPCServices = map[string][]string{
	"Metadata": {
		"Ping",
		"Version",
		"RuntimeStatus",
		"GetTokenMetadata",
		"GetTokenMetadataBatch",
		"GetContractInfo",
		"GetContractInfoBatch",
		"SearchContractInfo",
		"SearchContractInfoBatch",
		"GetNiftyswapTokenQuantity",
		"GetNiftyswapUnitPrices",
	},
}

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 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 ContractInfo

type ContractInfo struct {
	ChainID    uint64                  `json:"chainId"`
	Address    string                  `json:"address"`
	Name       string                  `json:"name"`
	Type       string                  `json:"type"`
	Symbol     string                  `json:"symbol"`
	Decimals   *uint64                 `json:"decimals,omitempty"`
	LogoURI    string                  `json:"logoURI"`
	Extensions *ContractInfoExtensions `json:"extensions"`
}

type ContractInfoExtensions

type ContractInfoExtensions struct {
	Link          string `json:"link"`
	Description   string `json:"description"`
	OgImage       string `json:"ogImage"`
	OriginChainID uint64 `json:"originChainId"`
	OriginAddress string `json:"originAddress"`
}

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 GetNiftyswapUnitPricesRequest

type GetNiftyswapUnitPricesRequest struct {
	SwapType *SwapType         `json:"swapType"`
	Ids      []prototyp.BigInt `json:"ids"`
	Amounts  []prototyp.BigInt `json:"amounts"`
}

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 Metadata

type Metadata interface {
	Ping(ctx context.Context) (bool, error)
	Version(ctx context.Context) (*Version, error)
	RuntimeStatus(ctx context.Context) (*RuntimeStatus, error)
	GetTokenMetadata(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) ([]*TokenMetadata, error)
	GetTokenMetadataBatch(ctx context.Context, chainID string, contractTokenMap map[string][]string) (map[string][]*TokenMetadata, error)
	GetContractInfo(ctx context.Context, chainID string, contractAddress string) (*ContractInfo, error)
	GetContractInfoBatch(ctx context.Context, chainID string, contractAddresses []string) (map[string]*ContractInfo, error)
	SearchContractInfo(ctx context.Context, contractAddress string) ([]*ContractInfo, error)
	SearchContractInfoBatch(ctx context.Context, contractAddresses []string) (map[string][]*ContractInfo, error)
	GetNiftyswapTokenQuantity(ctx context.Context, chainID string, contractAddress string, tokenIDs []string) (map[string]string, error)
	GetNiftyswapUnitPrices(ctx context.Context, chainID string, contractAddress string, req *GetNiftyswapUnitPricesRequest) (map[string]string, error)
}

func NewMetadataClient

func NewMetadataClient(addr string, client HTTPClient) Metadata

type RuntimeChecks

type RuntimeChecks struct {
}

type RuntimeStatus

type RuntimeStatus struct {
	HealthOK   bool           `json:"healthOK"`
	StartTime  time.Time      `json:"startTime"`
	Uptime     uint64         `json:"uptime"`
	Ver        string         `json:"ver"`
	Branch     string         `json:"branch"`
	CommitHash string         `json:"commitHash"`
	Checks     *RuntimeChecks `json:"checks"`
}

type SwapType

type SwapType uint32
const (
	SwapType_UNKNOWN SwapType = 0
	SwapType_BUY     SwapType = 1
	SwapType_SELL    SwapType = 2
)

func (SwapType) MarshalJSON

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

func (SwapType) String

func (x SwapType) String() string

func (*SwapType) UnmarshalJSON

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

type TokenMetadata

type TokenMetadata struct {
	TokenID         string                   `json:"tokenId"`
	ContractAddress prototyp.Hash            `json:"contractAddress"`
	Name            string                   `json:"name"`
	Description     string                   `json:"description"`
	Image           string                   `json:"image"`
	Decimals        uint64                   `json:"decimals"`
	Properties      map[string]interface{}   `json:"properties"`
	ImageData       string                   `json:"image_data,omitempty"`
	ExternalUrl     string                   `json:"external_url,omitempty"`
	BackgroundColor string                   `json:"background_color,omitempty"`
	Attributes      []map[string]interface{} `json:"attributes"`
}

type Version

type Version struct {
	WebrpcVersion string `json:"webrpcVersion"`
	SchemaVersion string `json:"schemaVersion"`
	SchemaHash    string `json:"schemaHash"`
	AppVersion    string `json:"appVersion"`
}

Jump to

Keyboard shortcuts

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