node

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package node is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlockNotFound       = errors.New("block not found")
	ErrTransactionNotFound = errors.New("transaction not found")
)

Functions

func ContextWithRequestID

func ContextWithRequestID(parent context.Context, id jsonrpc.ID) context.Context

Types

type Client

type Client interface {
	Requester
	Subscriber

	// URL returns the backend URL we are connected to
	URL() string

	// BlockNumber returns the current block number at head
	BlockNumber(ctx context.Context) (uint64, error)

	// NetVersion returns the netversion
	NetVersion(ctx context.Context) (string, error)

	// NetPeerCount returns the net peer count
	NetPeerCount(ctx context.Context) (uint64, error)

	// Syncing returns syncing status
	Syncing(ctx context.Context) (bool, error)

	// ChainId returns the chain id
	ChainId(ctx context.Context) (string, error)

	// EstimateGas returns the estimate gas
	EstimateGas(ctx context.Context, msg eth.Transaction) (uint64, error)

	// MaxPriorityFeePerGas (EIP1559) returns the suggested tip for block
	MaxPriorityFeePerGas(ctx context.Context) (uint64, error)

	// GasPrice (Legacy) returns the suggested gas price
	GasPrice(ctx context.Context) (uint64, error)

	// GetTransactionCount get the pending nonce for public address
	GetTransactionCount(ctx context.Context, address eth.Address, numberOrTag eth.BlockNumberOrTag) (uint64, error)

	// SendRawTransaction will send the raw signed transaction return tx hash or error
	SendRawTransaction(ctx context.Context, msg string) (string, error)

	// BlockByNumber can be used to get a block by its number
	BlockByNumber(ctx context.Context, number uint64, full bool) (*eth.Block, error)

	// BlockByNumberOrTag can be used to get a block by its number or tag (e.g. latest)
	BlockByNumberOrTag(ctx context.Context, numberOrTag eth.BlockNumberOrTag, full bool) (*eth.Block, error)

	// BlockByHash can be used to get a block by its hash
	BlockByHash(ctx context.Context, hash string, full bool) (*eth.Block, error)

	// TransactionByHash can be used to get transaction by its hash
	TransactionByHash(ctx context.Context, hash string) (*eth.Transaction, error)

	// SubscribeNewHeads initiates a subscription for newHead events
	SubscribeNewHeads(ctx context.Context) (Subscription, error)

	// SubscribeNewPendingTransactions initiates a subscription for newPendingTransaction events
	SubscribeNewPendingTransactions(ctx context.Context) (Subscription, error)

	// TransactionReceipt can be used to get a TransactionReceipt for a particular transaction
	TransactionReceipt(ctx context.Context, hash string) (*eth.TransactionReceipt, error)

	// Logs returns an array of Logs matching the passed in filter
	Logs(ctx context.Context, filter eth.LogFilter) ([]eth.Log, error)

	// IsBidirectional returns true if the under laying transport supports bidirectional features such as subscriptions
	IsBidirectional() bool
}

Client represents a connection to an ethereum node

func NewClient

func NewClient(ctx context.Context, rawURL string) (Client, error)

func NewCustomClient

func NewCustomClient(requester Requester, subscriber Subscriber) (Client, error)

type MockClient

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

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) BlockByHash

func (m *MockClient) BlockByHash(ctx context.Context, hash string, full bool) (*eth.Block, error)

BlockByHash mocks base method.

func (*MockClient) BlockByNumber

func (m *MockClient) BlockByNumber(ctx context.Context, number uint64, full bool) (*eth.Block, error)

BlockByNumber mocks base method.

func (*MockClient) BlockByNumberOrTag

func (m *MockClient) BlockByNumberOrTag(ctx context.Context, numberOrTag eth.BlockNumberOrTag, full bool) (*eth.Block, error)

BlockByNumberOrTag mocks base method.

func (*MockClient) BlockNumber

func (m *MockClient) BlockNumber(ctx context.Context) (uint64, error)

BlockNumber mocks base method.

func (*MockClient) ChainId

func (m *MockClient) ChainId(ctx context.Context) (string, error)

ChainId mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

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

func (*MockClient) EstimateGas

func (m *MockClient) EstimateGas(ctx context.Context, msg eth.Transaction) (uint64, error)

EstimateGas mocks base method.

func (*MockClient) GasPrice

func (m *MockClient) GasPrice(ctx context.Context) (uint64, error)

GasPrice mocks base method.

func (*MockClient) GetTransactionCount

func (m *MockClient) GetTransactionCount(ctx context.Context, address eth.Address, numberOrTag eth.BlockNumberOrTag) (uint64, error)

GetTransactionCount mocks base method.

func (*MockClient) IsBidirectional

func (m *MockClient) IsBidirectional() bool

IsBidirectional mocks base method.

func (*MockClient) Logs

func (m *MockClient) Logs(ctx context.Context, filter eth.LogFilter) ([]eth.Log, error)

Logs mocks base method.

func (*MockClient) MaxPriorityFeePerGas

func (m *MockClient) MaxPriorityFeePerGas(ctx context.Context) (uint64, error)

MaxPriorityFeePerGas mocks base method.

func (*MockClient) NetPeerCount

func (m *MockClient) NetPeerCount(ctx context.Context) (string, error)

NetPeerCount mocks base method.

func (*MockClient) NetVersion

func (m *MockClient) NetVersion(ctx context.Context) (string, error)

NetVersion mocks base method.

func (*MockClient) Request

Request mocks base method.

func (*MockClient) SendRawTransaction

func (m *MockClient) SendRawTransaction(ctx context.Context, msg string) (string, error)

SendRawTransaction mocks base method.

func (*MockClient) Subscribe

func (m *MockClient) Subscribe(ctx context.Context, r *jsonrpc.Request) (Subscription, error)

Subscribe mocks base method.

func (*MockClient) SubscribeNewHeads

func (m *MockClient) SubscribeNewHeads(ctx context.Context) (Subscription, error)

SubscribeNewHeads mocks base method.

func (*MockClient) SubscribeNewPendingTransactions

func (m *MockClient) SubscribeNewPendingTransactions(ctx context.Context) (Subscription, error)

SubscribeNewPendingTransactions mocks base method.

func (*MockClient) TransactionByHash

func (m *MockClient) TransactionByHash(ctx context.Context, hash string) (*eth.Transaction, error)

TransactionByHash mocks base method.

func (*MockClient) TransactionReceipt

func (m *MockClient) TransactionReceipt(ctx context.Context, hash string) (*eth.TransactionReceipt, error)

TransactionReceipt mocks base method.

func (*MockClient) URL

func (m *MockClient) URL() string

URL mocks base method.

type MockClientMockRecorder

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

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) BlockByHash

func (mr *MockClientMockRecorder) BlockByHash(ctx, hash, full interface{}) *gomock.Call

BlockByHash indicates an expected call of BlockByHash.

func (*MockClientMockRecorder) BlockByNumber

func (mr *MockClientMockRecorder) BlockByNumber(ctx, number, full interface{}) *gomock.Call

BlockByNumber indicates an expected call of BlockByNumber.

func (*MockClientMockRecorder) BlockByNumberOrTag

func (mr *MockClientMockRecorder) BlockByNumberOrTag(ctx, numberOrTag, full interface{}) *gomock.Call

BlockByNumberOrTag indicates an expected call of BlockByNumberOrTag.

func (*MockClientMockRecorder) BlockNumber

func (mr *MockClientMockRecorder) BlockNumber(ctx interface{}) *gomock.Call

BlockNumber indicates an expected call of BlockNumber.

func (*MockClientMockRecorder) ChainId

func (mr *MockClientMockRecorder) ChainId(ctx interface{}) *gomock.Call

ChainId indicates an expected call of ChainId.

func (*MockClientMockRecorder) EstimateGas

func (mr *MockClientMockRecorder) EstimateGas(ctx, msg interface{}) *gomock.Call

EstimateGas indicates an expected call of EstimateGas.

func (*MockClientMockRecorder) GasPrice

func (mr *MockClientMockRecorder) GasPrice(ctx interface{}) *gomock.Call

GasPrice indicates an expected call of GasPrice.

func (*MockClientMockRecorder) GetTransactionCount

func (mr *MockClientMockRecorder) GetTransactionCount(ctx, address, numberOrTag interface{}) *gomock.Call

GetTransactionCount indicates an expected call of GetTransactionCount.

func (*MockClientMockRecorder) IsBidirectional

func (mr *MockClientMockRecorder) IsBidirectional() *gomock.Call

IsBidirectional indicates an expected call of IsBidirectional.

func (*MockClientMockRecorder) Logs

func (mr *MockClientMockRecorder) Logs(ctx, filter interface{}) *gomock.Call

Logs indicates an expected call of Logs.

func (*MockClientMockRecorder) MaxPriorityFeePerGas

func (mr *MockClientMockRecorder) MaxPriorityFeePerGas(ctx interface{}) *gomock.Call

MaxPriorityFeePerGas indicates an expected call of MaxPriorityFeePerGas.

func (*MockClientMockRecorder) NetPeerCount

func (mr *MockClientMockRecorder) NetPeerCount(ctx interface{}) *gomock.Call

NetPeerCount indicates an expected call of NetPeerCount.

func (*MockClientMockRecorder) NetVersion

func (mr *MockClientMockRecorder) NetVersion(ctx interface{}) *gomock.Call

NetVersion indicates an expected call of NetVersion.

func (*MockClientMockRecorder) Request

func (mr *MockClientMockRecorder) Request(ctx, r interface{}) *gomock.Call

Request indicates an expected call of Request.

func (*MockClientMockRecorder) SendRawTransaction

func (mr *MockClientMockRecorder) SendRawTransaction(ctx, msg interface{}) *gomock.Call

SendRawTransaction indicates an expected call of SendRawTransaction.

func (*MockClientMockRecorder) Subscribe

func (mr *MockClientMockRecorder) Subscribe(ctx, r interface{}) *gomock.Call

Subscribe indicates an expected call of Subscribe.

func (*MockClientMockRecorder) SubscribeNewHeads

func (mr *MockClientMockRecorder) SubscribeNewHeads(ctx interface{}) *gomock.Call

SubscribeNewHeads indicates an expected call of SubscribeNewHeads.

func (*MockClientMockRecorder) SubscribeNewPendingTransactions

func (mr *MockClientMockRecorder) SubscribeNewPendingTransactions(ctx interface{}) *gomock.Call

SubscribeNewPendingTransactions indicates an expected call of SubscribeNewPendingTransactions.

func (*MockClientMockRecorder) TransactionByHash

func (mr *MockClientMockRecorder) TransactionByHash(ctx, hash interface{}) *gomock.Call

TransactionByHash indicates an expected call of TransactionByHash.

func (*MockClientMockRecorder) TransactionReceipt

func (mr *MockClientMockRecorder) TransactionReceipt(ctx, hash interface{}) *gomock.Call

TransactionReceipt indicates an expected call of TransactionReceipt.

func (*MockClientMockRecorder) URL

func (mr *MockClientMockRecorder) URL() *gomock.Call

URL indicates an expected call of URL.

type MockRequester

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

MockRequester is a mock of Requester interface.

func NewMockRequester

func NewMockRequester(ctrl *gomock.Controller) *MockRequester

NewMockRequester creates a new mock instance.

func (*MockRequester) EXPECT

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

func (*MockRequester) Request

Request mocks base method.

type MockRequesterMockRecorder

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

MockRequesterMockRecorder is the mock recorder for MockRequester.

func (*MockRequesterMockRecorder) Request

func (mr *MockRequesterMockRecorder) Request(ctx, r interface{}) *gomock.Call

Request indicates an expected call of Request.

type MockSubscriber

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

MockSubscriber is a mock of Subscriber interface.

func NewMockSubscriber

func NewMockSubscriber(ctrl *gomock.Controller) *MockSubscriber

NewMockSubscriber creates a new mock instance.

func (*MockSubscriber) EXPECT

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

func (*MockSubscriber) Subscribe

func (m *MockSubscriber) Subscribe(ctx context.Context, r *jsonrpc.Request) (Subscription, error)

Subscribe mocks base method.

type MockSubscriberMockRecorder

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

MockSubscriberMockRecorder is the mock recorder for MockSubscriber.

func (*MockSubscriberMockRecorder) Subscribe

func (mr *MockSubscriberMockRecorder) Subscribe(ctx, r interface{}) *gomock.Call

Subscribe indicates an expected call of Subscribe.

type MockSubscription

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

MockSubscription is a mock of Subscription interface.

func NewMockSubscription

func NewMockSubscription(ctrl *gomock.Controller) *MockSubscription

NewMockSubscription creates a new mock instance.

func (*MockSubscription) Ch

func (m *MockSubscription) Ch() <-chan *jsonrpc.Notification

Ch mocks base method.

func (*MockSubscription) EXPECT

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

func (*MockSubscription) ID

func (m *MockSubscription) ID() string

ID mocks base method.

func (*MockSubscription) Response

func (m *MockSubscription) Response() *jsonrpc.RawResponse

Response mocks base method.

func (*MockSubscription) Unsubscribe

func (m *MockSubscription) Unsubscribe(ctx context.Context) error

Unsubscribe mocks base method.

type MockSubscriptionMockRecorder

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

MockSubscriptionMockRecorder is the mock recorder for MockSubscription.

func (*MockSubscriptionMockRecorder) Ch

Ch indicates an expected call of Ch.

func (*MockSubscriptionMockRecorder) ID

ID indicates an expected call of ID.

func (*MockSubscriptionMockRecorder) Response

func (mr *MockSubscriptionMockRecorder) Response() *gomock.Call

Response indicates an expected call of Response.

func (*MockSubscriptionMockRecorder) Unsubscribe

func (mr *MockSubscriptionMockRecorder) Unsubscribe(ctx interface{}) *gomock.Call

Unsubscribe indicates an expected call of Unsubscribe.

type Requester

type Requester interface {
	// Request method can be used to send JSONRPC requests and receive JSONRPC responses
	Request(ctx context.Context, r *jsonrpc.Request) (*jsonrpc.RawResponse, error)
}

type Subscriber

type Subscriber interface {
	// Subscribe method can be used to subscribe via eth_subscribe
	Subscribe(ctx context.Context, r *jsonrpc.Request) (Subscription, error)
}

type Subscription

type Subscription interface {
	Response() *jsonrpc.RawResponse
	ID() string
	Ch() <-chan *jsonrpc.Notification
	Unsubscribe(ctx context.Context) error
}

type SubscriptionParams

type SubscriptionParams struct {
	Subscription string          `json:"subscription"`
	Result       json.RawMessage `json:"result"`
}

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
Package websocket implements a websocket connection to an Ethereum node.
Package websocket implements a websocket connection to an Ethereum node.
mocks
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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