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

fix: Swap input amount bug fix #1128

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
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: 2 additions & 0 deletions .changeset/brave-icons-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
- **feat**: moved `onSuccess` and `onError` for Swap component at top level. By @zizzamia #1123
- **patch**: removed unneccessary address prop from `Transaction` component and fix issue where Sponsor component isn't visible. By @abcrane123 #1114
- **chore**: updated disconnect SVG image. By @cpcramer #1103
- **fix**: improved issue with Swap where it wasn't fetching quote for amount without a leading 0. By @abcrane123 #1128
g
2 changes: 1 addition & 1 deletion src/swap/components/SwapProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function SwapProvider({
if (source.token === undefined || destination.token === undefined) {
return;
}
if (amount === '' || Number.parseFloat(amount) === 0) {
if (amount === '' || amount === '.' || Number.parseFloat(amount) === 0) {
return destination.setAmount('');
}

Expand Down
2 changes: 1 addition & 1 deletion src/swap/utils/getAPIParamsForToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function getAPIParamsForToken(
message: '',
};
}
if (!/^(?:0|[1-9]\d*)(?:\.\d+)?$/.test(amount)) {
if (!/^(?:0|[1-9]\d*|\.\d+)(?:\.\d*)?$/.test(amount)) {
return {
code: 'INVALID_INPUT',
error: 'Invalid input: amount must be a non-negative number string',
Expand Down