services

package
v0.0.0-...-607e7b9 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TokenContractAddressKey is the key in the currency metadata map
	// that represents the contract address of a token
	TokenContractAddressKey = "token_address"
	// NoMethodSig is the method signature name when a contract call does not have one
	NoMethodSig = "NO-METHOD-SIG"
)

Variables

View Source
var (
	// Errors contains all errors that could be returned
	// by this Rosetta implementation.
	Errors = []*types.Error{
		ErrUnimplemented,
		ErrUnavailableOffline,
		ErrGeth,
		ErrUnableToDecompressPubkey,
		ErrUnclearIntent,
		ErrUnableToParseIntermediateResult,
		ErrSignatureInvalid,
		ErrBroadcastFailed,
		ErrCallParametersInvalid,
		ErrCallOutputMarshal,
		ErrCallMethodInvalid,
		ErrBlockOrphaned,
		ErrInvalidAddress,
		ErrGethNotReady,
		ErrInvalidNonce,
		ErrInvalidTokenContractAddress,
		ErrBadRequest,
		ErrUnableToParseTransaction,
		ErrInvalidGasPrice,
		ErrInvalidSignature,
		ErrFetchFunctionSignatureMethodID,
		ErrInvalidTransaction,
		ErrInvalidGasLimit,
		ErrInvalidGasTipCap,
		ErrInvalidGasFeeCap,
		ErrL1DataFee,
	}

	// ErrUnimplemented is returned when an endpoint
	// is called that is not implemented.
	ErrUnimplemented = &types.Error{
		Code:    0,
		Message: "Endpoint not implemented",
	}

	// ErrUnavailableOffline is returned when an endpoint
	// is called that is not available offline.
	ErrUnavailableOffline = &types.Error{
		Code:    1,
		Message: "Endpoint unavailable offline",
	}

	// ErrGeth is returned when geth
	// errors on a request.
	ErrGeth = &types.Error{
		Code:    2,
		Message: "geth error",
	}

	// ErrUnableToDecompressPubkey is returned when
	// the *types.PublicKey provided in /construction/derive
	// cannot be decompressed.
	ErrUnableToDecompressPubkey = &types.Error{
		Code:    3,
		Message: "unable to decompress public key",
	}

	// ErrUnclearIntent is returned when operations
	// provided in /construction/preprocess or /construction/payloads
	// are not valid.
	ErrUnclearIntent = &types.Error{
		Code:    4,
		Message: "Unable to parse intent",
	}

	// ErrUnableToParseIntermediateResult is returned
	// when a data structure passed between Construction
	// API calls is not valid.
	ErrUnableToParseIntermediateResult = &types.Error{
		Code:    5,
		Message: "Unable to parse intermediate result",
	}

	// ErrSignatureInvalid is returned when a signature
	// cannot be parsed.
	ErrSignatureInvalid = &types.Error{
		Code:    6,
		Message: "Signature invalid",
	}

	// ErrBroadcastFailed is returned when transaction
	// broadcast fails.
	ErrBroadcastFailed = &types.Error{
		Code:    7,
		Message: "Unable to broadcast transaction",
	}

	// ErrCallParametersInvalid is returned when
	// the parameters for a particular call method
	// are considered invalid.
	ErrCallParametersInvalid = &types.Error{
		Code:    8,
		Message: "Call parameters invalid",
	}

	// ErrCallOutputMarshal is returned when the output
	// for /call cannot be marshaled.
	ErrCallOutputMarshal = &types.Error{
		Code:    9,
		Message: "Call output marshal failed",
	}

	// ErrCallMethodInvalid is returned when a /call
	// method is invalid.
	ErrCallMethodInvalid = &types.Error{
		Code:    10,
		Message: "Call method invalid",
	}

	// ErrBlockOrphaned is returned when a block being
	// processed is orphaned and it is not possible
	// to gather all receipts. At some point in the future,
	// it may become possible to gather all receipts if the
	// block becomes part of the canonical chain again.
	ErrBlockOrphaned = &types.Error{
		Code:      11,
		Message:   "Block orphaned",
		Retriable: true,
	}

	// ErrInvalidAddress is returned when an address
	// is not valid.
	ErrInvalidAddress = &types.Error{
		Code:    12,
		Message: "Invalid address",
	}

	// ErrGethNotReady is returned when geth
	// cannot yet serve any queries.
	ErrGethNotReady = &types.Error{
		Code:      13,
		Message:   "geth not ready",
		Retriable: true,
	}

	// ErrInvalidNonce is returned when input nonce
	// is invalid.
	ErrInvalidNonce = &types.Error{
		Code:    14,
		Message: "Nonce invalid",
	}

	// ErrInvalidTokenContractAddress is returned when the token
	// contract address is invalid
	ErrInvalidTokenContractAddress = &types.Error{
		Code:    15,
		Message: "Invalid token contract address",
	}

	// ErrBadRequest is returned when the request is invalid
	ErrBadRequest = &types.Error{
		Code:    16,
		Message: "Bad request",
	}

	// ErrUnableToParseTransaction is returned when the transaction
	// cannot be parsed
	ErrUnableToParseTransaction = &types.Error{
		Code:    17,
		Message: "unable to parse the transaction",
	}

	// ErrInvalidGasPrice is returned when input gas price
	// is invalid.
	ErrInvalidGasPrice = &types.Error{
		Code:    18,
		Message: "Gas price invalid",
	}

	// ErrInvalidSignature is returned when a signature
	// cannot be parsed.
	ErrInvalidSignature = &types.Error{
		Code:    19,
		Message: "Signature invalid",
	}

	// ErrFetchFunctionSignatureMethodID is returned when
	// hash.Write fails to hash a function signature
	ErrFetchFunctionSignatureMethodID = &types.Error{
		Code:    20,
		Message: "Failed to hash function signature",
	}

	// ErrInvalidTransaction is returned when a transaction is invalid
	ErrInvalidTransaction = &types.Error{
		Code:    21,
		Message: "Transaction invalid",
	}

	// ErrInvalidGasLimit is returned when input gas limit
	// is invalid.
	ErrInvalidGasLimit = &types.Error{
		Code:    22,
		Message: "Gas limit invalid",
	}

	ErrInvalidGasTipCap = &types.Error{
		Code:    23,
		Message: "Gas tip cap invalid",
	}

	ErrInvalidGasFeeCap = &types.Error{
		Code:    24,
		Message: "Gas fee cap invalid",
	}

	ErrL1DataFee = &types.Error{
		Code:    25,
		Message: "Failed to get L1 data fee",
	}
)

Functions

func AsEthTransaction

func AsEthTransaction(tx *transaction) *types.Transaction

func NewBlockchainRouter

func NewBlockchainRouter(
	config *configuration.Configuration,
	client Client,
	asserter *asserter.Asserter,
) http.Handler

NewBlockchainRouter creates a Mux http.Handler from a collection of server controllers.

func NewMempoolAPIService

func NewMempoolAPIService() server.MempoolAPIServicer

NewMempoolAPIService creates a new instance of a MempoolAPIService.

Types

type AccountAPIService

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

AccountAPIService implements the server.AccountAPIServicer interface.

func NewAccountAPIService

func NewAccountAPIService(
	cfg *configuration.Configuration,
	client Client,
) *AccountAPIService

NewAccountAPIService returns a new *AccountAPIService.

func (*AccountAPIService) AccountBalance

AccountBalance implements /account/balance.

func (*AccountAPIService) AccountCoins

AccountCoins implements /account/coins.

type BlockAPIService

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

BlockAPIService implements the server.BlockAPIServicer interface.

func NewBlockAPIService

func NewBlockAPIService(
	cfg *configuration.Configuration,
	client Client,
) *BlockAPIService

NewBlockAPIService creates a new instance of a BlockAPIService.

func (*BlockAPIService) Block

Block implements the /block endpoint.

func (*BlockAPIService) BlockTransaction

BlockTransaction implements the /block/transaction endpoint.

type CallAPIService

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

CallAPIService implements the server.CallAPIServicer interface.

func NewCallAPIService

func NewCallAPIService(cfg *configuration.Configuration, client Client) *CallAPIService

NewCallAPIService creates a new instance of a CallAPIService.

func (*CallAPIService) Call

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

Call implements the /call endpoint.

type Client

type Client interface {
	Status(context.Context) (
		*types.BlockIdentifier,
		int64,
		*types.SyncStatus,
		[]*types.Peer,
		error,
	)

	Block(
		context.Context,
		*types.PartialBlockIdentifier,
	) (*types.Block, error)

	Balance(
		context.Context,
		*types.AccountIdentifier,
		*types.PartialBlockIdentifier,
		[]*types.Currency,
	) (*types.AccountBalanceResponse, error)

	PendingNonceAt(context.Context, common.Address) (uint64, error)

	EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)

	SuggestGasPrice(ctx context.Context) (*big.Int, error)

	SuggestGasTipCap(ctx context.Context) (*big.Int, error)

	BaseFee(ctx context.Context) (*big.Int, error)

	SendTransaction(ctx context.Context, tx *ethTypes.Transaction) error

	Call(
		ctx context.Context,
		request *types.CallRequest,
	) (*types.CallResponse, error)

	CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)

	CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)

	PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

	HeaderByNumber(ctx context.Context, number *big.Int) (*ethTypes.Header, error)

	FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]ethTypes.Log, error)

	SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- ethTypes.Log) (ethereum.Subscription, error)
}

Client is used by the servicers to get block data and to submit transactions.

type ConstructionAPIService

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

ConstructionAPIService implements the server.ConstructionAPIServicer interface.

func NewConstructionAPIService

func NewConstructionAPIService(
	cfg *configuration.Configuration,
	client Client,
) *ConstructionAPIService

NewConstructionAPIService creates a new instance of a ConstructionAPIService.

func (*ConstructionAPIService) ConstructionCombine

ConstructionCombine implements the /construction/combine endpoint.

func (*ConstructionAPIService) ConstructionDerive

ConstructionDerive implements the /construction/derive endpoint.

func (*ConstructionAPIService) ConstructionHash

ConstructionHash implements the /construction/hash endpoint.

func (*ConstructionAPIService) ConstructionMetadata

ConstructionMetadata implements the /construction/metadata endpoint.

func (*ConstructionAPIService) ConstructionParse

ConstructionParse implements the /construction/parse endpoint.

func (*ConstructionAPIService) ConstructionPayloads

ConstructionPayloads implements the /construction/payloads endpoint.

func (*ConstructionAPIService) ConstructionPreprocess

ConstructionPreprocess implements the /construction/preprocess endpoint.

func (*ConstructionAPIService) ConstructionSubmit

ConstructionSubmit implements the /construction/submit endpoint.

func (*ConstructionAPIService) GetClient

func (s *ConstructionAPIService) GetClient() Client

type MempoolAPIService

type MempoolAPIService struct {
}

MempoolAPIService implements the server.MempoolAPIServicer interface.

func (*MempoolAPIService) Mempool

Mempool implements the /mempool endpoint.

func (*MempoolAPIService) MempoolTransaction

MempoolTransaction implements the /mempool/transaction endpoint.

type NetworkAPIService

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

NetworkAPIService implements the server.NetworkAPIServicer interface.

func NewNetworkAPIService

func NewNetworkAPIService(
	cfg *configuration.Configuration,
	client Client,
) *NetworkAPIService

NewNetworkAPIService creates a new instance of a NetworkAPIService.

func (*NetworkAPIService) NetworkList

NetworkList implements the /network/list endpoint

func (*NetworkAPIService) NetworkOptions

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

NetworkOptions implements the /network/options endpoint.

func (*NetworkAPIService) NetworkStatus

NetworkStatus implements the /network/status endpoint.

Jump to

Keyboard shortcuts

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