Skip to content

feat(solana): override tokens#1479

Merged
shoom3301 merged 2 commits into
mainfrom
feat/solana-overrides
Jul 15, 2026
Merged

feat(solana): override tokens#1479
shoom3301 merged 2 commits into
mainfrom
feat/solana-overrides

Conversation

@shoom3301

@shoom3301 shoom3301 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

The source of tokens doesn't define SOL and WSOL well, so I added a static SolanaOverrides.json to control that.
In the future we can use it to fix other tokens.

Summary by CodeRabbit

  • New Features

    • Added support for curated Solana token overrides, including SOL and WSOL metadata.
    • Token overrides can now add or replace entries in the generated token list.
    • Added Token-2022 metadata for supported tokens.
  • Bug Fixes

    • Corrected Wrapped SOL symbol display from SOL to WSOL.
    • Improved filtering of invalid or unsupported token entries.
  • Chores

    • Standardized the project’s package manager configuration.

@shoom3301 shoom3301 requested review from a team and limitofzero July 14, 2026 11:30
@shoom3301 shoom3301 self-assigned this Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Yarn package manager metadata, refreshes Solana token data, introduces SOL/WSOL overrides, and updates generation to validate Jupiter tokens, merge overrides, sort output, and report validation drops.

Changes

Solana token generation

Layer / File(s) Summary
Solana token data and overrides
src/public/SolanaDefault.json, src/public/SolanaOverrides.json
Refreshes Solana metadata and token entries, changes wrapped SOL to WSOL, and defines SOL and WSOL override records.
Override loading and generation flow
src/scripts/solana.ts
Loads and validates overrides, merges them by address with Jupiter tokens, reports validation counts, sorts the result, and writes the output.

Package manager metadata

Layer / File(s) Summary
Yarn package manager declaration
package.json
Adds the top-level Yarn version and checksum declaration.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant main
  participant JupiterStrictSet
  participant readOverrides
  participant applyOverrides
  main->>JupiterStrictSet: validate and map tokens
  main->>readOverrides: load SolanaOverrides.json
  readOverrides-->>main: override entries
  main->>applyOverrides: merge Jupiter tokens and overrides
  applyOverrides-->>main: replaced and appended tokens
  main->>main: sort tokens and write output
Loading

Suggested reviewers: limitofzero, kernelwhisperer

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the core change: adding Solana token overrides.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/solana-overrides

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/scripts/solana.ts (1)

112-125: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Validate override entries and guard JSON.parse.

readOverrides() guards the missing-file and non-array cases but then does an unchecked JSON.parse (throws uncaught on malformed JSON, crashing the whole generation run) and casts parsed as TokenInfo[] without checking that each entry actually has the required TokenInfo fields (chainId, address, name, symbol, decimals). Since the PR objective states this file is meant to be hand-extended for other tokens over time, a future typo/missing field would silently propagate into SolanaDefault.json instead of being caught here, the way isValidToken already catches malformed Jupiter entries.

♻️ Proposed fix: guard parsing and validate entries
+function isValidOverride(t: unknown): t is TokenInfo {
+  const o = t as Partial<TokenInfo>
+  return Boolean(
+    o &&
+      typeof o.address === 'string' &&
+      typeof o.name === 'string' &&
+      typeof o.symbol === 'string' &&
+      Number.isInteger(o.decimals) &&
+      (o.decimals ?? -1) >= 0 &&
+      typeof o.chainId === 'number',
+  )
+}
+
 function readOverrides(): TokenInfo[] {
   const filePath = path.join(SRC_DIR, OVERRIDES_FILE)
   if (!fs.existsSync(filePath)) {
     console.log(`No overrides file at ${filePath}, skipping`)
     return []
   }
-  const parsed = JSON.parse(fs.readFileSync(filePath, 'utf-8'))
+  let parsed: unknown
+  try {
+    parsed = JSON.parse(fs.readFileSync(filePath, 'utf-8'))
+  } catch (e) {
+    console.warn(`Failed to parse ${OVERRIDES_FILE}, skipping overrides: ${e}`)
+    return []
+  }
   if (!Array.isArray(parsed)) {
     console.warn(`Unexpected ${OVERRIDES_FILE} shape (expected array), skipping overrides`)
     return []
   }
-  return parsed as TokenInfo[]
+  const valid = parsed.filter(isValidOverride)
+  if (valid.length !== parsed.length) {
+    console.warn(`Dropped ${parsed.length - valid.length} malformed override entries`)
+  }
+  return valid
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/scripts/solana.ts` around lines 112 - 125, Update readOverrides() to
catch JSON.parse failures and return no overrides with a warning instead of
allowing malformed JSON to abort generation. After confirming the parsed value
is an array, validate every entry using the existing isValidToken validation or
equivalent checks for chainId, address, name, symbol, and decimals; return an
empty override list and warn when any entry is invalid, and only then treat the
entries as TokenInfo[].
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Around line 74-75: Update the shared CI setup before the yarn install step to
enable Corepack and activate the packageManager-declared Yarn 1.22.22 version,
ensuring the existing yarn install --frozen-lockfile command uses the pinned
Yarn release.

---

Nitpick comments:
In `@src/scripts/solana.ts`:
- Around line 112-125: Update readOverrides() to catch JSON.parse failures and
return no overrides with a warning instead of allowing malformed JSON to abort
generation. After confirming the parsed value is an array, validate every entry
using the existing isValidToken validation or equivalent checks for chainId,
address, name, symbol, and decimals; return an empty override list and warn when
any entry is invalid, and only then treat the entries as TokenInfo[].
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e9c66230-02d2-44e4-849f-f781eebd7992

📥 Commits

Reviewing files that changed from the base of the PR and between b0b29cd and e98cd8b.

📒 Files selected for processing (4)
  • package.json
  • src/public/SolanaDefault.json
  • src/public/SolanaOverrides.json
  • src/scripts/solana.ts

Comment thread package.json Outdated
@shoom3301 shoom3301 merged commit 7b3d9cc into main Jul 15, 2026
5 checks passed
@shoom3301 shoom3301 deleted the feat/solana-overrides branch July 15, 2026 13:12
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants