Skip to content

Commit

Permalink
[ens-domains-owned] fix latest block
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaituVR committed Sep 25, 2024
1 parent b7a576a commit db05348
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/strategies/ens-domains-owned/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"network": "1",
"addresses": [
"0xaCf4C2950107eF9b1C37faA1F9a866C8F0da88b9",
"0x0239769A1aDF4DeF9f07Da824B80B9C4fCB59593"
"0x0239769A1aDF4DeF9f07Da824B80B9C4fCB59593",
"0x8d2f3a76a76f055D62A931678ab16b042E7BADeb"
],
"snapshot": 11414195
}
Expand Down
49 changes: 28 additions & 21 deletions src/strategies/ens-domains-owned/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,38 @@ export async function strategy(
const params = Object.fromEntries(
pages
.map((page, i) => `_${i}`)
.map((q, i) => [
q,
{
__aliasFor: 'domains',
__args: {
block: snapshot !== 'latest' ? { number: snapshot } : undefined,
where: {
name: options.domain
},
first: 1000
.map((q, i) => {
const args: any = {
where: {
name: options.domain
},
id: true,
labelName: true,
subdomains: {
__args: {
where: {
owner_in: pages[i].map((address) => address.toLowerCase())
first: 1000
};

if (snapshot !== 'latest') {
args.block = { number: snapshot };
}

return [
q,
{
__aliasFor: 'domains',
__args: args,
id: true,
labelName: true,
subdomains: {
__args: {
where: {
owner_in: pages[i].map((address) => address.toLowerCase())
}
},
owner: {
id: true
}
},
owner: {
id: true
}
}
}
])
];
})
);

let result = await subgraphRequest(ENS_SUBGRAPH_URL[network], params);
Expand Down

0 comments on commit db05348

Please sign in to comment.