Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

teogeb
Copy link
Contributor

@teogeb teogeb commented Jun 9, 2025

Fixed addresses to match commit 3c4bc3b in PR #987.

Open questions

  • Quite surely the intention is to use these addresses, not the addresses which were in the config before this PR? Check this change in practice
  • Why "hub-contracts" are not included in the subgraphs? (maybe it is ok, not related to this PR)

Other changes

Updated startBlocks to 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").

@teogeb teogeb requested a review from harbu June 9, 2025 07:59
@teogeb teogeb marked this pull request as ready for review June 9, 2025 08:21
Copy link
Contributor

@harbu harbu left a 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 teogeb changed the base branch from master to main June 10, 2025 13:12
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
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.

2 participants