-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from ensdomains/deleted-name-filter
feat: deleted name filtering via subgraph
- Loading branch information
Showing
9 changed files
with
179 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
/* eslint-disable no-await-in-loop */ | ||
const { ethers } = require('hardhat') | ||
const { namehash, toHex, labelhash } = require('viem') | ||
const { EMPTY_ADDRESS } = require('../dist/cjs/utils/consts') | ||
const { packetToBytes } = require('../dist/cjs/utils/hexEncodedName') | ||
|
||
/** | ||
* @type {import('hardhat-deploy/types').DeployFunction} | ||
*/ | ||
const func = async function (hre) { | ||
const { getNamedAccounts } = hre | ||
const allNamedAccts = await getNamedAccounts() | ||
|
||
const nameWrapper = await ethers.getContract( | ||
'NameWrapper', | ||
await ethers.getSigner(allNamedAccts.owner), | ||
) | ||
const registry = await ethers.getContract( | ||
'ENSRegistry', | ||
await ethers.getSigner(allNamedAccts.owner), | ||
) | ||
|
||
/** | ||
* @param {string} name | ||
*/ | ||
const deleteName = async (name) => { | ||
const labels = name.split('.') | ||
const label = labelhash(labels.shift()) | ||
const node = namehash(labels.join('.')) | ||
|
||
const tx = await registry.setSubnodeRecord( | ||
node, | ||
label, | ||
EMPTY_ADDRESS, | ||
EMPTY_ADDRESS, | ||
0, | ||
) | ||
await tx.wait() | ||
} | ||
|
||
const name1 = 'wrapped-deleted.deletable.eth' | ||
const name2 = 'unwrapped-deleted.deletable.eth' | ||
|
||
// wrap wrapped-deleted.deletable.eth | ||
const approveTx = await registry.setApprovalForAll(nameWrapper.address, true) | ||
await approveTx.wait() | ||
const wrapTx = await nameWrapper.wrap( | ||
toHex(packetToBytes(name1)), | ||
allNamedAccts.owner, | ||
EMPTY_ADDRESS, | ||
) | ||
await wrapTx.wait() | ||
|
||
await deleteName(name1) | ||
await deleteName(name2) | ||
|
||
return true | ||
} | ||
|
||
func.id = 'delete-names' | ||
func.tags = ['delete-names'] | ||
func.runAtTheEnd = true | ||
|
||
module.exports = func |
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
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