Repository navigation
feat(sdk-coin-icp): allow account consolidations, add V2 address tests - #9962
Closed
ralph-bitgo[bot] wants to merge 2 commits into
Closed
ralph-bitgo[bot] wants to merge 2 commits into
ralph-bitgo[bot] wants to merge 2 commits into
Conversation
sdk-core's wallet.buildAccountConsolidations, sendAccountConsolidation and sendAccountConsolidations reject every coin whose base coin does not override allowsAccountConsolidations() to true. sdk-coin-icp inherited the false default, so bitgo-retail's consolidate flow fails for ICP before any transaction is built and V2 consolidation from the UI cannot work. Override the flag to true so receive-address -> root consolidations can be initiated. The platform enforces V2-only consolidation eligibility (CECHO-2443). Ticket: CECHO-2439 Session-Id: 84ade726-5312-4794-ba4c-fa887b5aabc5 Task-Id: cabd6df4-ceda-4d9d-abc8-8b4945964ba0
The V2 (non-memoId) wallet contract and the builder address pass-through were only covered at derivation index 0 with bare test vectors, so a regression in index handling or memo-suffix stripping could ship unnoticed ahead of the V2 rollout (CECHO-2445). Derive the index-1 receive address from the existing commonKeychain fixture exactly as deriveMPCWalletAddress does (secp256k1 m/1, first 33 bytes) and pin the V2 contract: a derived address verifies only at its own index, and memo-suffixed addresses are never accepted. Also pin that builders pass sender/receiver strings through verbatim (the ?memoId=0 recipient survives unchanged), that an omitted memo defaults to 0, and that verifyTransaction accepts the derived->root consolidation prebuild shape sent by sendAccountConsolidation. Ticket: CECHO-2439 Session-Id: 84ade726-5312-4794-ba4c-fa887b5aabc5 Task-Id: cabd6df4-ceda-4d9d-abc8-8b4945964ba0
Contributor
Contributor
|
|
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.
Description
@bitgo/sdk-coin-icpnow overridesallowsAccountConsolidations()to returntrue, and the V2 (HD-derived / non-memoId) wallet contract is pinned with tests.What changed
src/icp.ts: addIcp.allowsAccountConsolidations(): booleanreturningtrue(was thefalsedefault inherited fromBaseCoin). This is the only production change.test/unit/icp.ts: derive the index-1 receive address from the existing commonKeychain fixture exactly the wayderiveMPCWalletAddressdoes (secp256k1m/1, first 33 bytes of the derived public key) and pin the V2 contract in the renamedV2 non-memoId walletssuite: the V2 root verifies at index 0, a derived address verifies at its own index and is rejected at any other index, and memo-suffixed addresses (root?memoId=5) are never accepted. Also add averifyTransactiontest for the derived-to-root consolidation prebuild shape thatsendAccountConsolidationsends (sender = derived, single bare-root recipient), and assertallowsAccountConsolidations() === true.test/unit/transactionBuilder/transactionBuilder.ts: bare sender-to-receiver round-trip with nomemo(...): both sender ops and the receiver keep their addresses verbatim andmetadata.memois theDEFAULT_MEMOfill-in (0).test/unit/transaction.ts: the memo-suffixed receiver2b9b...dd7b?memoId=0survives verbatim inoperations[1]— builders never strip memo suffixes.Why
sdk-core's
wallet.buildAccountConsolidations,sendAccountConsolidationandsendAccountConsolidationsthrow"<coin> does not allow account consolidations."unlessbaseCoin.allowsAccountConsolidations()is true (modules/sdk-core/src/bitgo/wallet/wallet.ts). sdk-coin-icp never overrode thefalsedefault, so bitgo-retail's consolidate flow fails for ICP before any transaction is built — V2 consolidation from the UI cannot work. The platform enforces V2-only consolidation eligibility (CECHO-2443); this unblocks CECHO-2445.The remaining changes are test-only: the V2 verification contract and the builder address pass-through were only covered at derivation index 0, so a regression in index handling or memo-suffix stripping would ship unnoticed ahead of the V2 rollout.
Issue Number
CECHO-2439
Type of change
How Has This Been Tested?
cd modules/sdk-coin-icp && yarn unit-test— 105 passing (98 existing + 7 new). New-behavior proof: the same derived address verifies atindex: 1and is rejected atindex: 0. Pass-through proof: bare addresses appear verbatim withmetadata.memo === 0, and the?memoId=0recipient survives unchanged.cd modules/sdk-coin-icp && yarn lint && yarn check-fmt— clean.cd modules/sdk-coin-icp && yarn build-ts— compiles (the module tsconfig includestest/**/*).cd modules/sdk-core && yarn unit-test— passes unchanged (no sdk-core edits).Checklist:
Ticket: CECHO-2439