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: filter out expired ENS handles from results #150

Open
wants to merge 3 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
5 changes: 4 additions & 1 deletion src/addressResolvers/ens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ export async function resolveNames(handles: Handle[]): Promise<Record<Handle, Ad
} = await graphQlCall(
'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
`query Domains {
domains(where: {name_in: ["${normalizedHandles.join('","')}"]}) {
domains(where: {
name_in: ["${normalizedHandles.join('","')}"],
expiryDate_gt: "${Math.floor(Date.now() / 1e3)}"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expiryDate is null if name is a subdomain example 1.snapspace.eth should be fine.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add some tests for that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhhh... subdomain does not return any address, even without the expiryDate filter.

Should we just convert all subdomains to domains, and use the domain's resolved address ? (and map it back to the subdomain)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm getting complicated 😢 may be better to return the domain if doesn't have expiryDate for now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue is that subdomain does not return any result, even on master.

) {
name
resolvedAddress {
id
Expand Down
12 changes: 11 additions & 1 deletion test/unit/addressResolvers/ens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,15 @@ testAddressResolver(
'0xE6D0Dd18C6C3a9Af8C2FaB57d6e6A38E29d513cC',
'sdntestens.eth',
'0x0C67A201b93cf58D4a5e8D4E970093f0FB4bb0D1',
['domain.crypto', 'domain.lens', 'domain.com']
['domain.crypto', 'domain.lens', 'domain.com'],
() => {
return;
},
() => {
describe('when passing an expired domain name', () => {
it('should ignore results for expired domains', () => {
return expect(resolveNames(['49415.eth'])).resolves.toEqual({});
});
});
}
);
12 changes: 11 additions & 1 deletion test/unit/addressResolvers/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ export default function testAddressResolver(
validAddress,
validDomain,
blankAddress,
invalidDomains
invalidDomains,
extraLookupAddressesTests = () => {
return;
},
extraResolveNamesTests = () => {
return;
}
) {
describe(`${name} address resolver`, () => {
describe('lookupAddresses()', () => {
Expand Down Expand Up @@ -40,6 +46,8 @@ export default function testAddressResolver(
);
}, 10e3);
});

extraLookupAddressesTests();
});

describe('resolveNames()', () => {
Expand All @@ -64,6 +72,8 @@ export default function testAddressResolver(
});
}, 10e3);
});

extraResolveNamesTests();
});
});
}