Skip to content

Commit 224b47e

Browse files
committed
refactor: add fn to get chain client
1 parent 3573ba5 commit 224b47e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

universalClient/chains/chains.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,19 @@ func (c *Chains) StopAll() {
349349
c.chainConfigs = make(map[string]*uregistrytypes.ChainConfig)
350350
}
351351

352+
// GetClient returns the chain client for the specified chain ID
353+
func (c *Chains) GetClient(chainID string) (common.ChainClient, error) {
354+
c.chainsMu.RLock()
355+
defer c.chainsMu.RUnlock()
356+
357+
client, exists := c.chains[chainID]
358+
if !exists {
359+
return nil, fmt.Errorf("chain client not found for chain %s", chainID)
360+
}
361+
362+
return client, nil
363+
}
364+
352365
// getChainDB returns a database instance for a specific chain
353366
func (c *Chains) getChainDB(chainID string) (*db.DB, error) {
354367
// Create database file directly named after the chain's CAIP-2 format

0 commit comments

Comments
 (0)