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

bug-fix: include currency-greater-than param for 0 value #807

Merged
merged 9 commits into from
Aug 11, 2023

Conversation

shiqizng
Copy link
Contributor

@shiqizng shiqizng commented Aug 7, 2023

This PR fixes #810

@shiqizng shiqizng self-assigned this Aug 7, 2023
@shiqizng shiqizng requested a review from a team August 7, 2023 20:00
.test-env Outdated Show resolved Hide resolved
Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

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

This looks fine, but I don't think it completely closes #414 -- it still uses the '0' string workaround, and I wonder if we can just change the behavior of removeFalsyOrEmpty instead:
https://github.com/algorand/js-algorand-sdk/blob/develop/src/client/client.ts#L26

I'm not sure if this would affect the messagepack serialization behavior though.

@shiqizng
Copy link
Contributor Author

shiqizng commented Aug 8, 2023

This looks fine, but I don't think it completely closes #414 -- it still uses the '0' string workaround, and I wonder if we can just change the behavior of removeFalsyOrEmpty instead: https://github.com/algorand/js-algorand-sdk/blob/develop/src/client/client.ts#L26

I'm not sure if this would affect the messagepack serialization behavior though.

I don't see a way to change removeFalsyOrEmpty so it allows 0 value without adding a special case for key currency-greater-than.

@algorand/lamprey what do others think about this? should we use a string work around or add a special handling in removeFalsyOrEmpty for individual fields?

@algochoi
Copy link
Contributor

algochoi commented Aug 8, 2023

I don't see a way to change removeFalsyOrEmpty so it allows 0 value without adding a special case for key currency-greater-than.

I also don't see a very easy way to fix #414 without affecting serialization and breaking all our current tests.

It seems potentially ugly, but I'd actually be in favor of what you suggested (having special cases). I think it's more obvious and self-documenting that this is a weird workaround in the JS SDK. As is, I don't think it's obvious to devs why we need to pass '0's around without looking at this open issue (414), and especially if we have future client parameters that may require 0 as a valid parameter.

@jasonpaulos
Copy link
Contributor

It is possible we could stop running queries through the removeFalsyOrEmpty function? I'm not sure what benefits we even get from this. I'm pretty sure Python does not do something similar, and it certainly works.

@shiqizng
Copy link
Contributor Author

shiqizng commented Aug 8, 2023

It is possible we could stop running queries through the removeFalsyOrEmpty function? I'm not sure what benefits we even get from this. I'm pretty sure Python does not do something similar, and it certainly works.

If I remove this function, then the path seem to include accept=application%2Fjson which is causing the tests to fail.

✖ Then expect the path used to be "/v2/blocks/3?header-only=true" # tests/cucumber/steps/index.js:513
         AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
         + actual - expected

         + '/v2/blocks/3?accept=application%2Fjson'
         - '/v2/blocks/3?header-only=true'
                         ^
             + expected - actual

             -/v2/blocks/3?accept=application%2Fjson
             +/v2/blocks/3?header-only=true

@jasonpaulos
Copy link
Contributor

That's very strange, I have no idea where it's getting accept=application%2Fjson from... 🤔

@bbroder-algo
Copy link
Contributor

I think I would want to know what falsy values or values with length zero we are removing from queries, and whether it can be removed or replaced with alternate logic. my hunch is the accept=application%2Fjson situation can be resolved.

@shiqizng
Copy link
Contributor Author

I think I would want to know what falsy values or values with length zero we are removing from queries, and whether it can be removed or replaced with alternate logic. my hunch is the accept=application%2Fjson situation can be resolved.

This is to be addressed in #414

Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

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

Agree with @bbroder-algo that we need to change or remove that comment on the client method -- Otherwise LGTM, and I don't have a strong opinion on whether we need to address that falsy problem in this PR.

Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

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

Approving - optional nit regarding adding comments for converting params to string

@bbroder-algo bbroder-algo merged commit f14f30a into develop Aug 11, 2023
3 checks passed
joe-p pushed a commit to joe-p/js-algorand-sdk that referenced this pull request Apr 11, 2024
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.

Enable 0 value for currency-greater-than
5 participants