service

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultGasLimit is the cosmetic gas limit the facade reports (eth_estimateGas,
	// block gasLimit, tx gas, synthetic block gasUsed). The facade executes
	// transfers on Canton rather than an EVM, so gas is never metered — and the
	// gas price is fixed at 0 — making this value purely informational for wallets.
	DefaultGasLimit = 21_000
)

Variables

This section is empty.

Functions

func RegisterRoutes

func RegisterRoutes(r chi.Router, svc Service, rpcRequestTimeout time.Duration, logger *zap.Logger)

RegisterRoutes registers the Ethereum JSON-RPC endpoint on the given chi router.

Types

type EthAPI

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

EthAPI implements the eth_* JSON-RPC namespace. It is a thin adapter: each method translates the RPC signature to a Service call, dropping unused parameters (blockNrOrHash, overrides) that this facade does not need.

func (*EthAPI) BlockNumber

func (api *EthAPI) BlockNumber(ctx context.Context) (hexutil.Uint64, error)

func (*EthAPI) Call

func (api *EthAPI) Call(
	ctx context.Context,
	args *ethrpc.CallArgs,
	_ ethrpc.BlockNumberOrHash,
	_ *map[common.Address]any,
) (hexutil.Bytes, error)

func (*EthAPI) ChainId

func (api *EthAPI) ChainId(ctx context.Context) hexutil.Uint64

func (*EthAPI) EstimateGas

func (api *EthAPI) EstimateGas(ctx context.Context, args *ethrpc.CallArgs, _ *ethrpc.BlockNumberOrHash) (hexutil.Uint64, error)

func (*EthAPI) GasPrice

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

func (*EthAPI) GetBalance

func (api *EthAPI) GetBalance(ctx context.Context, address common.Address, _ ethrpc.BlockNumberOrHash) (*hexutil.Big, error)

func (*EthAPI) GetBlockByHash

func (api *EthAPI) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (*ethrpc.RPCBlock, error)

func (*EthAPI) GetBlockByNumber

func (api *EthAPI) GetBlockByNumber(ctx context.Context, blockNr ethrpc.BlockNumberOrHash, fullTx bool) (*ethrpc.RPCBlock, error)

func (*EthAPI) GetCode

func (api *EthAPI) GetCode(ctx context.Context, address common.Address, _ ethrpc.BlockNumberOrHash) (hexutil.Bytes, error)

func (*EthAPI) GetLogs

func (api *EthAPI) GetLogs(ctx context.Context, query ethrpc.FilterQuery) ([]*types.Log, error)

func (*EthAPI) GetTransactionByHash

func (api *EthAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*ethrpc.RPCTransaction, error)

func (*EthAPI) GetTransactionCount

func (api *EthAPI) GetTransactionCount(ctx context.Context, address common.Address, _ ethrpc.BlockNumberOrHash) (hexutil.Uint64, error)

func (*EthAPI) GetTransactionReceipt

func (api *EthAPI) GetTransactionReceipt(ctx context.Context, hash common.Hash) (*ethrpc.RPCReceipt, error)

func (*EthAPI) MaxPriorityFeePerGas

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

func (*EthAPI) SendRawTransaction

func (api *EthAPI) SendRawTransaction(ctx context.Context, data hexutil.Bytes) (common.Hash, error)

func (*EthAPI) Syncing

func (api *EthAPI) Syncing(ctx context.Context) (any, error)

type HTTP

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

HTTP handles Ethereum JSON-RPC requests over HTTP.

type NetAPI

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

NetAPI implements the net_* JSON-RPC namespace.

func NewNetAPI

func NewNetAPI(svc Service) *NetAPI

func (*NetAPI) Listening

func (*NetAPI) Listening() bool

func (*NetAPI) PeerCount

func (*NetAPI) PeerCount() hexutil.Uint

func (*NetAPI) Version

func (api *NetAPI) Version() string

type Service

type Service interface {
	ChainID(ctx context.Context) hexutil.Uint64
	BlockNumber(ctx context.Context) (hexutil.Uint64, error)
	GasPrice(ctx context.Context) (*hexutil.Big, error)
	MaxPriorityFeePerGas(ctx context.Context) (*hexutil.Big, error)
	EstimateGas(ctx context.Context, args *ethrpc.CallArgs) (hexutil.Uint64, error)
	GetBalance(ctx context.Context, address common.Address) (*hexutil.Big, error)
	GetTransactionCount(ctx context.Context, address common.Address) (hexutil.Uint64, error)
	GetCode(ctx context.Context, address common.Address) (hexutil.Bytes, error)
	Syncing(ctx context.Context) bool
	SendRawTransaction(ctx context.Context, data hexutil.Bytes) (common.Hash, error)
	GetTransactionReceipt(ctx context.Context, hash common.Hash) (*ethrpc.RPCReceipt, error)
	GetTransactionByHash(ctx context.Context, hash common.Hash) (*ethrpc.RPCTransaction, error)
	Call(ctx context.Context, args *ethrpc.CallArgs) (hexutil.Bytes, error)
	GetLogs(ctx context.Context, query ethrpc.FilterQuery) ([]*types.Log, error)
	GetBlockByNumber(ctx context.Context, blockNr ethrpc.BlockNumberOrHash, fullTx bool) (*ethrpc.RPCBlock, error)
	GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (*ethrpc.RPCBlock, error)
}

Service defines the Ethereum JSON-RPC business logic interface.

func NewLog

func NewLog(svc Service, logger *zap.Logger) Service

NewLog creates a logging decorator for Service. Returns svc unchanged if logger is nil.

func NewService

func NewService(
	cfg *ethrpc.Config,
	evmStore Store,
	tokenSvc TokenService,
) Service

NewService creates a new ethService.

type Store

type Store interface {
	// Read-only queries used by JSON-RPC handlers.
	GetLatestEvmBlockNumber(ctx context.Context) (uint64, error)
	GetEvmTransactionCount(ctx context.Context, fromAddress string) (uint64, error)
	GetEvmTransaction(ctx context.Context, txHash []byte) (*ethrpc.EvmTransaction, error)
	GetEvmLogsByTxHash(ctx context.Context, txHash []byte) ([]*ethrpc.EvmLog, error)
	GetEvmLogs(ctx context.Context, address []byte, topic0 []byte, fromBlock, toBlock uint64) ([]*ethrpc.EvmLog, error)
	GetBlockNumberByHash(ctx context.Context, blockHash []byte) (uint64, error)

	// InsertMempoolEntry records a new transfer intent with status=pending.
	// SendRawTransaction returns immediately after this insert; the submitter
	// worker drives pending → completed/failed asynchronously, and the miner
	// then seals the entry into a synthetic EVM block.
	InsertMempoolEntry(ctx context.Context, entry *ethrpc.MempoolEntry) error
}

Store is the narrow data-access interface consumed by the EthRPC service.

type TokenService

type TokenService interface {
	ERC20(address common.Address) (token.ERC20, error)
	Native() token.Native
}

TokenService is the narrow token-service interface consumed by the EthRPC service.

type Web3API

type Web3API struct{}

Web3API implements the web3_* JSON-RPC namespace.

func NewWeb3API

func NewWeb3API() *Web3API

func (*Web3API) ClientVersion

func (*Web3API) ClientVersion() string

func (*Web3API) Sha3

func (*Web3API) Sha3(input hexutil.Bytes) hexutil.Bytes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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