Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow optional "fetch_balance" parameter on /token-details route #204

Merged
merged 4 commits into from
Feb 7, 2025

Conversation

CassioMG
Copy link
Contributor

@CassioMG CassioMG commented Feb 6, 2025

Related: https://github.com/orgs/stellar/projects/58/views/2?pane=issue&itemId=80122477&issue=stellar%7Cfreighter%7C1646

Given the new "Add Token" API we are implementing on freighter's extension we'll need to return the token balance along with its other details in order to display it on the popup's UI (see comments) so users are aware of the new balance info.

@stellar-jenkins
Copy link

Something went wrong with PR preview build please check

network: NetworkNames
): Promise<{ name: string; symbol: string; decimals: string }> => {
network: NetworkNames,
fetchBalance: boolean = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: can we use a boolean naming convention here? should_fetch_balance or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stellar-jenkins
Copy link

@aristidesstaffieri
Copy link
Contributor

should we have a test at the route level as well?

@stellar-jenkins
Copy link

@CassioMG
Copy link
Contributor Author

CassioMG commented Feb 7, 2025

should we have a test at the route level as well?

@aristidesstaffieri good point, just added it here

Use decimals as a string consistently
@stellar-jenkins
Copy link

@CassioMG
Copy link
Contributor Author

CassioMG commented Feb 7, 2025

@aristidesstaffieri I've made a change so that it's returning balance as a string now: https://freighter-backend-pr204.previews.kube001.services.stellar-ops.com/api/v1/token-details/CD6HI2WJBAMTWRQWDWWASN5ZQO7H4WXMKGVKNQIPIMGZGESIW3FJ24MZ?network=TESTNET&pub_key=GBDQO6LWQJBMWWPZV3SVGEFGX5CIBMPHQKU7HJZPWQWV6EWI6DKRP5WB&should_fetch_balance=true

But it's funny though that decimals are appearing as a number, the code suggests it should be a string as well, we also have tests which take decimals as string 🤔

@aristidesstaffieri
Copy link
Contributor

@aristidesstaffieri I've made a change so that it's returning balance as a string now: https://freighter-backend-pr204.previews.kube001.services.stellar-ops.com/api/v1/token-details/CD6HI2WJBAMTWRQWDWWASN5ZQO7H4WXMKGVKNQIPIMGZGESIW3FJ24MZ?network=TESTNET&pub_key=GBDQO6LWQJBMWWPZV3SVGEFGX5CIBMPHQKU7HJZPWQWV6EWI6DKRP5WB&should_fetch_balance=true

But it's funny though that decimals are appearing as a number, the code suggests it should be a string as well, we also have tests which take decimals as string 🤔

Yeah that's a good point about decimals, I would guess that the http clients on the receiving ends are parsing it as a number when the json gets parsed but this lgtm for the big number, thanks!

@CassioMG CassioMG merged commit c6871b3 into release/1.5.0 Feb 7, 2025
4 checks passed
@CassioMG CassioMG deleted the cg-token-details-balance branch February 7, 2025 18:02
aristidesstaffieri added a commit that referenced this pull request Feb 11, 2025
* Bump the minor-and-patch group with 3 updates (#190)

Bumps the minor-and-patch group with 3 updates: [@blockaid/client](https://github.com/blockaid-official/blockaid-client-node), [@sentry/node](https://github.com/getsentry/sentry-javascript) and [fastify](https://github.com/fastify/fastify).


Updates `@blockaid/client` from 0.31.0 to 0.32.0
- [Release notes](https://github.com/blockaid-official/blockaid-client-node/releases)
- [Changelog](https://github.com/blockaid-official/blockaid-client-node/blob/main/CHANGELOG.md)
- [Commits](blockaid-official/blockaid-client-node@v0.31.0...v0.32.0)

Updates `@sentry/node` from 8.43.0 to 8.45.0
- [Release notes](https://github.com/getsentry/sentry-javascript/releases)
- [Changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md)
- [Commits](getsentry/sentry-javascript@8.43.0...8.45.0)

Updates `fastify` from 5.1.0 to 5.2.0
- [Release notes](https://github.com/fastify/fastify/releases)
- [Commits](fastify/fastify@v5.1.0...v5.2.0)

---
updated-dependencies:
- dependency-name: "@blockaid/client"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: "@sentry/node"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
- dependency-name: fastify
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: minor-and-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* add Blockaid reporting endpoints (#196)

* add Blockaid reporting endpoints

* use Blockaid tx warning type and update tests

* Bump webpack-cli from 5.1.4 to 6.0.1 in the major group (#195)

Bumps the major group with 1 update: [webpack-cli](https://github.com/webpack/webpack-cli).


Updates `webpack-cli` from 5.1.4 to 6.0.1
- [Release notes](https://github.com/webpack/webpack-cli/releases)
- [Changelog](https://github.com/webpack/webpack-cli/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack/webpack-cli/compare/[email protected]@6.0.1)

---
updated-dependencies:
- dependency-name: webpack-cli
  dependency-type: direct:development
  update-type: version-update:semver-major
  dependency-group: major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Allow optional "fetch_balance" parameter on /token-details route (#204)

* Allow optional "fetch_balance" parameter on "/token-details/:contractId" route

* fetch_balance => should_fetch_balance

* Add tests on the route level

* Parse balance to a string

Use decimals as a string consistently

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Piyal Basu <[email protected]>
Co-authored-by: Cássio Marcos Goulart <[email protected]>
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.

4 participants