⬆️ AFF_DIAMOND Upgrade Tool — REAL PRODUCTION UPGRADE ⚠️ MAINNET
Tool v1.0.1 · Facet bundle v1.0.0
⚠️ REAL UPGRADE — targets the ALREADY-LIVE AFF_DIAMOND, real member/affiliate data, real gas, real consequence.
This is NOT the fresh-deploy tool (aff-diamond-deploy.html) — that tool only ever ADDS facets to a
brand-new Diamond. This tool REPLACES facets on a Diamond already serving real traffic. Every step is
independent and resumable (progress auto-saves to this browser). Step 7 (the actual diamondCut) is the
one irreversible on-chain wiring change.
⚠️ Known-safe Remove-list scoping (built in from the start, T190; unified with
pay-diamond-upgrade.html/le-diamond-upgrade.html): the 7 real EIP-2535/Ownable core
selectors (diamondCut, the 4 Diamond Loupe reads, owner/transferOwnership)
are hardcoded below as PROTECTED_CORE_SELECTORS and are unconditionally excluded from Remove
consideration by selector value — filtered out before Replace/Add/Remove categorization runs, never
removed by this tool regardless of ABI-comparison logic. Selector-value-based rather than address-based:
these 7 selectors are fixed by the standard function signatures themselves, so the same guard is portable
to any Diamond without modification — the exact mechanism used by every upgrade tool in this project.
This is the direct fix for the real incident that bricked the live PAY_DIAMOND earlier the same day this
tool was built (see docs_role_based/002_crypto-dev/2026-07-30_DiamondTools_Fix_Records_v1.md, DIAMOND-TOOL-FIX
006/008/011 history). Still — review the COMPUTE CUT preview and run SIMULATE before every real CALL diamondCut.
Progress backup Every resolved address auto-saves to this browser (localStorage key 'affDiamondUpgradeV1'). Export/Import move progress across devices/browsers; Reset clears everything (asks to confirm).
Step 1 — Connect wallet, verify OWNER + network
Strict OWNER gate, same as every other tool in this project — if the
connected wallet isn't exactly OWNER, every deploy/write button stays disabled.
Step 2 — Set the ALREADY-LIVE AFF_DIAMOND address
Pre-filled with the real T121 mainnet address from
2026-07-29_Diamond_Contract_Reference_MAINNET_v3.md. Edit only if
AFF_DIAMOND is ever redeployed and this address changes.
AFF_DIAMOND:
Steps 3-6 — Deploy the 4 Affiliate facets
Same real compiled source already embedded in aff-diamond-deploy.html (no
functional change since the T121 deploy — this first real use of the tool will therefore
produce a clean Replace-only cut with 0 Add/Remove). Same manual-override/resumable pattern
as every other Diamond tool in this project: paste a known address to skip redeploying.
Click "REFRESH LIVE SELECTORS FROM CHAIN" first — a free, read-only facets()
call straight to the real AFF_DIAMOND — to pull the actual current selector set (and each
selector's live facetAddress) directly from chain state. COMPUTE CUT builds
Replace/Add against that live data, and builds the Remove list ONLY from selectors whose live
facetAddress is NOT one of the 3 hardcoded CORE_FACET_ADDRESSES (see the warning
box above) — core Diamond selectors can never appear in a Remove list from this tool.
Step 8 — Verify
Calls facets() through the live Diamond and shows every
registered facet address + selector count, so the upgrade can be visually confirmed.