Skip to content

refactor: extract shared DateConverter for parseTimestamp - #38

Open
NathanOyewole wants to merge 4 commits into
jup-ag:mainfrom
NathanOyewole:refactor/date-converter-shared
Open

NathanOyewole wants to merge 4 commits into
jup-ag:mainfrom
NathanOyewole:refactor/date-converter-shared

Conversation

@NathanOyewole

Copy link
Copy Markdown

Summary

Fixes #25. Both SpotCommand and PerpsCommand had duplicate parseTimestamp() implementations with inconsistent return formats (ISO vs Unix seconds). Extracted into a shared DateConverter utility in src/lib/.

Changes

  • Created src/lib/DateConverter.ts with toISO() and toUnixSeconds() methods.
  • SpotCommand.parseTimestamp now delegates to DateConverter.toISO().
  • PerpsCommand.parseTimestamp now delegates to DateConverter.toUnixSeconds().

Test plan

  • Verify existing tests pass.
  • Verify timestamp parsing still works in both commands.

Instead of silently skipping tokens with missing metadata, log a warning
and display the token with available on-chain information (mint address,
raw balance). This prevents incomplete portfolio displays without user
awareness.

Fixes jup-ag#24
Replace Promise.all() with Promise.allSettled() so that a single
corrupted or unreadable keypair file no longer crashes the entire
keys list command. Valid keys are still displayed, and a warning
is logged for any that failed to load.

Fixes jup-ag#23
Add client-side validation for the --leverage flag in perps open.
Previously, any non-zero leverage value was accepted, leading to
cryptic API errors. Now throws a clear error if leverage is not
between 1 and 100.

Fixes jup-ag#26
Both SpotCommand and PerpsCommand had duplicate parseTimestamp()
implementations with inconsistent return formats (ISO vs Unix seconds).
Extract into a shared DateConverter utility in src/lib/.

Fixes jup-ag#25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate parseTimestamp() logic across commands

1 participant