refactor(wallet-flow): stable signerIds for React keys; tripwire test#238
Closed
jinglescode wants to merge 1 commit into
Closed
refactor(wallet-flow): stable signerIds for React keys; tripwire test#238jinglescode wants to merge 1 commit into
jinglescode wants to merge 1 commit into
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
3 tasks
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
Both new-wallet-flow and wallet-migration flow used the raw signer address as a React key in
ReviewSignersCard. That breaks badly:Fix: every signer row gets a stable opaque
signerIdgenerated when the row is created; the component usessignerIdas the React key. Address becomes regular state, free to be empty/duplicate transiently without breaking React identity.The same fix applied to both
useWalletFlowStateanduseMigrationWalletFlowState. The sharedsignerRows.tsmodule emits the id and keeps the parallel arrays in sync.Tripwire test
reviewSignersCardKey.test.tsis a source-regex tripwire suite that:ReviewSignersCard.tsxto assert the raw address is never used as a React keysignerIdsparallel tosignersAddressesThis catches future regressions structurally — the type system can't enforce "don't use address as key", but a regex over source can.
Base branch
This PR targets #237 (feat/server-hardening-and-audit-log) because it depends on the test infrastructure changes in that PR. Once #237 merges to main, this will auto-retarget to main.
Test plan
🤖 Generated with Claude Code