Skip to content

Commit

Permalink
contracts: Add L2Curation
Browse files Browse the repository at this point in the history
  • Loading branch information
tilacog committed Sep 25, 2023
1 parent 25e7466 commit 21ad0dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
14 changes: 14 additions & 0 deletions packages/common-ts/src/contracts/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Signer } from 'ethers'
import { connectContracts } from '.'

jest.mock('ethers')

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)
expect(contracts).toBeDefined()
})
})
10 changes: 8 additions & 2 deletions packages/common-ts/src/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import { L1GraphTokenGateway } from '@graphprotocol/contracts/dist/types/L1Graph
import { BridgeEscrow } from '@graphprotocol/contracts/dist/types/BridgeEscrow'
import { L2GraphToken } from '@graphprotocol/contracts/dist/types/L2GraphToken'
import { L2GraphTokenGateway } from '@graphprotocol/contracts/dist/types/L2GraphTokenGateway'
import { L2Curation } from '@graphprotocol/contracts/dist/types/L2Curation'

// Contract factories
import { Curation__factory } from '@graphprotocol/contracts/dist/types/factories/Curation__factory'
import { L2Curation__factory } from '@graphprotocol/contracts/dist/types/factories/L2Curation__factory'
import { DisputeManager__factory } from '@graphprotocol/contracts/dist/types/factories/DisputeManager__factory'
import { EpochManager__factory } from '@graphprotocol/contracts/dist/types/factories/EpochManager__factory'
import { GNS__factory } from '@graphprotocol/contracts/dist/types/factories/GNS__factory'
Expand All @@ -47,7 +49,7 @@ import { L2GraphTokenGateway__factory } from '@graphprotocol/contracts/dist/type
export const GraphChain = graphChain

export interface NetworkContracts {
curation: Curation
curation: Curation | L2Curation
disputeManager: DisputeManager
epochManager: EpochManager
gns: GNS
Expand Down Expand Up @@ -110,8 +112,11 @@ export const connectContracts = async (
? GNS__factory.connect(getContractAddress('L1GNS'), providerOrSigner)
: GNS__factory.connect(getContractAddress('L2GNS'), providerOrSigner)

const curation = GraphChain.isL1(chainId)
? Curation__factory.connect(getContractAddress('Curation'), providerOrSigner)
: L2Curation__factory.connect(getContractAddress('L2Curation'), providerOrSigner)

const contracts: NetworkContracts = {
curation: Curation__factory.connect(getContractAddress('Curation'), providerOrSigner),
disputeManager: DisputeManager__factory.connect(
getContractAddress('DisputeManager'),
providerOrSigner,
Expand All @@ -121,6 +126,7 @@ export const connectContracts = async (
providerOrSigner,
),
gns,
curation,
rewardsManager: RewardsManager__factory.connect(
getContractAddress('RewardsManager'),
providerOrSigner,
Expand Down

0 comments on commit 21ad0dc

Please sign in to comment.