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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion account-kit/infra/src/middleware/gasManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

let { data } = await client.call({
to: policyToken.address,
data: encodeFunctionData({
Expand Down
Loading