rpc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 29 Imported by: 1

Documentation

Index

Constants

View Source
const (
	OptionsFromKey   = "from"
	OptionsToKey     = "to"
	OptionsValueKey  = "value"
	OptionsMethodKey = "method"
	OptionsArgsKey   = "args"
)
View Source
const (
	RosettaVersion = "1.3.1"
	BlockchainName = "celo"
)

Variables

View Source
var (
	ErrValidation    = NewErrorResponse(400, "Request body invalid")
	ErrUnimplemented = NewErrorResponse(405, "Unimplemented rosetta endpoint")
	ErrInternal      = NewErrorResponse(500, "Internal server error")
	ErrCeloClient    = NewErrorResponse(502, "Celo node rpc request failed")
)
View Source
var (
	ErrBadBlockIdentifier = errors.New("Bad block identifier")
	ErrFetchBlockHeader   = errors.New("Failed to fetch block header")
	ErrMissingTxInBlock   = errors.New("Transaction doesn't belong to block")
)
View Source
var (
	CeloGold = &types.Currency{
		Symbol:   "cGLD",
		Decimals: 18,
	}
	CeloDollar = &types.Currency{
		Symbol:   "cUSD",
		Decimals: 18,
	}
)
View Source
var (
	MiddlewareVersion = "1.0.1"
	NodeVersion       = params.Version
)

Functions

func AllCallMethods added in v0.7.5

func AllCallMethods() []string

func FullToPartialBlockIdentifier

func FullToPartialBlockIdentifier(blockIdentifer *rosettaTypes.BlockIdentifier) *rosettaTypes.PartialBlockIdentifier

func HeaderContainsTx

func HeaderContainsTx(header *ethclient.HeaderAndTxnHashes, txHash common.Hash) bool

func HeaderToBlockIdentifier

func HeaderToBlockIdentifier(header *gethTypes.Header) *rosettaTypes.BlockIdentifier

func HeaderToParentBlockIdentifier

func HeaderToParentBlockIdentifier(header *gethTypes.Header) *rosettaTypes.BlockIdentifier

func LogErrCeloClient

func LogErrCeloClient(rpcEndpoint string, err error) *types.Error

func LogErrDetails added in v0.7.3

func LogErrDetails(rosettaErr *types.Error, err error) *types.Error

func LogErrFetchBlockHeader

func LogErrFetchBlockHeader(err error) *types.Error

func LogErrInternal

func LogErrInternal(err error, params ...interface{}) *types.Error

func LogErrUnimplemented

func LogErrUnimplemented(rosettaEndpoint string) *types.Error

func LogErrValidation

func LogErrValidation(err error) *types.Error

func MapTxHashesToTransaction

func MapTxHashesToTransaction(txHashes []common.Hash) []*rosettaTypes.TransactionIdentifier

func NewAmount

func NewAmount(value *big.Int, currency *rosettaTypes.Currency) *rosettaTypes.Amount

func NewErrorResponse

func NewErrorResponse(code int32, msg string) *types.Error

[Caution]: all expected error responses must be enumerated in /network/options

func NewOperationIdentifier

func NewOperationIdentifier(index int64) *rosettaTypes.OperationIdentifier

func NewRetriableErrorResponse

func NewRetriableErrorResponse(code int32, msg string) *types.Error

[Caution]: all expected error responses must be enumerated in /network/options

func NewRosettaServer

func NewRosettaServer(cc *client.CeloClient, db db.RosettaDBReader, cfg *RosettaServerConfig, chainParams *chain.ChainParameters) (*rosettaServer, error)

func OperationsFromAnalyzer

func OperationsFromAnalyzer(iop *analyzer.Operation, baseIndex int64) []*rosettaTypes.Operation

func PeersFromInfo

func PeersFromInfo(peersInfo []p2p.PeerInfo) []*rosettaTypes.Peer

func TxIdsFromTxAccountMap

func TxIdsFromTxAccountMap(txAccountMap txpool.TxAccountMap) []*rosettaTypes.TransactionIdentifier

Types

type CallLogsResult added in v0.7.7

type CallLogsResult struct {
	Logs []gethTypes.Log `json:"logs"`
}

type CallMethod added in v0.7.5

type CallMethod string
const CeloCall CallMethod = "celo_call"
const CeloGetLogs CallMethod = "celo_getLogs"

func (CallMethod) String added in v0.7.5

func (cm CallMethod) String() string

type CallResult added in v0.7.7

type CallResult struct {
	Raw             []byte                 `json:"raw"`
	BlockIdentifier *types.BlockIdentifier `json:"block_identifier"`
}

type OperationResult

type OperationResult string
const (
	OperationSuccess OperationResult = "success"
	OperationFailed  OperationResult = "failed"
)

func GetOperationStatus

func GetOperationStatus(success bool) OperationResult

func (OperationResult) String

func (or OperationResult) String() string

func (OperationResult) ToOperationStatus

func (or OperationResult) ToOperationStatus() *types.OperationStatus

type RosettaServerConfig

type RosettaServerConfig struct {
	Port           uint
	Interface      string
	RequestTimeout time.Duration
}

func (*RosettaServerConfig) ListenAddress

func (hs *RosettaServerConfig) ListenAddress() string

type Servicer

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

Servicer is a service that implents the logic for the Servicerr This service should implement the business logic for every endpoint for the AccountApi API. Include any external packages or services that will be required by this service.

func NewServicer

func NewServicer(celoClient *client.CeloClient, db db.RosettaDBReader, cfg *RosettaServerConfig, cp *chain.ChainParameters) (*Servicer, error)

NewServicer creates a default api service

func (*Servicer) AccountBalance

AccountBalance - Get an Account Balance

func (*Servicer) Block

func (s *Servicer) Block(ctx context.Context, request *types.BlockRequest) (*types.BlockResponse, *types.Error)

Block - Get a Block

func (*Servicer) BlockTransaction

BlockTransaction - Get a Block Transaction

func (*Servicer) Call added in v0.7.5

func (s *Servicer) Call(ctx context.Context, request *types.CallRequest) (*types.CallResponse, *types.Error)

func (*Servicer) ConstructionCombine added in v0.7.3

func (*Servicer) ConstructionDerive added in v0.7.3

func (*Servicer) ConstructionHash added in v0.7.3

func (*Servicer) ConstructionMetadata

func (*Servicer) ConstructionParse added in v0.7.3

func (*Servicer) ConstructionPayloads added in v0.7.3

func (*Servicer) ConstructionPreprocess added in v0.7.3

func (*Servicer) ConstructionSubmit

func (*Servicer) Mempool

func (s *Servicer) Mempool(ctx context.Context, request *types.NetworkRequest) (*types.MempoolResponse, *types.Error)

Mempool - Get All Mempool Transactions

func (*Servicer) MempoolTransaction

MempoolTransaction - Get a Mempool Transaction

func (*Servicer) NetworkList

func (s *Servicer) NetworkList(ctx context.Context, request *types.MetadataRequest) (*types.NetworkListResponse, *types.Error)

func (*Servicer) NetworkOptions

func (s *Servicer) NetworkOptions(ctx context.Context, request *types.NetworkRequest) (*types.NetworkOptionsResponse, *types.Error)

func (*Servicer) NetworkStatus

func (s *Servicer) NetworkStatus(ctx context.Context, request *types.NetworkRequest) (*types.NetworkStatusResponse, *types.Error)

NetworkStatus - Get Network Status

Jump to

Keyboard shortcuts

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