-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:ensdomains/ensjs-v3 into sendName-u…
…pdate
- Loading branch information
Showing
11 changed files
with
92 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { config } from 'dotenv' | ||
import fs from 'fs' | ||
import yaml from 'js-yaml' | ||
import path from 'path' | ||
|
||
export const main = (options) => { | ||
const directory = path.resolve(process.cwd(), options.directory) | ||
const fileName = path.resolve(directory, 'subgraph.yaml') | ||
const file = yaml.load(fs.readFileSync(fileName, 'utf8')) | ||
|
||
config({ path: path.resolve(process.cwd(), options.env) }) | ||
|
||
const parsed = JSON.parse(process.env[options.var]) | ||
const addresses = Object.keys(parsed).reduce( | ||
(acc, key) => ({ ...acc, [key.toLowerCase()]: parsed[key] }), | ||
{}, | ||
) | ||
const addressKeys = Object.keys(addresses) | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (const s of file.dataSources) { | ||
s.network = 'mainnet' | ||
if (s.source.startBlock) s.source.startBlock = 0 | ||
// eslint-disable-next-line no-continue | ||
if (!s.source.address) continue | ||
let sourceName = s.name.toLowerCase() | ||
if (sourceName.endsWith('old')) { | ||
sourceName = sourceName.replace(/(.*)old/, 'legacy$1') | ||
} | ||
if (sourceName === 'baseregistrar') { | ||
sourceName = 'baseregistrarimplementation' | ||
} | ||
if (addressKeys.includes(sourceName)) { | ||
s.source.address = addresses[sourceName] | ||
} else { | ||
throw new Error(`Couldn't lookup contract: ${sourceName}, ${s.name}`) | ||
} | ||
} | ||
|
||
fs.writeFileSync(fileName, yaml.dump(file)) | ||
} |
Binary file not shown.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.