Repository navigation
CSHLD-863: feat(statics): identity-guarded AMS refresh of already-registered coins - #10004
Draft
prajwalu142 wants to merge 1 commit into
Draft
prajwalu142 wants to merge 1 commit into
prajwalu142 wants to merge 1 commit into
Conversation
Contributor
Contributor
|
|
prajwalu142
force-pushed
the
prajwalu/cshld-1957-guarded-token-refresh
branch
3 times, most recently
from
October 19, 2026 11:08
6ac69f4 to
f405dec
Compare
problem/goal Re-land the AMS-driven refresh of already-registered coins that was reverted from statics 2138 (#9970 reverting #9922). The original implementation replaced any known coin matched by an AMS record, including base chains, which swapped LightningCoin for DynamicCoin and broke wallet-platform coin singletons on staging (CSHLD-1957). implementation details - createToken stays pure: known coins are returned untouched; unknown records build via constructToken (extracted from createToken). - createTokenMapUsingConfigDetails owns the refresh: known tokens flow instead of being skipped, and the refreshed record is written through CoinMap.replace, which rejects same-id replacements that change the coin class (CoinClassMismatchError) or the immutable identity fields id, name, alias and contract address (CoinImmutableFieldsMismatchError). Known base chains never reach the refresh path. - createTokenMapUsingTrimmedConfigDetails lets known tokens continue into feature enrichment and delegates the refresh to the config details builder. - New tests pin the base-chain parity canary, the tlnbtc regression, refresh with class preservation, class-swap rejection, per-field identity rejection (id, name, alias, contract address), alias-drop fail-closed on builder refresh, and AMS feature updates flowing through while identity stays untouched. verification npx mocha test/unit/ in modules/statics: 39700 passing, 0 failing; tsc --noEmit clean; eslint clean. Ticket: CSHLD-863
prajwalu142
force-pushed
the
prajwalu/cshld-1957-guarded-token-refresh
branch
from
October 19, 2026 11:17
f405dec to
881f6b6
Compare
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.
Re-lands the AMS-driven refresh of already-registered coins reverted from statics 2138 (#9970 reverting #9922), this time identity-guarded so AMS can never swap a known coin's class or identity.
Problem / Goal
#9922 let
createTokenreplace any known coin matched by an AMS record — including base chains — which rebuilttlnbtcas aDynamicCoinand broke@bitgo-beta/abstract-lightning(coin is not a lightning coin) →getCoinSingletons()failed in every wallet-platform process on staging (CSHLD-1957). This PR restores the feature with the guard rails that were missing:CoinMap.replacethat rejects class changes and identity-field (id / name / contract address) redefinitions.Implementation details
createTokenis pure again: known coins are returned untouched; unknown records build viaconstructToken, extracted fromcreateToken.createTokenMapUsingConfigDetailsowns the refresh: known tokens flow instead of being skipped; the refreshed record is written throughCoinMap.replace, which throwsCoinClassMismatchErroron constructor mismatch andCoinImmutableFieldsMismatchErroron id / name / contract-address drift (failures warn and keep the existing record).createTokenMapUsingTrimmedConfigDetailsenriches and delegates to it.CoinClassMismatchError,CoinImmutableFieldsMismatchErrorinstatics/errors.ts.Verification
npx mocha test/unit/inmodules/statics: 39697 passing, 0 failing, 0 pending — including new fixture-based tests: base-chain parity canary,tlnbtcregression, refresh with class preservation, class-swap rejection, identity-field rejection, per-family replacement.tsc --noEmitclean;eslintclean.Ticket: CSHLD-863