refactor(wallet-flow): stable signerIds for React keys; tripwire test#247
Merged
Conversation
The new-wallet-flow and wallet-migration flow used the raw signer address as a React key in ReviewSignersCard. Two issues: 1. The address can be empty/undefined while the user is editing, which makes the key non-unique → React reuses inputs across rows, swapping names and addresses while typing. 2. Two signers can momentarily share the same partial input, again producing duplicate keys. Fix: every row gets a stable opaque `signerId` generated when the row is created; the component uses `signerId` as the React key. Address becomes regular state, free to be empty/duplicate transiently without breaking React identity. The same fix applied to both `useWalletFlowState` (new wallet) and `useMigrationWalletFlowState` (migration). The shared `signerRows.ts` module emits the id and keeps the parallel arrays in sync. `reviewSignersCardKey.test.ts` is a tripwire suite that: - greps the source to assert the raw address is never used as a key - verifies both flow-state hooks expose signerIds parallel to signersAddresses This catches future regressions structurally — the type system can't enforce \"don't use address as key\", but a regex over source can. Test plan - 171/171 tests pass deterministically on top of #237 - Typecheck clean Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-opening as new PR — original #238 was auto-closed when its base branch (
feat/server-hardening-and-audit-log) was deleted on merge of #237. Same diff, now targetingmain.Introduces stable opaque
signerIdgenerators for the wallet creation flow's parallel arrays (signersAddresses, signersStakeKeys, signersDRepKeys, signersDescriptions), so React keys are no longer derived from raw addresses. Includes a source-regex tripwire test that fails if anyone reverts to usingaddressas a React key in the review-signers card.See original #238 for full discussion.
Test plan
npm run test -- reviewSignersCardKey🤖 Generated with Claude Code