Skip to content

Commit 6375757

Browse files
committed
- update return param for resolvedAddresses according to new spec
1 parent eb070ce commit 6375757

File tree

7 files changed

+45
-11
lines changed

7 files changed

+45
-11
lines changed

packages/snap/snap.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/idriss-crypto/snap/tree/main/packages/snap"
88
},
99
"source": {
10-
"shasum": "e62eZBXNxmhAJNEekne9FE4al/PwbyFoesoGWgHptGM=",
10+
"shasum": "rZ3/bn8vq8mEBpc9WsKQTIgmz+Rs/SzZX4QUfnpmN3g=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",

packages/snap/src/index.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe('onNameLookup', () => {
4141
{
4242
resolvedAddress: TWITTER_ADDRESS_MOCK,
4343
protocol: 'IDriss',
44+
domainName: TWITTER_MOCK,
4445
},
4546
],
4647
});
@@ -57,6 +58,7 @@ describe('onNameLookup', () => {
5758
{
5859
resolvedAddress: MAIL_ADDRESS_MOCK,
5960
protocol: 'IDriss',
61+
domainName: MAIL_MOCK,
6062
},
6163
],
6264
});
@@ -84,6 +86,7 @@ describe('onNameLookup', () => {
8486
{
8587
resolvedAddress: UD_ADDRESS_MOCK,
8688
protocol: 'Unstoppable Domains',
89+
domainName: UD_DOMAIN_MOCK,
8790
},
8891
],
8992
});
@@ -111,6 +114,7 @@ describe('onNameLookup', () => {
111114
{
112115
resolvedAddress: ENS_ADDRESS_MOCK,
113116
protocol: 'ENS',
117+
domainName: ENS_DOMAIN_MOCK,
114118
},
115119
],
116120
});
@@ -138,6 +142,7 @@ describe('onNameLookup', () => {
138142
{
139143
resolvedAddress: FARCASTER_ADDRESS_MOCK,
140144
protocol: 'Farcaster',
145+
domainName: FARCASTER_DOMAIN_MOCK,
141146
},
142147
],
143148
});
@@ -165,6 +170,7 @@ describe('onNameLookup', () => {
165170
{
166171
resolvedAddress: LENS_ADDRESS_MOCK,
167172
protocol: 'Lens',
173+
domainName: LENS_DOMAIN_MOCK,
168174
},
169175
],
170176
});

packages/snap/src/resolvers/ens.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const provider = new JsonRpcProvider(ETHEREUM_RPC_URL);
1414
*/
1515
export async function resolveENS(
1616
domain: string,
17-
): Promise<{ resolvedAddress: string; protocol: string }[]> {
17+
): Promise<
18+
{ resolvedAddress: string; protocol: string; domainName: string }[]
19+
> {
1820
const resolvedENS = await provider.resolveName(domain);
1921
if (!resolvedENS) {
2022
return [];
@@ -28,5 +30,7 @@ export async function resolveENS(
2830
console.log('Error resolving ens:', error);
2931
return [];
3032
}
31-
return [{ resolvedAddress: resolvedENS, protocol: 'ENS' }];
33+
return [
34+
{ resolvedAddress: resolvedENS, protocol: 'ENS', domainName: domain },
35+
];
3236
}

packages/snap/src/resolvers/farcaster.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { BASE_API_URL } from '../constants';
99
*/
1010
export async function resolveFarcasterName(
1111
domain: string,
12-
): Promise<{ resolvedAddress: string; protocol: string }[]> {
12+
): Promise<
13+
{ resolvedAddress: string; protocol: string; domainName: string }[]
14+
> {
1315
try {
1416
let userFID: string;
1517
let connectedAddress = '';
@@ -45,7 +47,13 @@ export async function resolveFarcasterName(
4547
}
4648

4749
if (connectedAddress) {
48-
return [{ resolvedAddress: connectedAddress, protocol: 'Farcaster' }];
50+
return [
51+
{
52+
resolvedAddress: connectedAddress,
53+
protocol: 'Farcaster',
54+
domainName: domain,
55+
},
56+
];
4957
}
5058
return [];
5159
} catch (error) {

packages/snap/src/resolvers/idriss.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ const resolverContract = contract as IDrissResolver;
2929
export async function resolveIDriss(
3030
userInput: string,
3131
resolveOptions: ResolveOptions = {},
32-
): Promise<{ resolvedAddress: string; protocol: string }[]> {
32+
): Promise<
33+
{ resolvedAddress: string; protocol: string; domainName: string }[]
34+
> {
3335
const identifier = await transformIdentifier(userInput);
3436
const filteredWalletTags = filterWalletTags(resolveOptions);
3537

@@ -72,5 +74,11 @@ export async function resolveIDriss(
7274

7375
const publicETH = entries.find((entry) => entry[0] === 'Public ETH');
7476
const resolvedIDriss = publicETH?.[1] ?? entries[0]?.[1] ?? '';
75-
return [{ resolvedAddress: resolvedIDriss, protocol: 'IDriss' }];
77+
return [
78+
{
79+
resolvedAddress: resolvedIDriss,
80+
protocol: 'IDriss',
81+
domainName: userInput,
82+
},
83+
];
7684
}

packages/snap/src/resolvers/lens.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ const client = new LensClient({
1313
*/
1414
export async function resolveLensProfile(
1515
domain: string,
16-
): Promise<{ resolvedAddress: string; protocol: string }[]> {
16+
): Promise<
17+
{ resolvedAddress: string; protocol: string; domainName: string }[]
18+
> {
1719
try {
1820
const handle = domain.replace('@', '').replace('.lens', '');
1921

@@ -22,7 +24,9 @@ export async function resolveLensProfile(
2224
// Resolve the address using LensClient
2325
const address = await client.handle.resolveAddress({ handle: lensHandle });
2426
if (address) {
25-
return [{ resolvedAddress: address, protocol: 'Lens' }];
27+
return [
28+
{ resolvedAddress: address, protocol: 'Lens', domainName: domain },
29+
];
2630
}
2731
return [];
2832
} catch (error) {

packages/snap/src/resolvers/unstoppable_domains.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ import { BASE_API_URL } from '../constants';
99
*/
1010
export async function resolveUnstoppableDomain(
1111
domain: string,
12-
): Promise<{ resolvedAddress: string; protocol: string }[]> {
12+
): Promise<
13+
{ resolvedAddress: string; protocol: string; domainName: string }[]
14+
> {
1315
const response = await fetch(
1416
`${BASE_API_URL}resolve-unstoppable-domains?domain=${domain}`,
1517
);
1618
const data = await response.json();
1719
const resolvedAddress = data.records['crypto.ETH.address'] as string;
1820
if (resolvedAddress) {
19-
return [{ resolvedAddress, protocol: 'Unstoppable Domains' }];
21+
return [
22+
{ resolvedAddress, protocol: 'Unstoppable Domains', domainName: domain },
23+
];
2024
}
2125
return [];
2226
}

0 commit comments

Comments
 (0)