Skip to content

Commit

Permalink
snap modified
Browse files Browse the repository at this point in the history
  • Loading branch information
bowensanders committed Sep 23, 2024
1 parent 3a7cc20 commit 7cf691c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/examples/packages/name-lookup/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "xk7O5itVsuV3Dfldq3rI3WgggHa3z7HX7e17jzheE8w=",
"shasum": "8w0VHAID5gqtyRoZ92f070XZcdkf7tOqEeaYavhEslg=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
30 changes: 25 additions & 5 deletions packages/examples/packages/name-lookup/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,32 @@ export const onNameLookup: OnNameLookupHandler = async (request) => {
}

if (domain) {
const resolvedAddress = '0xc0ffee254729296a45a3885639AC7E10F9d54979';
return {
resolvedAddresses: [
{ resolvedAddress, protocol: 'test protocol', domainName: domain },
],
const resolutions = {
fooBar: '0xc0ffee254729296a45a3885639AC7E10F9d54979',
bar: '0x0000000000000000000000000000000000000000',
barstool: '0x1234567890123456789012345678901234567890',
};

const getResolution = (domainName: string) => {
if (resolutions[domainName]) {
return { resolvedAddress: resolutions[domainName], domainName };
}
const entries = Object.entries(resolutions);
for (const [key, value] of entries) {
if (key.startsWith(domainName)) {
return {
domainName: key,
resolvedAddress: value,
protocol: 'test protocol',
};
}
}
return null;
};
const fetchedResolution = getResolution(domain);
if (fetchedResolution !== null) {
return { resolvedAddresses: [fetchedResolution] };
}
}

return null;
Expand Down

0 comments on commit 7cf691c

Please sign in to comment.