Skip to content

Commit

Permalink
Resolve .xyz as UNS domains
Browse files Browse the repository at this point in the history
  • Loading branch information
iurevych committed Nov 14, 2024
1 parent b48f953 commit c6487d5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 9.3.1

- Resolve .xyz TLD as UNS domains

## 9.3.0

- Support Base blockchain UNS domains resolution
Expand Down
2 changes: 1 addition & 1 deletion src/Ens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ export default class Ens extends NamingService {
private checkSupportedDomain(domain: string): boolean {
return (
domain === 'eth' ||
/^([^\s\\.]+\.)+(eth|luxe|xyz|kred)+$/.test(domain) ||
/^([^\s\\.]+\.)+(eth|luxe|kred)+$/.test(domain) ||
/^([^\s\\.]+\.)(addr\.)(reverse)$/.test(domain)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Resolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,10 +968,10 @@ export default class Resolution {
async locations(domains: string[]): Promise<Locations> {
const zilDomains = domains.filter((domain) => domain.endsWith('.zil'));
const ensDomains = domains.filter((domain) =>
domain.match(/^([^\s\\.]+\.)+(eth|luxe|xyz|kred)+$/),
domain.match(/^([^\s\\.]+\.)+(eth|luxe|kred)+$/),
);
const nonEnsDomains = domains.filter(
(domain) => !domain.match(/^([^\s\\.]+\.)+(eth|luxe|xyz|kred)+$/),
(domain) => !domain.match(/^([^\s\\.]+\.)+(eth|luxe|kred)+$/),
);
// Here, we call both UNS and ZNS methods and merge the results.
// If any of the calls fails, this method will fail as well as we aren't interested in partial results.
Expand Down
2 changes: 1 addition & 1 deletion src/Uns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ export default class Uns extends NamingService {
!!tokens.length &&
!(
domain === 'eth' ||
/^[^-]*[^-]*\.(eth|luxe|xyz|kred|addr\.reverse)$/.test(domain)
/^[^-]*[^-]*\.(eth|luxe|kred|addr\.reverse)$/.test(domain)
) &&
tokens.every((v) => !!v.length)
);
Expand Down
2 changes: 1 addition & 1 deletion src/UnsInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default class UnsInternal {
!!tokens.length &&
!(
domain === 'eth' ||
/^[^-]*[^-]*\.(eth|luxe|xyz|kred|addr\.reverse)$/.test(domain)
/^[^-]*[^-]*\.(eth|luxe|kred|addr\.reverse)$/.test(domain)
) &&
tokens.every((v) => !!v.length)
);
Expand Down
15 changes: 2 additions & 13 deletions src/tests/Ens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ describe('ENS', () => {
'0x4da70a332a7a98a58486f551a455b1398ce309d9bd3a4f0800da4eec299829a4',
callMethod: '0xDa1756Bb923Af5d1a05E277CB1E54f1D0A127890',
resolverCallToAddr: '0xb0E7a465D255aE83eb7F8a50504F3867B945164C',
resolverCallToName: 'adrian.argent.xyz',
resolverCallToName: 'adrian.argent.luxy',
});
const result = await ens?.reverseOf(
'0xb0E7a465D255aE83eb7F8a50504F3867B945164C',
);
expectSpyToBeCalled(eyes);
expect(result).toEqual('adrian.argent.xyz');
expect(result).toEqual('adrian.argent.luxy');
});

it('reverses address to ENS domain null', async () => {
Expand All @@ -93,17 +93,6 @@ describe('ENS', () => {
expect(result).toEqual(null);
});

it('resolves .xyz name using ENS blockchain', async () => {
const eyes = mockAsyncMethods(ens, {
resolver: '0xDa1756Bb923Af5d1a05E277CB1E54f1D0A127890',
fetchAddress: '0xb0E7a465D255aE83eb7F8a50504F3867B945164C',
});

const result = await resolution.addr('adrian.argent.xyz', 'ETH');
expectSpyToBeCalled(eyes);
expect(result).toEqual('0xb0E7a465D255aE83eb7F8a50504F3867B945164C');
});

it('resolves .luxe name using ENS blockchain', async () => {
const eyes = mockAsyncMethods(ens, {
resolver: '0xBD5F5ec7ed5f19b53726344540296C02584A5237',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function constructRecords(
return records;
}

const EnsTlds = ['eth', 'luxe', 'xyz', 'kred', 'reverse'];
const EnsTlds = ['eth', 'luxe', 'kred', 'reverse'];

export const findNamingServiceName = async (
domain: string,
Expand Down

0 comments on commit c6487d5

Please sign in to comment.