Skip to content

registrar, SimplexNamePolicy: claim an offered name under the terms in one transaction - #54

Draft
brenzi-agent wants to merge 8 commits into
simplex-network:simplexfrom
brenzi-agent:ab/one-step-claim
Draft

brenzi-agent wants to merge 8 commits into
simplex-network:simplexfrom
brenzi-agent:ab/one-step-claim

Conversation

@brenzi-agent

@brenzi-agent brenzi-agent commented Nov 27, 2026 •

Copy link
Copy Markdown

A recipient claims an offered name in two transactions today: acceptGeneralTermsForClaim / acceptCommunityTermsForClaim on the name policy, then transferFrom on the registrar. Registration takes the terms and the commitment in one (commitUnderGeneralTerms). This adds a one-transaction claim, sent by the recipient.

Change (~40 contract lines; no storage change; no change to any existing function, event or error)

  • BaseRegistrarImplementation.claimUnderTerms(from, tokenId, offer, acceptedTermsHash), sent by the recipient: the checks of claimWithSig (ownerOf == from, else NotNameOwner; getApproved == msg.sender && offer == offers[tokenId], else NotOffered), then the new policy hook recordClaimTerms(tokenId, from, offer, hash, msg.sender), then _transfer.
  • SimplexNamePolicy.recordClaimTerms (registrar only, else NotRegistrar) stores the hash in acceptedClaimTerms and nothing else. _transfer's existing hook calls consumeTransfer, which checks the hash against the current terms of the name's kind, emits the acceptance event and deletes the record, as for the two-step claim. A stale or wrong-kind hash reverts TermsNotAccepted.
  • INamePolicy gains recordClaimTerms; docs/upgrades.md gains its row.
  • The logs of the one-step claim equal those of the two transactions from the same state: the acceptance event, NewOwner, Transfer (tests and rehearsals).
sequenceDiagram
  actor R as Recipient
  participant G as BaseRegistrar
  participant P as SimplexNamePolicy
  R->>G: claimUnderTerms(from, tokenId, offer, termsHash)
  G->>G: ownerOf == from, approved == R, offer current
  G->>P: recordClaimTerms(tokenId, from, offer, termsHash, R)
  G->>G: _transfer(from, R, tokenId)
  G->>P: consumeTransfer(...) checks the terms of the name's kind, emits acceptance
Loading

Why on the registrar: a policy-only change cannot move the token (transferFrom requires an approved caller, OpenZeppelin ERC721.sol:152); an entry point on the policy would skip consumeTransfer (the policy is a controller, BaseRegistrarImplementation.sol:605) and give an upgradeable contract the power to move any offered name to its offeree without the offeree's call.

Upgrade: two proxies, the policy first (admin Safe nonce n), then the registrar (n + 1); in either order no executed step calls code not yet deployed, and the two-step claim keeps working throughout. Procedure, rollback and rehearsals: docs/plans/one-step-claim.md in brenzi/simplex-namespace-contract.

Evidence

  • Storage layouts of all eight contracts identical to 6e035ad; the interface adds only claimUnderTerms and recordClaimTerms. Runtime size: registrar 21,248 → 21,731 bytes, policy 18,177 → 18,462.
  • Gas on a mainnet fork (block 26506180), after both upgrades, from one state: acceptGeneralTermsForClaim 52,640 + transferFrom 138,136 = 190,776; claimUnderTerms 142,381 (−25%).
  • Rehearsals: local (deploy 6e035ad, upgrade step by step, claims before, between and after, both orders, a policy without the hook) and mainnet fork (prepareUpgrade and the decoder accepted both candidates with empty INTENDED; claims of real names between and after the upgrades; rollback).
  • Tests: test/simplex/TestClaimUnderTerms.test.ts, committed before the code (2b6a44b, then 6baded6). The fork runs no CI on pushes of this branch, so no CI run records the tests failing before the code. This pull request's run at cc024cc passes: 66 test files, 1313 tests (run 45995268131).
  • Three blind review rounds; rounds 2 and 3 found nothing blocking.

The two commits 488e50d / 52a95ac (a CI trigger and its removal) cancel out; a squash merge drops them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant