jsonrpc

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MPL-2.0 Imports: 9 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGasFactor

func DefaultGasFactor(i uint64) uint64

Types

type Client

type Client struct {
	GasLimitFactor func(gasLimit uint64) uint64
	// contains filtered or unexported fields
}

Client is the jsonrpc client

func NewClient

func NewClient(addr string) (*Client, error)

NewClient creates a new client

func NewClientWithTransport added in v0.1.7

func NewClientWithTransport(trans transport.Transport) *Client

func (*Client) Call

func (c *Client) Call(method string, out interface{}, params ...interface{}) error

Call makes a jsonrpc call

func (*Client) Close

func (c *Client) Close() error

Close closes the tranport

func (*Client) Eth

func (c *Client) Eth() *Eth

Eth returns the reference to the eth namespace

func (*Client) L2 added in v0.1.14

func (c *Client) L2() *L2

L2 returns the reference to the l2 namespace

func (*Client) Net

func (c *Client) Net() *Net

Net returns the reference to the net namespace

func (*Client) Subscribe

func (c *Client) Subscribe(method string, param interface{}, callback func(b []byte)) (func() error, error)

Subscribe starts a new subscription

func (*Client) SubscribeLogs added in v0.1.2

func (c *Client) SubscribeLogs(callback func(log *web3.Log), addresses []web3.Address, topics ...[][]web3.Hash) (func() error, error)

Emits logs which are part of newly added blocks that match specified filter criteria.

When a chain reorganization occurs, logs which are part of blocks on the old chain will be emitted again with the property removed set to true. Further, logs which are part of the blocks on the new chain are emitted, meaning that it is possible to see logs for the same transaction multiple times in the case of a reorganization.

Parameters is an object with the following fields: adddress (optional): either a string representing an address or an array of such strings.Only logs created from one of these addresses will be emitted. topics: an array of topic specifiers. Each topic specifier is either null, a string representing a topic, or an array of strings.Each position in the array which is not null restricts the emitted logs to only those who have one of the given topics in that position. Some examples of topic specifications: []: Any topics allowed. [A]: A in first position (and anything after). [null, B]: Anything in first position and B in second position (and anything after). [A, B]: A in first position and B in second position (and anything after). [[A, B], [A, B]]: (A or B) in first position and (A or B) in second position (and anything after).

func (*Client) SubscribeNewHeads added in v0.1.2

func (c *Client) SubscribeNewHeads(callback func(b *web3.Block)) (func() error, error)

Emits an event any time a new header is added to the chain, including during a chain reorganization. When a chain reorganization occurs, this subscription will emit an event containing all new headers for the new chain. In particular, this means that you may see multiple headers emitted with the same height, and when this happens the later header should be taken as the correct one after a reorganization.

func (*Client) SubscribePendingTx added in v0.1.2

func (c *Client) SubscribePendingTx(watchAddr web3.Address, callback func(tx *web3.Transaction)) (func() error, error)

func (*Client) SubscriptionEnabled

func (c *Client) SubscriptionEnabled() bool

SubscriptionEnabled returns true if the subscription endpoints are enabled

func (*Client) Web3

func (c *Client) Web3() *Web3

Web3 returns the reference to the web3 namespace

type Eth

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

Eth is the eth namespace

func (*Eth) Accounts

func (e *Eth) Accounts() ([]web3.Address, error)

Accounts returns a list of addresses owned by client.

func (*Eth) BlockNumber

func (e *Eth) BlockNumber() (uint64, error)

BlockNumber returns the number of most recent block.

func (*Eth) Call

func (e *Eth) Call(msg *web3.CallMsg, block web3.BlockNumber) (string, error)

Call executes a new message call immediately without creating a transaction on the block chain.

func (*Eth) ChainID

func (e *Eth) ChainID() (*big.Int, error)

ChainID returns the id of the chain

func (*Eth) EstimateGas

func (e *Eth) EstimateGas(msg *web3.CallMsg) (uint64, error)

EstimateGas generates and returns an estimate of how much gas is necessary to allow the transaction to complete.

func (*Eth) EstimateGasContract

func (e *Eth) EstimateGasContract(bin []byte) (uint64, error)

EstimateGasContract estimates the gas to deploy a contract

func (*Eth) GasPrice

func (e *Eth) GasPrice() (uint64, error)

GasPrice returns the current price per gas in wei.

func (*Eth) GetBalance

func (e *Eth) GetBalance(addr web3.Address, blockNumber web3.BlockNumber) (*big.Int, error)

GetBalance returns the balance of the account of given address.

func (*Eth) GetBlockByHash

func (e *Eth) GetBlockByHash(hash web3.Hash, full bool) (*web3.Block, error)

GetBlockByHash returns information about a block by hash.

func (*Eth) GetBlockByNumber

func (e *Eth) GetBlockByNumber(i web3.BlockNumber, full bool) (*web3.Block, error)

GetBlockByNumber returns information about a block by block number.

func (*Eth) GetCode

func (e *Eth) GetCode(addr web3.Address) (string, error)

GetCode returns the code of a contract

func (*Eth) GetFilterChanges

func (e *Eth) GetFilterChanges(id string) ([]*web3.Log, error)

GetFilterChanges returns the filter changes for log filters

func (*Eth) GetFilterChangesBlock

func (e *Eth) GetFilterChangesBlock(id string) ([]web3.Hash, error)

GetFilterChangesBlock returns the filter changes for block filters

func (*Eth) GetHeaderByHash added in v0.1.14

func (e *Eth) GetHeaderByHash(hash web3.Hash) (*web3.Header, error)

GetHeaderByHash returns information about a header by hash.

func (*Eth) GetHeaderByNumber added in v0.1.14

func (e *Eth) GetHeaderByNumber(num web3.BlockNumber) (*web3.Header, error)

GetHeaderByNumber returns information about a header by number.

func (*Eth) GetLogs

func (e *Eth) GetLogs(filter *web3.LogFilter) ([]*web3.Log, error)

GetLogs returns an array of all logs matching a given filter object

func (*Eth) GetNonce

func (e *Eth) GetNonce(addr web3.Address, blockNumber web3.BlockNumber) (uint64, error)

GetNonce returns the nonce of the account

func (*Eth) GetStorage

func (ec *Eth) GetStorage(account web3.Address, key web3.Hash, blockNumber web3.BlockNumber) (web3.Hash, error)

StorageAt returns the value of key in the contract storage of the given account.

func (*Eth) GetTransactionByBlockHashAndIndex added in v0.1.2

func (e *Eth) GetTransactionByBlockHashAndIndex(blockHash web3.Hash, index uint64) (*web3.Transaction, error)

GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index.

func (*Eth) GetTransactionByBlockNumberAndIndex added in v0.1.2

func (e *Eth) GetTransactionByBlockNumberAndIndex(blockNumber web3.BlockNumber, index uint64) (*web3.Transaction, error)

GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index.

func (*Eth) GetTransactionByHash

func (e *Eth) GetTransactionByHash(hash web3.Hash) (*web3.Transaction, error)

GetTransactionByHash returns a transaction by his hash

func (*Eth) GetTransactionReceipt

func (e *Eth) GetTransactionReceipt(hash web3.Hash) (*web3.Receipt, error)

GetTransactionReceipt returns the receipt of a transaction by transaction hash.

func (*Eth) NewBlockFilter

func (e *Eth) NewBlockFilter() (string, error)

NewBlockFilter creates a new block filter

func (*Eth) NewFilter

func (e *Eth) NewFilter(filter *web3.LogFilter) (string, error)

NewFilter creates a new log filter

func (*Eth) SendRawTransaction

func (e *Eth) SendRawTransaction(data []byte) (web3.Hash, error)

SendRawTransaction sends a signed transaction in rlp format.

func (*Eth) SendTransaction

func (e *Eth) SendTransaction(txn *web3.Transaction) (web3.Hash, error)

SendTransaction creates new message call transaction or a contract creation.

func (*Eth) UninstallFilter

func (e *Eth) UninstallFilter(id string) (bool, error)

UninstallFilter uninstalls a filter

type GlobalInfo added in v0.1.14

type GlobalInfo struct {
	//total batch num in l1 RollupInputChain contract
	L1InputInfo InputChainInfo
	//l2 client have checked tx batch num
	L2CheckedBatchNum hexutil.Uint64
	//the total block num l2 already checked,start from 1, because genesis block do not need to check
	L2CheckedBlockNum hexutil.Uint64
	//l2 client head block num
	L2HeadBlockNumber   hexutil.Uint64
	L1SyncedBlockNumber hexutil.Uint64
	L1SyncedTimestamp   *hexutil.Uint64
}

type InputChainInfo added in v0.1.14

type InputChainInfo struct {
	PendingQueueIndex hexutil.Uint64
	TotalBatches      hexutil.Uint64
	QueueSize         hexutil.Uint64
}

type L1RelayMsgParams added in v0.1.14

type L1RelayMsgParams struct {
	Target       web3.Address   `json:"target"`
	Sender       web3.Address   `json:"sender"`
	Message      hexutil.Bytes  `json:"message"`
	MessageIndex hexutil.Uint64 `json:"messageIndex"`
	RLPHeader    hexutil.Bytes  `json:"rlpHeader"`
	StateInfo    *RPCBatchState `json:"stateInfo"`
	Proof        []web3.Hash    `json:"proof"`
}

type L2 added in v0.1.14

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

L2 is the l2 client namespace

func (*L2) GetBatch added in v0.1.14

func (l *L2) GetBatch(batchNumber uint64, useDetail bool) (*RPCBatch, error)

func (*L2) GetBatchState added in v0.1.14

func (l *L2) GetBatchState(batchNumber uint64) (*RPCBatchState, error)

func (*L2) GetEnqueuedTxs added in v0.1.14

func (l *L2) GetEnqueuedTxs(queueStart, queueNum uint64) ([]*RPCEnqueuedTx, error)

func (*L2) GetL1RelayMsgParams added in v0.1.14

func (l *L2) GetL1RelayMsgParams(msgIndex uint64) (*L1RelayMsgParams, error)

func (*L2) GetL2MMRProof added in v0.1.14

func (l *L2) GetL2MMRProof(msgIndex, size uint64) ([]web3.Hash, error)

func (*L2) GetL2RelayMsgParams added in v0.1.14

func (l *L2) GetL2RelayMsgParams(msgIndex uint64) (*L2RelayMsgParams, error)

func (*L2) GetReadStorageProof added in v0.1.14

func (l *L2) GetReadStorageProof(input []byte, parentBlockHash web3.Hash, batchIndex uint64) ([]string, error)

func (*L2) GetRollupStateHash added in v0.1.14

func (l *L2) GetRollupStateHash(batchIndex uint64) (web3.Hash, error)

func (*L2) GlobalInfo added in v0.1.14

func (l *L2) GlobalInfo() (*GlobalInfo, error)

tx batch data is already encoded as params of AppendBatch in RollupInputChain.sol, just add a func selector beyond it to invoke the AppendBatch is fine.

func (*L2) InputBatchNumber added in v0.1.14

func (l *L2) InputBatchNumber() (hexutil.Uint64, error)

func (*L2) StateBatchNumber added in v0.1.14

func (l *L2) StateBatchNumber() (hexutil.Uint64, error)

type L2RelayMsgParams added in v0.1.14

type L2RelayMsgParams struct {
	Target       web3.Address   `json:"target"`
	Sender       web3.Address   `json:"sender"`
	Message      hexutil.Bytes  `json:"message"`
	MessageIndex hexutil.Uint64 `json:"messageIndex"`
	MMRSize      hexutil.Uint64 `json:"mmrSize"`
	Proof        []web3.Hash    `json:"proof"`
}

type Net

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

Net is the net namespace

func (*Net) Listening

func (n *Net) Listening() (bool, error)

Listening returns true if client is actively listening for network connections

func (*Net) PeerCount

func (n *Net) PeerCount() (uint64, error)

PeerCount returns number of peers currently connected to the client

func (*Net) Version

func (n *Net) Version() (uint64, error)

Version returns the current network id

type RPCBatch added in v0.1.14

type RPCBatch struct {
	Sequencer   web3.Address   `json:"sequencer"`
	BatchNumber hexutil.Uint64 `json:"batchNumber"`
	BatchHash   web3.Hash      `json:"batchHash"`
	QueueStart  hexutil.Uint64 `json:"queueStart"`
	QueueNum    hexutil.Uint64 `json:"queueNum"`
	SubBatches  []*RPCSubBatch `json:"subBatches"`
	Version     hexutil.Uint64 `json:"version"` // version of encode type, 0 for normal rlp, 1 for brotli code of rlp
}

type RPCBatchState added in v0.1.14

type RPCBatchState struct {
	Index     hexutil.Uint64
	Proposer  web3.Address
	Timestamp hexutil.Uint64
	BlockHash web3.Hash
}

type RPCEnqueuedTx added in v0.1.14

type RPCEnqueuedTx struct {
	QueueIndex hexutil.Uint64 `json:"queueIndex"`
	From       web3.Address   `json:"from"`
	To         web3.Address   `json:"to"`
	RlpTx      hexutil.Bytes  `json:"rlpTx"`
	Timestamp  hexutil.Uint64 `json:"timestamp"`
}

type RPCSubBatch added in v0.1.14

type RPCSubBatch struct {
	Timestamp hexutil.Uint64      `json:"timestamp"`
	Txs       []*web3.Transaction `json:"transactions"` // RPCTransaction or txHash
}

type Web3

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

Web3 is the web3 namespace

func (*Web3) ClientVersion

func (w *Web3) ClientVersion() (string, error)

ClientVersion returns the current client version

func (*Web3) Sha3

func (w *Web3) Sha3(val []byte) ([]byte, error)

Sha3 returns Keccak-256 (not the standardized SHA3-256) of the given data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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