Skip to content

Commit 0f4df3b

Browse files
committed
feat: increase support for evmChainIds in different types using ethers BigNumberish
1 parent c313106 commit 0f4df3b

File tree

1 file changed

+9
-2
lines changed
  • packages/automation/src/lib/utils

1 file changed

+9
-2
lines changed

packages/automation/src/lib/utils/chain.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
import { ethers } from 'ethers';
2+
13
import { LIT_EVM_CHAINS } from '@lit-protocol/constants';
24

3-
export function getEvmChain(evmChainId: number) {
5+
export function getEvmChain(evmChainId: ethers.BigNumberish) {
6+
const evmChainIdNumber = ethers.BigNumber.from(evmChainId).toNumber();
7+
if (evmChainIdNumber === 0) {
8+
throw new Error('EVM chainId cannot be 0');
9+
}
10+
411
const chain = Object.values(LIT_EVM_CHAINS).find(
5-
(chain) => chain.chainId === evmChainId
12+
(chain) => chain.chainId === evmChainIdNumber
613
);
714
if (!chain) {
815
throw new Error(`EVM chain with chainId ${evmChainId} not found`);

0 commit comments

Comments
 (0)