indexer

package
v0.11.4 Latest Latest
Warning

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

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

Documentation

Overview

sequence-indexer v0.4.0 d44c148ecd843665eba71e66908382e569d8821a -- 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 IndexerPathPrefix = "/rpc/Indexer/"

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 ContractType_name = map[uint8]string{
	0: "UNKNOWN",
	1: "ERC20",
	2: "ERC721",
	3: "ERC1155",
	4: "SEQUENCE_WALLET",
	5: "ERC20_BRIDGE",
	6: "ERC721_BRIDGE",
	7: "ERC1155_BRIDGE",
}
View Source
var ContractType_value = map[string]uint8{
	"UNKNOWN":         0,
	"ERC20":           1,
	"ERC721":          2,
	"ERC1155":         3,
	"SEQUENCE_WALLET": 4,
	"ERC20_BRIDGE":    5,
	"ERC721_BRIDGE":   6,
	"ERC1155_BRIDGE":  7,
}
View Source
var EventLogDataType_name = map[uint8]string{
	0: "UNKNOWN",
	1: "TOKEN_TRANSFER",
	2: "SEQUENCE_TXN",
}
View Source
var EventLogDataType_value = map[string]uint8{
	"UNKNOWN":        0,
	"TOKEN_TRANSFER": 1,
	"SEQUENCE_TXN":   2,
}
View Source
var EventLogType_name = map[uint8]string{
	0: "UNKNOWN",
	1: "BLOCK_ADDED",
	2: "BLOCK_REMOVED",
}
View Source
var EventLogType_value = map[string]uint8{
	"UNKNOWN":       0,
	"BLOCK_ADDED":   1,
	"BLOCK_REMOVED": 2,
}
View Source
var SortOrder_name = map[uint32]string{
	0: "DESC",
	1: "ASC",
}
View Source
var SortOrder_value = map[string]uint32{
	"DESC": 0,
	"ASC":  1,
}
View Source
var TxnTransferType_name = map[uint32]string{
	0: "UNKNOWN",
	1: "SEND",
	2: "RECEIVE",
}
View Source
var TxnTransferType_value = map[string]uint32{
	"UNKNOWN": 0,
	"SEND":    1,
	"RECEIVE": 2,
}
View Source
var WebRPCServices = map[string][]string{
	"Indexer": {
		"Ping",
		"Version",
		"RuntimeStatus",
		"GetChainID",
		"GetEtherBalance",
		"GetTokenBalances",
		"GetTokenSupplies",
		"GetTokenSuppliesMap",
		"GetBalanceUpdates",
		"GetTransactionHistory",
	},
}

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 ContractType

type ContractType uint8
const (
	ContractType_UNKNOWN         ContractType = 0
	ContractType_ERC20           ContractType = 1
	ContractType_ERC721          ContractType = 2
	ContractType_ERC1155         ContractType = 3
	ContractType_SEQUENCE_WALLET ContractType = 4
	ContractType_ERC20_BRIDGE    ContractType = 5
	ContractType_ERC721_BRIDGE   ContractType = 6
	ContractType_ERC1155_BRIDGE  ContractType = 7
)

func (ContractType) MarshalJSON

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

func (ContractType) String

func (x ContractType) String() string

func (*ContractType) UnmarshalJSON

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

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 EtherBalance

type EtherBalance struct {
	AccountAddress prototyp.Hash   `json:"accountAddress"`
	BalanceWei     prototyp.BigInt `json:"balanceWei"`
}

type EventLog

type EventLog struct {
	ID              uint64           `json:"id" db:"id,omitempty"`
	Type            EventLogType     `json:"type" db:"type"`
	BlockNumber     uint64           `json:"blockNumber" db:"block_num"`
	BlockHash       prototyp.Hash    `json:"blockHash" db:"block_hash"`
	ContractAddress prototyp.Hash    `json:"contractAddress" db:"contract_address"`
	ContractType    ContractType     `json:"contractType" db:"contract_type"`
	TxnHash         prototyp.Hash    `json:"txnHash" db:"txn_hash"`
	TxnIndex        uint             `json:"txnIndex" db:"txn_index"`
	TxnLogIndex     uint             `json:"txnLogIndex" db:"txn_log_index"`
	LogDataType     EventLogDataType `json:"logDataType" db:"log_data_type"`
	TS              time.Time        `json:"ts" db:"ts"`
	LogData         string           `json:"logData" db:"log_data"`
}

type EventLogDataType

type EventLogDataType uint8
const (
	EventLogDataType_UNKNOWN        EventLogDataType = 0
	EventLogDataType_TOKEN_TRANSFER EventLogDataType = 1
	EventLogDataType_SEQUENCE_TXN   EventLogDataType = 2
)

func (EventLogDataType) MarshalJSON

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

func (EventLogDataType) String

func (x EventLogDataType) String() string

func (*EventLogDataType) UnmarshalJSON

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

type EventLogType

type EventLogType uint8
const (
	EventLogType_UNKNOWN       EventLogType = 0
	EventLogType_BLOCK_ADDED   EventLogType = 1
	EventLogType_BLOCK_REMOVED EventLogType = 2
)

func (EventLogType) MarshalJSON

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

func (EventLogType) String

func (x EventLogType) String() string

func (*EventLogType) UnmarshalJSON

func (x *EventLogType) UnmarshalJSON(b []byte) 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 IndexState

type IndexState struct {
	ChainID      prototyp.BigInt `json:"chainId" db:"chain_id"`
	LastBlockNum uint64          `json:"lastBlockNum" db:"last_block_num"`
}

type Indexer

type Indexer interface {
	Ping(ctx context.Context) (bool, error)
	Version(ctx context.Context) (*Version, error)
	RuntimeStatus(ctx context.Context) (*RuntimeStatus, error)
	GetChainID(ctx context.Context) (uint64, error)
	GetEtherBalance(ctx context.Context, accountAddress *string) (*EtherBalance, error)
	GetTokenBalances(ctx context.Context, accountAddress *string, contractAddress *string) ([]*TokenBalance, error)
	GetTokenSupplies(ctx context.Context, contractAddress string) (*ContractType, []*TokenSupply, error)
	GetTokenSuppliesMap(ctx context.Context, tokenMap map[string][]string) (map[string][]*TokenSupply, error)
	GetBalanceUpdates(ctx context.Context, contractAddress string, lastUpdateID uint64, page *Page) (*Page, []*TokenBalance, error)
	GetTransactionHistory(ctx context.Context, filter *TransactionHistoryFilter, page *Page) (*Page, []*Transaction, error)
}

func NewIndexerClient

func NewIndexerClient(addr string, client HTTPClient) Indexer

type Page

type Page struct {
	PageSize *uint32      `json:"pageSize"`
	Page     *uint32      `json:"page"`
	More     *bool        `json:"more"`
	Column   *string      `json:"column"`
	Before   *interface{} `json:"before"`
	After    *interface{} `json:"after"`
	Sort     []*SortBy    `json:"sort"`
}

type RuntimeChecks

type RuntimeChecks struct {
	Running      bool   `json:"running"`
	SyncMode     string `json:"syncMode"`
	LastBlockNum uint64 `json:"lastBlockNum"`
}

type RuntimeStatus

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

type SortBy

type SortBy struct {
	Column string     `json:"column"`
	Order  *SortOrder `json:"order"`
}

type SortOrder

type SortOrder uint32
const (
	SortOrder_DESC SortOrder = 0
	SortOrder_ASC  SortOrder = 1
)

func (SortOrder) MarshalJSON

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

func (SortOrder) String

func (x SortOrder) String() string

func (*SortOrder) UnmarshalJSON

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

type TokenBalance

type TokenBalance struct {
	ID              uint64             `json:"id,omitempty" db:"id,omitempty"`
	Key             prototyp.Key       `json:"-" db:"key"`
	ContractAddress prototyp.Hash      `json:"contractAddress" db:"contract_address"`
	ContractType    ContractType       `json:"contractType" db:"contract_type"`
	AccountAddress  prototyp.HashMaybe `json:"accountAddress,omitempty" db:"account_address,omitempty"`
	TokenID         prototyp.BigInt    `json:"tokenID,omitempty" db:"token_id"`
	Balance         prototyp.BigInt    `json:"balance" db:"balance"`
	BlockHash       prototyp.Hash      `json:"blockHash,omitempty" db:"block_hash"`
	BlockNumber     uint64             `json:"blockNumber,omitempty" db:"block_num"`
	UpdateID        uint64             `json:"updateId" db:"update_id"`
	ChainID         uint64             `json:"chainId" db:"-"`
}

type TokenHistory

type TokenHistory struct {
	ID              uint64        `json:"id" db:"id,omitempty"`
	BlockNumber     uint64        `json:"blockNumber" db:"block_num"`
	BlockHash       prototyp.Hash `json:"blockHash" db:"block_hash"`
	ContractAddress prototyp.Hash `json:"contractAddress" db:"contract_address"`
	ContractType    ContractType  `json:"contractType" db:"contract_type"`
	FromAddress     prototyp.Hash `json:"fromAddress" db:"from_address"`
	ToAddress       prototyp.Hash `json:"toAddress" db:"to_address"`
	TxnHash         prototyp.Hash `json:"txnHash" db:"txn_hash"`
	TxnIndex        uint          `json:"txnIndex" db:"txn_index"`
	TxnLogIndex     uint          `json:"txnLogIndex" db:"txn_log_index"`
	LogData         string        `json:"logData" db:"log_data"`
	TS              time.Time     `json:"ts" db:"ts"`
}

type TokenSupply

type TokenSupply struct {
	TokenID prototyp.BigInt `json:"tokenID,omitempty" db:"token_id"`
	Supply  prototyp.BigInt `json:"supply" db:"supply"`
	ChainID uint64          `json:"chainId" db:"-"`
}

type Transaction

type Transaction struct {
	TxnHash     prototyp.Hash  `json:"txnHash"`
	BlockNumber uint64         `json:"blockNumber"`
	BlockHash   prototyp.Hash  `json:"blockHash"`
	ChainID     uint64         `json:"chainId"`
	MetaTxnID   *string        `json:"metaTxnID"`
	Transfers   []*TxnTransfer `json:"transfers"`
	Timestamp   *time.Time     `json:"timestamp" db:"ts,omitempty"`
}

type TransactionHistoryFilter

type TransactionHistoryFilter struct {
	AccountAddress     *string  `json:"accountAddress"`
	ContractAddress    *string  `json:"contractAddress"`
	AccountAddresses   []string `json:"accountAddresses"`
	ContractAddresses  []string `json:"contractAddresses"`
	TransactionHashes  []string `json:"transactionHashes"`
	MetaTransactionIDs []string `json:"metaTransactionIDs"`
	FromBlock          *uint64  `json:"fromBlock"`
	ToBlock            *uint64  `json:"toBlock"`
}

type TxnTransfer

type TxnTransfer struct {
	TransferType    TxnTransferType   `json:"transferType"`
	ContractAddress prototyp.Hash     `json:"contractAddress"`
	ContractType    ContractType      `json:"contractType"`
	From            prototyp.Hash     `json:"from"`
	To              prototyp.Hash     `json:"to"`
	TokenIds        []prototyp.BigInt `json:"tokenIds,omitempty"`
	Amounts         []prototyp.BigInt `json:"amounts"`
}

type TxnTransferType

type TxnTransferType uint32
const (
	TxnTransferType_UNKNOWN TxnTransferType = 0
	TxnTransferType_SEND    TxnTransferType = 1
	TxnTransferType_RECEIVE TxnTransferType = 2
)

func (TxnTransferType) MarshalJSON

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

func (TxnTransferType) String

func (x TxnTransferType) String() string

func (*TxnTransferType) UnmarshalJSON

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

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