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

Amount input #91

Merged
merged 3 commits into from
Mar 6, 2024
Merged

Amount input #91

merged 3 commits into from
Mar 6, 2024

Conversation

samsiegart
Copy link
Contributor

fixes Agoric/agoric-sdk#8893

  • Adds a useAmountInput hook based off the implementation in dapp-inter for handling denom decimal places.
  • Adds a basic <AmountInput> component that makes use of the hook conveniently.

Tested locally with dapp-offer-up

const parsed = parseAsValue(str, AssetKind.NAT, decimalPlaces);
onChange(parsed);
} catch {
console.debug('Invalid input', str);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add an optional onError prop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this is worth bubbling up necessarily. I'm not sure in practice when parseAsValue would throw (because we're giving it a NAT here and a string), it's more just so the app doesn't crash worst case.

@samsiegart samsiegart enabled auto-merge (rebase) March 6, 2024 22:14
@samsiegart samsiegart merged commit 09ca26c into main Mar 6, 2024
1 check passed
@samsiegart samsiegart deleted the amount-input branch March 6, 2024 22:18
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.

Create AmountInput UI Component
2 participants