fix(sdk): silence provider logs in deriveIsmConfig (#4194)
### Description - silences provider logs in deriveIsmConfig, like deriveHookConfig - created HyperlaneReader class for readers to extend in order to reuse `setSmartProviderLogLevel` ### Drive-by changes - none ### Related issues - fixes https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/4061 ### Backward compatibility - yes ### Testing - manual - cidan/relayer-images-bump
parent
5c93f69238
commit
ed63e04c4a
@ -0,0 +1,5 @@ |
||||
--- |
||||
'@hyperlane-xyz/sdk': patch |
||||
--- |
||||
|
||||
Creates HyperlaneReader to re-use dyn provider log level & silences provider logs in deriveIsmConfig like deriveHookConfig. |
@ -0,0 +1,28 @@ |
||||
import { providers } from 'ethers'; |
||||
import { LevelWithSilentOrString } from 'pino'; |
||||
|
||||
import { MultiProvider } from '../providers/MultiProvider.js'; |
||||
import { HyperlaneSmartProvider } from '../providers/SmartProvider/SmartProvider.js'; |
||||
import { ChainNameOrId } from '../types.js'; |
||||
|
||||
export class HyperlaneReader { |
||||
provider: providers.Provider; |
||||
|
||||
constructor( |
||||
protected readonly multiProvider: MultiProvider, |
||||
protected readonly chain: ChainNameOrId, |
||||
) { |
||||
this.provider = this.multiProvider.getProvider(chain); |
||||
} |
||||
|
||||
/** |
||||
* Conditionally sets the log level for a smart provider. |
||||
* |
||||
* @param level - The log level to set, e.g. 'debug', 'info', 'warn', 'error'. |
||||
*/ |
||||
protected setSmartProviderLogLevel(level: LevelWithSilentOrString): void { |
||||
if ('setLogLevel' in this.provider) { |
||||
(this.provider as HyperlaneSmartProvider).setLogLevel(level); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue