Documentation
¶
Overview ¶
Package chainManager provides blockchain connection management for multichain operations. This package manages connections to multiple Ethereum-compatible blockchains, providing a unified interface for interacting with different Chains in the EigenLayer multichain ecosystem.
Index ¶
- Variables
- type Chain
- type ChainConfig
- type ChainManager
- type EthClientInterface
- type IChainManager
- type MockEthClientInterface
- func (_m *MockEthClientInterface) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (_m *MockEthClientInterface) BlockNumber(ctx context.Context) (uint64, error)
- func (_m *MockEthClientInterface) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (_m *MockEthClientInterface) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
- func (_m *MockEthClientInterface) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
- func (_m *MockEthClientInterface) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
- func (_m *MockEthClientInterface) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (_m *MockEthClientInterface) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (_m *MockEthClientInterface) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (_m *MockEthClientInterface) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (_m *MockEthClientInterface) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (_m *MockEthClientInterface) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (_m *MockEthClientInterface) SuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (_m *MockEthClientInterface) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- type MockIChainManager
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChainNotFound is returned when a requested chain ID is not found in the manager ErrChainNotFound = errors.New("chain not found") )
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct { // RPCClient is the active client connection for this chain RPCClient EthClientInterface // contains filtered or unexported fields }
Chain represents an active connection to a blockchain. It contains both the configuration and the active RPC client connection.
type ChainConfig ¶
type ChainConfig struct { // ChainID is the unique identifier for the blockchain network ChainID uint64 // RPCUrl is the URL endpoint for connecting to the blockchain RPC RPCUrl string }
ChainConfig holds the configuration for connecting to a blockchain. This includes the chain ID and the RPC URL for establishing connections.
type ChainManager ¶
ChainManager implements IChainManager and manages multiple blockchain connections. It maintains a registry of active Chains indexed by their chain IDs.
func NewChainManager ¶
func NewChainManager() *ChainManager
NewChainManager creates a new ChainManager instance. The manager is initialized with an empty chain registry.
Returns:
- *ChainManager: A new chain manager instance
func (*ChainManager) AddChain ¶
func (cm *ChainManager) AddChain(cfg *ChainConfig) error
AddChain adds a new blockchain connection to the manager. This method establishes a connection to the specified RPC URL and stores the resulting chain connection for future use.
Parameters:
- cfg: The chain configuration containing chain ID and RPC URL
Returns:
- error: An error if the chain already exists or connection fails
func (*ChainManager) GetChainForId ¶
func (cm *ChainManager) GetChainForId(chainId uint64) (*Chain, error)
GetChainForId retrieves a chain connection by its chain ID. This method looks up an existing chain connection in the manager's registry.
Parameters:
- chainId: The chain ID to look up
Returns:
- *Chain: The chain connection if found
- error: ErrChainNotFound if the chain ID is not registered
type EthClientInterface ¶ added in v0.0.10
type EthClientInterface interface { // Block operations BlockNumber(ctx context.Context) (uint64, error) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) // Gas operations EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error) SuggestGasTipCap(ctx context.Context) (*big.Int, error) // Transaction operations TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) // Contract binding support (required for go-ethereum's bind package) bind.ContractBackend bind.ContractCaller bind.ContractTransactor bind.ContractFilterer bind.DeployBackend }
EthClientInterface defines the methods needed for blockchain operations. This interface allows for mocking and testing while maintaining compatibility with ethclient.Client and the go-ethereum bind package.
type IChainManager ¶
type IChainManager interface { // AddChain adds a new blockchain connection to the manager AddChain(cfg *ChainConfig) error // GetChainForId retrieves a chain connection by its chain ID GetChainForId(chainId uint64) (*Chain, error) }
IChainManager defines the interface for managing blockchain connections. Implementations provide the ability to add new Chains and retrieve existing chain connections by their chain ID.
type MockEthClientInterface ¶ added in v0.0.10
MockEthClientInterface is an autogenerated mock type for the EthClientInterface type
func NewMockEthClientInterface ¶ added in v0.0.10
func NewMockEthClientInterface(t interface { mock.TestingT Cleanup(func()) }) *MockEthClientInterface
NewMockEthClientInterface creates a new instance of MockEthClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockEthClientInterface) BlockByNumber ¶ added in v0.0.10
func (_m *MockEthClientInterface) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
BlockByNumber provides a mock function with given fields: ctx, number
func (*MockEthClientInterface) BlockNumber ¶ added in v0.0.10
func (_m *MockEthClientInterface) BlockNumber(ctx context.Context) (uint64, error)
BlockNumber provides a mock function with given fields: ctx
func (*MockEthClientInterface) CallContract ¶ added in v0.0.10
func (_m *MockEthClientInterface) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract provides a mock function with given fields: ctx, call, blockNumber
func (*MockEthClientInterface) CodeAt ¶ added in v0.0.10
func (_m *MockEthClientInterface) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
CodeAt provides a mock function with given fields: ctx, contract, blockNumber
func (*MockEthClientInterface) EstimateGas ¶ added in v0.0.10
func (_m *MockEthClientInterface) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
EstimateGas provides a mock function with given fields: ctx, msg
func (*MockEthClientInterface) FilterLogs ¶ added in v0.0.10
func (_m *MockEthClientInterface) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
FilterLogs provides a mock function with given fields: ctx, q
func (*MockEthClientInterface) HeaderByNumber ¶ added in v0.0.10
func (_m *MockEthClientInterface) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
HeaderByNumber provides a mock function with given fields: ctx, number
func (*MockEthClientInterface) PendingCodeAt ¶ added in v0.0.10
func (_m *MockEthClientInterface) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
PendingCodeAt provides a mock function with given fields: ctx, account
func (*MockEthClientInterface) PendingNonceAt ¶ added in v0.0.10
func (_m *MockEthClientInterface) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
PendingNonceAt provides a mock function with given fields: ctx, account
func (*MockEthClientInterface) SendTransaction ¶ added in v0.0.10
func (_m *MockEthClientInterface) SendTransaction(ctx context.Context, tx *types.Transaction) error
SendTransaction provides a mock function with given fields: ctx, tx
func (*MockEthClientInterface) SubscribeFilterLogs ¶ added in v0.0.10
func (_m *MockEthClientInterface) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs provides a mock function with given fields: ctx, q, ch
func (*MockEthClientInterface) SuggestGasPrice ¶ added in v0.0.10
SuggestGasPrice provides a mock function with given fields: ctx
func (*MockEthClientInterface) SuggestGasTipCap ¶ added in v0.0.10
SuggestGasTipCap provides a mock function with given fields: ctx
func (*MockEthClientInterface) TransactionReceipt ¶ added in v0.0.10
func (_m *MockEthClientInterface) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionReceipt provides a mock function with given fields: ctx, txHash
type MockIChainManager ¶ added in v0.0.10
MockIChainManager is an autogenerated mock type for the IChainManager type
func NewMockIChainManager ¶ added in v0.0.10
func NewMockIChainManager(t interface { mock.TestingT Cleanup(func()) }) *MockIChainManager
NewMockIChainManager creates a new instance of MockIChainManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockIChainManager) AddChain ¶ added in v0.0.10
func (_m *MockIChainManager) AddChain(cfg *ChainConfig) error
AddChain provides a mock function with given fields: cfg
func (*MockIChainManager) GetChainForId ¶ added in v0.0.10
func (_m *MockIChainManager) GetChainForId(chainId uint64) (*Chain, error)
GetChainForId provides a mock function with given fields: chainId