Documentation
¶
Index ¶
- Constants
- Variables
- func ChecksumAddress(address string) (string, bool)
- func NewAccountService(config *Config, client client.Client, pChainBackend AccountBackend, ...) server.AccountAPIServicer
- func NewBlockService(config *Config, c client.Client, pChainBackend BlockBackend) server.BlockAPIServicer
- func NewCallService(config *Config, client client.Client) server.CallAPIServicer
- func NewConstructionService(config *Config, client client.Client, pChainBackend ConstructionBackend, ...) server.ConstructionAPIServicer
- func NewMempoolService(config *Config, client client.Client) server.MempoolAPIServicer
- func NewNetworkService(config *Config, client client.Client, pChainBackend NetworkBackend) server.NetworkAPIServicer
- func WrapError(err *types.Error, message interface{}) *types.Error
- type AccountBackend
- type AccountService
- type BlockBackend
- type BlockService
- type CallService
- type Config
- type ConstructionBackend
- type ConstructionService
- func (s ConstructionService) ConstructionCombine(ctx context.Context, req *types.ConstructionCombineRequest) (*types.ConstructionCombineResponse, *types.Error)
- func (s ConstructionService) ConstructionDerive(ctx context.Context, req *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error)
- func (s ConstructionService) ConstructionHash(ctx context.Context, req *types.ConstructionHashRequest) (*types.TransactionIdentifierResponse, *types.Error)
- func (s ConstructionService) ConstructionMetadata(ctx context.Context, req *types.ConstructionMetadataRequest) (*types.ConstructionMetadataResponse, *types.Error)
- func (s ConstructionService) ConstructionParse(ctx context.Context, req *types.ConstructionParseRequest) (*types.ConstructionParseResponse, *types.Error)
- func (s ConstructionService) ConstructionPayloads(ctx context.Context, req *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error)
- func (s ConstructionService) ConstructionPreprocess(ctx context.Context, req *types.ConstructionPreprocessRequest) (*types.ConstructionPreprocessResponse, *types.Error)
- func (s ConstructionService) ConstructionSubmit(ctx context.Context, req *types.ConstructionSubmitRequest) (*types.TransactionIdentifierResponse, *types.Error)
- func (s ConstructionService) CreateGenericContractCallOperationDescription(operations []*types.Operation) ([]*parser.OperationDescription, error)
- func (s ConstructionService) CreateTransferOperationDescription(operations []*types.Operation) ([]*parser.OperationDescription, error)
- func (s ConstructionService) CreateUnwrapOperationDescription(operations []*types.Operation) ([]*parser.OperationDescription, error)
- type GetTransactionReceiptInput
- type MempoolService
- type NetworkBackend
- type NetworkService
- func (s *NetworkService) NetworkList(_ context.Context, _ *types.MetadataRequest) (*types.NetworkListResponse, *types.Error)
- func (s *NetworkService) NetworkOptions(ctx context.Context, request *types.NetworkRequest) (*types.NetworkOptionsResponse, *types.Error)
- func (s *NetworkService) NetworkStatus(ctx context.Context, request *types.NetworkRequest) (*types.NetworkStatusResponse, *types.Error)
Constants ¶
const ( ModeOffline = "offline" ModeOnline = "online" StandardIngestion = "standard" AnalyticsIngestion = "analytics" )
const ( MiddlewareVersion = "0.1.39" BlockchainName = "Avalanche" )
const BalanceOfMethodPrefix = "0x70a08231000000000000000000000000"
Variables ¶
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) 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) )
Functions ¶
func ChecksumAddress ¶ added in v0.0.7
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
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 ¶
func (s AccountService) AccountBalance( ctx context.Context, req *types.AccountBalanceRequest, ) (*types.AccountBalanceResponse, *types.Error)
AccountBalance implements the /account/balance endpoint
func (AccountService) AccountCoins ¶
func (s AccountService) AccountCoins( ctx context.Context, req *types.AccountCoinsRequest, ) (*types.AccountCoinsResponse, *types.Error)
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 ¶
func (s *BlockService) BlockTransaction( ctx context.Context, request *types.BlockTransactionRequest, ) (*types.BlockTransactionResponse, *types.Error)
BlockTransaction implements the /block/transaction endpoint.
type CallService ¶
type CallService struct {
// contains filtered or unexported fields
}
CallService implements /call/* endpoints
func (CallService) Call ¶
func (s CallService) Call( ctx context.Context, req *types.CallRequest, ) (*types.CallResponse, *types.Error)
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
IsAnalyticsMode returns true if running in analytics ingestion mode
func (Config) IsOfflineMode ¶
IsOfflineMode returns true if running in offline mode
func (Config) IsOnlineMode ¶
IsOnlineMode returns true if running in online mode
func (Config) IsStandardMode ¶ added in v0.0.26
IsStandardMode returns true if running in standard ingestion mode
func (Config) IsTokenListEmpty ¶ added in v0.0.26
IsTokenListEmpty returns true if the token addresses list is empty
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 ¶
func (s ConstructionService) ConstructionCombine( ctx context.Context, req *types.ConstructionCombineRequest, ) (*types.ConstructionCombineResponse, *types.Error)
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 ¶
func (s ConstructionService) ConstructionDerive( ctx context.Context, req *types.ConstructionDeriveRequest, ) (*types.ConstructionDeriveResponse, *types.Error)
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 ¶
func (s ConstructionService) ConstructionHash( ctx context.Context, req *types.ConstructionHashRequest, ) (*types.TransactionIdentifierResponse, *types.Error)
ConstructionHash implements /construction/hash endpoint.
TransactionHash returns the network-specific transaction hash for a signed transaction.
func (ConstructionService) ConstructionMetadata ¶
func (s ConstructionService) ConstructionMetadata( ctx context.Context, req *types.ConstructionMetadataRequest, ) (*types.ConstructionMetadataResponse, *types.Error)
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 ¶
func (s ConstructionService) ConstructionParse( ctx context.Context, req *types.ConstructionParseRequest, ) (*types.ConstructionParseResponse, *types.Error)
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 ¶
func (s ConstructionService) ConstructionPayloads( ctx context.Context, req *types.ConstructionPayloadsRequest, ) (*types.ConstructionPayloadsResponse, *types.Error)
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 ¶
func (s ConstructionService) ConstructionPreprocess( ctx context.Context, req *types.ConstructionPreprocessRequest, ) (*types.ConstructionPreprocessResponse, *types.Error)
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 ¶
func (s ConstructionService) ConstructionSubmit( ctx context.Context, req *types.ConstructionSubmitRequest, ) (*types.TransactionIdentifierResponse, *types.Error)
ConstructionSubmit implements /construction/submit endpoint.
Submit a pre-signed transaction to the node.
func (ConstructionService) CreateGenericContractCallOperationDescription ¶ added in v0.1.36
func (s ConstructionService) CreateGenericContractCallOperationDescription(operations []*types.Operation) ([]*parser.OperationDescription, error)
func (ConstructionService) CreateTransferOperationDescription ¶ added in v0.1.23
func (s ConstructionService) CreateTransferOperationDescription( operations []*types.Operation, ) ([]*parser.OperationDescription, error)
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 ¶
func (s MempoolService) Mempool( ctx context.Context, _ *types.NetworkRequest, ) (*types.MempoolResponse, *types.Error)
Mempool implements the /mempool endpoint
func (MempoolService) MempoolTransaction ¶
func (s MempoolService) MempoolTransaction( _ context.Context, _ *types.MempoolTransactionRequest, ) (*types.MempoolTransactionResponse, *types.Error)
MempoolTransaction implements the /mempool/transaction endpoint
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 ¶
func (s *NetworkService) NetworkList( _ context.Context, _ *types.MetadataRequest, ) (*types.NetworkListResponse, *types.Error)
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