Skip to content
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

fix: add unwrap detection from parent owner setSubnodeX #78

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Test

on: [push]

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Run Tests
run: yarn codegen && yarn test
89 changes: 89 additions & 0 deletions networks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"mainnet": {
"ENSRegistry": {
"address": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
"startBlock": 9380380
},
"ENSRegistryOld": {
"address": "0x314159265dd8dbb310642f98f50c066173c1259b",
"startBlock": 3327417
},
"Resolver": {
"startBlock": 3327417
},
"BaseRegistrar": {
"address": "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85",
"startBlock": 9380410
},
"EthRegistrarControllerOld": {
"address": "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5",
"startBlock": 9380471
},
"EthRegistrarController": {
"address": "0x253553366Da8546fC250F225fe3d25d0C782303b",
"startBlock": 16925618
},
"NameWrapper": {
"address": "0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401",
"startBlock": 16925608
}
},
"goerli": {
"ENSRegistry": {
"address": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
"startBlock": 2086611
},
"ENSRegistryOld": {
"address": "0x112234455c3a32fd11230c42e7bccd4a84e02010",
"startBlock": 43152
},
"Resolver": {
"startBlock": 43152
},
"BaseRegistrar": {
"address": "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85",
"startBlock": 2086621
},
"EthRegistrarControllerOld": {
"address": "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5",
"startBlock": 2086640
},
"EthRegistrarController": {
"address": "0xCc5e7dB10E65EED1BBD105359e7268aa660f6734",
"startBlock": 8649286
},
"NameWrapper": {
"address": "0x114D4603199df73e7D157787f8778E21fCd13066",
"startBlock": 8649122
}
},
"sepolia": {
"ENSRegistry": {
"address": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
"startBlock": 3702728
},
"ENSRegistryOld": {
"address": "0x94f523b8261B815b87EFfCf4d18E6aBeF18d6e4b",
"startBlock": 3702721
},
"Resolver": {
"startBlock": 3702721
},
"BaseRegistrar": {
"address": "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85",
"startBlock": 3702731
},
"EthRegistrarControllerOld": {
"address": "0x7e02892cfc2Bfd53a75275451d73cF620e793fc0",
"startBlock": 3790197
},
"EthRegistrarController": {
"address": "0xFED6a969AaA60E4961FCD3EBF1A2e8913ac65B72",
"startBlock": 3790244
},
"NameWrapper": {
"address": "0x0635513f179D50A207757E05759CbD106d7dFcE8",
"startBlock": 3790153
}
}
}
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
"remove-local": "graph remove graphprotocol/ens --node http://127.0.0.1:8020",
"docker:setup": "yarn codegen && yarn docker:create-local && yarn docker:deploy-local",
"docker:create-local": "graph create graphprotocol/ens --node http://ens-app_graph-node_1:8020",
"docker:deploy-local": "graph deploy graphprotocol/ens --debug --ipfs http://ens-app_ipfs_1:5001 --node http://ens-app_graph-node_1:8020/ --version-label 0.0.1",
"docker:deploy-local": "graph deploy graphprotocol/ens --ipfs http://ens-app_ipfs_1:5001 --node http://ens-app_graph-node_1:8020/ --version-label 0.0.1",
"docker:remove-local": "graph remove graphprotocol/ens --node http://ens-app_graph-node_1:8020",
"build": "graph build",
"deploy": "graph deploy ensdomains/ens --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/",
"deploy": "graph deploy --network mainnet --product hosted-service ensdomains/ens",
"deploy:goerli": "graph deploy --network goerli --product hosted-service ensdomains/ensgoerli",
"deploy:sepolia": "graph deploy --network sepolia --studio enssepolia",
"watch-local": "graph deploy graphprotocol/ens --watch --debug --node http://127.0.0.1:8020/ --ipfs http://localhost:5001"
},
"devDependencies": {
"@ensdomains/content-hash": "^2.5.3",
"@graphprotocol/graph-cli": "^0.44.0",
"@graphprotocol/graph-ts": "^0.29.1",
"assemblyscript": "^0.26.3",
"@graphprotocol/graph-cli": "^0.51.2",
"@graphprotocol/graph-ts": "^0.31.0",
"assemblyscript": "^0.19.0",
"matchstick-as": "^0.5.0",
"typescript": "^4.9.4"
}
Expand Down
24 changes: 22 additions & 2 deletions src/ensRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// Import types and APIs from graph-ts
import { BigInt, crypto, ens } from "@graphprotocol/graph-ts";
import { BigInt, crypto, ens, log, store } from "@graphprotocol/graph-ts";

import { concat, createEventID, EMPTY_ADDRESS, ROOT_NODE } from "./utils";
import {
concat,
createEventID,
EMPTY_ADDRESS,
ETH_NODE,
ROOT_NODE,
} from "./utils";

// Import event types from the registry contract ABI
import {
Expand Down Expand Up @@ -123,6 +129,20 @@ function _handleNewOwner(event: NewOwnerEvent, isMigrated: boolean): void {
}
}

// this is effectively an unwrap event UNLESS it's a namewrapper upgrade, but the namewrapper events should handle that situation
log.warning("domain: {}, wrappedDomain: {}", [
domain.id,
domain.wrappedDomain._id,
]);
if (domain.wrappedDomain._id) {
domain.wrappedOwner = null;
if (domain.expiryDate && domain.parent !== ETH_NODE) {
domain.expiryDate = null;
}

store.remove("WrappedDomain", subnode);
}

domain.owner = event.params.owner.toHexString();
domain.parent = event.params.node.toHexString();
domain.labelhash = event.params.label;
Expand Down
4 changes: 4 additions & 0 deletions tests/.latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "0.5.4",
"timestamp": 1689639506312
}
Loading