Documentation
¶
Overview ¶
Package rpc provides access to the RPC client
Index ¶
- Variables
- func IsSame(a string, b string) bool
- func PingRpc(providerUrl string) error
- type Connection
- func (conn *Connection) GetBalanceAt(addr base.Address, bn base.Blknum) (*base.Wei, error)
- func (conn *Connection) GetBalanceAtToken(token, holder base.Address, hexBlockNo string) (*base.Wei, error)
- func (conn *Connection) GetBlockBodyByNumber(bn base.Blknum) (types.Block, error)
- func (conn *Connection) GetBlockHashByHash(hash string) (base.Hash, error)
- func (conn *Connection) GetBlockHashByNumber(bn base.Blknum) (base.Hash, error)
- func (conn *Connection) GetBlockHeaderByNumber(bn base.Blknum) (types.LightBlock, error)
- func (conn *Connection) GetBlockNumberByHash(hash string) (base.Blknum, error)
- func (conn *Connection) GetBlockTimestamp(bn base.Blknum) base.Timestamp
- func (conn *Connection) GetClientIDs() (uint64, uint64, error)
- func (conn *Connection) GetClientVersion() (version string, err error)
- func (conn *Connection) GetContractCodeAt(addr base.Address, bn base.Blknum) ([]byte, error)
- func (conn *Connection) GetContractDeployBlock(address base.Address) (block base.Blknum, err error)
- func (conn *Connection) GetContractProxyAt(address base.Address, blockNumber base.Blknum) (base.Address, error)
- func (conn *Connection) GetEnsAddress(addrOrEns string) (string, bool)
- func (conn *Connection) GetEnsAddresses(addrs []string) (out []string, found bool)
- func (conn *Connection) GetEnsName(addr string) (string, bool)
- func (conn *Connection) GetLatestBlockNumber() base.Blknum
- func (conn *Connection) GetLogsByNumber(bn base.Blknum, ts base.Timestamp) ([]types.Log, error)
- func (conn *Connection) GetLogsCountInBlock(bn base.Blknum, ts base.Timestamp) (uint64, error)
- func (conn *Connection) GetMetaData(testmode bool) (*types.MetaData, error)
- func (conn *Connection) GetMinerAndWithdrawals(bn base.Blknum) ([]types.Withdrawal, base.Address, error)
- func (conn *Connection) GetReceipt(bn base.Blknum, txid base.Txnum, suggested base.Timestamp) (receipt types.Receipt, err error)
- func (conn *Connection) GetReceiptNoTimestamp(bn base.Blknum, txid base.Txnum) (receipt types.Receipt, err error)
- func (conn *Connection) GetReceiptsByNumber(bn base.Blknum, ts base.Timestamp) ([]types.Receipt, map[base.Txnum]*types.Receipt, error)
- func (conn *Connection) GetState(fieldBits types.StatePart, address base.Address, blockNumber base.Blknum, ...) (*types.State, error)
- func (conn *Connection) GetTokenState(tokenAddress base.Address, hexBlockNo string) (token *types.Token, err error)
- func (conn *Connection) GetTracesByBlockNumber(bn base.Blknum) ([]types.Trace, error)
- func (conn *Connection) GetTracesByTransactionHash(txHash string, transaction *types.Transaction) ([]types.Trace, error)
- func (conn *Connection) GetTracesByTransactionId(bn base.Blknum, txid base.Txnum) ([]types.Trace, error)
- func (conn *Connection) GetTracesCountInBlock(bn base.Blknum) (uint64, error)
- func (conn *Connection) GetTransactionAppByHash(hash string) (types.Appearance, error)
- func (conn *Connection) GetTransactionByAppearance(app *types.Appearance, fetchTraces bool) (*types.Transaction, error)
- func (conn *Connection) GetTransactionByNumberAndId(bn base.Blknum, txid base.Txnum) (*types.Transaction, error)
- func (conn *Connection) GetTransactionCountInBlock(bn base.Blknum) (uint64, error)
- func (conn *Connection) GetTransactionHashByHash(hash string) (string, error)
- func (conn *Connection) GetTransactionHashByHashAndID(hash string, txId base.Txnum) (string, error)
- func (conn *Connection) GetTransactionHashByNumberAndID(bn base.Blknum, txId base.Txnum) (base.Hash, error)
- func (conn *Connection) GetTransactionPrefundByApp(theApp *types.Appearance) (tx *types.Transaction, err error)
- func (conn *Connection) GetTransactionRewardByTypeAndApp(rt base.Txnum, theApp *types.Appearance) (*types.Transaction, error)
- func (conn *Connection) GetUncleBodiesByNumber(bn base.Blknum) ([]types.Block, error)
- func (conn *Connection) GetUnclesCountInBlock(bn base.Blknum) (uint64, error)
- func (conn *Connection) GetWithdrawalsByNumber(bn base.Blknum) ([]types.Withdrawal, error)
- func (conn *Connection) IsContractAt(address base.Address, bn base.Blknum) error
- func (conn *Connection) IsContractAtLatest(address base.Address) error
- func (conn *Connection) IsNodeArchive() bool
- func (conn *Connection) IsNodeTracing() (error, bool)
- func (conn *Connection) StoreReadable() bool
- func (conn *Connection) StoreWritable() bool
- func (conn *Connection) TestLog(caches map[walk.CacheType]bool)
- type LogFilter
- type StateFilters
Constants ¶
This section is empty.
Variables ¶
var ErrNotAContract = errors.New("not a contract")
Functions ¶
Types ¶
type Connection ¶
type Connection struct { Chain string Store *cache.Store // Cache Store to use for read/write. Write can be disabled by setting Store to read-only mode LatestBlockTimestamp base.Timestamp EnabledMap map[walk.CacheType]bool }
Connection carries additional context to rpc calls
func NewConnection ¶
func NewReadOnlyConnection ¶
func NewReadOnlyConnection(chain string) *Connection
func TempConnection ¶
func TempConnection(chain string) *Connection
func (*Connection) GetBalanceAt ¶
GetBalanceAt returns a balance for an address at a block
func (*Connection) GetBalanceAtToken ¶
func (conn *Connection) GetBalanceAtToken(token, holder base.Address, hexBlockNo string) (*base.Wei, error)
GetBalanceAtToken returns token balance for given block. `hexBlockNo` can be "latest" or "" for the latest block or decimal number or hex number with 0x prefix.
func (*Connection) GetBlockBodyByNumber ¶
GetBlockBodyByNumber fetches the block with transactions from the RPC.
func (*Connection) GetBlockHashByHash ¶
func (conn *Connection) GetBlockHashByHash(hash string) (base.Hash, error)
GetBlockHashByHash returns a block's hash if it's a valid block
func (*Connection) GetBlockHashByNumber ¶
GetBlockHashByNumber returns a block's hash if it's a valid block
func (*Connection) GetBlockHeaderByNumber ¶
func (conn *Connection) GetBlockHeaderByNumber(bn base.Blknum) (types.LightBlock, error)
GetBlockHeaderByNumber fetches the block with only transactions' hashes from the RPC
func (*Connection) GetBlockNumberByHash ¶
func (conn *Connection) GetBlockNumberByHash(hash string) (base.Blknum, error)
GetBlockNumberByHash returns a block's hash if it's a valid block
func (*Connection) GetBlockTimestamp ¶
func (conn *Connection) GetBlockTimestamp(bn base.Blknum) base.Timestamp
GetBlockTimestamp returns the timestamp associated with a given block
func (*Connection) GetClientIDs ¶
func (conn *Connection) GetClientIDs() (uint64, uint64, error)
GetClientIDs returns both chainId and networkId from the node
func (*Connection) GetClientVersion ¶
func (conn *Connection) GetClientVersion() (version string, err error)
GetClientVersion returns the version of the client
func (*Connection) GetContractCodeAt ¶
GetContractCodeAt returns a code (if any) for an address at a block
func (*Connection) GetContractDeployBlock ¶
func (*Connection) GetContractProxyAt ¶
func (conn *Connection) GetContractProxyAt(address base.Address, blockNumber base.Blknum) (base.Address, error)
GetContractProxyAt returns the proxy address for a contract if any
func (*Connection) GetEnsAddress ¶
func (conn *Connection) GetEnsAddress(addrOrEns string) (string, bool)
GetEnsAddress converts a single string, if it contains .eth, into an address. Note, we take chain parameter, but ignore it choosing to look at mainnet ENS only
func (*Connection) GetEnsAddresses ¶
func (conn *Connection) GetEnsAddresses(addrs []string) (out []string, found bool)
GetEnsAddresses converts an array of strings, if they contains .eth, into addresses. Note, we take chain parameter, but ignore it choosing to look at mainnet ENS only
func (*Connection) GetEnsName ¶
func (conn *Connection) GetEnsName(addr string) (string, bool)
GetEnsName converts an address into an ens name if registered, returns the address otherwise.
func (*Connection) GetLatestBlockNumber ¶
func (conn *Connection) GetLatestBlockNumber() base.Blknum
GetLatestBlockNumber returns the block number at the front of the chain (i.e. latest)
func (*Connection) GetLogsByNumber ¶
GetLogsByNumber returns the logs of a block
func (*Connection) GetLogsCountInBlock ¶
GetLogsCountInBlock returns the number of logs in a block
func (*Connection) GetMetaData ¶
func (conn *Connection) GetMetaData(testmode bool) (*types.MetaData, error)
func (*Connection) GetMinerAndWithdrawals ¶
func (conn *Connection) GetMinerAndWithdrawals(bn base.Blknum) ([]types.Withdrawal, base.Address, error)
GetMinerAndWithdrawals returns the miner and withdrawals for a block
func (*Connection) GetReceipt ¶
func (conn *Connection) GetReceipt(bn base.Blknum, txid base.Txnum, suggested base.Timestamp) (receipt types.Receipt, err error)
GetReceipt retrieves a single receipt by block number and transaction id. If suggested is provided, it will be used for the timestamp of the logs.
func (*Connection) GetReceiptNoTimestamp ¶
func (conn *Connection) GetReceiptNoTimestamp(bn base.Blknum, txid base.Txnum) (receipt types.Receipt, err error)
GetReceiptNoTimestamp fetches receipt from the RPC. If txGasPrice is provided, it will be used for receipts in blocks before London
func (*Connection) GetReceiptsByNumber ¶
func (conn *Connection) GetReceiptsByNumber(bn base.Blknum, ts base.Timestamp) ([]types.Receipt, map[base.Txnum]*types.Receipt, error)
GetReceiptsByNumber returns all receipts in a blocks along with their logs
func (*Connection) GetState ¶
func (conn *Connection) GetState(fieldBits types.StatePart, address base.Address, blockNumber base.Blknum, filters StateFilters) (*types.State, error)
GetState returns account state (search: FromRpc)
func (*Connection) GetTokenState ¶
func (conn *Connection) GetTokenState(tokenAddress base.Address, hexBlockNo string) (token *types.Token, err error)
GetTokenState returns token state for given block. `hexBlockNo` can be "latest" or "" for the latest block or decimal number or hex number with 0x prefix. (search: FromRpc)
func (*Connection) GetTracesByBlockNumber ¶
GetTracesByBlockNumber returns a slice of traces in the given block
func (*Connection) GetTracesByTransactionHash ¶
func (conn *Connection) GetTracesByTransactionHash(txHash string, transaction *types.Transaction) ([]types.Trace, error)
GetTracesByTransactionHash returns a slice of traces in a given transaction's hash
func (*Connection) GetTracesByTransactionId ¶
func (conn *Connection) GetTracesByTransactionId(bn base.Blknum, txid base.Txnum) ([]types.Trace, error)
GetTracesByTransactionId returns a slice of traces in a given transaction
func (*Connection) GetTracesCountInBlock ¶
func (conn *Connection) GetTracesCountInBlock(bn base.Blknum) (uint64, error)
GetTracesCountInBlock returns the number of traces in a block
func (*Connection) GetTransactionAppByHash ¶
func (conn *Connection) GetTransactionAppByHash(hash string) (types.Appearance, error)
GetTransactionAppByHash returns a transaction's appearance if it's a valid transaction
func (*Connection) GetTransactionByAppearance ¶
func (conn *Connection) GetTransactionByAppearance(app *types.Appearance, fetchTraces bool) (*types.Transaction, error)
func (*Connection) GetTransactionByNumberAndId ¶
func (conn *Connection) GetTransactionByNumberAndId(bn base.Blknum, txid base.Txnum) (*types.Transaction, error)
func (*Connection) GetTransactionCountInBlock ¶
func (conn *Connection) GetTransactionCountInBlock(bn base.Blknum) (uint64, error)
GetTransactionCountInBlock returns the number of transactions in a block
func (*Connection) GetTransactionHashByHash ¶
func (conn *Connection) GetTransactionHashByHash(hash string) (string, error)
GetTransactionHashByHash returns a transaction's hash if it's a valid transaction, an empty string otherwise
func (*Connection) GetTransactionHashByHashAndID ¶
GetTransactionHashByHashAndID returns a transaction's hash if it's a valid transaction
func (*Connection) GetTransactionHashByNumberAndID ¶
func (conn *Connection) GetTransactionHashByNumberAndID(bn base.Blknum, txId base.Txnum) (base.Hash, error)
GetTransactionHashByNumberAndID returns a transaction's hash if it's a valid transaction
func (*Connection) GetTransactionPrefundByApp ¶
func (conn *Connection) GetTransactionPrefundByApp(theApp *types.Appearance) (tx *types.Transaction, err error)
func (*Connection) GetTransactionRewardByTypeAndApp ¶
func (conn *Connection) GetTransactionRewardByTypeAndApp(rt base.Txnum, theApp *types.Appearance) (*types.Transaction, error)
func (*Connection) GetUncleBodiesByNumber ¶
GetUncleBodiesByNumber returns the number of uncles in a block. (search: FromRpc)
func (*Connection) GetUnclesCountInBlock ¶
func (conn *Connection) GetUnclesCountInBlock(bn base.Blknum) (uint64, error)
GetUnclesCountInBlock returns the number of uncles in a block. (search: FromRpc)
func (*Connection) GetWithdrawalsByNumber ¶
func (conn *Connection) GetWithdrawalsByNumber(bn base.Blknum) ([]types.Withdrawal, error)
GetWithdrawalsByNumber returns all withdrawals in a block
func (*Connection) IsContractAt ¶
IsContractAt checks if an account is a contract
func (*Connection) IsContractAtLatest ¶
func (conn *Connection) IsContractAtLatest(address base.Address) error
IsContractAtLatest checks if an account is a contract at the latest block
func (*Connection) IsNodeArchive ¶
func (conn *Connection) IsNodeArchive() bool
IsNodeArchive tries to return true if the node is an archive node with the following caveteat: we assume that the node has been initialized with a pre-allocation. This is a reasonable assumption for most chains, but not all. For example, if a chain does not have a pre-allocation, this function will return false, when in fact the node may be an archive node.
func (*Connection) IsNodeTracing ¶
func (conn *Connection) IsNodeTracing() (error, bool)
IsNodeTracing returns true if the node exposes the `block_trace` RPC endpoint. It queries block 1 or a user supplied block (which we presume exists). The function returns false if block_trace returns an error or doesn't exist.
func (*Connection) StoreReadable ¶
func (conn *Connection) StoreReadable() bool
StoreReadable is a shorthand to check if Store is initialized. It will return false for nil pointer to Connection
func (*Connection) StoreWritable ¶
func (conn *Connection) StoreWritable() bool