Resolve Namebase decentralized domains in MetaMask

Namebase domains are Handshake names minted onto Ethereum as non-expiring
ERC-721s. MetaMask cannot resolve them on its own: it asks the ENS registry,
which has never heard of them. This snap knows where to look instead.

It talks to no server. Whatever a name resolves to is where the user's money
goes, so it is read from the chain through the user's own provider - which is
also why no network permission is needed. addr() falls back to whoever holds
the token, so a name keeps paying the right person after a sale.

The manifest declares chains only and carries no TLD list, so enabling minting
on a new TLD needs no change here. Two rules in src/index.ts filter instead:
stay out of TLDs another naming system is authoritative for, and ignore
anything without two labels. When in doubt the answer is null, never an
address.

Hashing mirrors the registry's dsld_node() and every test vector is generated
from it. Two requirements are pinned because breaking either is silent: UTS-46
must be transitional, and it must not be ENSIP-15. Either mistake yields a
valid-looking node with no records and a name that never resolves. The built
bundle is tested separately from the source because tr46 reaches for the Node
punycode builtin - without that polyfill the build is clean and every
non-ASCII name fails at runtime.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YUVyawKbjSWw57md791LUu
This commit is contained in:
2026-08-09 14:45:29 -04:00
commit e90426ff43
14 changed files with 8231 additions and 0 deletions

16
images/icon.svg Normal file
View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.2" baseProfile="tiny-ps" viewBox="0 0 320 320" xmlns="http://www.w3.org/2000/svg">
<title>Namebase</title>
<defs>
<linearGradient id="nbdot" gradientUnits="userSpaceOnUse" x1="21.6047" y1="4.34818" x2="27.1338" y2="9.87731">
<stop offset="0" stop-color="#FF5980"/>
<stop offset="1" stop-color="#FFA882"/>
</linearGradient>
</defs>
<rect width="320" height="320" fill="#FFFFFF"/>
<g transform="translate(64,64) scale(6)">
<path d="M16 5C23.1797 5 29 10.8203 29 18V30H21V18C21 15.2386 18.7614 13 16 13V5Z" fill="#007FFF"/>
<path d="M16 5C8.8203 5 3 10.8203 3 18V30H11V18C11 15.2386 13.2386 13 16 13V5Z" fill="#FFB700"/>
<path d="M27.1428 7.21429C28.7207 7.21429 29.9999 5.9351 29.9999 4.35714C29.9999 2.77919 28.7207 1.5 27.1428 1.5C25.5648 1.5 24.2856 2.77919 24.2856 4.35714C24.2856 5.9351 25.5648 7.21429 27.1428 7.21429Z" fill="url(#nbdot)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 912 B