providerwrapper

package
v0.0.0-...-613d1fa Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package providerwrapper wraps a web3 provider in order to implement the RPCClient interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RPCClient

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

func NewRPCClient

func NewRPCClient(provider js.Value) *RPCClient

func (*RPCClient) BatchCallContext

func (c *RPCClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error

BatchCall sends all given requests as a single batch and waits for the server to return a response for all of them. The wait duration is bounded by the context's deadline.

In contrast to CallContext, BatchCallContext only returns errors that have occurred while sending the request. Any error specific to a request is reported through the Error field of the corresponding BatchElem.

Note that batch calls may not be executed atomically on the server side.

func (*RPCClient) CallContext

func (c *RPCClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error

CallContext performs a JSON-RPC call with the given arguments. If the context is canceled before the call has successfully returned, CallContext returns immediately.

The result must be a pointer so that package json can unmarshal into it. You can also pass nil, in which case the result is ignored.

func (*RPCClient) Close

func (c *RPCClient) Close()

Close is a no-op in this implementation.

func (*RPCClient) EthSubscribe

func (c *RPCClient) EthSubscribe(ctx context.Context, channel interface{}, args ...interface{}) (*rpc.ClientSubscription, error)

EthSubscribe registers a subscripion under the "eth" namespace.

Jump to

Keyboard shortcuts

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