Documentation
¶
Index ¶
- Constants
- Variables
- func DialWithRetry(ctx context.Context, logger aggkitcommon.Logger, ...) (aggkittypes.EthClienter, error)
- func NewRPCClient(ctx context.Context, logger aggkitcommon.Logger, ...) (aggkittypes.EthClienter, error)
- func NewRPCClientModeOp(ctx context.Context, logger aggkitcommon.Logger, ...) (aggkittypes.EthClienter, error)
- func RetrieveBlockHeaders(ctx context.Context, log aggkitcommon.Logger, ...) ([]*aggkittypes.BlockHeader, error)
- func RetrieveBlockHeadersBatch(ctx context.Context, log aggkitcommon.Logger, ...) ([]*aggkittypes.BlockHeader, error)
- func RetrieveBlockHeadersLegacy(ctx context.Context, log aggkitcommon.Logger, ...) ([]*aggkittypes.BlockHeader, error)
- func TryParseError(err error) (error, bool)
- type DefaultEthClient
- func (c *DefaultEthClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
- func (c *DefaultEthClient) Call(result any, method string, args ...any) error
- func (c *DefaultEthClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
- func (c *DefaultEthClient) CustomBlockNumber(ctx context.Context, number aggkittypes.BlockName) (uint64, error)
- func (c *DefaultEthClient) CustomHeaderByNumber(ctx context.Context, number *aggkittypes.BlockNumberFinality) (*aggkittypes.BlockHeader, error)
- type OpNodeClienter
- type RPCOpNodeDecorator
Constants ¶
const (
ExtraParamFieldName = "OpNodeURL"
)
Variables ¶
var ( // ErrGasRequiredExceedsAllowance gas required exceeds the allowance ErrGasRequiredExceedsAllowance = errors.New("gas required exceeds allowance") // ErrContentLengthTooLarge content length is too large ErrContentLengthTooLarge = errors.New("content length too large") // ErrTimestampMustBeInsideRange Timestamp must be inside range ErrTimestampMustBeInsideRange = errors.New("timestamp must be inside range") // ErrInsufficientAllowance insufficient allowance ErrInsufficientAllowance = errors.New("insufficient allowance") // ErrBothGasPriceAndMaxFeeGasAreSpecified both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified ErrBothGasPriceAndMaxFeeGasAreSpecified = errors.New( "both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified", ) // ErrMaxFeeGasAreSpecifiedButLondonNotActive maxFeePerGas or maxPriorityFeePerGas // specified but london fork is not active yet ErrMaxFeeGasAreSpecifiedButLondonNotActive = errors.New( "maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet", ) // ErrNoSigner no signer to authorize the transaction with ErrNoSigner = errors.New("no signer to authorize the transaction with") // ErrMissingTrieNode means that a node is missing on the trie ErrMissingTrieNode = errors.New("missing trie node") // ErrNotFound is used when the object is not found ErrNotFound = errors.New("not found") // ErrPrivateKeyNotFound used when the provided sender does not have a private key registered to be used ErrPrivateKeyNotFound = errors.New("can't find sender private key to sign tx") )
var (
ErrNotImplemented = errors.New("not implemented")
)
Functions ¶
func DialWithRetry ¶
func DialWithRetry(ctx context.Context, logger aggkitcommon.Logger, cfg *ethermanconfig.RPCClientConfig) (aggkittypes.EthClienter, error)
DialWithRetry attempts to connect to an Ethereum client with retries and exponential backoff. It returns an EthClienter on success or an error if all attempts fail.
func NewRPCClient ¶ added in v0.1.0
func NewRPCClient(ctx context.Context, logger aggkitcommon.Logger, cfg ethermanconfig.RPCClientConfig) (aggkittypes.EthClienter, error)
NewRPCClient creates a new RPC client based on the provided configuration. It supports both basic RPC mode and OPNode mode. In basic mode, it simply creates a client with the given URL. In OPNode mode, it creates a client that uses the OPNode client to get the finalized block.
func NewRPCClientModeOp ¶ added in v0.1.0
func NewRPCClientModeOp(ctx context.Context, logger aggkitcommon.Logger, cfg ethermanconfig.RPCClientConfig) (aggkittypes.EthClienter, error)
NewRPCClientModeOp creates a new RPC client that uses the OPNode client to get the finalized block
func RetrieveBlockHeaders ¶ added in v0.8.0
func RetrieveBlockHeaders(ctx context.Context, log aggkitcommon.Logger, ethClient aggkittypes.BaseEthereumClienter, rpcClient aggkittypes.RPCClienter, blockNumbers []uint64, maxConcurrency int) ([]*aggkittypes.BlockHeader, error)
RetrieveBlockHeaders retrieves block headers for the given block numbers using batch requests if rpcClient is provided
func RetrieveBlockHeadersBatch ¶ added in v0.8.0
func RetrieveBlockHeadersBatch(ctx context.Context, log aggkitcommon.Logger, rpcClient aggkittypes.RPCClienter, blockNumbers []uint64, maxConcurrency int) ([]*aggkittypes.BlockHeader, error)
RetrieveBlockHeaders retrieves block headers for the given block numbers using batch requests with concurrency control
func RetrieveBlockHeadersLegacy ¶ added in v0.8.0
func RetrieveBlockHeadersLegacy(ctx context.Context, log aggkitcommon.Logger, ethClient aggkittypes.BaseEthereumClienter, blockNumbers []uint64, maxConcurrency int) ([]*aggkittypes.BlockHeader, error)
RetrieveBlockHeadersLegacy retrieves block headers for the given block numbers using individual requests this is used in simulated environments where batch requests are not supported
func TryParseError ¶
Types ¶
type DefaultEthClient ¶
type DefaultEthClient struct {
aggkittypes.EthereumClienter
aggkittypes.RPCClienter
// If true, the block Hash is getted from JSON RPC
// if false, the block Hash is getted from go-ethereum RLP hashing of header
HashFromJSON bool
// contains filtered or unexported fields
}
func NewDefaultEthClient ¶
func NewDefaultEthClient(client aggkittypes.EthereumClienter, rpcClient aggkittypes.RPCClienter, cfg *ethermanconfig.RPCClientConfig, ) *DefaultEthClient
This function is for legacy code that doesn't use logger
func NewDefaultEthClientWithLogger ¶
func NewDefaultEthClientWithLogger( logger aggkitcommon.Logger, client aggkittypes.EthereumClienter, rpcClient aggkittypes.RPCClienter, cfg *ethermanconfig.RPCClientConfig, ) *DefaultEthClient
func (*DefaultEthClient) BatchCallContext ¶
func (*DefaultEthClient) Call ¶
func (c *DefaultEthClient) Call(result any, method string, args ...any) error
func (*DefaultEthClient) CallContext ¶
func (c *DefaultEthClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
func (*DefaultEthClient) CustomBlockNumber ¶
func (c *DefaultEthClient) CustomBlockNumber(ctx context.Context, number aggkittypes.BlockName) (uint64, error)
func (*DefaultEthClient) CustomHeaderByNumber ¶
func (c *DefaultEthClient) CustomHeaderByNumber(ctx context.Context, number *aggkittypes.BlockNumberFinality) (*aggkittypes.BlockHeader, error)
type OpNodeClienter ¶ added in v0.1.0
type RPCOpNodeDecorator ¶ added in v0.1.0
type RPCOpNodeDecorator struct {
aggkittypes.EthClienter
OpNodeClient OpNodeClienter
}
RPCOpNodeDecorator is a decorator for the ethclient.Client that intercepts calls to the HeaderByNumber method and if the block number is the FinalizedBlockNumber, it will ask the OpNodeClient for the finalized block instead of asking the ethclient.Client
func NewRPCOpNodeDecorator ¶ added in v0.1.0
func NewRPCOpNodeDecorator(client aggkittypes.EthClienter, opNodeClient OpNodeClienter) *RPCOpNodeDecorator