From 8fc8df91d3e776410e82c9554d98248074fe2415 Mon Sep 17 00:00:00 2001 From: MayurK-cmd Date: Thu, 27 Aug 2026 20:38:58 +0530 Subject: [PATCH] fix: add warning for missing token metadata in spot portfolio Previously, when token metadata was unavailable from the API, the spot portfolio command would silently skip tokens without warning the user, leading to incomplete or misleading portfolio displays. Changes: - Add console.warn() when token metadata lookup fails - Include mint address in warning for debugging - Add e2e test verifying command handles missing metadata gracefully --- src/commands/SpotCommand.ts | 3 +++ src/e2e.test.ts | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/commands/SpotCommand.ts b/src/commands/SpotCommand.ts index ab28856..ef238e8 100644 --- a/src/commands/SpotCommand.ts +++ b/src/commands/SpotCommand.ts @@ -400,6 +400,9 @@ export class SpotCommand { } const info = tokenMap.get(mint); if (!info) { + console.warn( + `Warning: Could not fetch metadata for token ${mint}. Skipping.` + ); continue; } const multiplier = Swap.getScaledUiMultiplier(info); diff --git a/src/e2e.test.ts b/src/e2e.test.ts index fc3f878..e58fe17 100644 --- a/src/e2e.test.ts +++ b/src/e2e.test.ts @@ -106,3 +106,13 @@ describe("keys add (dist/index.js)", () => { expect(second.stdout + second.stderr).toContain("already exists"); }); }); + +describe("spot portfolio", () => { + test("handles portfolio lookup without crashing on missing metadata", () => { + // This test verifies that the command completes without crashing + // even if token metadata is unavailable + const result = runCli("spot", "portfolio", "--address", TEST_SEED_ADDRESS); + // Should complete (may fail on API, but not crash on missing metadata) + expect(result.status).toBeLessThanOrEqual(1); + }); +});