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

Read the amount from the URL if it is set #203

Merged
merged 1 commit into from
Mar 28, 2023

Conversation

mcintyre94
Copy link
Collaborator

Closes #202

This issue is caused by the POS app using only local state for the amount, while other fields (like recipient and label) use the URL values. This PR sets the initial value of the amount state using the amount query param if it is present.

@vercel
Copy link

vercel bot commented Mar 23, 2023

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

Name Status Preview Comments Updated
solana-pay ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 27, 2023 at 1:44PM (UTC)
solana-pay-docs ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 27, 2023 at 1:44PM (UTC)

Comment on lines 36 to 37
if (Array.isArray(queryAmount)) return new BigNumber(queryAmount[0]);
return new BigNumber(queryAmount)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I think we might need to validate the amount in some way. If it doesn't pass a simple regex, we probably don't want to instantiate a BigNumber from it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added some validation (not NaN, finite, >0) using BigNumber functions. I think that's a bit more straightforward than adding our own regex, and since the amount is displayed on screen + in the wallet it's ok to allow whatever parsing flexibility BigNumber has here. Can add a regex instead if you'd prefer though, I don't have a strong view either way really.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think either is fine. My idea was simply to check it against ^\d+(\.\d+)?$ since this is (more or less) what describes a valid manual amount entry into the UI. Zero amounts are technically probably okay to allow (they are allowed in the protocol) but I don't care enough to change this.

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.

Query issue: Amount does not show on pending page
2 participants