endpoint

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: CC0-1.0 Imports: 21 Imported by: 5

Documentation

Index

Constants

View Source
const (
	GasForNearTxsCallDefault     = 300000000000000
	DepositForNearTxsCallDefault = 0
)

Variables

This section is empty.

Functions

func Process

func Process[T any](ctx context.Context, name string, endpoint *Endpoint, handler func(ctx context.Context) (*T, error), args ...any) (*T, error)

Types

type Config

type Config struct {
	ProxyUrl          string
	ProxyEndpoints    map[string]bool `mapstructure:"proxyEndpoints"`
	DisabledEndpoints map[string]bool `mapstructure:"disabledEndpoints"`
	EthConfig         EthConfig       `mapstructure:"eth"`
	EngineConfig      EngineConfig    `mapstructure:"engine"`
}

func GetConfig

func GetConfig() *Config

type Debug

type Debug struct {
	*Endpoint
}

func NewDebug

func NewDebug(endpoint *Endpoint) *Debug

func (*Debug) TraceTransaction

func (d *Debug) TraceTransaction(_ context.Context, hash common.H256) (*response.CallFrame, error)

TraceTransaction attempts to run the transaction in the exact same manner as it was executed on the network. It replays any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.

On missing or invalid param returns errors code '-32602' with custom message.
If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

type DebugProcessorAware

type DebugProcessorAware struct {
	*Debug
}

func NewDebugProcessorAware

func NewDebugProcessorAware(d *Debug) *DebugProcessorAware

func (*DebugProcessorAware) TraceTransaction

func (d *DebugProcessorAware) TraceTransaction(ctx context.Context, hash common.H256) (*response.CallFrame, error)

type Endpoint

type Endpoint struct {
	DbHandler     db.Handler
	Logger        *log.Logger
	Config        *Config
	WithProcessor func(Processor)
	Processors    []Processor
}

func New

func New(dbh db.Handler) *Endpoint

func (*Endpoint) HandleConfigChange

func (e *Endpoint) HandleConfigChange()

type EngineConfig

type EngineConfig struct {
	NearNetworkID                 string   `mapstructure:"nearNetworkID"`
	NearArchivalNodeURL           string   `mapstructure:"nearArchivalNodeURL"`
	NearNodeURL                   string   `mapstructure:"nearNodeURL"`
	Signer                        string   `mapstructure:"signer"`
	SignerKey                     string   `mapstructure:"signerKey"`
	FunctionKeyPrefixPattern      string   `mapstructure:"functionKeyPrefixPattern"`
	FunctionKeyMapper             string   `mapstructure:"functionKeyMapper"`
	AsyncSendRawTxs               bool     `mapstructure:"asyncSendRawTxs"`
	MinGasPrice                   *big.Int `mapstructure:"minGasPrice"`
	MinGasLimit                   uint64   `mapstructure:"minGasLimit"`
	GasForNearTxsCall             uint64   `mapstructure:"gasForNearTxsCall"`
	DepositForNearTxsCall         *big.Int `mapstructure:"depositForNearTxsCall"`
	RetryWaitTimeMsForNearTxsCall int      `mapstructure:"retryWaitTimeMsForNearTxsCall"`
	RetryNumberForNearTxsCall     int      `mapstructure:"retryNumberForNearTxsCall"`
}

type Eth

type Eth struct {
	*Endpoint
}

func NewEth

func NewEth(endpoint *Endpoint) *Eth

func (*Eth) Accounts

func (e *Eth) Accounts(_ context.Context) (*[]string, error)

Accounts returns empty array

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) BlockNumber

func (e *Eth) BlockNumber(ctx context.Context) (*primitives.HexUint, error)

BlockNumber returns the latest block number from DB if API is enabled by configuration.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure, returns errors code '-32000' with custom message.

func (*Eth) Coinbase

func (e *Eth) Coinbase(_ context.Context) (*string, error)

Coinbase returns constant 0x0, see relayer.yml to configure coinBase

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) EstimateGas

func (e *Eth) EstimateGas(_ context.Context, txs engine.TransactionForCall, bNumOrHash *common.BlockNumberOrHash) (*common.Uint256, error)

EstimateGas returns constant gas estimation provided in configuration file. The endpoint should be proxied to Mainnet to get an estimate of how much gas is necessary to allow the transaction to complete.

If API is disabled, returns error code '-32601' with message 'the method does not exist/is not available'.
On missing or invalid param returns error code '-32602' with custom message.

func (*Eth) GasPrice

func (e *Eth) GasPrice(_ context.Context) (*common.Uint256, error)

GasPrice returns constant gas price provided in the configuration file. The endpoint should be proxied to Mainnet to get the value used in the Aurora infrastructure.

If API is disabled, returns error code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) GetBlockByHash

func (e *Eth) GetBlockByHash(ctx context.Context, hash common.H256, isFull *bool) (*response.Block, error)

GetBlockByHash returns the block from DB, with the given block hash. `hash` is required but `isFull` is an optional parameter, if not provided default is false. If isFull is true all transactions in the block with all details otherwise returns only the hashes of the transactions are returned.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On missing or invalid param returns errors code '-32602' with custom message.
If hash not found (KeyNotFoundError) returns nil
On DB failure or hash not found, returns errors code '-32000' with custom message.

func (*Eth) GetBlockByNumber

func (e *Eth) GetBlockByNumber(ctx context.Context, number common.BN64, isFull *bool) (*response.Block, error)

GetBlockByNumber returns the block from DB, with the given block number. `number` is required but `isFull` is an optional parameter, if not provided default is false. If isFull is true all transactions in the block with all details otherwise returns only the hashes of the transactions are returned.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure or number not found, returns errors code '-32000' with custom message.
On missing or invalid param returns errors code '-32602' with custom message.

func (*Eth) GetBlockTransactionCountByHash

func (e *Eth) GetBlockTransactionCountByHash(ctx context.Context, hash common.H256) (*primitives.HexUint, error)

GetBlockTransactionCountByHash returns the number of transactions withing the given block hash.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure or hash not found, returns errors code '-32000' with custom message.
On missing or invalid param returns errors code '-32602' with custom message.

func (*Eth) GetBlockTransactionCountByNumber

func (e *Eth) GetBlockTransactionCountByNumber(ctx context.Context, number *common.BN64) (*primitives.HexUint, error)

GetBlockTransactionCountByNumber returns the number of transactions within the given block number. `number` parameter is optional and the latest block is used if `number` parameter is not provided

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure or number not found, returns errors code '-32000' with custom message.
On missing or invalid param returns errors code '-32602' with custom message.

func (*Eth) GetCompilers

func (e *Eth) GetCompilers(_ context.Context) (*[]string, error)

GetCompilers returns empty array

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) GetFilterChanges

func (e *Eth) GetFilterChanges(ctx context.Context, filterId common.Uint256) (*[]interface{}, error)

GetFilterChanges polls method for a filter, on success returns an array of logs which occurred since last poll.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On failure, returns errors code '-32000' with custom message.

func (*Eth) GetFilterLogs

func (e *Eth) GetFilterLogs(ctx context.Context, filterId common.Uint256) (*[]*response.Log, error)

GetFilterLogs returns an array of all logs matching filter with given id.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure, returns errors code '-32000' with custom message.

func (*Eth) GetLogs

func (e *Eth) GetLogs(ctx context.Context, rawFilter request.Filter) (*[]*response.Log, error)

GetLogs returns an array of log objects for the given filter

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On filter option parsing failure, returns errors code '32602' with custom message.
On DB failure, returns errors code '-32000' with custom message.

func (*Eth) GetTransactionByBlockHashAndIndex

func (e *Eth) GetTransactionByBlockHashAndIndex(ctx context.Context, hash common.H256, index common.Uint64) (*response.Transaction, error)

GetTransactionByBlockHashAndIndex returns the transaction information of the given block hash and transaction index

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure or hash not found, returns errors code '-32000' with custom message.

func (*Eth) GetTransactionByBlockNumberAndIndex

func (e *Eth) GetTransactionByBlockNumberAndIndex(ctx context.Context, number common.BN64, index common.Uint64) (*response.Transaction, error)

GetTransactionByBlockNumberAndIndex returns the transaction information of the given block number and transaction index.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure or number not found, returns errors code '-32000' with custom message.

func (*Eth) GetTransactionByHash

func (e *Eth) GetTransactionByHash(ctx context.Context, hash common.H256) (*response.Transaction, error)

GetTransactionByHash returns the transaction information of the given transaction hash.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure or hash not found, returns errors code '-32000' with custom message.
On missing or invalid param returns errors code '-32602' with custom message.

func (*Eth) GetTransactionReceipt

func (e *Eth) GetTransactionReceipt(ctx context.Context, hash common.H256) (*response.TransactionReceipt, error)

GetTransactionReceipt returns the receipt of a transaction by transaction hash.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On missing or invalid param returns error code '-32602' with custom message.
If hash not found (KeyNotFoundError) returns nil
On DB failure or other internal errors, returns errors code '-32000' with custom message.

func (*Eth) GetUncleByBlockHashAndIndex

func (e *Eth) GetUncleByBlockHashAndIndex(_ context.Context, _ *common.H256, _ *common.Uint64) (*string, error)

GetUncleByBlockHashAndIndex returns null/nil

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On missing or invalid param returns error code '-32602' with custom message.

func (*Eth) GetUncleByBlockNumberAndIndex

func (e *Eth) GetUncleByBlockNumberAndIndex(_ context.Context, _ *common.BN64, _ *common.Uint64) (*string, error)

GetUncleByBlockNumberAndIndex returns null/nil

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On missing or invalid param returns error code '-32602' with custom message.

func (*Eth) GetUncleCountByBlockHash

func (e *Eth) GetUncleCountByBlockHash(ctx context.Context, hash common.H256) (*common.Uint256, error)

GetUncleCountByBlockHash returns zero

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On missing or invalid param returns error code '-32602' with custom message.
If hash not found (KeyNotFoundError) returns nil
On DB failure or other internal errors, returns errors code '-32000' with custom message.

func (*Eth) GetUncleCountByBlockNumber

func (e *Eth) GetUncleCountByBlockNumber(ctx context.Context, number *common.BN64) (*common.Uint256, error)

GetUncleCountByBlockNumber returns zero

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On missing or invalid param returns error code '-32602' with custom message.
If block number not found (KeyNotFoundError) returns nil
On DB failure or other internal errors, returns errors code '-32000' with custom message.

func (*Eth) Hashrate

func (e *Eth) Hashrate(_ context.Context) (*common.Uint256, error)

Hashrate returns constant 0x0, see relayer.yml to configure Hashrate

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) Mining

func (e *Eth) Mining(_ context.Context) (*bool, error)

Mining returns constant false

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) NewBlockFilter

func (e *Eth) NewBlockFilter(ctx context.Context) (*common.Uint256, error)

NewBlockFilter creates a filter and returns newly created filter ID on success. To check if the state has changed, call "eth_getFilterChanges".

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure, returns errors code '-32000' with custom message.

func (*Eth) NewFilter

func (e *Eth) NewFilter(ctx context.Context, rawFilter request.Filter) (*common.Uint256, error)

NewFilter creates a new filter based on the filter options and returns newly created filter ID on success.

FilterOptions object is mandatory but all keys are optional

  • fromBlock: QUANTITY|TAG - Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.

  • toBlock: QUANTITY|TAG - Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.

  • address: DATA|Array - Contract address or a list of addresses from which logs should originate.

  • topics: Array of DATA - Topics are order-dependent. Each topic can also be an array of DATA with "or" options.

    If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'. On filter option parsing failure, returns errors code '32602' with custom message. On DB failure, returns errors code '-32000' with custom message.

func (*Eth) NewPendingTransactionFilter

func (e *Eth) NewPendingTransactionFilter(_ context.Context) (*string, error)

NewPendingTransactionFilter returns empty array

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) PendingTransactions

func (e *Eth) PendingTransactions(_ context.Context) (*[]string, error)

PendingTransactions returns empty array

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) ProtocolVersion

func (e *Eth) ProtocolVersion(_ context.Context) (*common.Uint256, error)

ProtocolVersion returns constant 0x41, see relayer.yml to configure ProtocolVersion

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) Syncing

func (e *Eth) Syncing(_ context.Context) (*bool, error)

Syncing returns constant false

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Eth) UninstallFilter

func (e *Eth) UninstallFilter(ctx context.Context, filterId common.Uint256) (*bool, error)

UninstallFilter deletes a filter with given filter id and returns true on success. Additionally, filters timeout when they aren't requested with "eth_getFilterChanges" for a period of time.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On DB failure or filterId not found, returns errors code '-32000' with custom message.

type EthConfig

type EthConfig struct {
	ProtocolVersion common.Uint256 `mapstructure:"protocolVersion"`
	Hashrate        common.Uint256 `mapstructure:"hashrate"`
	GasEstimate     common.Uint256 `mapstructure:"gasEstimate"`
	GasPrice        common.Uint256 `mapstructure:"gasPrice"`
	ZeroAddress     string         `mapstructure:"zeroAddress"`
}

type EthProcessorAware

type EthProcessorAware struct {
	*Eth
}

func NewEthProcessorAware

func NewEthProcessorAware(eth *Eth) *EthProcessorAware

func (*EthProcessorAware) Accounts

func (e *EthProcessorAware) Accounts(ctx context.Context) (*[]string, error)

func (*EthProcessorAware) BlockNumber

func (e *EthProcessorAware) BlockNumber(ctx context.Context) (*primitives.HexUint, error)

func (*EthProcessorAware) Coinbase

func (e *EthProcessorAware) Coinbase(ctx context.Context) (*string, error)

func (*EthProcessorAware) EstimateGas

func (*EthProcessorAware) GasPrice

func (e *EthProcessorAware) GasPrice(ctx context.Context) (*common.Uint256, error)

func (*EthProcessorAware) GetBlockByHash

func (e *EthProcessorAware) GetBlockByHash(ctx context.Context, hash common.H256, isFull *bool) (*response.Block, error)

func (*EthProcessorAware) GetBlockByNumber

func (e *EthProcessorAware) GetBlockByNumber(ctx context.Context, number common.BN64, isFull *bool) (*response.Block, error)

func (*EthProcessorAware) GetBlockTransactionCountByHash

func (e *EthProcessorAware) GetBlockTransactionCountByHash(ctx context.Context, hash common.H256) (*primitives.HexUint, error)

func (*EthProcessorAware) GetBlockTransactionCountByNumber

func (e *EthProcessorAware) GetBlockTransactionCountByNumber(ctx context.Context, number *common.BN64) (*primitives.HexUint, error)

func (*EthProcessorAware) GetCompilers

func (e *EthProcessorAware) GetCompilers(ctx context.Context) (*[]string, error)

func (*EthProcessorAware) GetFilterChanges

func (e *EthProcessorAware) GetFilterChanges(ctx context.Context, filterId common.Uint256) (*[]interface{}, error)

func (*EthProcessorAware) GetFilterLogs

func (e *EthProcessorAware) GetFilterLogs(ctx context.Context, filterId common.Uint256) (*[]*response.Log, error)

func (*EthProcessorAware) GetLogs

func (e *EthProcessorAware) GetLogs(ctx context.Context, rawFilter request.Filter) (*[]*response.Log, error)

func (*EthProcessorAware) GetTransactionByBlockHashAndIndex

func (e *EthProcessorAware) GetTransactionByBlockHashAndIndex(ctx context.Context, hash common.H256, index common.Uint64) (*response.Transaction, error)

func (*EthProcessorAware) GetTransactionByBlockNumberAndIndex

func (e *EthProcessorAware) GetTransactionByBlockNumberAndIndex(ctx context.Context, number common.BN64, index common.Uint64) (*response.Transaction, error)

func (*EthProcessorAware) GetTransactionByHash

func (e *EthProcessorAware) GetTransactionByHash(ctx context.Context, hash common.H256) (*response.Transaction, error)

func (*EthProcessorAware) GetTransactionReceipt

func (e *EthProcessorAware) GetTransactionReceipt(ctx context.Context, hash common.H256) (*response.TransactionReceipt, error)

func (*EthProcessorAware) GetUncleByBlockHashAndIndex

func (e *EthProcessorAware) GetUncleByBlockHashAndIndex(ctx context.Context, hash *common.H256, index *common.Uint64) (*string, error)

func (*EthProcessorAware) GetUncleByBlockNumberAndIndex

func (e *EthProcessorAware) GetUncleByBlockNumberAndIndex(ctx context.Context, number *common.BN64, index *common.Uint64) (*string, error)

func (*EthProcessorAware) GetUncleCountByBlockHash

func (e *EthProcessorAware) GetUncleCountByBlockHash(ctx context.Context, hash common.H256) (*common.Uint256, error)

func (*EthProcessorAware) GetUncleCountByBlockNumber

func (e *EthProcessorAware) GetUncleCountByBlockNumber(ctx context.Context, number *common.BN64) (*common.Uint256, error)

func (*EthProcessorAware) Hashrate

func (e *EthProcessorAware) Hashrate(ctx context.Context) (*common.Uint256, error)

func (*EthProcessorAware) Mining

func (e *EthProcessorAware) Mining(ctx context.Context) (*bool, error)

func (*EthProcessorAware) NewBlockFilter

func (e *EthProcessorAware) NewBlockFilter(ctx context.Context) (*common.Uint256, error)

func (*EthProcessorAware) NewFilter

func (e *EthProcessorAware) NewFilter(ctx context.Context, filter request.Filter) (*common.Uint256, error)

func (*EthProcessorAware) NewPendingTransactionFilter

func (e *EthProcessorAware) NewPendingTransactionFilter(ctx context.Context) (*string, error)

func (*EthProcessorAware) PendingTransactions

func (e *EthProcessorAware) PendingTransactions(ctx context.Context) (*[]string, error)

func (*EthProcessorAware) ProtocolVersion

func (e *EthProcessorAware) ProtocolVersion(ctx context.Context) (*common.Uint256, error)

func (*EthProcessorAware) Syncing

func (e *EthProcessorAware) Syncing(ctx context.Context) (*bool, error)

func (*EthProcessorAware) UninstallFilter

func (e *EthProcessorAware) UninstallFilter(ctx context.Context, filterId common.Uint256) (*bool, error)

type Net

type Net struct {
	*Endpoint
}

func NewNet

func NewNet(endpoint *Endpoint) *Net

func (*Net) Listening

func (e *Net) Listening(_ context.Context) (*bool, error)

Listening always returns true on success

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

func (*Net) PeerCount

func (e *Net) PeerCount(_ context.Context) (*string, error)

PeerCount always returns hex zero

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

type NetProcessorAware

type NetProcessorAware struct {
	*Net
}

func NewNetProcessorAware

func NewNetProcessorAware(net *Net) *NetProcessorAware

func (*NetProcessorAware) Listening

func (e *NetProcessorAware) Listening(ctx context.Context) (*bool, error)

func (*NetProcessorAware) PeerCount

func (e *NetProcessorAware) PeerCount(ctx context.Context) (*string, error)

type Parity

type Parity struct {
	*Endpoint
}

func NewParity

func NewParity(endpoint *Endpoint) *Parity

func (*Parity) PendingTransactions

func (p *Parity) PendingTransactions(_ context.Context, _ *common.Uint64, _ *interface{}) (*[]string, error)

PendingTransactions returns a list of txs currently in the queue. As of now method always returns empty array since the relayer has no txs queue support.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.

type ParityProcessorAware

type ParityProcessorAware struct {
	*Parity
}

func NewParityProcessorAware

func NewParityProcessorAware(p *Parity) *ParityProcessorAware

func (*ParityProcessorAware) PendingTransactions

func (e *ParityProcessorAware) PendingTransactions(ctx context.Context, limit *common.Uint64, filter *interface{}) (*[]string, error)

type Processor

type Processor interface {
	Pre(context.Context, string, *Endpoint, *any, ...any) (context.Context, bool, error)
	Post(context.Context, string, *any, *error) context.Context
}

type Web3

type Web3 struct {
	*Endpoint
}

func NewWeb3

func NewWeb3(endpoint *Endpoint) *Web3

func (*Web3) ClientVersion

func (e *Web3) ClientVersion(_ context.Context) (*string, error)

ClientVersion returns client version

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
TODO: implement

func (*Web3) Sha3

func (e *Web3) Sha3(_ context.Context, in string) (*string, error)

Sha3 returns Keccak-256 hash of the given data.

If API is disabled, returns errors code '-32601' with message 'the method does not exist/is not available'.
On failure, returns errors code '-32000' with custom message.

type Web3ProcessorAware

type Web3ProcessorAware struct {
	*Web3
}

func NewWeb3ProcessorAware

func NewWeb3ProcessorAware(web3 *Web3) *Web3ProcessorAware

func (*Web3ProcessorAware) ClientVersion

func (e *Web3ProcessorAware) ClientVersion(ctx context.Context) (*string, error)

func (*Web3ProcessorAware) Sha3

func (e *Web3ProcessorAware) Sha3(ctx context.Context, in string) (*string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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