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

Fix JSON decoding #502

Merged
merged 2 commits into from
Jan 25, 2022
Merged

Fix JSON decoding #502

merged 2 commits into from
Jan 25, 2022

Conversation

aldur
Copy link
Contributor

@aldur aldur commented Jan 20, 2022

Hey team,

I think I found a bug in how we decode json responses; essentially, we always pick the wrong parser.

Look at the following code snippet:

  const assetDetails = await client
    .getAssetByID(ASAIdx)
    .setIntDecoding(algosdk.IntDecoding.BIGINT)
    .do();
  console.log(typeof assetDetails.params.total);

Before: number
Now: bigint

I also think that we should add a unit test for this. My JS skills are somehow limited, but I'd be happy to give it a shot if you point me in the right direction :)

@aldur aldur requested a review from barnjamin January 20, 2022 09:32
@jasonpaulos
Copy link
Contributor

@aldur thank you for catching this! I agree we should also have a unit test for this before merging.

Perhaps you could make the HTTPClient.parseJSON function public (in order to test it) and add a unit test in tests/9.Client.ts?

@aldur
Copy link
Contributor Author

aldur commented Jan 25, 2022

Added unit tests :)

Copy link
Contributor

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@jasonpaulos jasonpaulos merged commit 1160d85 into develop Jan 25, 2022
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.

2 participants