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
93 lines
3.5 KiB
HTML
93 lines
3.5 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>Install - Namebase Domains snap</title>
|
|
<style>
|
|
:root { color-scheme: light dark; --ink:#101418; --mute:#5b6570; --line:#d8dde3; --bg:#fff; --ok:#0a7d32; --bad:#b0202b; }
|
|
@media (prefers-color-scheme: dark) {
|
|
:root { --ink:#e9edf1; --mute:#98a3ae; --line:#2a3138; --bg:#0d1114; --ok:#5fd48a; --bad:#ff8189; }
|
|
}
|
|
* { box-sizing: border-box; }
|
|
body { margin:0; padding:48px 24px; background:var(--bg); color:var(--ink);
|
|
font:16px/1.6 ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; }
|
|
main { max-width: 640px; margin: 0 auto; }
|
|
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -0.01em; }
|
|
p.sub { color: var(--mute); margin: 0 0 2rem; }
|
|
button { font: inherit; font-weight: 600; padding: .7rem 1.4rem; border-radius: 10px;
|
|
border: 0; background: var(--ink); color: var(--bg); cursor: pointer; }
|
|
button:disabled { opacity: .5; cursor: not-allowed; }
|
|
#status { margin-top: 1.25rem; padding: .9rem 1.1rem; border:1px solid var(--line);
|
|
border-radius: 10px; white-space: pre-wrap; display: none; }
|
|
#status.show { display: block; }
|
|
.ok { color: var(--ok); } .bad { color: var(--bad); }
|
|
ol { color: var(--mute); padding-left: 1.2rem; }
|
|
code { font-family: ui-monospace,SFMono-Regular,Menlo,monospace; font-size: .9em;
|
|
background: color-mix(in srgb, var(--ink) 8%, transparent); padding: .1em .35em; border-radius: 4px; }
|
|
hr { border:0; border-top:1px solid var(--line); margin: 2rem 0; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<h1>Namebase Domains</h1>
|
|
<p class="sub">Install the local build into MetaMask Flask.</p>
|
|
|
|
<button id="install">Install snap</button>
|
|
<div id="status"></div>
|
|
|
|
<hr>
|
|
|
|
<p class="sub" style="margin-bottom:.75rem">Then test it:</p>
|
|
<ol>
|
|
<li>Open Flask and switch to <b>Ethereum Mainnet</b> - the snap only answers on <code>eip155:1</code>.</li>
|
|
<li>Press <b>Send</b>, and type <code>e.xp</code> into the To field.</li>
|
|
<li>It should resolve to <code>0xf1F2Dde…33A1Cd7</code>.</li>
|
|
</ol>
|
|
</main>
|
|
|
|
<script>
|
|
// Local snaps are served by `npm run serve` on 8080; this page is served separately, so the ID is
|
|
// absolute rather than relative to wherever you opened it from.
|
|
const SNAP_ID = 'local:http://localhost:8080';
|
|
|
|
const statusEl = document.getElementById('status');
|
|
const button = document.getElementById('install');
|
|
|
|
function say(message, kind) {
|
|
statusEl.textContent = message;
|
|
statusEl.className = 'show ' + (kind || '');
|
|
}
|
|
|
|
button.addEventListener('click', async () => {
|
|
if (!window.ethereum) {
|
|
say('No wallet found. MetaMask Flask must be installed and enabled for this page.', 'bad');
|
|
return;
|
|
}
|
|
|
|
button.disabled = true;
|
|
say('Waiting for MetaMask…');
|
|
|
|
try {
|
|
const result = await window.ethereum.request({
|
|
method: 'wallet_requestSnaps',
|
|
params: { [SNAP_ID]: {} },
|
|
});
|
|
const installed = result?.[SNAP_ID];
|
|
say('Installed: ' + (installed?.version ?? 'ok') +
|
|
'\nNow open Send in Flask and type a .xp name.', 'ok');
|
|
} catch (error) {
|
|
// 4001 is the user dismissing the prompt, which is not a failure worth shouting about.
|
|
const message = error?.code === 4001
|
|
? 'Installation was dismissed.'
|
|
: (error?.message || String(error));
|
|
say(message + '\n\nIf this says the method is not supported, you are on regular MetaMask - ' +
|
|
'local snaps need Flask.', 'bad');
|
|
} finally {
|
|
button.disabled = false;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|