feat: regenerate asset data 08/23/2025#10358
Conversation
📝 WalkthroughWalkthroughData-only refresh: updated ERC20 token color mappings, replaced the entire encoded related-asset index JSON, and added migration entry 168 to clear assets. No code signatures, APIs, or runtime logic were modified. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as App Startup
participant M as MigrationRunner
participant S as StateStore
participant A as AssetService
App->>M: init()
M->>S: getCurrentVersion()
M->>M: run pending migrations (0..168)
rect #EEF6FF
note right of M: migration 168 added (clearAssets)
M->>S: clearAssets() -- migration 168
end
App->>A: load color-map.json
A-->>App: token color map loaded
App->>A: load encodedRelatedAssetIndex.json
A-->>App: related asset index loaded
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/state/migrations/index.ts (1)
42-212: Optional: generate the assets migration map to avoid manual off‑by‑one errorsThe hand-enumerated 0..168 pattern is easy to miss on routine bumps. Consider deriving the map programmatically so future regens only change a single integer.
Apply this minimal replacement for the block:
-export const clearAssetsMigrations = { - 0: clearAssets, - 1: clearAssets, - /* …entries 2..167 trimmed for brevity… */ - 167: clearAssets, - 168: clearAssets, -} as unknown as Omit<MigrationManifest, '_persist'> +export const clearAssetsMigrations = Object.fromEntries( + Array.from({ length: 169 }, (_, i) => [i, clearAssets]), +) as unknown as Omit<MigrationManifest, '_persist'>If you prefer readability, a tiny helper avoids magic numbers:
const makeMigrationMap = (last: number) => Object.fromEntries(Array.from({ length: last + 1 }, (_, i) => [i, clearAssets])) as unknown as Omit<MigrationManifest, '_persist'> export const clearAssetsMigrations = makeMigrationMap(168)scripts/generateAssetData/color-map.json (1)
525-531: Routine generated data refresh — safe to skip detailed reviewThis is machine-generated, data-only, and follows filename kebab-case and .json extension guidelines. If desired, add a “coderabbitai:ignore” label/pattern to auto-skip future “feat: regenerate asset data …” PRs. I can help set that up.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (7)
packages/caip/src/adapters/coincap/generated/eip155_1/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_1/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_42161/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_43114/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_56/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_8453/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/solana_5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/adapter.jsonis excluded by!**/generated/**
📒 Files selected for processing (3)
scripts/generateAssetData/color-map.json(24 hunks)src/lib/asset-service/service/encodedRelatedAssetIndex.json(1 hunks)src/state/migrations/index.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)
**/*.{ts,tsx}: ALWAYS use Result<T, E> pattern for error handling in swappers and APIs
ALWAYS use Ok() and Err() from @sniptt/monads for monadic error handling
ALWAYS use custom error classes from @shapeshiftoss/errors
ALWAYS provide meaningful error codes for internationalization
ALWAYS include relevant details in error objects
ALWAYS wrap async operations in try-catch blocks
ALWAYS use AsyncResultOf utility for converting promises to Results
ALWAYS provide fallback error handling
ALWAYS use timeoutMonadic for API calls
ALWAYS provide appropriate timeout values for API calls
ALWAYS handle timeout errors gracefully
ALWAYS validate inputs before processing
ALWAYS provide clear validation error messages
ALWAYS use early returns for validation failures
ALWAYS log errors for debugging
ALWAYS use structured logging for errors
ALWAYS include relevant context in error logs
Throwing errors instead of using monadic patterns is an anti-pattern
Missing try-catch blocks for async operations is an anti-pattern
Generic error messages without context are an anti-pattern
Not handling specific error types is an anti-pattern
Missing timeout handling is an anti-pattern
No input validation is an anti-pattern
Poor error logging is an anti-pattern
Using any for error types is an anti-pattern
Missing error codes for internationalization is an anti-pattern
No fallback error handling is an anti-pattern
Console.error without structured logging is an anti-pattern
**/*.{ts,tsx}: ALWAYS use camelCase for variables, functions, and methods
ALWAYS use descriptive names that explain the purpose for variables and functions
ALWAYS use verb prefixes for functions that perform actions
ALWAYS use PascalCase for types, interfaces, and enums
ALWAYS use descriptive names that indicate the structure for types, interfaces, and enums
ALWAYS use suffixes like Props, State, Config, Type when appropriate for types and interfaces
ALWAYS use UPPER_SNAKE_CASE for constants and configuration values
ALWAYS use d...
Files:
src/state/migrations/index.ts
**/*
📄 CodeRabbit inference engine (.cursor/rules/naming-conventions.mdc)
**/*: ALWAYS use appropriate file extensions
Flag files without kebab-case
Files:
src/state/migrations/index.tssrc/lib/asset-service/service/encodedRelatedAssetIndex.jsonscripts/generateAssetData/color-map.json
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/react-best-practices.mdc)
USE Redux only for global state shared across multiple places
Files:
src/state/migrations/index.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: NeOMakinG
PR: shapeshift/web#10136
File: src/lib/asset-service/service/encodedRelatedAssetIndex.json:1-1
Timestamp: 2025-07-29T10:22:27.037Z
Learning: PRs with titles starting with "feat: regenerate asset data" are routine daily asset updates that don't need detailed code analysis. Users prefer to skip automated reviews for these maintenance PRs using coderabbitai ignore.
🧬 Code graph analysis (1)
src/state/migrations/index.ts (1)
src/state/migrations/clearAssets.ts (1)
clearAssets(6-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Install and Cache
🔇 Additional comments (28)
src/state/migrations/index.ts (2)
211-212: LGTM: added assets migration 168 to clear persisted assets after data refreshThis keeps the “clear on rehydrate” behavior aligned with today’s asset data regen. No issues spotted.
42-212: TheassetsPersistConfig.versionis computed dynamically—no manual bump neededThe
versioninassetsPersistConfigusesMath.max(...Object.keys(clearAssetsMigrations).map(Number)), so it will always equal the highest migration key (which your script confirmed is 168 and that keys 0–168 are contiguous). You don’t need to manually bump a static version number here—this review comment can be removed.Likely an incorrect or invalid review comment.
src/lib/asset-service/service/encodedRelatedAssetIndex.json (2)
1-1: LGTM: data-only related-asset index refreshLooks machine-generated; schema (object of numeric-string keys → arrays of ints) remains consistent. Combined with the new assets migration, this should safely invalidate stale persisted relations on rehydrate.
1-1: Sanity checks passed for encodedRelatedAssetIndex.jsonAll validations succeeded without issues:
- JSON is a top-level object and parses correctly.
- Every key is a numeric string, and every value is an array of non-negative integers.
- No per-key duplicate related IDs were found.
- Stats: 1,379 keys with an average of ~2.68 related IDs per key.
These checks can safely be wired into CI for any future “regenerate asset data” PRs.
scripts/generateAssetData/color-map.json (24)
528-528: LGTM: added mainnet color mappingKey format and lowercase address are consistent; color is valid #RRGGBB.
2426-2426: LGTM: added mainnet color mappingSchema and color format look correct.
2467-2467: LGTM: added mainnet color mappingAll conventions respected.
2792-2792: LGTM: added mainnet color mappingNo issues spotted.
4516-4519: LGTM: added two mainnet mappingsBoth entries conform to key and color formats.
4546-4546: LGTM: added mainnet color mappingConsistent with neighboring entries.
5119-5119: LGTM: added mainnet color mappingValid hex color and normalized address.
7840-7840: LGTM: added Arbitrum color mappingFormat and casing look good.
7926-7926: LGTM: added Arbitrum color mappingNo schema deviations.
8048-8048: LGTM: added Arbitrum color mappingAll good.
8347-8347: LGTM: added Arbitrum color mappingEntry is well-formed.
8958-8958: LGTM: added Avalanche color mappingValid color; address normalized.
9388-9388: LGTM: added BSC color mappingKey uses bep20 namespace as expected; color valid.
11443-11443: LGTM: added BSC color mappingConsistent with prior conventions.
11514-11514: LGTM: added BSC color mappingLooks correct.
11697-11697: LGTM: added BSC color mappingAll good.
12417-12417: LGTM: added Base color mappingSchema and color check out.
12532-12532: LGTM: added Base color mappingNo issues.
12578-12578: LGTM: added Base color mappingEntry is well-formed.
12603-12603: LGTM: added Base color mappingValid #RRGGBB.
12905-12905: LGTM: added Base color mappingConforms to established pattern.
12963-12963: LGTM: added Base color mappingNo concerns.
13250-13250: LGTM: added Base color mappingEverything looks consistent.
13724-13724: LGTM: added Base color mappingAddress normalization and color format are correct.
4601e01 to
81006e2
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/lib/asset-service/service/encodedRelatedAssetIndex.json (2)
1-1: Filename isn’t kebab-case per guidelinesCoding guidelines say to flag files without kebab-case. This file is camelCase (encodedRelatedAssetIndex.json). If/when feasible, consider aligning to kebab-case (e.g., encoded-related-asset-index.json) via a low-risk, repo-wide rename coordinated with import paths and generators. Not blocking.
1-1: Add CI step to validate encodedRelatedAssetIndex.json schema and duplicatesWe’ve confirmed that the following shell snippet successfully parses the JSON, ensures the top‐level is an object, all values are arrays of non-negative integers, and each array has no duplicate entries:
#!/bin/bash set -euo pipefail FILE="src/lib/asset-service/service/encodedRelatedAssetIndex.json" # Parse and basic JSON validity jq -e . "$FILE" >/dev/null # Schema & duplicate checks jq -e ' (type=="object") and ([.[] | type=="array"] | all) and ([.[] | all(.[]; (type=="number") and (floor==.) and .>=0)] | all) and ([.[] | (length == (unique | length))] | all) ' "$FILE" >/dev/null echo "encodedRelatedAssetIndex.json schema/dup checks passed."Please integrate this guard into our CI pipeline:
- Add the script (e.g.
scripts/validate-encodedRelatedAssetIndex.sh) and mark it executable.- Modify
.github/workflows/ci.yml(or equivalent) to invoke this script as a pre-test step.This will prevent accidental schema regressions or duplicate entries in the index.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (7)
packages/caip/src/adapters/coincap/generated/eip155_1/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_1/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_42161/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_43114/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_56/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_8453/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/solana_5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/adapter.jsonis excluded by!**/generated/**
📒 Files selected for processing (3)
scripts/generateAssetData/color-map.json(39 hunks)src/lib/asset-service/service/encodedRelatedAssetIndex.json(1 hunks)src/state/migrations/index.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/state/migrations/index.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*
📄 CodeRabbit inference engine (.cursor/rules/naming-conventions.mdc)
**/*: ALWAYS use appropriate file extensions
Flag files without kebab-case
Files:
src/lib/asset-service/service/encodedRelatedAssetIndex.jsonscripts/generateAssetData/color-map.json
🧠 Learnings (1)
📓 Common learnings
Learnt from: NeOMakinG
PR: shapeshift/web#10136
File: src/lib/asset-service/service/encodedRelatedAssetIndex.json:1-1
Timestamp: 2025-07-29T10:22:27.037Z
Learning: PRs with titles starting with "feat: regenerate asset data" are routine daily asset updates that don't need detailed code analysis. Users prefer to skip automated reviews for these maintenance PRs using coderabbitai ignore.
🔇 Additional comments (41)
src/lib/asset-service/service/encodedRelatedAssetIndex.json (1)
1-1: Data-only refresh from CI — LGTMMatches the “routine daily asset updates” pattern from prior learnings; no runtime logic touched. Proceeding with a light review as requested historically.
scripts/generateAssetData/color-map.json (40)
131-131: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0x044e874f23f9a7e5dad696554a116c4bb62fecb7 → #04E373 looks valid (lowercased address, 6-digit hex).
529-529: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0x15e8c742614b5d8db4083a41df1a14f5d2bfb400 → #2F2F2F passes format checks.
832-832: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0x2418055d547bd210c944f73b5a7288ea05d087e7 → #2474CC passes format checks.
1941-1941: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0x53b560979a31dcb0d866edc1bbfeb1214c7e7f8a → #2474CC looks consistent with the palette used elsewhere.
2468-2468: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0x69b1ac639c0153b8eae75e4c19a176d07071683c → #C2AF1E validated.
2793-2793: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0x76b6f7bd8857195c5165a49a6ff75f84a3f081ca → #653E4F validated.
4120-4120: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0xb253ade07051c71be64c235f38fdd5db6753f3bd → #202F33 validated.
4514-4514: LGTM: new mainnet color mappings added
- eip155:1/erc20:0xc2d09cf86b9ff43cb29ef8ddca57a4eb4410d5f3 → #046BFC
- eip155:1/erc20:0xc311fd6da9686507f33991543d8158ef5fadd5e7 → #FBD35B
Both entries conform to address and hex format conventions.Also applies to: 4517-4517
4544-4544: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0xc42d337861878baa4dc820d9e6b6c667c2b57e8a → #2474CC validated.
4587-4587: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0xc5e17741d6717acda377fb3a13174d912e968c6d → #487663 validated.
5116-5116: LGTM: new mainnet color mapping addedKey eip155:1/erc20:0xdd9f61a85ffe73e41ef889817972f0b0aae6d6dd → #FBA486 validated.
7835-7835: LGTM: new Arbitrum color mapping addedKey eip155:42161/erc20:0x77198965565e945f1b7ba02d39b1fb49510c83ed → #E0AFC5 validated.
7921-7921: LGTM: new Arbitrum color mapping addedKey eip155:42161/erc20:0x8be4715f1db9e8551fea5ef8b30a2eb99398e5d2 → #E0AFC5 validated.
8043-8043: LGTM: new Arbitrum color mapping addedKey eip155:42161/erc20:0xaabb9cbac15a3d646dcdc6574bcfcfb989e1fdd8 → #065756 validated.
8212-8212: LGTM: new Arbitrum color mapping addedKey eip155:42161/erc20:0xd6be2dc6767da105b73e1e78f9a61fe4eb9b03e0 → #406695 validated.
8343-8343: LGTM: new Arbitrum color mapping addedKey eip155:42161/erc20:0xf617792ea9dceb2208f4c440258b21d2f3fdb9a3 → #406695 validated.
8954-8954: LGTM: new Avalanche color mapping addedKey eip155:43114/erc20:0xeec951bfdeb358371a19512c6c33cdd840d47db0 → #F5DA64 validated.
9383-9383: LGTM: new BSC color mapping addedKey eip155:56/bep20:0x2056d14a4116a7165cfeb7d79db760a06b57dbca → #CCB07A validated.
9988-9988: LGTM: new BSC color mapping addedKey eip155:56/bep20:0x527be6fa23ff71e3faf5c2c1511b0531b67a701d → #050404 validated.
10075-10075: LGTM: new BSC color mapping addedKey eip155:56/bep20:0x58b4441b97c577b66e46aa155e04dc4652fd0d34 → #050404 validated.
10962-10962: LGTM: new BSC color mapping addedKey eip155:56/bep20:0x9cfae8067322394e34e6b734c4a3f72acc4a7fe5 → #090706 validated.
11028-11028: LGTM: new BSC color mapping addedKey eip155:56/bep20:0xa23e43ff30b6bb9972a6c6617a9aebad34adca3f → #050404 validated.
11358-11358: LGTM: new BSC color mapping addedKey eip155:56/bep20:0xbcba33bf0b3cd8d626b7a3732a3ee18a0af51bd0 → #050504 validated.
11443-11443: LGTM: cross-network color consistency noteKey eip155:56/bep20:0xc2d09cf86b9ff43cb29ef8ddca57a4eb4410d5f3 → #046BFC. Same color appears on mainnet and Base for this address family; good cross-network consistency.
11514-11514: LGTM: new BSC color mapping addedKey eip155:56/bep20:0xc940a6746f8ffa8a9476c116030e5d4baded805a → #B69526 validated.
11652-11652: LGTM: new BSC color mapping addedKey eip155:56/bep20:0xd5cee155593f7a5da4db3181e8af6a37e73f6c8f → #9BF3EC validated.
11698-11698: LGTM: new BSC color mapping addedKey eip155:56/bep20:0xd955c9ba56fb1ab30e34766e252a97ccce3d31a6 → #6B82EC validated.
11951-11951: LGTM: new BSC color mapping addedKey eip155:56/bep20:0xee61a49a180cd23c3e629c5a70c1ee6539c004bd → #050404 validated.
12201-12201: LGTM: new Base color mapping addedKey eip155:8453/erc20:0x0390a285c97f04c6ac9d162352b44e6fc310d3f2 → #302E2A validated.
12225-12225: LGTM: new Base color mapping addedKey eip155:8453/erc20:0x06a05043eb2c1691b19c2c13219db9212269ddc5 → #E4E4E4 validated.
12421-12421: LGTM: new Base color mapping addedKey eip155:8453/erc20:0x1d69c205416c683e3d0efc93b76a78ee7755945c → #08A2C8 validated.
12536-12536: LGTM: new Base color mapping addedKey eip155:8453/erc20:0x2c159a183d9056e29649ce7e56e59ca833d32624 → #CEDDFC validated.
12582-12582: LGTM: new Base color mapping addedKey eip155:8453/erc20:0x323ac72a3a6267d97427944989b896fb411fdcbb → #E32433 validated.
12907-12907: LGTM: new Base color mapping addedKey eip155:8453/erc20:0x5fe2de3e565a6a501a4ec44aab8664b1e1d674ac25 → #EBEBE3 validated.
12965-12965: LGTM: new Base color mapping addedKey eip155:8453/erc20:0x6557207175c770cb441ae9a476e67586b0737773 → #07C30D validated.
13250-13250: LGTM: new Base color mapping addedKey eip155:8453/erc20:0x8dd524a86195a6ef95304e7f0dd9c405a2e78859 → #ED8F34 validated.
13650-13650: LGTM: cross-network color consistency noteKey eip155:8453/erc20:0xc2d09cf86b9ff43cb29ef8ddca57a4eb4410d5f3 → #046BFC. Color matches mainnet/BSC entries; consistency retained.
13725-13725: LGTM: new Base color mapping addedKey eip155:8453/erc20:0cbeef01994e24a60f7dcb8de98e75ad8bd4ad60d → #2474CC validated.
14083-14083: LGTM: new Base color mapping addedKey eip155:8453/erc20:0xfca9fc2cb2dde04732ad07e4bb73db8cc8bfed1d → #202F33 validated.
128-14086: All ERC20/BEP20 entries pass validation; only manually-coded native (slip44/bip122/cosmos) keys were flagged as expectedThe validator reports 15 “bad keys” and 2 “bad values,” but these all correspond to manually-added native assets (bip122, cosmos, and slip44 entries) that our generation/validation script isn’t intended to cover. Every eip155:*/(erc20|bep20):0x… mapping—i.e. the auto-generated token entries—is correctly formatted (lowercase 0x address and #RRGGBB color).
• No malformed ERC20/BEP20 keys or color values found
• Native‐asset entries (slip44, bip122, cosmos) can safely be ignored by the validator
• (Optional) You may refine the script to skip those manual keys in future CI checks
0xApotheosis
left a comment
There was a problem hiding this comment.
Diff sane, runtime check sane.
Generated from CI.
Summary by CodeRabbit