service

package
v0.1.46 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Overview

Package service is a generated GoMock package.

Index

Constants

View Source
const (
	ModeOffline        = "offline"
	ModeOnline         = "online"
	StandardIngestion  = "standard"
	AnalyticsIngestion = "analytics"
)
View Source
const (
	MiddlewareVersion = "0.1.46"
	BlockchainName    = "Avalanche"
)
View Source
const BalanceOfMethodPrefix = "0x70a08231000000000000000000000000"

Variables

View Source
var (
	// Errors lists all available error types
	Errors = []*types.Error{
		ErrNotReady,
		ErrNotImplemented,
		ErrNotSupported,
		ErrUnavailableOffline,
		ErrInternalError,
		ErrInvalidInput,
		ErrClientError,
		ErrBlockInvalidInput,
		ErrBlockNotFound,
		ErrCallInvalidMethod,
		ErrCallInvalidParams,
		ErrTransactionNotFound,
	}

	// General errors
	ErrNotReady            = makeError(1, "Node is not ready", true)
	ErrNotImplemented      = makeError(2, "Endpoint is not implemented", false)
	ErrNotSupported        = makeError(3, "Endpoint is not supported", false)
	ErrUnavailableOffline  = makeError(4, "Endpoint is not available offline", false)
	ErrInternalError       = makeError(5, "Internal server error", true)
	ErrInvalidInput        = makeError(6, "Invalid input", false)
	ErrClientError         = makeError(7, "Client error", true)
	ErrBlockInvalidInput   = makeError(8, "Block number or hash is required", false)
	ErrBlockNotFound       = makeError(9, "Block was not found", true)
	ErrCallInvalidMethod   = makeError(10, "Invalid call method", false)
	ErrCallInvalidParams   = makeError(11, "invalid call params", false)
	ErrTransactionNotFound = makeError(12, "Transaction was not found", true)
)
View Source
var NodeVersion = fmt.Sprintf(
	"%d.%d.%d",
	version.Current.Major,
	version.Current.Minor,
	version.Current.Patch,
)

Functions

func ChecksumAddress added in v0.0.7

func ChecksumAddress(address string) (string, bool)

ChecksumAddress ensures an Ethereum hex address is in Checksum Format. If the address cannot be converted, it returns !ok.

func NewAccountService

func NewAccountService(
	config *Config,
	client client.Client,
	pChainBackend AccountBackend,
	cChainAtomicTxBackend AccountBackend,
) server.AccountAPIServicer

NewAccountService returns a new network servicer

func NewBlockService

func NewBlockService(
	config *Config,
	c client.Client,
	pChainBackend BlockBackend,
) server.BlockAPIServicer

NewBlockService returns a new block servicer

func NewCallService

func NewCallService(config *Config, client client.Client) server.CallAPIServicer

NewCallService returns a new call servicer

func NewConstructionService

func NewConstructionService(
	config *Config,
	client client.Client,
	pChainBackend ConstructionBackend,
	cChainAtomicTxBackend ConstructionBackend,
) server.ConstructionAPIServicer

NewConstructionService returns a new construction servicer

func NewMempoolService

func NewMempoolService(config *Config, client client.Client) server.MempoolAPIServicer

NewMempoolService returns a new mempool servicer

func NewNetworkService

func NewNetworkService(
	config *Config,
	client client.Client,
	pChainBackend NetworkBackend,
) server.NetworkAPIServicer

NewNetworkService returns a new network servicer

func WrapError added in v0.1.26

func WrapError(err *types.Error, message interface{}) *types.Error

Types

type AccountBackend added in v0.1.26

type AccountBackend interface {
	// ShouldHandleRequest returns whether a given request should be handled by this backend
	ShouldHandleRequest(req interface{}) bool
	// AccountBalance implements /account/balance endpoint for this backend
	AccountBalance(ctx context.Context, req *types.AccountBalanceRequest) (*types.AccountBalanceResponse, *types.Error)
	// AccountCoins implements /account/coins endpoint for this backend
	AccountCoins(ctx context.Context, req *types.AccountCoinsRequest) (*types.AccountCoinsResponse, *types.Error)
}

AccountBackend represents a backend that implements /account family of apis for a subset of requests. Endpoint handlers in this file delegates requests to corresponding backends based on the request. Each backend implements a ShouldHandleRequest method to determine whether that backend should handle the given request.

P-chain and C-chain atomic transaction logic are implemented in pchain.Backend and cchainatomictx.Backend respectively. Eventually, the C-chain non-atomic transaction logic implemented in this file should be extracted to its own backend as well.

type AccountService

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

AccountService implements the /account/* endpoints

func (AccountService) AccountBalance

AccountBalance implements the /account/balance endpoint

func (AccountService) AccountCoins

AccountCoins implements the /account/coins endpoint

type BlockBackend added in v0.1.26

type BlockBackend interface {
	// ShouldHandleRequest returns whether a given request should be handled by this backend
	ShouldHandleRequest(req interface{}) bool
	// Block implements /block endpoint for this backend
	Block(ctx context.Context, request *types.BlockRequest) (*types.BlockResponse, *types.Error)
	// BlockTransaction implements /block/transaction endpoint for this backend
	BlockTransaction(ctx context.Context, request *types.BlockTransactionRequest) (*types.BlockTransactionResponse, *types.Error)
}

BlockBackend represents a backend that implements /block family of apis for a subset of requests Endpoint handlers in this file delegates requests to corresponding backends based on the request. Each backend implements a ShouldHandleRequest method to determine whether that backend should handle the given request.

P-chain support is implemented in pchain.Backend which implements this interface. Eventually, the C-chain block logic implemented in this file should be extracted to its own backend as well.

type BlockService

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

BlockService implements the /block/* endpoints

func (*BlockService) Block

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

Block implements the /block endpoint

func (*BlockService) BlockTransaction

BlockTransaction implements the /block/transaction endpoint.

type CallService

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

CallService implements /call/* endpoints

func (CallService) Call

Call implements the /call endpoint.

type Config

type Config struct {
	Mode               string
	ChainID            *big.Int
	NetworkID          *types.NetworkIdentifier
	GenesisBlockHash   string
	AvaxAssetID        string
	IngestionMode      string
	TokenWhiteList     []string
	BridgeTokenList    []string
	IndexUnknownTokens bool

	// Upgrade Times
	AP5Activation uint64
}

Config holds the service configuration

func (Config) IsAnalyticsMode added in v0.0.26

func (c Config) IsAnalyticsMode() bool

IsAnalyticsMode returns true if running in analytics ingestion mode

func (Config) IsOfflineMode

func (c Config) IsOfflineMode() bool

IsOfflineMode returns true if running in offline mode

func (Config) IsOnlineMode

func (c Config) IsOnlineMode() bool

IsOnlineMode returns true if running in online mode

func (Config) IsStandardMode added in v0.0.26

func (c Config) IsStandardMode() bool

IsStandardMode returns true if running in standard ingestion mode

func (Config) IsTokenListEmpty added in v0.0.26

func (c Config) IsTokenListEmpty() bool

IsTokenListEmpty returns true if the token addresses list is empty

func (Config) Signer

func (c Config) Signer() ethtypes.Signer

Signer returns an eth signer object for a given chain

type ConstructionBackend added in v0.1.26

type ConstructionBackend interface {
	// ShouldHandleRequest returns whether a given request should be handled by this backend
	ShouldHandleRequest(req interface{}) bool
	// ConstructionDerive implements /construction/derive endpoint for this backend
	ConstructionDerive(ctx context.Context, req *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error)
	// ConstructionPreprocess implements /construction/preprocess endpoint for this backend
	ConstructionPreprocess(ctx context.Context, req *types.ConstructionPreprocessRequest) (*types.ConstructionPreprocessResponse, *types.Error)
	// ConstructionMetadata implements /construction/metadata endpoint for this backend
	ConstructionMetadata(ctx context.Context, req *types.ConstructionMetadataRequest) (*types.ConstructionMetadataResponse, *types.Error)
	// ConstructionPayloads implements /construction/payloads endpoint for this backend
	ConstructionPayloads(ctx context.Context, req *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error)
	// ConstructionParse implements /construction/parse endpoint for this backend
	ConstructionParse(ctx context.Context, req *types.ConstructionParseRequest) (*types.ConstructionParseResponse, *types.Error)
	// ConstructionCombine implements /construction/combine endpoint for this backend
	ConstructionCombine(ctx context.Context, req *types.ConstructionCombineRequest) (*types.ConstructionCombineResponse, *types.Error)
	// ConstructionHash implements /construction/hash endpoint for this backend
	ConstructionHash(ctx context.Context, req *types.ConstructionHashRequest) (*types.TransactionIdentifierResponse, *types.Error)
	// ConstructionSubmit implements /construction/submit endpoint for this backend
	ConstructionSubmit(ctx context.Context, req *types.ConstructionSubmitRequest) (*types.TransactionIdentifierResponse, *types.Error)
}

ConstructionBackend represents a backend that implements /construction family of apis for a subset of requests. Endpoint handlers in this file delegates requests to corresponding backends based on the request. Each backend implements a ShouldHandleRequest method to determine whether that backend should handle the given request.

P-chain and C-chain atomic transaction logic are implemented in pchain.Backend and cchainatomictx.Backend respectively. Eventually, the C-chain non-atomic transaction logic implemented in this file should be extracted to its own backend as well.

type ConstructionService

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

ConstructionService implements /construction/* endpoints

func (ConstructionService) ConstructionCombine

ConstructionCombine implements /construction/combine endpoint.

Combine creates a network-specific transaction from an unsigned transaction and an array of provided signatures. The signed transaction returned from this method will be sent to the /construction/submit endpoint by the caller.

func (ConstructionService) ConstructionDerive

ConstructionDerive implements /construction/derive endpoint.

Derive returns the AccountIdentifier associated with a public key. Blockchains that require an on-chain action to create an account should not implement this method.

func (ConstructionService) ConstructionHash

ConstructionHash implements /construction/hash endpoint.

TransactionHash returns the network-specific transaction hash for a signed transaction.

func (ConstructionService) ConstructionMetadata

ConstructionMetadata implements /construction/metadata endpoint.

Get any information required to construct a transaction for a specific network. Metadata returned here could be a recent hash to use, an account sequence number, or even arbitrary chain state. The request used when calling this endpoint is created by calling /construction/preprocess in an offline environment.

func (ConstructionService) ConstructionParse

ConstructionParse implements /construction/parse endpoint

Parse is called on both unsigned and signed transactions to understand the intent of the formulated transaction. This is run as a sanity check before signing (after /construction/payloads) and before broadcast (after /construction/combine).

func (ConstructionService) ConstructionPayloads

ConstructionPayloads implements /construction/payloads endpoint

Payloads is called with an array of operations and the response from /construction/metadata. It returns an unsigned transaction blob and a collection of payloads that must be signed by particular AccountIdentifiers using a certain SignatureType. The array of operations provided in transaction construction often times can not specify all "effects" of a transaction (consider invoked transactions in Ethereum). However, they can deterministically specify the "intent" of the transaction, which is sufficient for construction. For this reason, parsing the corresponding transaction in the Data API (when it lands on chain) will contain a superset of whatever operations were provided during construction.

func (ConstructionService) ConstructionPreprocess

ConstructionPreprocess implements /construction/preprocess endpoint.

Preprocess is called prior to /construction/payloads to construct a request for any metadata that is needed for transaction construction given (i.e. account nonce).

func (ConstructionService) ConstructionSubmit

ConstructionSubmit implements /construction/submit endpoint.

Submit a pre-signed transaction to the node.

func (ConstructionService) CreateUnwrapOperationDescription added in v0.1.23

func (s ConstructionService) CreateUnwrapOperationDescription(
	operations []*types.Operation,
) ([]*parser.OperationDescription, error)

type GetTransactionReceiptInput

type GetTransactionReceiptInput struct {
	TxHash string `json:"tx_hash"`
}

GetTransactionReceiptInput is the input to the call method "eth_getTransactionReceipt".

type MempoolService

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

MempoolService implements the /mempool/* endpoints

func (MempoolService) Mempool

Mempool implements the /mempool endpoint

func (MempoolService) MempoolTransaction

MempoolTransaction implements the /mempool/transaction endpoint

type MockAccountBackend added in v0.1.42

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

MockAccountBackend is a mock of AccountBackend interface.

func NewMockAccountBackend added in v0.1.42

func NewMockAccountBackend(ctrl *gomock.Controller) *MockAccountBackend

NewMockAccountBackend creates a new mock instance.

func (*MockAccountBackend) AccountBalance added in v0.1.42

AccountBalance mocks base method.

func (*MockAccountBackend) AccountCoins added in v0.1.42

AccountCoins mocks base method.

func (*MockAccountBackend) EXPECT added in v0.1.42

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAccountBackend) ShouldHandleRequest added in v0.1.42

func (m *MockAccountBackend) ShouldHandleRequest(arg0 any) bool

ShouldHandleRequest mocks base method.

type MockAccountBackendMockRecorder added in v0.1.42

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

MockAccountBackendMockRecorder is the mock recorder for MockAccountBackend.

func (*MockAccountBackendMockRecorder) AccountBalance added in v0.1.42

func (mr *MockAccountBackendMockRecorder) AccountBalance(arg0, arg1 any) *gomock.Call

AccountBalance indicates an expected call of AccountBalance.

func (*MockAccountBackendMockRecorder) AccountCoins added in v0.1.42

func (mr *MockAccountBackendMockRecorder) AccountCoins(arg0, arg1 any) *gomock.Call

AccountCoins indicates an expected call of AccountCoins.

func (*MockAccountBackendMockRecorder) ShouldHandleRequest added in v0.1.42

func (mr *MockAccountBackendMockRecorder) ShouldHandleRequest(arg0 any) *gomock.Call

ShouldHandleRequest indicates an expected call of ShouldHandleRequest.

type MockConstructionBackend added in v0.1.42

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

MockConstructionBackend is a mock of ConstructionBackend interface.

func NewMockConstructionBackend added in v0.1.42

func NewMockConstructionBackend(ctrl *gomock.Controller) *MockConstructionBackend

NewMockConstructionBackend creates a new mock instance.

func (*MockConstructionBackend) ConstructionCombine added in v0.1.42

ConstructionCombine mocks base method.

func (*MockConstructionBackend) ConstructionDerive added in v0.1.42

ConstructionDerive mocks base method.

func (*MockConstructionBackend) ConstructionHash added in v0.1.42

ConstructionHash mocks base method.

func (*MockConstructionBackend) ConstructionMetadata added in v0.1.42

ConstructionMetadata mocks base method.

func (*MockConstructionBackend) ConstructionParse added in v0.1.42

ConstructionParse mocks base method.

func (*MockConstructionBackend) ConstructionPayloads added in v0.1.42

ConstructionPayloads mocks base method.

func (*MockConstructionBackend) ConstructionPreprocess added in v0.1.42

ConstructionPreprocess mocks base method.

func (*MockConstructionBackend) ConstructionSubmit added in v0.1.42

ConstructionSubmit mocks base method.

func (*MockConstructionBackend) EXPECT added in v0.1.42

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockConstructionBackend) ShouldHandleRequest added in v0.1.42

func (m *MockConstructionBackend) ShouldHandleRequest(arg0 any) bool

ShouldHandleRequest mocks base method.

type MockConstructionBackendMockRecorder added in v0.1.42

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

MockConstructionBackendMockRecorder is the mock recorder for MockConstructionBackend.

func (*MockConstructionBackendMockRecorder) ConstructionCombine added in v0.1.42

func (mr *MockConstructionBackendMockRecorder) ConstructionCombine(arg0, arg1 any) *gomock.Call

ConstructionCombine indicates an expected call of ConstructionCombine.

func (*MockConstructionBackendMockRecorder) ConstructionDerive added in v0.1.42

func (mr *MockConstructionBackendMockRecorder) ConstructionDerive(arg0, arg1 any) *gomock.Call

ConstructionDerive indicates an expected call of ConstructionDerive.

func (*MockConstructionBackendMockRecorder) ConstructionHash added in v0.1.42

func (mr *MockConstructionBackendMockRecorder) ConstructionHash(arg0, arg1 any) *gomock.Call

ConstructionHash indicates an expected call of ConstructionHash.

func (*MockConstructionBackendMockRecorder) ConstructionMetadata added in v0.1.42

func (mr *MockConstructionBackendMockRecorder) ConstructionMetadata(arg0, arg1 any) *gomock.Call

ConstructionMetadata indicates an expected call of ConstructionMetadata.

func (*MockConstructionBackendMockRecorder) ConstructionParse added in v0.1.42

func (mr *MockConstructionBackendMockRecorder) ConstructionParse(arg0, arg1 any) *gomock.Call

ConstructionParse indicates an expected call of ConstructionParse.

func (*MockConstructionBackendMockRecorder) ConstructionPayloads added in v0.1.42

func (mr *MockConstructionBackendMockRecorder) ConstructionPayloads(arg0, arg1 any) *gomock.Call

ConstructionPayloads indicates an expected call of ConstructionPayloads.

func (*MockConstructionBackendMockRecorder) ConstructionPreprocess added in v0.1.42

func (mr *MockConstructionBackendMockRecorder) ConstructionPreprocess(arg0, arg1 any) *gomock.Call

ConstructionPreprocess indicates an expected call of ConstructionPreprocess.

func (*MockConstructionBackendMockRecorder) ConstructionSubmit added in v0.1.42

func (mr *MockConstructionBackendMockRecorder) ConstructionSubmit(arg0, arg1 any) *gomock.Call

ConstructionSubmit indicates an expected call of ConstructionSubmit.

func (*MockConstructionBackendMockRecorder) ShouldHandleRequest added in v0.1.42

func (mr *MockConstructionBackendMockRecorder) ShouldHandleRequest(arg0 any) *gomock.Call

ShouldHandleRequest indicates an expected call of ShouldHandleRequest.

type NetworkBackend added in v0.1.26

type NetworkBackend interface {
	// ShouldHandleRequest returns whether a given request should be handled by this backend
	ShouldHandleRequest(req interface{}) bool
	// NetworkIdentifier returns the identifier of the network it supports
	NetworkIdentifier() *types.NetworkIdentifier
	// NetworkStatus implements /network/status endpoint for this backend
	NetworkStatus(ctx context.Context, request *types.NetworkRequest) (*types.NetworkStatusResponse, *types.Error)
	// NetworkOptions implements /network/options endpoint for this backend
	NetworkOptions(ctx context.Context, request *types.NetworkRequest) (*types.NetworkOptionsResponse, *types.Error)
}

NetworkBackend represents a backend that implements /block family of apis for a subset of requests Endpoint handlers in this file delegates requests to corresponding backends based on the request. Each backend implements a ShouldHandleRequest method to determine whether that backend should handle the given request.

P-chain support is implemented in pchain.Backend which implements this interface. Eventually, the C-chain block logic implemented in this file should be extracted to its own backend as well.

type NetworkService

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

NetworkService implements all /network endpoints

func (*NetworkService) NetworkList

NetworkList implements the /network/list endpoint

func (*NetworkService) NetworkOptions

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

NetworkOptions implements the /network/options endpoint

func (*NetworkService) NetworkStatus

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

NetworkStatus implements the /network/status endpoint

Directories

Path Synopsis
backend
pchain/indexer
Package indexer is a generated GoMock package.
Package indexer is a generated GoMock package.

Jump to

Keyboard shortcuts

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