-
Notifications
You must be signed in to change notification settings - Fork 5
fix(network-subgraphs): Update iotex contract addresses
#1010
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
harbu
reviewed
Jun 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to say which it should be, newer addresses were recently deployed contracts so probably this is correct?
teogeb
added a commit
that referenced
this pull request
Jun 12, 2025
Extracted subgraph configs (mainly contract addresses and `startBlock`
values) to a separate `subgraph-config.json` file. Now the actual
`subgraph.yaml` is generated in `build.sh` by filling the config options
to a Handlebars template.
We don't need separate environment specific `subgraph_* yaml` files
anymore.
## Implementation
There is a small `fill-handlebars-template.mjs` script which reads the
config from `stdin` and outputs the filled template to `stdout`. There
is no custom logic in that script, and alternative we could use some
ready-made external Handlebars utility instead of this script.
## Config file
The config file was generated from the existing `subgraph_*.yaml` files
by this script:
```js
import { readFileSync } from 'fs'
import yaml from 'js-yaml'
const ENVIRONMENT_IDS = ['dev2', 'polygon', 'polygonAmoy', 'peaq', 'iotex']
const output = {}
for (const environmentId of ENVIRONMENT_IDS) {
const fileId = (environmentId === 'polygonAmoy') ? 'amoy' : environmentId
const fileName = `subgraph_${fileId}.yaml`
const fileContents = readFileSync(fileName, 'utf8')
const yamlData = yaml.load(fileContents)
const contracts = {}
for (const dataSource of yamlData.dataSources) {
const source = dataSource.source
const key = (source.abi === 'NodeRegistry') ? 'StorageNodeRegistry' : source.abi
contracts[key] = {
address: source.address,
startBlock: source.startBlock
}
}
const networkId = (environmentId === 'polygon')
? 'matic' :
((environmentId === 'polygonAmoy') ? 'polygon-amoy' : environmentId)
output[environmentId] = {
networkId,
hubContracts: (environmentId !== 'iotex'),
contracts
}
}
console.log(JSON.stringify(output, undefined, 4))
```
## Small changes to subgraph.yaml output
The subgraph.yaml output generated by the `build.sh` matches almost
exactly the current files. Exceptions:
- removed some TODO comments
- unified quotes to be single quotes
- unified the description
See three commits in this PR for the exact unifications. There was also
test.sh script in commit
[bda37c6](bda37c6)
to check that the outputs match the current files.
## Notes about Iotex
Thet addresses in the `subgraph-config.json` matches the addresses which
were used in `subgraph_iotex.yaml`, but don't match the values of
`@streamr/config`. Therefore this PR doesn't change any functionality.
There is a separate PR about this
#1010 issue.
Also in that PR or in a follow-up PR we may add hub contracts to `iotex`
config. If we do that we should remove the `hubContracts` property from
the `subgraph-configs.json` (and the related if statement in
`subgraph.yaml.hbs`) as the value for that is true in environment.s
|
These changes are part of #1044 |
rollup-ravenx5hy8
added a commit
to rollup-ravenx5hy8/network-contracts
that referenced
this pull request
Nov 6, 2025
Extracted subgraph configs (mainly contract addresses and `startBlock`
values) to a separate `subgraph-config.json` file. Now the actual
`subgraph.yaml` is generated in `build.sh` by filling the config options
to a Handlebars template.
We don't need separate environment specific `subgraph_* yaml` files
anymore.
## Implementation
There is a small `fill-handlebars-template.mjs` script which reads the
config from `stdin` and outputs the filled template to `stdout`. There
is no custom logic in that script, and alternative we could use some
ready-made external Handlebars utility instead of this script.
## Config file
The config file was generated from the existing `subgraph_*.yaml` files
by this script:
```js
import { readFileSync } from 'fs'
import yaml from 'js-yaml'
const ENVIRONMENT_IDS = ['dev2', 'polygon', 'polygonAmoy', 'peaq', 'iotex']
const output = {}
for (const environmentId of ENVIRONMENT_IDS) {
const fileId = (environmentId === 'polygonAmoy') ? 'amoy' : environmentId
const fileName = `subgraph_${fileId}.yaml`
const fileContents = readFileSync(fileName, 'utf8')
const yamlData = yaml.load(fileContents)
const contracts = {}
for (const dataSource of yamlData.dataSources) {
const source = dataSource.source
const key = (source.abi === 'NodeRegistry') ? 'StorageNodeRegistry' : source.abi
contracts[key] = {
address: source.address,
startBlock: source.startBlock
}
}
const networkId = (environmentId === 'polygon')
? 'matic' :
((environmentId === 'polygonAmoy') ? 'polygon-amoy' : environmentId)
output[environmentId] = {
networkId,
hubContracts: (environmentId !== 'iotex'),
contracts
}
}
console.log(JSON.stringify(output, undefined, 4))
```
## Small changes to subgraph.yaml output
The subgraph.yaml output generated by the `build.sh` matches almost
exactly the current files. Exceptions:
- removed some TODO comments
- unified quotes to be single quotes
- unified the description
See three commits in this PR for the exact unifications. There was also
test.sh script in commit
[bda37c6](streamr-dev/network-contracts@bda37c6)
to check that the outputs match the current files.
## Notes about Iotex
Thet addresses in the `subgraph-config.json` matches the addresses which
were used in `subgraph_iotex.yaml`, but don't match the values of
`@streamr/config`. Therefore this PR doesn't change any functionality.
There is a separate PR about this
streamr-dev/network-contracts#1010 issue.
Also in that PR or in a follow-up PR we may add hub contracts to `iotex`
config. If we do that we should remove the `hubContracts` property from
the `subgraph-configs.json` (and the related if statement in
`subgraph.yaml.hbs`) as the value for that is true in environment.s
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed addresses to match commit 3c4bc3b in PR #987.
Open questions
Other changes
Updated
startBlocksto match contract creation blocks (the data is from iotexscan.io's contract pages: search by address, click transaction under "Contract creation", see value for "Block Height").