Commit 6b9fc055 authored by smartcontracts's avatar smartcontracts Committed by GitHub

feat(cu): add util for getting chain ID (#2509)

Adds a one-liner for getting chain ID given an ethers.Provider input.
Going to follow this PR up with a good first issue to use this util
wherever we're trying to get the chain ID.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent 8e75dbfa
---
'@eth-optimism/core-utils': patch
---
Adds a one-liner for getting chain ID from provider
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
*/ */
export * from './fallback-provider' export * from './fallback-provider'
export * from './network'
import { Provider } from '@ethersproject/abstract-provider'
export const getChainId = async (provider: Provider): Promise<number> => {
const network = await provider.getNetwork()
return network.chainId
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment