Repository navigation
feat: allow updating already-registered coins via replaceExistingCoin - #9922
Merged
Merged
Conversation
Contributor
Contributor
|
|
prajwalu142
force-pushed
the
CSHLD-863-replace-existing-coin-fields
branch
6 times, most recently
from
October 8, 2026 10:35
53cca16 to
8ca89b8
Compare
veetragjain
reviewed
Oct 8, 2026
veetragjain
reviewed
Oct 8, 2026
prajwalu142
force-pushed
the
CSHLD-863-replace-existing-coin-fields
branch
from
October 8, 2026 12:06
8ca89b8 to
8b99134
Compare
Problem/goal: createToken and the token map builders skip any coin already present in the static coin map, so an AMS payload for an existing token can never refresh its modifiable fields (features, fullName, decimalPlaces) without a statics release. Goal: let AMS update known tokens while the fields that define the asset stay immutable. Implementation details: - CoinMap.replace only swaps when the old and new records are both tokens and agree on id, symbol (prefix + suffix), contract address and alias. Otherwise the existing record is kept. Coins not yet in the map are still added. - createToken no longer returns the stale static record. For a known token it constructs the token, calls coins.replace, and returns the record the map holds. A config that fails token validation keeps the existing record instead of throwing. The initializer switch moved into a private constructToken. - createTokenMapUsingConfigDetails mirrors a refreshed token into its rebuilt map. The two trimmed-config gates now only skip known base chains; known tokens flow through the refresh path. Verification: Statics unit suite: 39324 passing, 0 failing. eslint on the changed files: 0 errors. New replace tests cover a matching swap with index lookups by name, id and contract address, and keeping the existing record on a differing symbol, contract address, alias or id and for base coins. The old precedence tests were rewritten to the new contract and the AMS fixture suite restores the global coin map afterwards. Ticket: CSHLD-863
prajwalu142
force-pushed
the
CSHLD-863-replace-existing-coin-fields
branch
from
October 9, 2026 12:10
8b99134 to
787e718
Compare
veetragjain
approved these changes
Oct 13, 2026
prajwalu142
marked this pull request as ready for review
October 13, 2026 09:21
10 of 13 tasks
prajwalu142
added a commit
that referenced
this pull request
Oct 19, 2026
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
added a commit
that referenced
this pull request
Oct 19, 2026
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
added a commit
that referenced
this pull request
Oct 19, 2026
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
added a commit
that referenced
this pull request
Oct 19, 2026
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
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.
Problem
createTokenMapUsingTrimmedConfigDetails and createToken skip any coin
already present in the static coin map (statics wins), so an AMS payload
for an existing coin can never change its features without a statics
release and a consumer redeploy.
Goal
Let AMS payloads update already-registered coins for allowlisted fields
only, keeping identity/structural fields immutable, so feature changes
reach consumers without a statics release — without ever crashing the
registration process on a malformed payload.
Fix
replaceExistingCoin(token)in statics: replacesthe registered entry with a frozen, prototype-preserving copy —
existing values copied verbatim, features taken from the config. Full
feature sets apply verbatim; delta-only configs merge onto the
registered coin's CURRENT features (existing ∪ additionalFeatures −
excludedFeatures), so statics-migration rows with empty deltas no-op.
No-op returning the same registered object when nothing differs.
Rebuilds all CoinMap indexes (name, id, alias, contract address, NFT
collection).
alias,symbol,contractAddress): a payload claimingdifferent values for a blocklisted field is ignored with a warning
— the registered entry stays untouched; malformed updates never crash
registration.
nameremains replaceable.isCoinPresentInCoinMapspot with the normal flowpreserved (no loop breaks):
createTokenpresent branch;createTokenMapUsingConfigDetailsloop (if/else — replaced entryre-pointed into BaseCoins);
createTokenMapUsingTrimmedConfigDetailsand
createTokenUsingTrimmedConfigDetails. New-token paths reuse theexisting
getTokenFeatureshelper instead of inline feature merges.Testing
New
replaceExistingCoinsuite: replace + index rebuild, no-op on equalfeatures, delta merge with dedupe across repeated refreshes, verbatim
copy of existing values, blocklisted-field payloads ignored (registered
coin returned untouched), unregistered coin throws. Contract pin updated
to the new update semantics; builder tests passing configs for
already-registered coins restore touched entries so the global map stays
pristine across suites. Full statics suite 39324 passing / 0 failing;
tsc and eslint clean.
Ticket: CSHLD-863
🤖 Generated with Claude Code