rpcapi

package
v2.0.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Copyright (c) 2023-2024 Nibi, Inc.

Index

Constants

View Source
const (
	// Cosmos namespaces
	NamespaceCosmos = "cosmos"

	// Ethereum namespaces
	NamespaceWeb3   = "web3"
	NamespaceEth    = "eth"
	NamespaceNet    = "net"
	NamespaceTxPool = "txpool"
	NamespaceDebug  = "debug"
)

RPC namespaces and API version

Variables

This section is empty.

Functions

func GetRPCAPIs

func GetRPCAPIs(ctx *server.Context,
	clientCtx client.Context,
	tmWSClient *rpcclient.WSClient,
	allowUnprotectedTxs bool,
	indexer eth.EVMTxIndexer,
	selectedAPIs []string,
) []rpc.API

GetRPCAPIs returns the list of all APIs

Types

type APICreator

type APICreator = func(
	ctx *server.Context,
	clientCtx client.Context,
	tendermintWebsocketClient *rpcclient.WSClient,
	allowUnprotectedTxs bool,
	indexer eth.EVMTxIndexer,
) []rpc.API

APICreator creates the JSON-RPC API implementations.

type APIWeb3

type APIWeb3 struct{}

APIWeb3 is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewImplWeb3API

func NewImplWeb3API() *APIWeb3

NewImplWeb3API creates an instance of the Web3 API.

func (*APIWeb3) ClientVersion

func (a *APIWeb3) ClientVersion() string

ClientVersion returns the client version in the Web3 user agent format.

func (*APIWeb3) Sha3

func (a *APIWeb3) Sha3(input string) hexutil.Bytes

Sha3 returns the keccak-256 hash of the passed-in input.

type ErrorMessageJSON

type ErrorMessageJSON struct {
	Code    *big.Int `json:"code"`
	Message string   `json:"message"`
}

type ErrorResponseJSON

type ErrorResponseJSON struct {
	Jsonrpc string            `json:"jsonrpc"`
	Error   *ErrorMessageJSON `json:"error"`
	ID      *big.Int          `json:"id"`
}

type EthAPI

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

EthAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewImplEthAPI

func NewImplEthAPI(logger log.Logger, backend backend.EVMBackend) *EthAPI

NewImplEthAPI creates an instance of the public ETH Web3 API.

func (*EthAPI) Accounts

func (e *EthAPI) Accounts() ([]common.Address, error)

Accounts returns the list of accounts available to this node.

func (*EthAPI) BlockNumber

func (e *EthAPI) BlockNumber() (hexutil.Uint64, error)

BlockNumber returns the current block number.

func (*EthAPI) Call

func (e *EthAPI) Call(args evm.JsonTxArgs,
	blockNrOrHash rpc.BlockNumberOrHash,
	_ *rpc.StateOverride,
) (hexutil.Bytes, error)

Call performs a raw contract call.

func (*EthAPI) ChainId

func (e *EthAPI) ChainId() (*hexutil.Big, error)

ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.

func (*EthAPI) EstimateGas

func (e *EthAPI) EstimateGas(
	args evm.JsonTxArgs, blockNrOptional *rpc.BlockNumber,
) (hexutil.Uint64, error)

EstimateGas returns an estimate of gas usage for the given smart contract call.

func (*EthAPI) FeeHistory

func (e *EthAPI) FeeHistory(blockCount gethrpc.DecimalOrHex,
	lastBlock gethrpc.BlockNumber,
	rewardPercentiles []float64,
) (*rpc.FeeHistoryResult, error)

func (*EthAPI) FillTransaction

func (e *EthAPI) FillTransaction(
	args evm.JsonTxArgs,
) (*rpc.SignTransactionResult, error)

FillTransaction fills the defaults (nonce, gas, gasPrice or 1559 fields) on a given unsigned transaction, and returns it to the caller for further processing (signing + broadcast).

func (*EthAPI) GasPrice

func (e *EthAPI) GasPrice() (*hexutil.Big, error)

GasPrice returns the current gas price based on Ethermint's gas price oracle.

func (*EthAPI) GetBalance

func (e *EthAPI) GetBalance(
	address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
) (*hexutil.Big, error)

GetBalance returns the provided account's balance up to the provided block number.

func (*EthAPI) GetBlockByHash

func (e *EthAPI) GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)

GetBlockByHash returns the block identified by hash.

func (*EthAPI) GetBlockByNumber

func (e *EthAPI) GetBlockByNumber(ethBlockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

GetBlockByNumber returns the block identified by number.

func (*EthAPI) GetBlockTransactionCountByHash

func (e *EthAPI) GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint

GetBlockTransactionCountByHash returns the number of transactions in the block identified by hash.

func (*EthAPI) GetBlockTransactionCountByNumber

func (e *EthAPI) GetBlockTransactionCountByNumber(
	blockNum rpc.BlockNumber,
) *hexutil.Uint

GetBlockTransactionCountByNumber returns the number of transactions in the block identified by number.

func (*EthAPI) GetCode

func (e *EthAPI) GetCode(
	address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
) (hexutil.Bytes, error)

GetCode returns the contract code at the given address and block number.

func (*EthAPI) GetPendingTransactions

func (e *EthAPI) GetPendingTransactions() ([]*rpc.EthTxJsonRPC, error)

GetPendingTransactions returns the transactions that are in the transaction pool and have a from address that is one of the accounts this node manages.

func (*EthAPI) GetProof

func (e *EthAPI) GetProof(address common.Address,
	storageKeys []string,
	blockNrOrHash rpc.BlockNumberOrHash,
) (*rpc.AccountResult, error)

GetProof returns an account object with proof and any storage proofs

func (*EthAPI) GetStorageAt

func (e *EthAPI) GetStorageAt(
	address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash,
) (hexutil.Bytes, error)

GetStorageAt returns the contract storage at the given address, block number, and key.

func (*EthAPI) GetTransactionByBlockHashAndIndex

func (e *EthAPI) GetTransactionByBlockHashAndIndex(
	hash common.Hash, idx hexutil.Uint,
) (*rpc.EthTxJsonRPC, error)

GetTransactionByBlockHashAndIndex returns the transaction identified by hash and index.

func (*EthAPI) GetTransactionByBlockNumberAndIndex

func (e *EthAPI) GetTransactionByBlockNumberAndIndex(
	blockNum rpc.BlockNumber, idx hexutil.Uint,
) (*rpc.EthTxJsonRPC, error)

GetTransactionByBlockNumberAndIndex returns the transaction identified by number and index.

func (*EthAPI) GetTransactionByHash

func (e *EthAPI) GetTransactionByHash(hash common.Hash) (*rpc.EthTxJsonRPC, error)

GetTransactionByHash returns the transaction identified by hash.

func (*EthAPI) GetTransactionCount

func (e *EthAPI) GetTransactionCount(
	address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
) (*hexutil.Uint64, error)

GetTransactionCount returns the number of transactions at the given address up to the given block number.

func (*EthAPI) GetTransactionLogs

func (e *EthAPI) GetTransactionLogs(txHash common.Hash) ([]*gethcore.Log, error)

GetTransactionLogs returns the logs given a transaction hash.

func (*EthAPI) GetTransactionReceipt

func (e *EthAPI) GetTransactionReceipt(
	hash common.Hash,
) (map[string]interface{}, error)

GetTransactionReceipt returns the transaction receipt identified by hash.

func (*EthAPI) GetUncleByBlockHashAndIndex

func (e *EthAPI) GetUncleByBlockHashAndIndex(
	_ common.Hash, _ hexutil.Uint,
) map[string]interface{}

GetUncleByBlockHashAndIndex returns the uncle identified by hash and index. Always returns nil.

func (*EthAPI) GetUncleByBlockNumberAndIndex

func (e *EthAPI) GetUncleByBlockNumberAndIndex(
	_, _ hexutil.Uint,
) map[string]interface{}

GetUncleByBlockNumberAndIndex returns the uncle identified by number and index. Always returns nil.

func (*EthAPI) GetUncleCountByBlockHash

func (e *EthAPI) GetUncleCountByBlockHash(_ common.Hash) hexutil.Uint

GetUncleCountByBlockHash returns the number of uncles in the block identified by hash. Always zero.

func (*EthAPI) GetUncleCountByBlockNumber

func (e *EthAPI) GetUncleCountByBlockNumber(_ rpc.BlockNumber) hexutil.Uint

GetUncleCountByBlockNumber returns the number of uncles in the block identified by number. Always zero.

func (*EthAPI) MaxPriorityFeePerGas

func (e *EthAPI) MaxPriorityFeePerGas() (*hexutil.Big, error)

MaxPriorityFeePerGas returns a suggestion for a gas tip cap for dynamic fee transactions.

func (*EthAPI) ProtocolVersion

func (e *EthAPI) ProtocolVersion() hexutil.Uint

ProtocolVersion returns the supported Ethereum protocol version.

func (*EthAPI) Resend

func (e *EthAPI) Resend(_ context.Context,
	args evm.JsonTxArgs,
	gasPrice *hexutil.Big,
	gasLimit *hexutil.Uint64,
) (common.Hash, error)

Resend accepts an existing transaction and a new gas price and limit. It will remove the given transaction from the pool and reinsert it with the new gas price and limit.

func (*EthAPI) SendRawTransaction

func (e *EthAPI) SendRawTransaction(data hexutil.Bytes) (common.Hash, error)

SendRawTransaction send a raw Ethereum transaction.

func (*EthAPI) SendTransaction

func (e *EthAPI) SendTransaction(
	txArgs evm.JsonTxArgs,
) (common.Hash, error)

SendTransaction sends an Ethereum transaction.

func (*EthAPI) SignTypedData

func (e *EthAPI) SignTypedData(
	address common.Address, typedData apitypes.TypedData,
) (hexutil.Bytes, error)

SignTypedData signs EIP-712 conformant typed data

func (*EthAPI) Syncing

func (e *EthAPI) Syncing() (interface{}, error)

Syncing returns false in case the node is currently not syncing with the network. It can be up to date or has not yet received the latest block headers from its pears. In case it is synchronizing:

- startingBlock: block number this node started to synchronize from - currentBlock: block number this node is currently importing - highestBlock: block number of the highest block header this node has received from peers - pulledStates: number of state entries processed until now - knownStates: number of known state entries that still need to be pulled

type IEthAPI

type IEthAPI interface {
	// Getting Blocks
	//
	// Retrieves information from a particular block in the blockchain.
	BlockNumber() (hexutil.Uint64, error)
	GetBlockByNumber(ethBlockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)
	GetBlockByHash(hash common.Hash, fullTx bool) (map[string]interface{}, error)
	GetBlockTransactionCountByHash(hash common.Hash) *hexutil.Uint
	GetBlockTransactionCountByNumber(blockNum rpc.BlockNumber) *hexutil.Uint

	// Reading Transactions
	//
	// Retrieves information on the state data for addresses regardless of whether
	// it is a user or a smart contract.
	GetTransactionByHash(hash common.Hash) (*rpc.EthTxJsonRPC, error)
	GetTransactionCount(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error)
	GetTransactionReceipt(hash common.Hash) (map[string]interface{}, error)
	GetTransactionByBlockHashAndIndex(hash common.Hash, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)
	GetTransactionByBlockNumberAndIndex(blockNum rpc.BlockNumber, idx hexutil.Uint) (*rpc.EthTxJsonRPC, error)

	// Writing Transactions
	//
	// Allows developers to both send ETH from one address to another, write data
	// on-chain, and interact with smart contracts.
	SendRawTransaction(data hexutil.Bytes) (common.Hash, error)
	SendTransaction(args evm.JsonTxArgs) (common.Hash, error)

	// Account Information
	//
	// Returns information regarding an address's stored on-chain data.
	Accounts() ([]common.Address, error)
	GetBalance(
		address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
	) (*hexutil.Big, error)
	GetStorageAt(
		address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash,
	) (hexutil.Bytes, error)
	GetCode(
		address common.Address, blockNrOrHash rpc.BlockNumberOrHash,
	) (hexutil.Bytes, error)
	GetProof(
		address common.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash,
	) (*rpc.AccountResult, error)

	// EVM/Smart Contract Execution
	//
	// Allows developers to read data from the blockchain which includes executing
	// smart contracts. However, no data is published to the Ethereum network.
	Call(
		args evm.JsonTxArgs, blockNrOrHash rpc.BlockNumberOrHash, _ *rpc.StateOverride,
	) (hexutil.Bytes, error)

	// Chain Information
	//
	// Returns information on the Ethereum network and internal settings.
	ProtocolVersion() hexutil.Uint
	GasPrice() (*hexutil.Big, error)
	EstimateGas(
		args evm.JsonTxArgs, blockNrOptional *rpc.BlockNumber,
	) (hexutil.Uint64, error)
	FeeHistory(
		blockCount gethrpc.DecimalOrHex, lastBlock gethrpc.BlockNumber, rewardPercentiles []float64,
	) (*rpc.FeeHistoryResult, error)
	MaxPriorityFeePerGas() (*hexutil.Big, error)
	ChainId() (*hexutil.Big, error)

	// Getting Uncles
	//
	// Returns information on uncle blocks are which are network rejected blocks
	// and replaced by a canonical block instead.
	GetUncleByBlockHashAndIndex(
		hash common.Hash, idx hexutil.Uint,
	) map[string]interface{}
	GetUncleByBlockNumberAndIndex(
		number, idx hexutil.Uint,
	) map[string]interface{}
	GetUncleCountByBlockHash(hash common.Hash) hexutil.Uint
	GetUncleCountByBlockNumber(blockNum rpc.BlockNumber) hexutil.Uint

	// Other
	Syncing() (interface{}, error)
	GetTransactionLogs(txHash common.Hash) ([]*gethcore.Log, error)
	SignTypedData(
		address common.Address, typedData apitypes.TypedData,
	) (hexutil.Bytes, error)
	FillTransaction(
		args evm.JsonTxArgs,
	) (*rpc.SignTransactionResult, error)
	Resend(
		ctx context.Context, args evm.JsonTxArgs,
		gasPrice *hexutil.Big, gasLimit *hexutil.Uint64,
	) (common.Hash, error)
	GetPendingTransactions() ([]*rpc.EthTxJsonRPC, error)
}

Ethereum API: Allows connection to a full node of the Nibiru blockchain network via Nibiru EVM. Developers can interact with on-chain EVM data and send different types of transactions to the network by utilizing the endpoints provided by the API. The API follows a JSON-RPC standard. If not otherwise specified, the interface is derived from the Alchemy Ethereum API: https://docs.alchemy.com/alchemy/apis/ethereum

type NetAPI

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

NetAPI is the eth_ prefixed set of APIs in the Web3 JSON-RPC spec.

func NewImplNetAPI

func NewImplNetAPI(clientCtx client.Context) *NetAPI

NewImplNetAPI creates an instance of the public Net Web3 API.

func (*NetAPI) Listening

func (s *NetAPI) Listening() bool

Listening returns if client is actively listening for network connections.

func (*NetAPI) PeerCount

func (s *NetAPI) PeerCount() int

PeerCount returns the number of peers currently connected to the client.

func (*NetAPI) Version

func (s *NetAPI) Version() string

Version returns the current ethereum protocol version.

type SubscriptionNotification

type SubscriptionNotification struct {
	Jsonrpc string              `json:"jsonrpc"`
	Method  string              `json:"method"`
	Params  *SubscriptionResult `json:"params"`
}

type SubscriptionResponseJSON

type SubscriptionResponseJSON struct {
	Jsonrpc string      `json:"jsonrpc"`
	Result  interface{} `json:"result"`
	ID      float64     `json:"id"`
}

type SubscriptionResult

type SubscriptionResult struct {
	Subscription gethrpc.ID  `json:"subscription"`
	Result       interface{} `json:"result"`
}

type TxPoolAPI

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

TxPoolAPI offers and API for the transaction pool. It only operates on data that is non-confidential.

func NewImplTxPoolAPI

func NewImplTxPoolAPI(logger log.Logger) *TxPoolAPI

NewImplTxPoolAPI creates a new tx pool service that gives information about the transaction pool.

func (*TxPoolAPI) Content

func (api *TxPoolAPI) Content() (
	map[string]map[string]map[string]*rpc.EthTxJsonRPC, error,
)

Content returns the transactions contained within the transaction pool

func (*TxPoolAPI) Inspect

func (api *TxPoolAPI) Inspect() (map[string]map[string]map[string]string, error)

Inspect returns the content of the transaction pool and flattens it into an

func (*TxPoolAPI) Status

func (api *TxPoolAPI) Status() map[string]hexutil.Uint

Status returns the number of pending and queued transaction in the pool.

type WebsocketsServer

type WebsocketsServer interface {
	Start()
}

func NewWebsocketsServer

func NewWebsocketsServer(
	clientCtx client.Context,
	logger log.Logger,
	tmWSClient *rpcclient.WSClient,
	cfg *config.Config,
) WebsocketsServer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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