Skip to content

Commit bca6a12

Browse files
authored
Merge pull request #309 from graphprotocol/mde/address-book-package
2 parents c5c3040 + 0ac6fb7 commit bca6a12

File tree

7 files changed

+1409
-1082
lines changed

7 files changed

+1409
-1082
lines changed
Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
import * as fs from 'fs'
22
import * as mustache from 'mustache'
3-
import * as networkAddresses from '@graphprotocol/contracts/addresses.json'
3+
import * as horizonAddresses from '@graphprotocol/address-book/horizon/addresses.json'
4+
import * as subgraphServiceAddresses from '@graphprotocol/address-book/subgraph-service/addresses.json'
45
import { Addresses } from './addresses.template'
56

67
// mustache doesn't like numbered object keys
78
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8-
let renameAddresses: any = networkAddresses
9-
renameAddresses['arbsep'] = networkAddresses['421614']
9+
let renameHorizonAddresses: any = horizonAddresses
10+
renameHorizonAddresses['arbsep'] = horizonAddresses['421614']
11+
12+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13+
let renameSubgraphServiceAddresses: any = subgraphServiceAddresses
14+
renameSubgraphServiceAddresses['arbsep'] = subgraphServiceAddresses['421614']
15+
16+
const combinedAddresses = {
17+
arbsep: {
18+
...renameHorizonAddresses['arbsep'],
19+
...renameSubgraphServiceAddresses['arbsep']
20+
}
21+
}
1022

1123
export let addresses: Addresses = {
1224
controller: '{{arbsep.Controller.address}}',
1325
graphToken: '{{arbsep.L2GraphToken.address}}',
1426
epochManager: '{{arbsep.EpochManager.address}}',
15-
disputeManager: '{{arbsep.DisputeManager.address}}',
16-
horizonDisputeManager: '{{arbsep.HorizonDisputeManager.address}}',
17-
staking: '{{arbsep.L2Staking.address}}',
18-
stakingExtension: '{{arbsep.StakingExtension.address}}',
27+
disputeManager: '{{arbsep.LegacyDisputeManager.address}}',
28+
horizonDisputeManager: '{{arbsep.DisputeManager.address}}',
29+
staking: '{{arbsep.HorizonStaking.address}}',
30+
stakingExtension: '{{arbsep.HorizonStaking.address}}',
1931
curation: '{{arbsep.L2Curation.address}}',
2032
rewardsManager: '{{arbsep.RewardsManager.address}}',
21-
serviceRegistry: '{{arbsep.ServiceRegistry.address}}',
33+
serviceRegistry: '{{arbsep.LegacyServiceRegistry.address}}',
2234
gns: '{{arbsep.L2GNS.address}}',
2335
ens: '{{arbsep.IENS.address}}',
2436
ensPublicResolver: '{{arbsep.IPublicResolver.address}}',
@@ -39,7 +51,7 @@ export let addresses: Addresses = {
3951

4052
const main = (): void => {
4153
try {
42-
let output = JSON.parse(mustache.render(JSON.stringify(addresses), renameAddresses))
54+
let output = JSON.parse(mustache.render(JSON.stringify(addresses), combinedAddresses))
4355
output.blockNumber = '570450'
4456
output.bridgeBlockNumber = '570450'
4557
output.network = 'arbitrum-sepolia'
@@ -50,26 +62,10 @@ const main = (): void => {
5062
if(output.ethereumDIDRegistry == '') {
5163
output.ethereumDIDRegistry = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
5264
}
53-
// remove once we have proper packages
54-
if(output.subgraphService == '') {
55-
output.subgraphService = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
56-
}
57-
if(output.graphPayments == '') {
58-
output.graphPayments = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
59-
}
60-
if(output.horizonDisputeManager == '') {
61-
output.horizonDisputeManager = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
62-
}
63-
if(output.paymentsEscrow == '') {
64-
output.paymentsEscrow = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
65-
}
66-
if(output.graphTallyCollector == '') {
67-
output.graphTallyCollector = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
68-
}
6965
fs.writeFileSync(__dirname + '/generatedAddresses.json', JSON.stringify(output, null, 2))
7066
} catch (e) {
7167
console.log(`Error saving artifacts: ${e.message}`)
7268
}
7369
}
7470

75-
main()
71+
main()
Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
import * as fs from 'fs'
22
import * as mustache from 'mustache'
3-
import * as networkAddresses from '@graphprotocol/contracts/addresses.json'
3+
import * as horizonAddresses from '@graphprotocol/address-book/horizon/addresses.json'
4+
import * as subgraphServiceAddresses from '@graphprotocol/address-book/subgraph-service/addresses.json'
45
import { Addresses } from './addresses.template'
56

67
// mustache doesn't like numbered object keys
78
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8-
let renameAddresses: any = networkAddresses
9-
renameAddresses['arbitrum'] = networkAddresses['42161']
9+
let renameHorizonAddresses: any = horizonAddresses
10+
renameHorizonAddresses['arbitrum'] = horizonAddresses['42161'] || {}
11+
12+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13+
let renameSubgraphServiceAddresses: any = subgraphServiceAddresses
14+
renameSubgraphServiceAddresses['arbitrum'] = subgraphServiceAddresses['42161'] || {}
15+
16+
const combinedAddresses = {
17+
arbitrum: {
18+
...renameHorizonAddresses['arbitrum'],
19+
...renameSubgraphServiceAddresses['arbitrum']
20+
}
21+
}
1022

1123
export let addresses: Addresses = {
1224
controller: '{{arbitrum.Controller.address}}',
1325
graphToken: '{{arbitrum.L2GraphToken.address}}',
1426
epochManager: '{{arbitrum.EpochManager.address}}',
1527
disputeManager: '{{arbitrum.DisputeManager.address}}',
1628
horizonDisputeManager: '{{arbitrum.HorizonDisputeManager.address}}',
17-
staking: '{{arbitrum.L2Staking.address}}',
18-
stakingExtension: '{{arbitrum.StakingExtension.address}}',
29+
staking: '{{arbitrum.HorizonStaking.address}}',
30+
stakingExtension: '{{arbitrum.HorizonStaking.address}}',
1931
curation: '{{arbitrum.L2Curation.address}}',
2032
rewardsManager: '{{arbitrum.RewardsManager.address}}',
21-
serviceRegistry: '{{arbitrum.ServiceRegistry.address}}',
33+
serviceRegistry: '{{arbitrum.LegacyServiceRegistry.address}}',
2234
gns: '{{arbitrum.L2GNS.address}}',
2335
ens: '{{arbitrum.IENS.address}}',
2436
ensPublicResolver: '{{arbitrum.IPublicResolver.address}}',
@@ -39,38 +51,22 @@ export let addresses: Addresses = {
3951

4052
const main = (): void => {
4153
try {
42-
let output = JSON.parse(mustache.render(JSON.stringify(addresses), renameAddresses))
54+
let output = JSON.parse(mustache.render(JSON.stringify(addresses), combinedAddresses))
4355
output.blockNumber = '42440000' // Hardcoded a few thousand blocks before 1st contract deployed
4456
output.network = 'arbitrum-one'
4557
output.bridgeBlockNumber = '42449749' // Bridge deployment block on L2
4658
output.tokenLockManager = '0xFCf78AC094288D7200cfdB367A8CD07108dFa128'
4759
output.useTokenLockManager = false
4860
if(output.ethereumDIDRegistry == '') {
49-
output.ethereumDIDRegistry = '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B' // since the package doens't have it yet
61+
output.ethereumDIDRegistry = '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B' // since the package doesn't have it yet
5062
}
5163
if(output.ens == '') {
5264
output.ens = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
5365
}
54-
// remove once we have proper packages
55-
if(output.subgraphService == '') {
56-
output.subgraphService = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
57-
}
58-
if(output.graphPayments == '') {
59-
output.graphPayments = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
60-
}
61-
if(output.horizonDisputeManager == '') {
62-
output.horizonDisputeManager = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
63-
}
64-
if(output.paymentsEscrow == '') {
65-
output.paymentsEscrow = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
66-
}
67-
if(output.graphTallyCollector == '') {
68-
output.graphTallyCollector = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
69-
}
7066
fs.writeFileSync(__dirname + '/generatedAddresses.json', JSON.stringify(output, null, 2))
7167
} catch (e) {
7268
console.log(`Error saving artifacts: ${e.message}`)
7369
}
7470
}
7571

76-
main()
72+
main()

config/testAddressesL1.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import * as fs from 'fs'
22
import * as mustache from 'mustache'
3-
import * as networkAddresses from '@graphprotocol/contracts/addresses.json'
3+
import * as horizonAddresses from '@graphprotocol/address-book/horizon/addresses.json'
4+
import * as subgraphServiceAddresses from '@graphprotocol/address-book/subgraph-service/addresses.json'
45
import { Addresses } from './addresses.template'
56

67
// mustache doesn't like numbered object keys
78
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8-
let renameAddresses: any = networkAddresses
9-
renameAddresses['mainnet'] = networkAddresses['1']
9+
let renameHorizonAddresses: any = horizonAddresses
10+
renameHorizonAddresses['mainnet'] = horizonAddresses['1'] || {}
11+
12+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13+
let renameSubgraphServiceAddresses: any = subgraphServiceAddresses
14+
renameSubgraphServiceAddresses['mainnet'] = subgraphServiceAddresses['1'] || {}
15+
16+
const combinedAddresses = {
17+
mainnet: {
18+
...renameHorizonAddresses['mainnet'],
19+
...renameSubgraphServiceAddresses['mainnet']
20+
}
21+
}
1022

1123
export let addresses: Addresses = {
1224
controller: '0x0000000000000000000000000000000000000001',
@@ -39,7 +51,7 @@ export let addresses: Addresses = {
3951

4052
const main = (): void => {
4153
try {
42-
let output = JSON.parse(mustache.render(JSON.stringify(addresses), renameAddresses))
54+
let output = JSON.parse(mustache.render(JSON.stringify(addresses), combinedAddresses))
4355
output.blockNumber = '0' // Hardcoded a few thousand blocks before 1st contract deployed
4456
output.network = 'mainnet'
4557
output.bridgeBlockNumber = '0' // Bridge deployment block on L1
@@ -54,4 +66,4 @@ const main = (): void => {
5466
}
5567
}
5668

57-
main()
69+
main()

config/testAddressesL2.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import * as fs from 'fs'
22
import * as mustache from 'mustache'
3-
import * as networkAddresses from '@graphprotocol/contracts/addresses.json'
3+
import * as horizonAddresses from '@graphprotocol/address-book/horizon/addresses.json'
4+
import * as subgraphServiceAddresses from '@graphprotocol/address-book/subgraph-service/addresses.json'
45
import { Addresses } from './addresses.template'
56

67
// mustache doesn't like numbered object keys
78
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8-
let renameAddresses: any = networkAddresses
9-
renameAddresses['arbitrum'] = networkAddresses['42161']
9+
let renameHorizonAddresses: any = horizonAddresses
10+
renameHorizonAddresses['arbitrum'] = horizonAddresses['42161'] || {}
11+
12+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
13+
let renameSubgraphServiceAddresses: any = subgraphServiceAddresses
14+
renameSubgraphServiceAddresses['arbitrum'] = subgraphServiceAddresses['42161'] || {}
15+
16+
const combinedAddresses = {
17+
arbitrum: {
18+
...renameHorizonAddresses['arbitrum'],
19+
...renameSubgraphServiceAddresses['arbitrum']
20+
}
21+
}
1022

1123
export let addresses: Addresses = {
1224
controller: '0x0000000000000000000000000000000000000001',
@@ -39,14 +51,14 @@ export let addresses: Addresses = {
3951

4052
const main = (): void => {
4153
try {
42-
let output = JSON.parse(mustache.render(JSON.stringify(addresses), renameAddresses))
54+
let output = JSON.parse(mustache.render(JSON.stringify(addresses), combinedAddresses))
4355
output.blockNumber = '0' // Hardcoded a few thousand blocks before 1st contract deployed
4456
output.network = 'arbitrum-one'
4557
output.bridgeBlockNumber = '0' // Bridge deployment block on L2
4658
output.tokenLockManager = '0x0000000000000000000000000000000000000000'
4759
output.useTokenLockManager = false
4860
if(output.ethereumDIDRegistry == '') {
49-
output.ethereumDIDRegistry = '0x0000000000000000000000000000000000000000' // since the package doens't have it yet
61+
output.ethereumDIDRegistry = '0x0000000000000000000000000000000000000000' // since the package doesn't have it yet
5062
}
5163
if(output.ens == '') {
5264
output.ens = '0x0000000000000000000000000000000000000000' // to avoid crashes due to bad config
@@ -57,4 +69,4 @@ const main = (): void => {
5769
}
5870
}
5971

60-
main()
72+
main()

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"prepare:test-l2": "yarn && yarn prep:addresses:test:l2 && mustache ./config/generatedAddresses.json subgraph.template.yaml > subgraph.yaml && graph codegen --output-dir src/types/"
4343
},
4444
"devDependencies": {
45+
"@graphprotocol/address-book": "0.1.0",
4546
"@graphprotocol/contracts": "6.2.0",
4647
"@graphprotocol/graph-cli": "0.97.0",
4748
"@graphprotocol/graph-ts": "0.36.0",

src/mappings/helpers/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ export function createOrLoadGraphNetwork(
673673
graphNetwork.curationImplementations = []
674674
graphNetwork.staking = Address.fromString(addresses.staking)
675675
graphNetwork.stakingImplementations = []
676-
graphNetwork.disputeManager = Address.fromString(addresses.disputeManager)
676+
graphNetwork.disputeManager = Address.fromString(addresses.horizonDisputeManager)
677677
graphNetwork.gns = Address.fromString(addresses.gns)
678678
graphNetwork.serviceRegistry = Address.fromString(addresses.serviceRegistry)
679679
graphNetwork.rewardsManager = Address.fromString(addresses.rewardsManager)

0 commit comments

Comments
 (0)