Repository navigation
fix(statics): never swap known coins for a different coin class - #9971
Draft
ralph-bitgo[bot] wants to merge 1 commit into
Draft
ralph-bitgo[bot] wants to merge 1 commit into
ralph-bitgo[bot] wants to merge 1 commit into
Conversation
What: createToken() refreshes a known coin only when both the existing record and the AMS entry are tokens, and CoinMap.replace now rejects a candidate whose constructor differs from the record it would replace. Tests cover valid-UUID AMS entries for tlnbtc and btc and a DynamicCoin attempting to replace btc. Why: statics 15.1.1-beta.2138 rebuilt known base chains from AMS entries, so a LightningCoin such as tlnbtc became a generic DynamicCoin. Downstream abstract-lightning threw "coin is not a lightning coin", getCoinSingletons() failed in every wallet-platform process on staging, and ERC-7984 unwrap journeys cannot finish until coin singletons work. Ticket: CSHLD-1957 Session-Id: 0d9fb72f-b6e4-4906-8aad-9b1608911df4 Task-Id: 5c117f14-0e09-4396-b8fb-58501604623a
Contributor
Contributor
|
|
prajwalu142
marked this pull request as ready for review
October 14, 2026 14:45
prajwalu142
marked this pull request as draft
October 14, 2026 14:45
This branch has not been deployed
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
Fixes CSHLD-1957.
createToken()in@bitgo/staticsrefreshed any coin matched by an AMS entry — including known base chains — rebuilding it as a genericDynamicCoin. ALightningCoinsuch astlnbtcwas swapped out, so downstream@bitgo/abstract-lightningthrewcoin is not a lightning coinandgetCoinSingletons()failed in every wallet-platform process on staging (regression from #9922, shipped via@bitgo-beta/statics@15.1.1-beta.2138).What changed
modules/statics/src/coins.ts—createToken()now refreshes a known coin only when both the existing record and the AMS entry are tokens; known base coins keep their static record.modules/statics/src/map.ts—CoinMap.replace()rejects a candidate whose coin class differs from the record it would replace (coin '<name>' cannot be replaced: coin class changed from <Class> to <Class>), checked after the existing immutable-field checks so identity mismatches keep their specific errors.modules/statics/test/unit/coins.ts— regression tests: valid-UUID AMS entries fortlnbtc(LightningCoin) andbtc(UtxoCoin) preserve identity and class throughcreateTokenUsingTrimmedConfigDetailsandcreateTokenMapUsingTrimmedConfigDetails; aDynamicCoincan no longer replacebtc; the same-class base-coin refresh fixture now keeps the candidate's prototype. This replaces the previous test that passed only because it used the invalid id'btc'.Why
Staging is broken for every wallet-platform process that builds coin singletons (
/startupreadyclient-constants check, market-data worker, ERC-7984 unwrap decrypt worker), and an ERC-7984 unshield journey is stuck inDECRYPT_PENDING, retrying every ~15 minutes until coin lookups work again. The commit that introducedCoinMap.replacedocumented that replacement "only swaps when both records are tokens", but the shipped code never enforced it, so an AMS entry for a known base chain could swapLightningCoinforDynamicCoin.Issue Number
CSHLD-1957 (related: CSHLD-1936, CHALO-1809)
Type of change
How Has This Been Tested?
@bitgo/staticsunit suite (npx mochainmodules/statics): 39702 passing, 0 failing.tlnbtcviacreateTokenMapUsingTrimmedConfigDetails, and forbtcviacreateTokenUsingTrimmedConfigDetails): before the fix both becameDynamicCoin; after the fixLightningCoin/UtxoCoinand object identity are preserved. Repro script deleted after verification.yarn build(tsc) inmodules/statics, pluseslintandprettier --checkon the three changed files: 0 errors.Checklist
Ticket: CSHLD-1957