Commit Graph

25 Commits

Author SHA1 Message Date
martbost c7018f6258 My line: POL earned from each person; wallet picker features non-Trust wallets first
- /api/my/line sums TierPaid events per buyer for the signed-in member; the
  downline rows show "+X POL" (what that person has paid you so far).
- AppKit featuredWalletIds: MetaMask, Phantom, SafePal, Coinbase first; Trust
  Wallet stays available under All wallets.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-09 07:47:41 -05:00
martbost 9608d07544 Buy flow: balance pre-flight; Trust Wallet users get a drain-warning heads-up
Stops early when the wallet lacks the POL. Only Trust Wallet users see the
proportion warning (smaller package / add POL / other wallet); everyone else
goes straight to the wallet confirmation. Buy-pane tip + chatbot reworded.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-09 07:23:19 -05:00
martbost 68d68b1ebf Wallet: recover from a dead WalletConnect session instead of failing the buy
Probe the session after connect and retry once after a "disconnected" send
error by wiping the stale session and re-opening the picker (Trust kills the
session after its own security stop).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-09 06:41:09 -05:00
martbost 85532155a6 Make wallet disconnect not hang
AppKit's modal.disconnect() can stall on the WalletConnect relay (mobile),
leaving the Disconnect button spinning forever ("just loads and says
disconnect") and never reaching the reload. Race the disconnect against a
1.2s timeout, and fire-and-forget from the button with a guaranteed reload
that drops in-memory wallet state so the picker returns.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 13:57:35 -05:00
martbost 8be30bef13 Fix buy crash on wallets that return a numeric chainId
The chain guard did cur.toLowerCase() on the eth_chainId result. Per EIP-695
that's a hex string, but some wallets (Orlando's) return a number, so
cur.toLowerCase was undefined -> "cur.toLowerCase is not a function" aborted the
purchase. Compare chain ids numerically via a chainNum() normalizer (handles
hex string, decimal string, and number) in both the sendTx guard and ensureChain.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 11:51:42 -05:00
martbost 2cc21457bd Don't leave the connect modal stuck when already connected
On click, AppKit's session hasn't always rehydrated yet, so currentAddress()
returned null and we popped the picker even for an already-connected wallet —
and nothing closed it, leaving it stuck on screen after a purchase. Wait briefly
for the existing session to rehydrate before opening the picker, and always
close the modal once we have an address.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 11:41:07 -05:00
martbost 7b131dad28 Gas floor fix, chain guard, and dashboard footer
- wallet.js: fetch correct EIP-1559 fees from the network (Amoy/Polygon Bor
  enforce a ~25-30 gwei priority floor MetaMask's estimate misses) via new
  /api/gas; hard chain-guard before signing so a tx never lands on the wrong
  network; accept the wallet's usual networks in AppKit so its modal stops
  looping and drive add+switch ourselves.
- chain.js: suggestedFees() from eth_maxPriorityFeePerGas + base fee.
- Dashboard: move the Site links (Ad packages / Live ledger / The contract)
  out of the sidebar into a page footer; hide the sidebar scrollbar.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 10:49:34 -05:00
martbost 09804cda22 Fix wallet add/switch-network: use a clean RPC, not the WC proxy
AppKit's built-in networks advertise rpc.walletconnect.org/v1/?chainId=…&projectId=…
as the chain RPC. Wallets reject that query-string URL as "Invalid URL" when
adding/switching the network — Trust showed "Invalid URL", desktop MetaMask
looped on Switch Network, and the mobile buy failed because the switch to Amoy
never completed. Clone the chain with our clean public RPC before handing it to
AppKit/Wagmi.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 10:14:23 -05:00
martbost 7d6818a8d4 Buy flow: survive mobile app-switch fetch drops
Mobile drops in-flight fetches when the page returns from the wallet app, which
aborted the purchase before the tx ("Failed to fetch"). Retry /api/me and
/api/sponsor, and make waitTx keep polling through transient fetch failures.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 10:08:34 -05:00
martbost bd4040ff4f Rebuild wallet connect on Reown AppKit (universal, all wallets, working icons)
Replaces the low-level ethereum-provider + deprecated modal (broken icons, jank)
with Reown AppKit loaded from the CDN — the standard connector every wallet
supports, with QR + mobile deep-links and a polished picker. Keeps the exact
SIWE sign-in and contract buy/activate logic, driving AppKit's EIP-1193 provider.
CSP widened for the AppKit SDK/RPC + a worker.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 09:48:38 -05:00
martbost b0f807f6a5 WalletConnect buy: stop overriding gas (let wallet set fees)
Setting fees made MetaMask show an unclearable "site-suggested fee" alert. Hand
fee control back to the wallet; its own estimate meets Amoy's minimum.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 09:38:15 -05:00
martbost 952f2367d6 WalletConnect: always show the wallet picker (no auto-deeplink to last wallet)
Clear WALLETCONNECT_DEEPLINK_CHOICE before each connect so users aren't trapped
auto-launching a wallet that can't finish (e.g. Trust on Amoy); the All Wallets
picker shows every time so they can choose MetaMask.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 09:32:38 -05:00
martbost 89d636df82 Disconnect wallet: clear all WC state + reload so the picker truly reappears
Clearing localStorage alone wasn't enough — WalletConnect keeps the last wallet
and session in memory, so it auto-reconnected the same wallet. Broadened the
storage purge and reload the page after disconnect, guaranteeing a clean pick.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 09:26:34 -05:00
martbost 379a5352ea Add "Disconnect wallet" button (clears stuck WC session / switch wallets)
A stuck WalletConnect request or wrong-wallet choice could trap testers. New
IAPWallet.disconnect() drops the WC session, forgets the chosen provider, and
clears WC localStorage so the next connect re-offers the picker. Surfaced as a
"Disconnect wallet" button on the Wallet pane.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 09:21:42 -05:00
martbost d23eb10c58 WalletConnect buy: lower maxFeePerGas ceiling to 50 gwei
250 gwei ceiling tripped MetaMask's "network fee higher than necessary" alert on
Amoy (base fee ~0). 50 gwei keeps priority above Polygon's ~25 gwei floor while
reading as a normal fee, so buyers get a clean Confirm.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 09:12:19 -05:00
martbost 7469a4907c WalletConnect buy: set EIP-1559 fees above Polygon's min priority fee
Amoy/Polygon reject txs whose priority fee is under ~25 gwei ("gas tip below
minimum"); wallets lowball it. Set explicit maxPriorityFeePerGas 30 gwei,
maxFeePerGas 250 gwei ceiling, and a 600k gas limit so buys/activations aren't
rejected or mis-estimated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 09:07:00 -05:00
martbost 90e33a42b5 WalletConnect: add redirect metadata (return to dApp after wallet approvals)
Sets metadata.redirect so mobile wallets bounce the user back to /my after each
approval instead of stranding them in the wallet app.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 08:56:10 -05:00
martbost dcfc5ca86e WalletConnect: make the chain optional (fixes Trust hang on Amoy)
Requiring Amoy (80002) in the session namespaces made Trust Wallet hang on
"redirecting" — testnet wallets that don't natively list Amoy can't satisfy a
required-chain proposal. Switched to optionalChains so the session establishes;
the chain is switched/added after connect.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 08:44:21 -05:00
martbost 9cff0dc667 WalletConnect: gate to public chains (137/Amoy), not the private rehearsal
External wallets reject a WalletConnect session for the private rehearsal chain
(31337) with "user rejected", since they don't recognize custom chains. Only
offer WalletConnect on chains wallets know (Polygon mainnet / Amoy); it lights up
automatically when the site points at a public chain. Rehearsal keeps the
injected/dApp-browser path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 08:05:58 -05:00
martbost f0e42e47bb Add WalletConnect: connect from any mobile browser (no dApp browser)
Mobile users in a normal browser hit "no wallet found" because EIP-6963 only
sees injected/extension wallets. WalletConnect fixes it: the connect picker now
offers WalletConnect (auto-selected when no injected wallet is present), which
shows a QR on desktop and opens the wallet app directly on mobile — no in-app
dApp browser, no second login. Lazy-loads the @walletconnect/ethereum-provider
UMD from jsdelivr; the result is a plain EIP-1193 provider so sign/switch/buy are
unchanged. CSP widened for the SDK + WC relay. Project id lives in site config
(public value); gated so nothing changes until it's set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-08 07:36:07 -05:00
martbost 9fd85e0d6c Multi-wallet support: EIP-6963 discovery + picker
Detects all injected wallets via EIP-6963 (Trust, MetaMask, SafePal, Phantom,
OKX, TokenPocket, and any 6963 wallet), with named fallbacks for ones that don't
announce and window.ethereum(.providers). One wallet connects directly; multiple
show a picker. connect()/sendTx() resolve a provider before use.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-07 08:24:28 -05:00
martbost 85a6ac5bb0 Wallet: fix Trust Wallet chain-add + personal_sign ("invalid method parameters")
- wallet_addEthereumChain omits blockExplorerUrls when the config explorer is
  empty (rehearsal has none) — an empty-string URL made Trust Wallet reject the
  add with "invalid method parameters", blocking new users from adding the chain.
- personal_sign now hex-encodes the SIWE message (Trust Wallet requires hex;
  MetaMask took raw). Signed bytes are identical so server recovery is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-07 06:58:12 -05:00
martbost 013a88b7d0 Fix: relay tx receipts through the server (CSP blocked direct RPC polls)
After a wallet sent a transaction, waitTx polled the public RPC straight
from the browser, which connect-src 'self' blocks (Firefox NetworkError,
reported by Marty on Activate; the activation itself landed on-chain).
New /api/tx/<hash> relays eth_getTransactionReceipt via the server's RPC
pool, so the browser only ever talks to us and the mainnet flip needs no
CSP changes. Assets v=20260905a.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-05 05:40:56 -05:00
martbost a87a63d75d Branded Voice copy pass, members activity panels, menu update
Site copy regenerated through the bv-tester1 engine; em dashes scrubbed from
all user-visible strings. /api/my/activity serves per-member earnings,
referrals, and purchases from the chain index.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-04 12:51:16 -05:00
martbost f053c1befa InstantAdPay site skeleton: SIWE auth, live chain ledger, join links, buy flow
Zero-dependency Node server on the RM Circle pattern. Chain config lives in
the volume so the same code runs the Amoy dress rehearsal and mainnet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-04 12:25:34 -05:00