rpcapi

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecAuthRPC

func ExecAuthRPC[R any](ctx context.Context, w *Services, cfg *ExecCfg, method string, args ...any) (*R, error)

func UnauthenticatedTenRPCCall

func UnauthenticatedTenRPCCall[R any](ctx context.Context, w *Services, cfg *CacheCfg, method string, args ...any) (*R, error)

Types

type AccountResult

type AccountResult struct {
	Address      gethcommon.Address `json:"address"`
	AccountProof []string           `json:"accountProof"`
	Balance      *hexutil.Big       `json:"balance"`
	CodeHash     gethcommon.Hash    `json:"codeHash"`
	Nonce        hexutil.Uint64     `json:"nonce"`
	StorageHash  gethcommon.Hash    `json:"storageHash"`
	StorageProof []StorageResult    `json:"storageProof"`
}

Result structs for GetProof

type BlockChainAPI

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

func NewBlockChainAPI

func NewBlockChainAPI(we *Services) *BlockChainAPI

func (*BlockChainAPI) BlockNumber

func (api *BlockChainAPI) BlockNumber() hexutil.Uint64

func (*BlockChainAPI) Call

func (api *BlockChainAPI) Call(ctx context.Context, args gethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, blockOverrides *BlockOverrides) (hexutil.Bytes, error)

func (*BlockChainAPI) ChainId

func (api *BlockChainAPI) ChainId() *hexutil.Big

func (*BlockChainAPI) CreateAccessList

func (s *BlockChainAPI) CreateAccessList(ctx context.Context, args gethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (*accessListResult, error)

func (*BlockChainAPI) EstimateGas

func (api *BlockChainAPI) EstimateGas(ctx context.Context, args gethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *StateOverride) (hexutil.Uint64, error)

func (*BlockChainAPI) GetBalance

func (api *BlockChainAPI) GetBalance(ctx context.Context, address gethcommon.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error)

func (*BlockChainAPI) GetBlockByHash

func (api *BlockChainAPI) GetBlockByHash(ctx context.Context, hash gethcommon.Hash, fullTx bool) (map[string]interface{}, error)

func (*BlockChainAPI) GetBlockByNumber

func (api *BlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error)

func (*BlockChainAPI) GetBlockReceipts

func (s *BlockChainAPI) GetBlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]map[string]interface{}, error)

func (*BlockChainAPI) GetCode

func (api *BlockChainAPI) GetCode(ctx context.Context, address gethcommon.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

func (*BlockChainAPI) GetHeaderByHash

func (api *BlockChainAPI) GetHeaderByHash(ctx context.Context, hash gethcommon.Hash) map[string]interface{}

func (*BlockChainAPI) GetHeaderByNumber

func (api *BlockChainAPI) GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (map[string]interface{}, error)

func (*BlockChainAPI) GetProof

func (s *BlockChainAPI) GetProof(ctx context.Context, address gethcommon.Address, storageKeys []string, blockNrOrHash rpc.BlockNumberOrHash) (*AccountResult, error)

func (*BlockChainAPI) GetStorageAt

func (api *BlockChainAPI) GetStorageAt(ctx context.Context, address gethcommon.Address, params string, _ rpc.BlockNumberOrHash) (hexutil.Bytes, error)

GetStorageAt is not compatible with ETH RPC tooling. Ten network does not getStorageAt because it would violate the privacy guarantees of the network.

However, we can repurpose this method to be able to route Ten-specific requests through from an ETH RPC client. We call these requests Custom Queries.

This method signature matches eth_getStorageAt, but we use the address field to specify the custom query method, the hex-encoded position field to specify the parameters json, and nil for the block number.

In future, we can support both CustomQueries and some debug version of eth_getStorageAt if needed.

type BlockOverrides

type BlockOverrides struct {
	Number     *hexutil.Big
	Difficulty *hexutil.Big
	Time       *hexutil.Uint64
	GasLimit   *hexutil.Uint64
	Coinbase   *gethcommon.Address
	Random     *gethcommon.Hash
	BaseFee    *hexutil.Big
}

type CacheCfg

type CacheCfg struct {
	CacheType        CacheStrategy
	CacheTypeDynamic func() CacheStrategy
}

type CacheStrategy

type CacheStrategy uint8
const (
	NoCache     CacheStrategy = iota
	LatestBatch CacheStrategy = iota
	LongLiving  CacheStrategy = iota
)

type CircularBuffer

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

CircularBuffer is a data structure that uses a single, fixed-size buffer as if it was connected end-to-end.

func NewCircularBuffer

func NewCircularBuffer(size int) *CircularBuffer

NewCircularBuffer initializes a new CircularBuffer of the given size.

func (*CircularBuffer) Contains

func (cb *CircularBuffer) Contains(key LogKey) bool

Contains checks if the given LogKey exists in the buffer

func (*CircularBuffer) Push

func (cb *CircularBuffer) Push(key LogKey)

Push adds a new LogKey to the end of the buffer. If the buffer is full, it overwrites the oldest data with the new LogKey.

type DebugAPI

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

func NewDebugAPI

func NewDebugAPI(we *Services) *DebugAPI

func (*DebugAPI) ChaindbCompact

func (api *DebugAPI) ChaindbCompact() error

func (*DebugAPI) ChaindbProperty

func (api *DebugAPI) ChaindbProperty(property string) (string, error)

func (*DebugAPI) EventLogRelevancy

func (api *DebugAPI) EventLogRelevancy(_ context.Context, _ common.Hash) (interface{}, error)

EventLogRelevancy - specific to Ten - todo

func (*DebugAPI) GetRawBlock

func (api *DebugAPI) GetRawBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

func (*DebugAPI) GetRawHeader

func (api *DebugAPI) GetRawHeader(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)

func (*DebugAPI) GetRawReceipts

func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]hexutil.Bytes, error)

func (*DebugAPI) GetRawTransaction

func (s *DebugAPI) GetRawTransaction(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

func (*DebugAPI) PrintBlock

func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error)

func (*DebugAPI) SetHead

func (api *DebugAPI) SetHead(number hexutil.Uint64)

type EthereumAPI

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

func NewEthereumAPI

func NewEthereumAPI(we *Services,
) *EthereumAPI

func (*EthereumAPI) FeeHistory

func (api *EthereumAPI) FeeHistory(ctx context.Context, blockCount math.HexOrDecimal64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*FeeHistoryResult, error)

func (*EthereumAPI) GasPrice

func (api *EthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error)

func (*EthereumAPI) MaxPriorityFeePerGas

func (api *EthereumAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error)

func (*EthereumAPI) Syncing

func (api *EthereumAPI) Syncing() (interface{}, error)

type ExecCfg

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

type FeeHistoryResult

type FeeHistoryResult struct {
	OldestBlock  *hexutil.Big     `json:"oldestBlock"`
	Reward       [][]*hexutil.Big `json:"reward,omitempty"`
	BaseFee      []*hexutil.Big   `json:"baseFeePerGas,omitempty"`
	GasUsedRatio []float64        `json:"gasUsedRatio"`
}

type FilterAPI

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

func NewFilterAPI

func NewFilterAPI(we *Services) *FilterAPI

func (*FilterAPI) GetFilterChanges

func (api *FilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error)

func (*FilterAPI) GetFilterLogs

func (api *FilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Log, error)

func (*FilterAPI) GetLogs

func (api *FilterAPI) GetLogs(ctx context.Context, crit common.FilterCriteria) ([]*types.Log, error)

func (*FilterAPI) Logs

func (*FilterAPI) NewBlockFilter

func (api *FilterAPI) NewBlockFilter() rpc.ID

func (*FilterAPI) NewFilter

func (api *FilterAPI) NewFilter(crit common.FilterCriteria) (rpc.ID, error)

func (*FilterAPI) NewHeads

func (api *FilterAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error)

func (*FilterAPI) NewPendingTransactionFilter

func (api *FilterAPI) NewPendingTransactionFilter(_ *bool) rpc.ID

func (*FilterAPI) NewPendingTransactions

func (api *FilterAPI) NewPendingTransactions(ctx context.Context, fullTx *bool) (*rpc.Subscription, error)

func (*FilterAPI) UninstallFilter

func (api *FilterAPI) UninstallFilter(id rpc.ID) bool

type GWAccount

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

type GWUser

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

func (GWUser) GetAllAddresses

func (u GWUser) GetAllAddresses() []*common.Address

type LogKey

type LogKey struct {
	BlockHash common.Hash // Not necessary, but can be helpful in edge case of block reorg.
	TxHash    common.Hash
	Index     uint
}

LogKey uniquely represents a log (consists of BlockHash, TxHash, and Index)

type NetAPI added in v0.24.2

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

func NewNetAPI added in v0.24.2

func NewNetAPI(we *Services) *NetAPI

func (*NetAPI) Version added in v0.24.2

func (api *NetAPI) Version(ctx context.Context) (*string, error)

type NewHeadNotifier

type NewHeadNotifier interface {
	// contains filtered or unexported methods
}

type OverrideAccount

type OverrideAccount struct {
	Nonce     *hexutil.Uint64                      `json:"nonce"`
	Code      *hexutil.Bytes                       `json:"code"`
	Balance   **hexutil.Big                        `json:"balance"`
	State     *map[gethcommon.Hash]gethcommon.Hash `json:"state"`
	StateDiff *map[gethcommon.Hash]gethcommon.Hash `json:"stateDiff"`
}

type Services

type Services struct {
	HostAddrHTTP string // The HTTP address on which the Ten host can be reached
	HostAddrWS   string // The WS address on which the Ten host can be reached
	Storage      storage.Storage

	FileLogger gethlog.Logger

	Cache cache.Cache

	Config          *common.Config
	NewHeadsService *subscriptioncommon.NewHeadsService
	// contains filtered or unexported fields
}

Services handles the various business logic for the api endpoints

func NewServices

func NewServices(hostAddrHTTP string, hostAddrWS string, storage storage.Storage, stopControl *stopcontrol.StopControl, version string, logger gethlog.Logger, config *common.Config) *Services

func (*Services) AddAddressToUser

func (w *Services) AddAddressToUser(userID []byte, address string, signature []byte, signatureType viewingkey.SignatureType) error

AddAddressToUser checks if a message is in correct format and if signature is valid. If all checks pass we save address and signature against userID

func (*Services) DeleteUser

func (w *Services) DeleteUser(userID []byte) error

DeleteUser deletes user and accounts associated with user from the database for given userID

func (*Services) GenerateAndStoreNewUser

func (w *Services) GenerateAndStoreNewUser() ([]byte, error)

GenerateAndStoreNewUser generates new key-pair and userID, stores it in the database and returns hex encoded userID and error

func (*Services) GenerateUserMessageToSign

func (w *Services) GenerateUserMessageToSign(encryptionToken []byte, formatsSlice []string) (string, error)

func (*Services) GetTenNodeHealthStatus

func (w *Services) GetTenNodeHealthStatus() (bool, error)

func (*Services) IsStopping

func (w *Services) IsStopping() bool

IsStopping returns whether the WE is stopping

func (*Services) Logger

func (w *Services) Logger() gethlog.Logger

Logger returns the WE set logger

func (*Services) Stop

func (w *Services) Stop()

func (*Services) UserExists

func (w *Services) UserExists(userID []byte) bool

func (*Services) UserHasAccount

func (w *Services) UserHasAccount(userID []byte, address string) (bool, error)

UserHasAccount checks if provided account exist in the database for given userID

func (*Services) Version

func (w *Services) Version() string

type SignTransactionResult

type SignTransactionResult struct {
	Raw hexutil.Bytes      `json:"raw"`
	Tx  *types.Transaction `json:"tx"`
}

type StateOverride

type StateOverride map[gethcommon.Address]OverrideAccount

type StorageResult

type StorageResult struct {
	Key   string       `json:"key"`
	Value *hexutil.Big `json:"value"`
	Proof []string     `json:"proof"`
}

type TransactionAPI

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

func NewTransactionAPI

func NewTransactionAPI(we *Services) *TransactionAPI

func (*TransactionAPI) FillTransaction

func (*TransactionAPI) GetBlockTransactionCountByHash

func (s *TransactionAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) *hexutil.Uint

func (*TransactionAPI) GetBlockTransactionCountByNumber

func (s *TransactionAPI) GetBlockTransactionCountByNumber(ctx context.Context, blockNr gethrpc.BlockNumber) *hexutil.Uint

func (*TransactionAPI) GetRawTransactionByBlockHashAndIndex

func (s *TransactionAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes

func (*TransactionAPI) GetRawTransactionByBlockNumberAndIndex

func (s *TransactionAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr gethrpc.BlockNumber, index hexutil.Uint) hexutil.Bytes

func (*TransactionAPI) GetRawTransactionByHash

func (s *TransactionAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error)

func (*TransactionAPI) GetTransactionByBlockHashAndIndex

func (s *TransactionAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *rpc.RpcTransaction

func (*TransactionAPI) GetTransactionByBlockNumberAndIndex

func (s *TransactionAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr gethrpc.BlockNumber, index hexutil.Uint) *rpc.RpcTransaction

func (*TransactionAPI) GetTransactionByHash

func (s *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*rpc.RpcTransaction, error)

func (*TransactionAPI) GetTransactionCount

func (s *TransactionAPI) GetTransactionCount(ctx context.Context, address common.Address, blockNrOrHash gethrpc.BlockNumberOrHash) (*hexutil.Uint64, error)

func (*TransactionAPI) GetTransactionReceipt

func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error)

func (*TransactionAPI) PendingTransactions

func (s *TransactionAPI) PendingTransactions() ([]*rpc.RpcTransaction, error)

func (*TransactionAPI) Resend

func (s *TransactionAPI) Resend(ctx context.Context, sendArgs gethapi.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error)

func (*TransactionAPI) SendRawTransaction

func (s *TransactionAPI) SendRawTransaction(ctx context.Context, input hexutil.Bytes) (common.Hash, error)

func (*TransactionAPI) SendTransaction

func (s *TransactionAPI) SendTransaction(ctx context.Context, args gethapi.TransactionArgs) (common.Hash, error)

type TxPoolAPI

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

func NewTxPoolAPI

func NewTxPoolAPI(we *Services) *TxPoolAPI

func (*TxPoolAPI) Content

func (s *TxPoolAPI) Content() map[string]map[string]map[string]*rpc2.RpcTransaction

func (*TxPoolAPI) ContentFrom

func (s *TxPoolAPI) ContentFrom(_ common.Address) map[string]map[string]*rpc2.RpcTransaction

func (*TxPoolAPI) Inspect

func (s *TxPoolAPI) Inspect() map[string]map[string]map[string]string

func (*TxPoolAPI) Status

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

type Web3API added in v0.24.2

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

func NewWeb3API added in v0.24.2

func NewWeb3API(we *Services) *Web3API

func (*Web3API) ClientVersion added in v0.24.2

func (api *Web3API) ClientVersion(_ context.Context) (*string, error)

Jump to

Keyboard shortcuts

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