Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contracts: Add L2Curation #113

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading