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

Resolve .xyz as UNS domains #263

Merged
merged 4 commits into from
Nov 14, 2024
Merged
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: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 9.3.1

- Resolve .xyz TLD as UNS domains
- Remove .kred and .luxe from ENS resolution

## 9.3.0

- Support Base blockchain UNS domains resolution
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unstoppabledomains/resolution",
"version": "9.3.0",
"version": "9.3.1",
"description": "Domain Resolution for blockchain domains",
"main": "./build/index.js",
"directories": {
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)+$/.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)+$/),
);
const nonEnsDomains = domains.filter(
(domain) => !domain.match(/^([^\s\\.]+\.)+(eth|luxe|xyz|kred)+$/),
(domain) => !domain.match(/^([^\s\\.]+\.)+(eth)+$/),
);
// 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
5 changes: 1 addition & 4 deletions src/Uns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,7 @@ export default class Uns extends NamingService {
const tokens = domain.split('.');
return (
!!tokens.length &&
!(
domain === 'eth' ||
/^[^-]*[^-]*\.(eth|luxe|xyz|kred|addr\.reverse)$/.test(domain)
) &&
!(domain === 'eth' || /^[^-]*[^-]*\.(eth|addr\.reverse)$/.test(domain)) &&
tokens.every((v) => !!v.length)
);
}
Expand Down
5 changes: 1 addition & 4 deletions src/UnsInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ export default class UnsInternal {
const tokens = domain.split('.');
return (
!!tokens.length &&
!(
domain === 'eth' ||
/^[^-]*[^-]*\.(eth|luxe|xyz|kred|addr\.reverse)$/.test(domain)
) &&
!(domain === 'eth' || /^[^-]*[^-]*\.(eth|addr\.reverse)$/.test(domain)) &&
tokens.every((v) => !!v.length)
);
}
Expand Down
49 changes: 2 additions & 47 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.eth',
});
const result = await ens?.reverseOf(
'0xb0E7a465D255aE83eb7F8a50504F3867B945164C',
);
expectSpyToBeCalled(eyes);
expect(result).toEqual('adrian.argent.xyz');
expect(result).toEqual('adrian.argent.eth');
});

it('reverses address to ENS domain null', async () => {
Expand All @@ -93,51 +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',
fetchAddress: '0xf3dE750A73C11a6a2863761E930BF5fE979d5663',
});

const result = await resolution.addr('john.luxe', 'ETH');
expectSpyToBeCalled(eyes);
expect(result).toEqual('0xf3dE750A73C11a6a2863761E930BF5fE979d5663');
});

it('resolves .kred name using ENS blockchain', async () => {
const eyes = mockAsyncMethods(ens, {
resolver: '0x96184444629F3489c4dE199871E6F99568229d8f',
fetchAddress: '0x96184444629F3489c4dE199871E6F99568229d8f',
});
const result = await resolution.addr('brantly.kred', 'ETH');
expectSpyToBeCalled(eyes);
expect(result).toEqual('0x96184444629F3489c4dE199871E6F99568229d8f');
});

it('resolves .luxe name using ENS blockchain with thrown error', async () => {
const spies = mockAsyncMethods(ens, {
resolver: undefined,
owner: undefined,
});

await expectResolutionErrorCode(
resolution.addr('something.luxe', 'ETH'),
ResolutionErrorCode.UnregisteredDomain,
);
expectSpyToBeCalled(spies);
});

it('resolves name with resolver but without an owner', async () => {
const eyes = mockAsyncMethods(ens, {
resolver: '0x226159d592E2b063810a10Ebf6dcbADA94Ed68b8',
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', 'reverse'];

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