fix(statics): skip AMS tokens that reuse a static contract address or NFT collection id#8957
Closed
mmcshinsky-bitgo wants to merge 1 commit into
Closed
fix(statics): skip AMS tokens that reuse a static contract address or NFT collection id#8957mmcshinsky-bitgo wants to merge 1 commit into
mmcshinsky-bitgo wants to merge 1 commit into
Conversation
9a29706 to
d9db10b
Compare
Contributor
Author
|
Like #8959, will let coins team move forward with this. |
d9db10b to
7db3b4e
Compare
… nft collection id The ams<->static merge in createTokenMapUsingConfigDetails dedups via isCoinPresentInCoinMap, which only matches on name/id/alias -- never the contract address. An AMS-served token that reuses a contract address (or NFT collection id) already claimed by a static token under a different name slips through, and CoinMap.fromCoins -> addCoin then throws DuplicateContractAddressDefinitionError, aborting the entire token-map build for every consumer. Add CoinMap.hasTokenAddressConflict(coin) -- reusing the map's own contractAddressKey / nftCollectionIdKey derivation against its populated address/NFT indexes -- and use it in the merge loop to skip a colliding token instead of crashing. Statics coins are seeded first, so statics stays the source of truth and the colliding AMS token is the one dropped. Covers both contract-address and NFT-collection-id collisions. Surfaced by the eth:at bot token (0x0581ccdf...aa, eth testnet) added in #8885; the live AMS config serves a token at the same address under a different name. Supersedes the handoff reference in #8959 (closed). CSHLD-976
7db3b4e to
8e16a1c
Compare
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.
Fixes CSHLD-976. Supersedes the handoff reference #8959 (closed by @zahin-mohammad — "will let the coins team take this forward"); this adopts that PR's
hasTokenAddressConflictdesign.Problem
The AMS↔static merge in
createTokenMapUsingConfigDetails(and the…Trimmed…variant that calls it) dedups viaisCoinPresentInCoinMap(coins.ts:434), which only matches on name / id / alias — never the contract address:But
CoinMap.fromCoins→addCoin(map.ts:62-68) also dedups by contract address (family:network.type:contractAddress) and NFT collection id. An AMS-served token reusing a contract a static token already claims under a different name slips the guard and throwsDuplicateContractAddressDefinitionError, aborting the entire token-map build for every consumer (bitgo-retail hydration, bitgo-admin, bitgo-microservices, indexerdb, prime, client-admin,bitgo.ts, …).Surfaced by the static
eth:atbot token (0x0581ccdf…, eth testnet, added in #8885 /@bitgo/statics@58.43.0) colliding with the live AMS token at the same address under a different name.Fix
Add
CoinMap.hasTokenAddressConflict(coin)— reusing the map's own privatecontractAddressKey/nftCollectionIdKeyderivation against its populated_coinByContractAddress/_coinByNftCollectionIDindexes — and use it in the merge loop:Statics coins are seeded first, so statics stays the source of truth and the colliding AMS token is the one skipped. Checking the built coin against the map's own indexes means the key derivation/normalization always matches
addCoin(no parallel bookkeeping, no public key-builder surface). Covers contract-address and NFT-collection-id collisions. Strict statics self-construction is unchanged (still throws on genuine duplicates at build/test time).Acceptance criteria (CSHLD-976)
nftCollectionIdKey)Scope note
Targets the static↔AMS collision (the incident). A hypothetical AMS↔AMS duplicate (two server tokens at the same address, neither in statics) is a separate, pre-existing AMS data-integrity concern — left to surface rather than be silently masked here; the bitgo-retail guard (#6934) keeps it from crashing the UI.
Verification
npx mocha test/unit/coins.ts→ 28768 passing (incl. new test)tsc --buildclean,prettier --checkcleanRelated
eth:testnet:0x0581ccdf…under a different name. (Earlier statics-removal PR fix(statics): remove stale eth:at bot token colliding with live AMS #8960 was closed for this reason.)🤖 Generated with Claude Code