From 4a83afe7a2327f780713c9ed4d7a683d31604fbb Mon Sep 17 00:00:00 2001 From: Ford Date: Thu, 16 Nov 2023 15:34:36 -0800 Subject: [PATCH 1/5] v2.0.8 --- packages/common-ts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common-ts/package.json b/packages/common-ts/package.json index 3bff3df..c811bfc 100644 --- a/packages/common-ts/package.json +++ b/packages/common-ts/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/common-ts", - "version": "2.0.7", + "version": "2.0.8", "description": "Common TypeScript library for Graph Protocol components", "main": "dist/index.js", "types": "dist/index.d.ts", From 38817e99dabc7cb2d5a4fd60ac08257c74c1ac08 Mon Sep 17 00:00:00 2001 From: Ford Date: Thu, 16 Nov 2023 16:14:53 -0800 Subject: [PATCH 2/5] Made addressBook object an optional input to connectContracts() - Default to the file at '@graphprotocol/contracts/addresses.json' --- packages/common-ts/src/contracts/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/common-ts/src/contracts/index.ts b/packages/common-ts/src/contracts/index.ts index d0fae50..acfce23 100644 --- a/packages/common-ts/src/contracts/index.ts +++ b/packages/common-ts/src/contracts/index.ts @@ -1,6 +1,9 @@ import { providers, Signer } from 'ethers' import graphChain from './chain' +// Contract addresses +import * as DEPLOYED_CONTRACTS from '@graphprotocol/contracts/addresses.json' + // Contract ABIs import { Curation } from '@graphprotocol/contracts/dist/types/Curation' import { DisputeManager } from '@graphprotocol/contracts/dist/types/DisputeManager' @@ -73,9 +76,10 @@ export type AddressBook = { [key: string]: { [key: string]: { address: string } export const connectContracts = async ( providerOrSigner: providers.Provider | Signer, chainId: number, - addressBook: AddressBook, + addressBook: AddressBook | undefined, ): Promise => { - const deployedContracts = addressBook[`${chainId}`] + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const deployedContracts = addressBook ? addressBook[`${chainId}`] : (DEPLOYED_CONTRACTS as any)[`${chainId}`] if (!deployedContracts) { throw new Error(`chainId: '${chainId}' has no deployed contracts`) } From 7e9c1a12d14df52445ae70f8a528b204fb41ca60 Mon Sep 17 00:00:00 2001 From: Ford Date: Thu, 16 Nov 2023 16:15:26 -0800 Subject: [PATCH 3/5] 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([ [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 => { - // 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`) } From ee56a1542f51b346ba0736f64ca2f356d388a10c Mon Sep 17 00:00:00 2001 From: Ford Date: Thu, 16 Nov 2023 16:28:53 -0800 Subject: [PATCH 4/5] v2.0.9 --- packages/common-ts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common-ts/package.json b/packages/common-ts/package.json index c811bfc..4ad4f43 100644 --- a/packages/common-ts/package.json +++ b/packages/common-ts/package.json @@ -1,6 +1,6 @@ { "name": "@graphprotocol/common-ts", - "version": "2.0.8", + "version": "2.0.9", "description": "Common TypeScript library for Graph Protocol components", "main": "dist/index.js", "types": "dist/index.d.ts", From fefce098fb4f84ef04a6fef0f7b98b8ecd46ee72 Mon Sep 17 00:00:00 2001 From: Ford Date: Thu, 16 Nov 2023 16:33:03 -0800 Subject: [PATCH 5/5] Update .gitignore files, add .npmignore --- .gitignore | 3 +++ packages/common-ts/.gitignore | 1 + packages/common-ts/.npmignore | 1 + 3 files changed, 5 insertions(+) create mode 100644 packages/common-ts/.npmignore diff --git a/.gitignore b/.gitignore index 2c8cf00..96e5560 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,6 @@ dist .tern-port .npmrc .yarnrc + +# IDE directories +.idea diff --git a/packages/common-ts/.gitignore b/packages/common-ts/.gitignore index 4ebc8ae..5979734 100644 --- a/packages/common-ts/.gitignore +++ b/packages/common-ts/.gitignore @@ -1 +1,2 @@ coverage +.idea diff --git a/packages/common-ts/.npmignore b/packages/common-ts/.npmignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/packages/common-ts/.npmignore @@ -0,0 +1 @@ +.idea