feat(sdk-coin-sui): add MPCv2 support to recoverConsolidations - #9496
Conversation
Add an MPCv2-signed recovery test under the token recovery describe block, mirroring the native-transfer MPCv2 test added in the prior commit. Asserts getTSSSignature is not called and the resulting signature is wrapped in SUI's 0x00-flag envelope. The prior commit wired signRecoveryTransaction()'s MPCv2 dispatch into both recover() and recoverSuiToken(), but only exercised the native-transfer path in tests. The ticket explicitly calls out that token recovery (getTokenTransferBuilder) must also handle MPCv2, so this closes that coverage gap found during review. Ticket: WCI-1224 Session-Id: 0c067bc3-368d-4c82-9e68-8d08c89766d5 Task-Id: 8c5b0392-4a96-4479-a83b-8ba80cd2428d
44c478a to
0f3a34b
Compare
0f3a34b to
95ffdf2
Compare
95ffdf2 to
9983445
Compare
Phase 1 — SummaryThis PR adds MPCv2 support to Files changed: 2 | +191 / −8
flowchart TD
A[recoverConsolidations] -->|"userKey && walletPassphrase?"| B{detect once}
B -->|yes| C[getEddsaSigningMaterial → signingMaterial]
B -->|no| D[signingMaterial = undefined]
C --> E[scan loop: idx = startingScanIndex..endingScanIndex]
D --> E
E -->|per iteration| F["recover(recoverParams, signingMaterial)"]
F -->|token branch| G["recoverSuiToken(..., precomputedMaterial)"]
F -->|SUI branch| H["signRecoveryTransaction(..., precomputedMaterial)"]
G --> H
H --> I["precomputedMaterial ?? getEddsaSigningMaterial(...)"]
I --> J[sign & return tx]
Phase 2 — Ticket AlignmentTicket: PR title: The implementation directly addresses what the ticket implies: extend MPCv2 signed hot recovery (landed in part 1, #9493) to the consolidation sweep path, matching the DOT pattern (WCI-1236). Alignment is strong. Phase 3 — Index AnalysisNo new database queries introduced. Phase 4 — Type SafetyDouble casts found (
These patterns are acceptable for sinon spying on private methods and are consistent with existing test patterns in the file. No One minor note: typing Phase 5 — MPCv2 Correctness & Test QualityCorrectness
Test Quality
Consistency vs DOT (#9486) and ADA (#9497)
Summary of FindingsNo blocking issues. One minor test-quality flag:
Everything else is clean: the detection-once pattern is correctly implemented, all four test scenarios are covered, and the unsigned sweep path is properly gated. Generated by [ |
4994308 to
0349d5d
Compare
Add an optional precomputedMaterial parameter to Sui.recover() and thread it through recoverSuiToken()/signRecoveryTransaction() so the caller can supply pre-detected EddsaSigningMaterial and skip the getEddsaSigningMaterial detection call. recoverConsolidations() now detects signing material once via getEddsaSigningMaterial before its scan loop and passes it into every recover() call, instead of letting each iteration independently decrypt the keycard (as it did even after WCI-1224 added MPCv2 dispatch to recover()). Consolidating a wide range of receive-address indexes on an MPCv2 hot wallet would decrypt the same keycard once per scanned index, which is wasteful and slow for the default 20-address scan window (and worse for wider ranges). This mirrors the pattern already landed for DOT (WCI-1236). Ticket: WCI-1234 Session-Id: bf130f11-6bd0-4a91-88c6-a9138ecc96ab Task-Id: 179247fb-4ff6-49f3-9849-df120620c98b
9983445 to
3e17fea
Compare
Stack
This PR is part 2 of 2 in a stack. Review and merge in order:
recover()(base:master)recoverConsolidations()(base:wci-1224-sui-mpcv2-signed-hot-recovery) ← you are hereWhat
precomputedMaterial?: EddsaSigningMaterialparameter toSui.recover(), threaded throughrecoverSuiToken()andsignRecoveryTransaction(), so a caller can supply pre-detected signing material and skip thegetEddsaSigningMaterialdetection call.recoverConsolidations()now detects signing material once viagetEddsaSigningMaterialbefore its scan loop over receive-address indexes, and passes it into everyrecover()call, instead of letting each iteration independently decrypt the keycard.Why
Consolidating a wide range of receive-address indexes on an MPCv2 hot wallet would decrypt the same keycard once per scanned index — wasteful and slow for the default 20-address scan window (and worse for wider ranges). This mirrors the pattern already landed for DOT (WCI-1236).
Test plan
getEddsaSigningMaterialis called exactly once across all scanned indexes (not per iteration)yarn unit-testpasses (210/210) andyarn lintis cleanTicket: WCI-1234