Skip to content

Commit

Permalink
Add support for the Sepolia (L2) & Sepolia Arbitrum (L2) networks
Browse files Browse the repository at this point in the history
  • Loading branch information
fordN committed Nov 20, 2023
1 parent eb602fc commit 1cbd4ea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/common-ts/src/contracts/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const chainMap = new MapWithGetKey<number>([
[1, 42161], // Ethereum Mainnet - Arbitrum One
[4, 421611], // Ethereum Rinkeby - Arbitrum Rinkeby
[5, 421613], // Ethereum Goerli - Arbitrum Goerli
[11155111, 421614], // Ethereum Sepolia - Arbitrum Sepolia
[1337, 412346], // Localhost - Arbitrum Localhost
])

Expand Down
18 changes: 14 additions & 4 deletions packages/common-ts/src/contracts/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ const mockSigner = jest.fn() as unknown as Signer

describe('Contracts', () => {
// Test for each supported protocol network
test.each([1, 5, 42161, 421613])('Connect contracts [chainId: %p]', chainId => {
const contracts = connectContracts(mockSigner, chainId, DEPLOYED_CONTRACTS)
expect(contracts).toBeDefined()
})
test.each([1, 5, 42161, 421613, 421614, 11155111])(
'Connect contracts with explicit addressBook provided [chainId: %p]',
chainId => {
const contracts = connectContracts(mockSigner, chainId, DEPLOYED_CONTRACTS)
expect(contracts).toBeDefined()
},
)
test.each([1, 5, 42161, 421613, 421614, 11155111])(
'Connect contracts without explicit addressBook provided [chainId: %p]',
chainId => {
const contracts = connectContracts(mockSigner, chainId, undefined)
expect(contracts).toBeDefined()
},
)
})
6 changes: 4 additions & 2 deletions packages/common-ts/src/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ export const connectContracts = async (
chainId: number,
addressBook: AddressBook | undefined,
): Promise<NetworkContracts> => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const deployedContracts = addressBook ? addressBook[`${chainId}`] : (DEPLOYED_CONTRACTS as any)[`${chainId}`]
const deployedContracts = addressBook
? addressBook[`${chainId}`]
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
(DEPLOYED_CONTRACTS as any)[`${chainId}`]
if (!deployedContracts) {
throw new Error(`chainId: '${chainId}' has no deployed contracts`)
}
Expand Down

0 comments on commit 1cbd4ea

Please sign in to comment.