Skip to content

fix: build permit even maxTokenAmount is set to 0 #1605

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andysim3d
Copy link
Collaborator

@andysim3d andysim3d commented May 8, 2025

Pull Request Checklist


PR-Codex overview

This PR focuses on refining the condition that checks if maxTokenAmount is defined for a policyToken. The change enhances code clarity by explicitly checking for undefined rather than relying on a truthy check.

Detailed summary

  • Updated the condition from if (policyToken.maxTokenAmount) to if (policyToken.maxTokenAmount !== undefined) in gasManager.ts.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented May 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
aa-sdk-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 8, 2025 5:42pm
aa-sdk-ui-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 8, 2025 5:42pm

Copy link

github-actions bot commented May 8, 2025

🌿 Documentation Preview

Name Status Preview Updated (UTC)
Alchemy Docs ✅ Ready 🔗 Visit Preview May 8, 2025, 5:26 PM

@@ -408,7 +408,7 @@ const generateSignedPermit = async <

let maxAmountToken = maxUint256;

if (policyToken.maxTokenAmount) {
if (policyToken.maxTokenAmount !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

❔ What about the case that maxTokenAmount == null

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new bee to TS: this is typed as 'undefined | bigInt', is that possible to assign 'null' to it?

Copy link
Contributor

@jakehobbs jakehobbs May 15, 2025

Choose a reason for hiding this comment

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

i think best practice is to check for policyToken.maxTokenAmount != null, which checks for null or undefined.

i believe the main reason to make the change here is to defend against someone possibly making a change later where it's nullable and doesn't notice that you are strictly checking for undefined here.

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.

5 participants