Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
fa7e15a
webapp: test holding the deployment's values in the page
brenzi-agent Nov 25, 2026
3669bc5
webapp: hold the deployment's values in the page
brenzi-agent Nov 25, 2026
748713c
webapp: test a build for the deployment values its page reads
brenzi-agent Nov 25, 2026
7a807e3
webapp: test offering and signing only the deployment's terms and prices
brenzi-agent Nov 25, 2026
78cf9c7
webapp: offer and sign only the deployment's terms, prices and years
brenzi-agent Nov 25, 2026
b8804e3
webapp: hold the dev chain's name policy at its proxy's address
brenzi-agent Nov 25, 2026
d00c53f
webapp: start the browser tests' page servers with one shape
brenzi-agent Nov 25, 2026
2862e03
webapp: test following the service's downtime
brenzi-agent Nov 25, 2026
6931ae7
webapp: follow the service's downtime
brenzi-agent Nov 25, 2026
59f0735
webapp: ask again for terms changed before an order is sent
brenzi-agent Nov 25, 2026
8ef84e3
webapp: type an order's reads beside its downtime read
brenzi-agent Nov 25, 2026
93b6b96
webapp: test signing the dispute days of the order's own method
brenzi-agent Nov 25, 2026
fa7303d
webapp: sign the dispute days of the order's own method
brenzi-agent Nov 25, 2026
7e255cb
webapp: keep the service's config that the page has already read
brenzi-agent Nov 25, 2026
4714f67
webapp: aim two browser tests at the screens they check
brenzi-agent Nov 25, 2026
a348524
webapp: test showing payment details only with their proof from the p…
brenzi-agent Nov 25, 2026
ea646bc
webapp: show payment details only with their proof from the page's keys
brenzi-agent Nov 25, 2026
f330f75
Merge remote-tracking branch 'origin/names' into ab/names-hardening
brenzi-agent Nov 25, 2026
d17d254
webapp: mismatch an invoice's address with another wallet's, per coin
brenzi-agent Nov 25, 2026
3af959e
webapp: restore an order in the flow test with the payment it sealed
brenzi-agent Nov 25, 2026
633842e
webapp: the card form on its own origin
brenzi-agent Nov 25, 2026
9e6b28e
webapp: wait for the reload a downtime's end holds until the screen i…
brenzi-agent Nov 25, 2026
243ea8a
webapp: read the build's environment only where Vite gives the config…
brenzi-agent Nov 25, 2026
aec8ce9
webapp: sign every request for an order with its name key
brenzi-agent Nov 25, 2026
ca026b1
webapp: show the name address and its names on Etherscan
brenzi-agent Nov 25, 2026
6ac65f5
webapp: look for Stripe.js in a card page built with a key to mount with
brenzi-agent Nov 25, 2026
248e0e3
webapp: serve the page from GitHub Pages with the API on its own origin
brenzi-agent Nov 25, 2026
464612d
webapp: open the orders a held name code finds, and redraw unchecked …
brenzi-agent Nov 25, 2026
8c80fdb
webapp: read Your names' rows once the page is drawn
brenzi-agent Nov 25, 2026
fc53c92
webapp: wait for signed order reads, and open unknown links with a co…
brenzi-agent Nov 25, 2026
e9a6568
webapp: sign code orders' reads in the contract cases, and frame from…
brenzi-agent Nov 25, 2026
c92c17b
webapp: type the followed order's answers before the code is looked up
brenzi-agent Nov 25, 2026
5043f55
webapp: lead a held code's replaced order on, and fit the registered …
brenzi-agent Nov 25, 2026
755576d
webapp: withhold payment details of an order the page holds no record of
brenzi-agent Nov 25, 2026
f6457b5
webapp: keep a refusal's screen in view past the service's next read
brenzi-agent Nov 25, 2026
0435740
webapp: let Chromium's framing tests reach the local pages they frame
brenzi-agent Nov 25, 2026
6b2716c
webapp: ask for changed terms at Continue, and hold it in the downtime
brenzi-agent Nov 25, 2026
8d95662
webapp: give support the address proof wherever an order's reference is
brenzi-agent Nov 25, 2026
c4158e2
webapp: show the name address in Check your code with a name code
brenzi-agent Nov 25, 2026
5954e29
webapp: read the downtime and the API origin as their sources give them
brenzi-agent Nov 25, 2026
447ba64
webapp: answer a selection or reveal of another signer as an unknown id
brenzi-agent Nov 25, 2026
631c5a4
webapp: give each name one meaning, and a cancel to the signed test
brenzi-agent Nov 25, 2026
24cb8c1
webapp: compare MAINNET with the chain, and document a held value's c…
brenzi-agent Nov 25, 2026
c27e8d7
webapp: sign every request of an order's page with one signer
brenzi-agent Nov 25, 2026
fcc6e16
webapp: draw the screens of an order's page with its record, and with…
brenzi-agent Nov 25, 2026
532cecd
webapp: show the Etherscan link with the shown code, so long names fit
brenzi-agent Nov 26, 2026
17c341b
webapp: keep this browser's payment on reopen; forget wallets with codes
brenzi-agent Nov 26, 2026
37e5bd6
webapp: start nothing but the link in another page's frame
brenzi-agent Nov 26, 2026
59a6c53
webapp: sign an order's requests with its record's code
brenzi-agent Nov 26, 2026
016556d
webapp: draw the held price, and parse an invoice's client secret
brenzi-agent Nov 26, 2026
3242cc4
webapp: order the mock's refusals as the service orders them
brenzi-agent Nov 26, 2026
cd81e83
webapp: run the built page's tests whatever the browser tests found
brenzi-agent Nov 26, 2026
8908abf
Merge remote-tracking branch 'origin/names' into ab/names-hardening
brenzi-agent Nov 26, 2026
844a3d5
webapp: read offline an order link whose order the browser holds
brenzi-agent Nov 26, 2026
af84efc
webapp: wrap a name address that a row is too narrow for
brenzi-agent Nov 26, 2026
27ca7e7
webapp: record the screens the hardening changed
brenzi-agent Nov 26, 2026
b870802
webapp: keep the offline test's order before its page opens
brenzi-agent Nov 26, 2026
0717fba
webapp: hold stall notes and card reorders in the downtime
brenzi-agent Nov 26, 2026
443e3ea
webapp: test the card frame's origin check, and mount without a currency
brenzi-agent Nov 26, 2026
f01d908
webapp: bound the config read, so a silent API leaves the page drawn
brenzi-agent Nov 26, 2026
5a40e46
webapp: document the Pages host; refuse code orders in downtime first
brenzi-agent Nov 26, 2026
db13d27
webapp: record Your names with a registered row's name address
brenzi-agent Nov 26, 2026
0c1699a
webapp: keep an order's own terms and payee; find each code once a link
brenzi-agent Nov 26, 2026
5dc2b25
webapp: sign with records, name intent mismatches, and own row labels
brenzi-agent Nov 26, 2026
1adcadb
webapp: restore an order's terms in the flow test from an empty browser
brenzi-agent Nov 26, 2026
109cdb9
webapp: take a Stripe outage as no form, and a held price as paid
brenzi-agent Nov 26, 2026
9627a4a
webapp: sign each reveal as an order request of the order's name key
brenzi-agent Nov 26, 2026
0a160c1
webapp: test sealing the terms an order agreed to beside its payment
brenzi-agent Nov 26, 2026
8d10709
webapp: seal the terms an order agreed to beside its payment
brenzi-agent Nov 26, 2026
73e41c4
webapp: state that a tab hidden through a downtime keeps its values
brenzi-agent Nov 26, 2026
da99289
webapp: parse an invoice's address proof, and keep its payee as one f…
brenzi-agent Nov 26, 2026
a1f1dfc
webapp: expect the order's terms in its sealed data in the flow test
brenzi-agent Nov 26, 2026
66121ea
webapp: show the name address and Etherscan line under the registrati…
brenzi-agent Nov 26, 2026
ea5eb09
webapp: match the service's reveal refusals and downtime ini values
brenzi-agent Nov 26, 2026
2b9460e
webapp: sign a refused request again only after a clock change
brenzi-agent Nov 26, 2026
736cc5a
webapp: test order requests against the service's recorded vectors
brenzi-agent Nov 26, 2026
ac12e04
webapp: draw a name address and its Etherscan line as one note
brenzi-agent Nov 26, 2026
a33a052
webapp: fit the registered page with its name address on a phone
brenzi-agent Nov 26, 2026
bd90bce
webapp: record the registered screens with their name address note
brenzi-agent Nov 26, 2026
124ff10
Merge remote-tracking branch 'origin/names' into ab/names-hardening
brenzi-agent Nov 26, 2026
53afe5d
webapp: name an order request's signature apart from an address proof
brenzi-agent Nov 26, 2026
3d76411
webapp: watch the record's name, and give a reversed order's proof
brenzi-agent Nov 26, 2026
acfb137
webapp: send the mock's CORS headers only under /api/, as the service
brenzi-agent Nov 26, 2026
6e00cb6
webapp: keep the laptop fit check of a long name's registered page
brenzi-agent Nov 26, 2026
1b0547f
webapp: tell a browser without an order's name code what to do
brenzi-agent Nov 26, 2026
ccf67ed
webapp: list the Pages settings the deploy relies on
brenzi-agent Nov 26, 2026
8fbb69c
webapp: read the service's open Bitcoin invoice fixture for a name in…
brenzi-agent Nov 26, 2026
7a79bf5
webapp: record the no-code screen with its new line
brenzi-agent Nov 26, 2026
55ea6e7
webapp: fit a 63-letter name's registered page in a laptop's window
brenzi-agent Nov 26, 2026
fa06734
webapp: record the registered page with its laptop spacing
brenzi-agent Nov 26, 2026
020960e
Merge remote-tracking branch 'origin/names' into ab/names-hardening
brenzi-agent Nov 27, 2026
c430224
webapp: quote the no-code screen's line as the names page now words it
brenzi-agent Nov 27, 2026
04bcd6a
webapp: record the screens with the names page texts and the hardening
brenzi-agent Nov 27, 2026
64a83de
webapp: let a 63-letter name's registered page grow on a laptop too
brenzi-agent Nov 27, 2026
63624a8
webapp: link names to the SimpleX Names app, and word messages politely
brenzi-agent Nov 27, 2026
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
40 changes: 38 additions & 2 deletions .github/workflows/webapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,33 @@ jobs:
- run: npm test
- run: npm run build

pages:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: unit
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
cache-dependency-path: webapp/package-lock.json
- run: npm ci
- run: npm run build
- uses: actions/upload-pages-artifact@v3
with:
path: webapp/dist
- id: deploy
uses: actions/deploy-pages@v4

e2e:
runs-on: ubuntu-24.04
timeout-minutes: 150
Expand Down Expand Up @@ -85,12 +112,21 @@ jobs:
ulimit -c 0
npx playwright test --project=${{ matrix.browser }}
- name: Production build tests
if: ${{ !cancelled() }}
run: |
ulimit -c 0
npm run build
npx vite build --mode devchain
npx vite preview --host 127.0.0.1 &
curl -fs -o /dev/null --retry 30 --retry-delay 1 --retry-all-errors http://127.0.0.1:4173/
BASE_URL=http://127.0.0.1:4173 npx playwright test --project=${{ matrix.browser }} e2e/offline.spec.ts e2e/track.spec.ts e2e/mode-cache.spec.ts
BASE_URL=http://127.0.0.1:4173 npx playwright test --project=${{ matrix.browser }} e2e/offline.spec.ts e2e/track.spec.ts e2e/mode-cache.spec.ts e2e/card.spec.ts e2e/pages.spec.ts
- name: API on its own origin
if: ${{ !cancelled() }}
run: |
ulimit -c 0
VITE_API_ORIGIN=http://127.0.0.1:8099 npx vite build --mode devchain --outDir dist-api
npx vite preview --host 127.0.0.1 --port 4174 --outDir dist-api &
curl -fs -o /dev/null --retry 30 --retry-delay 1 --retry-all-errors http://127.0.0.1:4174/
API_ORIGIN=http://127.0.0.1:8099 BASE_URL=http://127.0.0.1:4174 npx playwright test --project=${{ matrix.browser }} e2e/pages.spec.ts
- name: Screens
id: screens
if: ${{ !cancelled() && matrix.browser == 'chromium' }}
Expand Down
2 changes: 2 additions & 0 deletions webapp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules/
dist/
dist-card/
dist-api/
test-results/
playwright-report/
dev/local-chain*.json
Expand Down
102 changes: 75 additions & 27 deletions webapp/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion webapp/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ All screens: how each one makes people feel, the criterion the language audit ap

| # | Screen | Issue |
|---|---|---|
| 1 | checkout-code-no-storage | Show the public address the name is stored at, and recommend checking on Etherscan that the name landed there. The link opens the page where the person sees the name owned by their address. The private key alone is not enough. |
| 1 | checkout-code-no-storage | Done: the name address is shown beside each name code, and the registered order's page and each registered row's name code link the SimpleX Names app's page of the address, asking to check that the name is listed. |
| 2 | checkout-community-accepted | The community terms shown make no sense. In the screenshots they are the dummy terms in dev/fixtures/terms/ (community-terms.md and general-terms.md), which dev/deploy.ts publishes; the deployed page shows the terms linked on chain. Make the screenshots show the real terms texts, and rewrite the community terms page where its own text is wrong. |
| 3 | checkout-community-unreadable | The screen says the terms cannot be shown; find why it reaches that state, and change what the person sees. |
| 4 | checkout-links-scan-dialog (phone), checkout-review-code-scan-dialog (phone) | The screenshots show no QR code; find whether the scan dialogs are broken or only the screenshots. |
Expand Down
11 changes: 11 additions & 0 deletions webapp/card/card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
html, body { margin: 0; padding: 0; background: transparent; }
body { font: 16px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #0D1B3A; }
html.dark body { color: #EAF2FF; }
.stand-in { padding: 18px; border: 1px dashed rgba(0, 83, 208, .14); border-radius: 16px; }
html.dark .stand-in { border-color: rgba(112, 240, 249, .18); }
.stand-in .label { margin: 0 0 4px; font-size: 14px; color: #8a5a00; }
html.dark .stand-in .label { color: #ffd38a; }
.stand-in .f { display: block; margin-top: 12px; }
.stand-in .f span { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; opacity: .75; }
.stand-in .box { padding: 13px 14px; border-radius: 12px; border: 1px solid rgba(0, 83, 208, .14); font-weight: 600; }
.stand-in .cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
14 changes: 14 additions & 0 deletions webapp/card/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="referrer" content="no-referrer">
<title>SimpleX names: card form</title>
<link rel="stylesheet" href="./card.css">
<script type="module" src="./main.ts"></script>
</head>
<body>
<div id="form"></div>
</body>
</html>
88 changes: 88 additions & 0 deletions webapp/card/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { SITE } from "../src/config.ts"
import { type FromCard, type MountedCard, mountCard, type Theme, type ToCard, MISMATCHED } from "../src/stripe.ts"

declare const __MAINNET__: boolean
declare global {
interface Window { stripeTestKey?: string }
}

const STAND_IN = "Test card form: no Stripe key is set, so Pay simulates a payment."
const form = document.getElementById("form")!
const fromPage = (origin: string) => SITE.pageOrigins.some((page) => origin === page || (!(typeof __MAINNET__ !== "undefined" && __MAINNET__) && origin.startsWith(`${page}:`)))
const keyOf = () => SITE.stripeKey || (typeof __MAINNET__ !== "undefined" && __MAINNET__ ? "" : window.stripeTestKey ?? "")

let page: string | null = null
let card: MountedCard | null = null
let dark = false
const followers = new Set<(dark: boolean) => void>()
const theme: Theme = {
dark: () => dark,
watch: (follow) => {
followers.add(follow)
return () => { followers.delete(follow) }
},
}

const send = (message: FromCard) => { if (page) parent.postMessage(message, page) }

function shade(next: boolean): void {
dark = next
document.documentElement.classList.toggle("dark", dark)
document.documentElement.style.colorScheme = dark ? "dark" : "light"
for (const follow of followers) follow(dark)
}

function standIn(): MountedCard {
const field = (text: string, value: string) => {
const label = document.createElement("label")
label.className = "f"
label.append(Object.assign(document.createElement("span"), { textContent: text }), Object.assign(document.createElement("div"), { className: "box", textContent: value }))
return label
}
const cols = Object.assign(document.createElement("div"), { className: "cols" })
cols.append(field("Expiry", "12 / 30"), field("CVC", "123"), field("Country", "Portugal"))
const box = Object.assign(document.createElement("div"), { className: "stand-in" })
box.append(Object.assign(document.createElement("p"), { className: "label", textContent: STAND_IN }), field("Card number", "4242 4242 4242 4242"), cols)
form.append(box)
return { confirm: async () => ({ kind: "submitted", id: "pi_stand_in" }), destroy: () => box.remove() }
}

async function mount(clientSecret: string, amount: number): Promise<void> {
const key = keyOf()
if (!key) {
if (!import.meta.env.DEV) return send({ type: "failed", reason: "unloaded" })
card = standIn()
return send({ type: "mounted" })
}
const mounted = await mountCard(key, clientSecret, { amount, currency: SITE.currency, live: SITE.stripeLive }, form, theme)
if (mounted === null || mounted === MISMATCHED) return send({ type: "failed", reason: mounted ?? "unloaded" })
card = mounted
send({ type: "mounted" })
}

async function confirm(): Promise<void> {
if (!card) return
const outcome = await card.confirm()
send(outcome.kind === "submitted" ? { type: "paid", id: outcome.id } : outcome.kind === "invalid" ? { type: "invalid" } : { type: "declined", message: outcome.message })
}

const isToCard = (m: unknown): m is ToCard => typeof m === "object" && m !== null && "type" in m && (
(m.type === "mount" && "clientSecret" in m && typeof m.clientSecret === "string" && "amount" in m && Number.isInteger(m.amount) && "dark" in m && typeof m.dark === "boolean")
|| (m.type === "theme" && "dark" in m && typeof m.dark === "boolean") || m.type === "confirm")

addEventListener("message", (e: MessageEvent<unknown>) => {
const m = e.data
if (e.source !== parent || !fromPage(e.origin) || !isToCard(m)) return
if (m.type === "mount") {
if (page !== null) return
page = e.origin
shade(m.dark)
void mount(m.clientSecret, m.amount)
return
}
if (e.origin !== page) return
if (m.type === "theme") shade(m.dark)
else void confirm()
})

new ResizeObserver(() => send({ type: "height", px: Math.ceil(form.getBoundingClientRect().height) })).observe(form)
14 changes: 14 additions & 0 deletions webapp/card/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { fileURLToPath } from "node:url"
import { defineConfig } from "vite"
import { LOCAL } from "../src/config.ts"

const PORT = Number(new URL(LOCAL.cardOrigin).port)

export default defineConfig(({ mode }) => ({
root: fileURLToPath(new URL(".", import.meta.url)),
envDir: fileURLToPath(new URL("..", import.meta.url)),
define: { __MAINNET__: JSON.stringify(mode === "production") },
server: { host: "127.0.0.1", port: PORT, strictPort: true },
preview: { host: "127.0.0.1", port: PORT, strictPort: true },
build: { target: "es2022", outDir: fileURLToPath(new URL("../dist-card", import.meta.url)), emptyOutDir: true },
}))
14 changes: 12 additions & 2 deletions webapp/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The names webapp with everything it needs, on a fresh local chain at each start:
# docker compose up --build then open http://localhost:5173 (the chain deploys in about 2 minutes)
# The page's source is mounted, so it follows the host's files; the mock and the production build need --build.
# docker compose --profile prod up --build preview the production build on http://localhost:4173
# docker compose --profile prod up --build preview the dev chain's build on http://localhost:4173
# The mock's controls (README) are on http://localhost:8099/control/..., the chain's RPC on http://localhost:8545, and the
# terms' texts, which the page links, on http://localhost:8098.
# Open the page on localhost: plain http on another address is no secure context, and the page's crypto needs one.
Expand Down Expand Up @@ -44,10 +44,20 @@ services:
depends_on:
backend: { condition: service_healthy }

card:
<<: *app
command: npx vite --config card/vite.config.ts --host 0.0.0.0
environment:
CHOKIDAR_USEPOLLING: "1"
volumes:
- ./src:/repo/webapp/src:ro
- ./card:/repo/webapp/card:ro
ports: ["127.0.0.1:5180:5180"]

preview:
<<: *app
profiles: [prod]
command: sh -c "npm run build && npx vite preview --host 0.0.0.0"
command: sh -c "npx vite build --mode devchain && npx vite preview --host 0.0.0.0"
environment:
MOCK_URL: http://backend:8099
ports: ["127.0.0.1:4173:4173"]
Expand Down
65 changes: 65 additions & 0 deletions webapp/dev/check-mainnet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { createPublicClient, getAddress, http, keccak256, parseAbi, toHex, type Hex } from "viem"
import { mainnet } from "viem/chains"
import { type Deployment, MAINNET, type PriceException } from "../src/config.ts"

const RPC_URL = process.env.RPC_URL
if (!RPC_URL) throw new Error("set RPC_URL to an Ethereum mainnet RPC")

const client = createPublicClient({ chain: mainnet, transport: http(RPC_URL) })
const SPONSOR = parseAbi(["function controller() view returns (address)"])
const CONTROLLER = parseAbi([
"function sponsor() view returns (address)",
"function defaultResolver() view returns (address)",
"function namePolicy() view returns (address)",
"function tldSuffix() view returns (string)",
"function prices() view returns (address)",
])
const ORACLE = parseAbi([
"struct LabelPrice { uint256 labelLength; uint256 priceCentsPerYear; }",
"function prices() view returns (uint256 base, LabelPrice[] exceptions)",
])
const POLICY = parseAbi([
"function generalTermsLink() view returns (string)",
"function generalTermsHash() view returns (bytes32)",
"function communityTermsLink() view returns (string)",
"function communityTermsHash() view returns (bytes32)",
])

const controller = await client.readContract({ address: getAddress(MAINNET.sponsor), abi: SPONSOR, functionName: "controller" })
const [chainId, sponsor, resolver, namePolicy, tldSuffix, oracle] = await Promise.all([
client.getChainId(),
client.readContract({ address: controller, abi: CONTROLLER, functionName: "sponsor" }),
client.readContract({ address: controller, abi: CONTROLLER, functionName: "defaultResolver" }),
client.readContract({ address: controller, abi: CONTROLLER, functionName: "namePolicy" }),
client.readContract({ address: controller, abi: CONTROLLER, functionName: "tldSuffix" }),
client.readContract({ address: controller, abi: CONTROLLER, functionName: "prices" }),
])
const [base, exceptions] = await client.readContract({ address: oracle, abi: ORACLE, functionName: "prices" })
const [generalLink, generalHash, communityLink, communityHash] = await Promise.all([
client.readContract({ address: namePolicy, abi: POLICY, functionName: "generalTermsLink" }),
client.readContract({ address: namePolicy, abi: POLICY, functionName: "generalTermsHash" }),
client.readContract({ address: namePolicy, abi: POLICY, functionName: "communityTermsLink" }),
client.readContract({ address: namePolicy, abi: POLICY, functionName: "communityTermsHash" }),
])
const general = { link: generalLink, hash: generalHash }
const community = { link: communityLink, hash: communityHash }

const priced = (list: readonly PriceException[]) => JSON.stringify([...list].sort((a, b) => a.labelLength - b.labelLength))
const chainTermsHeld = (held: Deployment["generalTerms"], terms: { link: string; hash: Hex }) =>
keccak256(toHex(terms.link)) === terms.hash && held.some((t) => t.link === terms.link && t.hash.toLowerCase() === terms.hash.toLowerCase())

const checks: [string, unknown, unknown][] = [
["chain id", chainId, MAINNET.chainId],
["sponsor", sponsor, getAddress(MAINNET.sponsor)],
["resolver", resolver, getAddress(MAINNET.resolver)],
["name policy", namePolicy, getAddress(MAINNET.namePolicy)],
["TLD", tldSuffix, `.${MAINNET.tld}`],
["base price", base, BigInt(MAINNET.priceBaseCentsPerYear)],
["price exceptions", priced(exceptions.map((e) => ({ labelLength: Number(e.labelLength), centsPerYear: Number(e.priceCentsPerYear) }))), priced(MAINNET.priceExceptions)],
[`general terms ${general.link} ${general.hash}`, chainTermsHeld(MAINNET.generalTerms, general), true],
[`community terms ${community.link} ${community.hash}`, chainTermsHeld(MAINNET.communityTerms, community), true],
]
const differs = checks.filter(([, chain, held]) => chain !== held)
for (const [what, chain, held] of differs) console.error(`${what}: the chain has ${String(chain)}, MAINNET ${String(held)}`)
if (differs.length) process.exit(1)
console.log(`MAINNET matches chain ${chainId}: controller ${controller}, sponsor ${sponsor}, resolver ${resolver}, name policy ${namePolicy}, price oracle ${oracle}`)
11 changes: 9 additions & 2 deletions webapp/dev/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "viem"
import { mnemonicToAccount, privateKeyToAccount } from "viem/accounts"
import { foundry } from "viem/chains"
import { LOCAL } from "../src/config.ts"
import { durationFor } from "../src/crypto/registration.ts"
import { BLOCK_POLL_MS, TERM_START_S, untilChainTime } from "./chain-time.ts"
import { registerNameTypedData } from "./register-name.ts"
Expand All @@ -27,8 +28,8 @@ const MAX_LABEL_LENGTH = 63n
const FEED_DECIMALS = 8
const FEED_PRICE = 100_000_000n
// the launch prices in cents a year (owner, 2026-10-21): $100, $200 and $400 for 2 years at 8 or more, 7 and 6 letters
const PRICE_BASE = 5000n
const PRICE_EXCEPTIONS = [{ labelLength: 7n, priceCentsPerYear: 10000n }, { labelLength: 6n, priceCentsPerYear: 20000n }]
const PRICE_BASE = BigInt(LOCAL.priceBaseCentsPerYear)
const PRICE_EXCEPTIONS = LOCAL.priceExceptions.map((e) => ({ labelLength: BigInt(e.labelLength), priceCentsPerYear: BigInt(e.centsPerYear) }))
// the seeded names are registered as a paid order is, for paid years from the term start
const SEED_YEARS = 2
const SEED_DISPUTE_DAYS = 120n
Expand Down Expand Up @@ -116,6 +117,12 @@ await write(owner, namePolicy, "setCommunityTerms", [COMMUNITY_TERMS_LINK])
await write(owner, namePolicy, "addCommunityNames", [COMMUNITY_NAMES])

const chainId = await publicClient.getChainId()
const differs = ([
["chainId", chainId, LOCAL.chainId], ["tld", TLD, LOCAL.tld], ["sponsor", sponsor.address, LOCAL.sponsor], ["resolver", resolver.address, LOCAL.resolver],
["namePolicy", namePolicy.address, LOCAL.namePolicy], ["baseRegistrar", baseRegistrar.address, LOCAL.baseRegistrar], ["general terms", GENERAL_TERMS_LINK, LOCAL.generalTerms[0].link],
["community terms", COMMUNITY_TERMS_LINK, LOCAL.communityTerms[0].link],
] as const).filter(([, deployed, held]) => deployed !== held)
if (differs.length) throw new Error(`the deployment differs from LOCAL in src/config.ts: ${differs.map(([what, deployed, held]) => `${what} ${deployed}, not ${held}`).join("; ")}`)
const holderAccount = privateKeyToAccount(holderKey)

// A name registered to the holder through the sponsor, as the store's service registers names.
Expand Down
Loading