From 1cbd4eac79ed09af7f422fc4d2314116006e70ce Mon Sep 17 00:00:00 2001
From: Ford <ford@thegraph.com>
Date: Thu, 16 Nov 2023 16:15:26 -0800
Subject: [PATCH] Add support for the Sepolia (L2) & Sepolia Arbitrum (L2)
 networks

---
 packages/common-ts/src/contracts/chain.ts      |  1 +
 packages/common-ts/src/contracts/index.test.ts | 18 ++++++++++++++----
 packages/common-ts/src/contracts/index.ts      |  6 ++++--
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/packages/common-ts/src/contracts/chain.ts b/packages/common-ts/src/contracts/chain.ts
index f5ee8c3..235e2af 100644
--- a/packages/common-ts/src/contracts/chain.ts
+++ b/packages/common-ts/src/contracts/chain.ts
@@ -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
 ])
 
diff --git a/packages/common-ts/src/contracts/index.test.ts b/packages/common-ts/src/contracts/index.test.ts
index e6cfde1..26a3f8e 100644
--- a/packages/common-ts/src/contracts/index.test.ts
+++ b/packages/common-ts/src/contracts/index.test.ts
@@ -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()
+    },
+  )
 })
diff --git a/packages/common-ts/src/contracts/index.ts b/packages/common-ts/src/contracts/index.ts
index acfce23..b136ce3 100644
--- a/packages/common-ts/src/contracts/index.ts
+++ b/packages/common-ts/src/contracts/index.ts
@@ -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`)
   }