Documentation
¶
Index ¶
- Variables
- func ReadBigInt(v json.RawMessage, e error) (*big.Int, error)
- func ReadString(v json.RawMessage, e error) (string, error)
- func ReadTo(target any) func(v json.RawMessage, e error) error
- func ReadUint64(v json.RawMessage, e error) (uint64, error)
- type Api
- func (a *Api) BlockNumber(ctx context.Context) (uint64, error)
- func (a *Api) ChainId(ctx context.Context) (uint64, error)
- func (a *Api) Do(method string, args ...any) (json.RawMessage, error)
- func (a *Api) To(target any, method string, args ...any) error
- func (a *Api) ToCtx(ctx context.Context, target any, method string, args ...any) error
- type Handler
- type RPC
- type RPCList
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoAvailableServer = errors.New("no available server")
)
Functions ¶
func ReadBigInt ¶ added in v0.1.1
ReadBigInt can decode a json-encoded bigint in various ways, including if it is a number literal or a string.
func ReadString ¶
func ReadString(v json.RawMessage, e error) (string, error)
ReadString decodes the return value as a string and returns it
func ReadTo ¶
func ReadTo(target any) func(v json.RawMessage, e error) error
ReadTo returns a setter function that will return an error if an error happens. This is a bit convoluted because of limitation in Go's syntax, but this could be used as:
err = ReadTo(&block)(target.Do("eth_getBlockByNumber", "0x1b4", true))
func ReadUint64 ¶
func ReadUint64(v json.RawMessage, e error) (uint64, error)
ReadUint64 decodes the return value and passes it as a uint64.
This can be used as: res, err := ReadUint64(target.Do("eth_blockNumber"))
Types ¶
type Api ¶ added in v0.1.4
type Api struct {
Handler
}
func (*Api) BlockNumber ¶ added in v0.1.4
type Handler ¶ added in v0.1.4
type RPC ¶
type RPC struct {
// contains filtered or unexported fields
}
TODO support ws protocol
Click to show internal directories.
Click to hide internal directories.