Skip to content
Open
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
17 changes: 15 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@edgeandnode/gds": "^6.9.0",
"@edgeandnode/go": "^10.5.1",
"@emotion/react": "^11.14.0",
"@graphprotocol/address-book": "^1.2.0",
"@graphprotocol/contracts": "^7.3.0",
"@pinax/graph-networks-registry": "^0.7.1",
"@react-hookz/web": "^25.2.0",
Expand Down
56 changes: 51 additions & 5 deletions website/src/contracts.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import HorizonAddresses from '@graphprotocol/address-book/horizon/addresses.json'
import IssuanceAddresses from '@graphprotocol/address-book/issuance/addresses.json'
import SubgraphServiceAddresses from '@graphprotocol/address-book/subgraph-service/addresses.json'
import ContractAddresses from '@graphprotocol/contracts/addresses.json'

import { getAddressLink } from '@edgeandnode/common'
Expand All @@ -7,14 +10,38 @@ import { Table } from '@/components'
import { useI18n } from '@/i18n'

type ValueOf<T> = T[keyof T]

/**
* Legacy protocol contracts (Ethereum Mainnet, Sepolia) sourced from `@graphprotocol/contracts`.
* The new Horizon deployments on Arbitrum live in `@graphprotocol/address-book` (see below).
*/
const contractsByNetworkId = ContractAddresses as Record<string, ValueOf<typeof ContractAddresses>>

export function ProtocolContractsTable({ networkId }: { networkId: number }) {
/**
* Horizon-era contracts (Arbitrum One, Arbitrum Sepolia) sourced from `@graphprotocol/address-book`.
* Each package file is keyed by chain ID, then by contract name. Reading straight from the package
* means new deployments are picked up automatically whenever the dependency is bumped.
*/
type AddressBookEntry = { address: string }
type AddressBook = Record<string, Record<string, AddressBookEntry>>

export const addressBookPackages = {
horizon: HorizonAddresses as AddressBook,
'subgraph-service': SubgraphServiceAddresses as AddressBook,
issuance: IssuanceAddresses as AddressBook,
}

export type AddressBookPackage = keyof typeof addressBookPackages

/** Shared name + address table used by both the legacy and address-book sources. */
function ContractsTable({
networkId,
contracts,
}: {
networkId: number
contracts: { name: string; address: string }[]
}) {
const { t } = useI18n()
const contracts = Object.entries(contractsByNetworkId[`${networkId}`] ?? {}).map(([name, contract]) => ({
...contract,
name,
}))
return (
<Table>
<tbody>
Expand All @@ -34,3 +61,22 @@ export function ProtocolContractsTable({ networkId }: { networkId: number }) {
</Table>
)
}

/** Legacy protocol contracts for a given network, from `@graphprotocol/contracts`. */
export function ProtocolContractsTable({ networkId }: { networkId: number }) {
const contracts = Object.entries(contractsByNetworkId[`${networkId}`] ?? {}).map(([name, contract]) => ({
name,
address: contract.address,
}))
return <ContractsTable networkId={networkId} contracts={contracts} />
}

/** Horizon-era contracts for a given network and package, from `@graphprotocol/address-book`. */
export function HorizonContractsTable({ networkId, product }: { networkId: number; product: AddressBookPackage }) {
const contracts = Object.entries(addressBookPackages[product][`${networkId}`] ?? {}).map(([name, contract]) => ({
name,
address: contract.address,
}))
if (contracts.length === 0) return null
return <ContractsTable networkId={networkId} contracts={contracts} />
}
36 changes: 28 additions & 8 deletions website/src/pages/en/contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,48 @@
title: Protocol Contracts
---

import { ProtocolContractsTable } from '@/contracts'
import { HorizonContractsTable, ProtocolContractsTable } from '@/contracts'

Below are the deployed contracts which power The Graph Network. Visit the official [contracts repository](https://github.com/graphprotocol/contracts) to learn more.
Below are the deployed contracts which power The Graph Network. The Arbitrum contracts are sourced directly from the [`@graphprotocol/address-book`](https://www.npmjs.com/package/@graphprotocol/address-book) package, so they stay current with each release. Visit the official [contracts repository](https://github.com/graphprotocol/contracts) to learn more.

## Arbitrum One

This is the principal deployment of The Graph Network.

<ProtocolContractsTable networkId={42161} />
### Horizon

## Ethereum Mainnet
<HorizonContractsTable networkId={42161} product="horizon" />

This was the original deployment of The Graph Network. Learn more about The Graph's scaling with Arbitrum.
### Subgraph Service

<ProtocolContractsTable networkId={1} />
<HorizonContractsTable networkId={42161} product="subgraph-service" />

### Issuance

<HorizonContractsTable networkId={42161} product="issuance" />

## Arbitrum Sepolia

This is the primary testnet for The Graph Network. Testnet is predominantly used by core developers and ecosystem participants for testing purposes. There are no guarantees of service or availability on The Graph's testnets.

<ProtocolContractsTable networkId={421614} />
### Horizon

<HorizonContractsTable networkId={421614} product="horizon" />

### Subgraph Service

<HorizonContractsTable networkId={421614} product="subgraph-service" />

### Issuance

<HorizonContractsTable networkId={421614} product="issuance" />

## Ethereum Mainnet

This was the original deployment of The Graph Network. Learn more about The Graph's scaling with Arbitrum.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should "Learn more about The Graph's scaling with Arbitrum" be a link? If we don't have anywhere to link to, maybe best to just remove it?


<ProtocolContractsTable networkId={1} />

## Sepolia
## Ethereum Sepolia

<ProtocolContractsTable networkId={11155111} />
Loading