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

feat: add support for L2 contracts #95

Merged
merged 7 commits into from
Nov 30, 2022
Merged

feat: add support for L2 contracts #95

merged 7 commits into from
Nov 30, 2022

Conversation

tmigone
Copy link
Contributor

@tmigone tmigone commented Aug 29, 2022

Motivation

This PR adds support for the soon to come L2 contracts.

Changes

  • The connectContracts function now returns the contracts for either L1 or L2 depending on the chainId used.
  • Added GraphChain utilities with some generic L1/L2 related methods.

Examples

import { connectContracts, GraphChain } from '@graphprotocol/common-ts'

// Get mainnet contracts
const l1Contracts  = await connectContracts(provider, 1)

// Get Arbitrum One contracts
const l2Contracts  = await connectContracts(provider, 42161)

// Chain utilities - see source code for more
const chainId = 1
console.log(GraphChain.l1Chains())
console.log(`Chain Id ${chainId} is L${GraphChain.isL1(chainId) ? '1' : '2'}`)
console.log(`Counterpart chain Id for chain ${chainId} is ${GraphChain.counterpart(chainId)}`)

Signed-off-by: Tomás Migone tomas@edgeandnode.com

@tmigone tmigone requested review from fordN and abarmat August 29, 2022 15:38
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Signed-off-by: Tomás Migone <tomas@edgeandnode.com>
Copy link
Member

@pcarranzav pcarranzav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🤖

@tmigone tmigone merged commit f300c97 into master Nov 30, 2022
@tmigone tmigone deleted the tmigone/support-l2 branch November 30, 2022 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants