Skip to content

Conversation

@GuiltyCrownne
Copy link

Summary:

  • Adds a reusable utility to fetch a user’s Stellar token balance and accompanying tests.
  • Changes
  • Add src/utils/getTokenBalance.ts using stellar-sdk (Horizon testnet by default).
  • Export server for easier mocking in tests.
  • Add src/utils/getTokenBalance.test.ts with 4 cases (custom token, no holding, XLM, error).
  • Add stellar-sdk dependency.

Tests

  • Jest tests cover success, no balance, native asset, and error fallback to '0'.
  • Notes
  • Safe defaults; returns '0' on errors or missing assets.

Closes #242

Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! I cannot test but it looks good!
Please make the requested change and test it!

@@ -0,0 +1,49 @@
import { Server, Asset } from "stellar-sdk";
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you import new modules, please update the package.json accordingly.
Also, I installed the package manually, and it says "Module '"stellar-sdk"' has no exported member 'Server'. Did you mean to use 'import Server from "stellar-sdk"' instead?".
(Maybe because you have a different version of the package than me, so that's why it's important to update the package.json)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add network-level cron configuration to automatically refresh user configs

2 participants