-
Notifications
You must be signed in to change notification settings - Fork 1
Harden ENSJobPages resolver handling, portable ENS audit tooling, and docs/artifacts refresh #154
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| const { createRequire } = require('node:module'); | ||
| const path = require('node:path'); | ||
|
|
||
| const requireFromHere = createRequire(__filename); | ||
|
|
||
| function loadEthers() { | ||
| const candidates = [ | ||
| path.resolve(__dirname, '../../../hardhat/node_modules/ethers'), | ||
| 'ethers', | ||
| ]; | ||
|
|
||
| for (const candidate of candidates) { | ||
| try { | ||
| const mod = requireFromHere(candidate); | ||
| return mod.ethers || mod; | ||
| } catch (error) { | ||
| if (candidate === candidates[candidates.length - 1]) throw error; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const raw = loadEthers(); | ||
| const isV6 = typeof raw.ZeroAddress === 'string'; | ||
|
|
||
| function compat() { | ||
| if (isV6) return raw; | ||
| const utils = raw.utils; | ||
| return { | ||
| ...raw, | ||
| ZeroAddress: raw.constants.AddressZero, | ||
| ZeroHash: raw.constants.HashZero, | ||
| Contract: raw.Contract, | ||
| JsonRpcProvider: raw.providers.JsonRpcProvider, | ||
| Interface: utils.Interface, | ||
| Wallet: raw.Wallet, | ||
| id: utils.id, | ||
| namehash: utils.namehash, | ||
| ensNormalize: (value) => value.trim().toLowerCase(), | ||
| solidityPackedKeccak256: (types, values) => utils.solidityKeccak256(types, values), | ||
|
Comment on lines
+25
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Comment on lines
+34
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The v5 branch returns Useful? React with 👍 / 👎. |
||
| }; | ||
|
Comment on lines
+28
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In the standalone Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| module.exports = { ethers: compat() }; | ||
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.
This new helper does not make the ENS operator scripts portable end-to-end yet.
audit-mainnet.ts,inventory-job-pages.ts,migrate-legacy-batch.ts, andrepair-job-page.tsnow import./lib/ethers, but they still instantiateCurlJsonRpcProvider, andscripts/ens/lib/json_rpc.js:5still does a hardrequire('../../../hardhat/node_modules/ethers'). In the exact fallback scenario this change is meant to support (nohardhat/node_modules/ethers, only a standaloneethersinstall), those scripts will still fail during module load before any RPC call.Useful? React with 👍 / 👎.