forked from graphprotocol/ens-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 160
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 #80 from ensdomains/fix/resolver-null-set
fix: set resolver on domain to null if 0x0
- Loading branch information
Showing
6 changed files
with
146 additions
and
18 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"version": "0.5.4", | ||
"timestamp": 1689639506312 | ||
"timestamp": 1689736116460 | ||
} |
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,130 @@ | ||
import { Address, Bytes, ethereum } from "@graphprotocol/graph-ts"; | ||
import { | ||
assert, | ||
beforeAll, | ||
newMockEvent, | ||
test, | ||
} from "matchstick-as/assembly/index"; | ||
import { handleNewOwner, handleNewResolver } from "../src/ensRegistry"; | ||
import { NewOwner, NewResolver } from "../src/types/ENSRegistry/EnsRegistry"; | ||
import { Domain } from "../src/types/schema"; | ||
|
||
const ETH_NAMEHASH = | ||
"0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae"; | ||
|
||
const DEFAULT_OWNER = "0x89205A3A3b2A69De6Dbf7f01ED13B2108B2c43e7"; | ||
|
||
const DEFAULT_RESOLVER = "0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"; | ||
|
||
const EMPTY_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
|
||
const createNewOwnerEvent = ( | ||
node: string, | ||
label: string, | ||
owner: string | ||
): NewOwner => { | ||
let mockEvent = newMockEvent(); | ||
let newNewOwnerEvent = new NewOwner( | ||
mockEvent.address, | ||
mockEvent.logIndex, | ||
mockEvent.transactionLogIndex, | ||
mockEvent.logType, | ||
mockEvent.block, | ||
mockEvent.transaction, | ||
mockEvent.parameters, | ||
mockEvent.receipt | ||
); | ||
|
||
newNewOwnerEvent.parameters = new Array(); | ||
let nodeParam = new ethereum.EventParam( | ||
"node", | ||
ethereum.Value.fromBytes(Bytes.fromHexString(node)) | ||
); | ||
let labelParam = new ethereum.EventParam( | ||
"label", | ||
ethereum.Value.fromBytes(Bytes.fromHexString(label)) | ||
); | ||
let ownerParam = new ethereum.EventParam( | ||
"owner", | ||
ethereum.Value.fromAddress(Address.fromString(owner)) | ||
); | ||
newNewOwnerEvent.parameters.push(nodeParam); | ||
newNewOwnerEvent.parameters.push(labelParam); | ||
newNewOwnerEvent.parameters.push(ownerParam); | ||
return newNewOwnerEvent; | ||
}; | ||
|
||
const createNewResolverEvent = ( | ||
node: string, | ||
resolver: string | ||
): NewResolver => { | ||
let mockEvent = newMockEvent(); | ||
let newResolverEvent = new NewResolver( | ||
mockEvent.address, | ||
mockEvent.logIndex, | ||
mockEvent.transactionLogIndex, | ||
mockEvent.logType, | ||
mockEvent.block, | ||
mockEvent.transaction, | ||
mockEvent.parameters, | ||
mockEvent.receipt | ||
); | ||
|
||
newResolverEvent.parameters = new Array(); | ||
let nodeParam = new ethereum.EventParam( | ||
"node", | ||
ethereum.Value.fromFixedBytes(Bytes.fromHexString(node)) | ||
); | ||
let resolverParam = new ethereum.EventParam( | ||
"resolver", | ||
ethereum.Value.fromAddress(Address.fromString(resolver)) | ||
); | ||
newResolverEvent.parameters.push(nodeParam); | ||
newResolverEvent.parameters.push(resolverParam); | ||
|
||
return newResolverEvent; | ||
}; | ||
|
||
beforeAll(() => { | ||
const ethLabelhash = | ||
"0x4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0"; | ||
const emptyNode = | ||
"0x0000000000000000000000000000000000000000000000000000000000000000"; | ||
const newNewOwnerEvent = createNewOwnerEvent( | ||
emptyNode, | ||
ethLabelhash, | ||
DEFAULT_OWNER | ||
); | ||
handleNewOwner(newNewOwnerEvent); | ||
}); | ||
|
||
test("sets 0x0 resolver to null", () => { | ||
// something.eth | ||
const labelhash = | ||
"0x68371d7e884c168ae2022c82bd837d51837718a7f7dfb7aa3f753074a35e1d87"; | ||
const namehash = | ||
"0x7857c9824139b8a8c3cb04712b41558b4878c55fa9c1e5390e910ee3220c3cce"; | ||
const newNewOwnerEvent = createNewOwnerEvent( | ||
ETH_NAMEHASH, | ||
labelhash, | ||
DEFAULT_OWNER | ||
); | ||
handleNewOwner(newNewOwnerEvent); | ||
|
||
const newNewResolverEvent = createNewResolverEvent( | ||
namehash, | ||
DEFAULT_RESOLVER | ||
); | ||
handleNewResolver(newNewResolverEvent); | ||
|
||
let fetchedDomain = Domain.load(namehash)!; | ||
|
||
assert.assertNotNull(fetchedDomain.resolver); | ||
|
||
const emptyResolverEvent = createNewResolverEvent(namehash, EMPTY_ADDRESS); | ||
handleNewResolver(emptyResolverEvent); | ||
|
||
fetchedDomain = Domain.load(namehash)!; | ||
|
||
assert.assertNull(fetchedDomain.resolver); | ||
}); |
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 |
---|---|---|
|
@@ -259,13 +259,6 @@ | |
which "2.0.2" | ||
yaml "1.10.2" | ||
|
||
"@graphprotocol/graph-ts@^0.27.0": | ||
version "0.27.0" | ||
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.27.0.tgz#948fe1716f6082964a01a63a19bcbf9ac44e06ff" | ||
integrity sha512-r1SPDIZVQiGMxcY8rhFSM0y7d/xAbQf5vHMWUf59js1KgoyWpM6P3tczZqmQd7JTmeyNsDGIPzd9FeaxllsU4w== | ||
dependencies: | ||
assemblyscript "0.19.10" | ||
|
||
"@graphprotocol/graph-ts@^0.31.0": | ||
version "0.31.0" | ||
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-ts/-/graph-ts-0.31.0.tgz#730668c0369828b31bef81e8d9bc66b9b48e3480" | ||
|
@@ -786,7 +779,7 @@ [email protected]: | |
binaryen "101.0.0-nightly.20210723" | ||
long "^4.0.0" | ||
|
||
[email protected], assemblyscript@^0.19.0, assemblyscript@^0.19.20: | ||
[email protected], assemblyscript@^0.19.0: | ||
version "0.19.23" | ||
resolved "https://registry.yarnpkg.com/assemblyscript/-/assemblyscript-0.19.23.tgz#16ece69f7f302161e2e736a0f6a474e6db72134c" | ||
integrity sha512-fwOQNZVTMga5KRsfY80g7cpOl4PsFQczMwHzdtgoqLXaYhkhavufKb0sB0l3T1DUxpAufA0KNhlbpuuhZUwxMA== | ||
|
@@ -2712,13 +2705,11 @@ make-error@^1.1.1: | |
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" | ||
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== | ||
|
||
matchstick-as@^0.5.0: | ||
version "0.5.0" | ||
resolved "https://registry.yarnpkg.com/matchstick-as/-/matchstick-as-0.5.0.tgz#cdafc1ef49d670b9cbe98e933bc2a5cb7c450aeb" | ||
integrity sha512-4K619YDH+so129qt4RB4JCNxaFwJJYLXPc7drpG+/mIj86Cfzg6FKs/bA91cnajmS1CLHdhHl9vt6Kd6Oqvfkg== | ||
matchstick-as@^0.5.2: | ||
version "0.5.2" | ||
resolved "https://registry.yarnpkg.com/matchstick-as/-/matchstick-as-0.5.2.tgz#6a6dde02d1d939c32458bd67bac688891a07a34c" | ||
integrity sha512-fb1OVphDKEvJY06Ue02Eh1CNncuW95vp6b8tNAP7UIqplICSLoU/zgN6U7ge7R0upsoO78C7CRi4EyK/7Jxz7g== | ||
dependencies: | ||
"@graphprotocol/graph-ts" "^0.27.0" | ||
assemblyscript "^0.19.20" | ||
wabt "1.0.24" | ||
|
||
md5.js@^1.3.4: | ||
|
5c048fb
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.
5c048fb?diff=unified#diff-40d32fbe8baa6e3cbf0ede9f3b5cb8ddb16ead97a3404409c2a4f66b66a43a1f