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

feat: validate amount inputs #465

Merged
merged 3 commits into from
Jul 14, 2023
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
1 change: 1 addition & 0 deletions src/components/form/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Input = forwardRef(
before: token || actionButton,
after: selectBefore,
})}
step="any"
autoComplete="off"
ref={ref}
/>
Expand Down
1 change: 1 addition & 0 deletions src/pages/wallet/IbcSendBackTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ function IbcSendBackTx({ token, chainID }: Props) {
decimals
),
})}
type="number"
token={ibcDetails?.baseDenom}
inputMode="decimal"
onFocus={max.reset}
Expand Down
1 change: 1 addition & 0 deletions src/pages/wallet/SendPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ const SendPage = () => {
),
})}
token={asset}
type="number"
inputMode="decimal"
onFocus={max.reset}
placeholder={getPlaceholder(decimals)}
Expand Down
1 change: 1 addition & 0 deletions src/pages/wallet/TransferPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ const TransferPage = () => {
),
})}
token={asset}
type="number"
inputMode="decimal"
onFocus={max.reset}
placeholder={getPlaceholder(decimals)}
Expand Down
10 changes: 10 additions & 0 deletions src/styles/_customize.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,13 @@
.recharts-legend-wrapper {
max-width: 45%;
}

input[type="number"] {
-moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
1 change: 1 addition & 0 deletions src/txs/gov/DepositForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const DepositForm = () => {
})}
token={networks[chain].baseAsset}
onFocus={max.reset}
type="number"
inputMode="decimal"
placeholder={getPlaceholder()}
autoFocus
Expand Down
3 changes: 3 additions & 0 deletions src/txs/gov/SubmitProposalForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ const SubmitProposalForm = ({ chain }: { chain: string }) => {
validate: validate.input(toInput(max)),
})}
inputMode="decimal"
type="number"
placeholder={placeholder}
selectBefore={
<Select {...register("spend.denom")} before>
Expand Down Expand Up @@ -372,6 +373,7 @@ const SubmitProposalForm = ({ chain }: { chain: string }) => {
valueAsNumber: true,
})}
inputMode="decimal"
type="number"
placeholder={getPlaceholder()}
selectBefore={
<Select {...register(`coins.${index}.denom`)} before>
Expand Down Expand Up @@ -483,6 +485,7 @@ const SubmitProposalForm = ({ chain }: { chain: string }) => {
true
),
})}
type="number"
token={networks[chain].baseAsset}
onFocus={max.reset}
inputMode="decimal"
Expand Down
1 change: 1 addition & 0 deletions src/txs/stake/QuickStakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ const QuickStakeForm = (props: Props) => {
valueAsNumber: true,
validate: validate.input(toInput(max.amount)),
})}
type="number"
token={denom}
onFocus={max.reset}
inputMode="decimal"
Expand Down
1 change: 1 addition & 0 deletions src/txs/stake/StakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ const StakeForm = (props: Props) => {
})}
token={denom}
onFocus={max.reset}
type="number"
inputMode="decimal"
placeholder={getPlaceholder()}
autoFocus
Expand Down
2 changes: 2 additions & 0 deletions src/txs/swap/TFMSwapForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ const TFMSwapForm = ({ chainID }: { chainID: string }) => {
),
})}
inputMode="decimal"
type="number"
placeholder={getPlaceholder(offerDecimals)}
onFocus={max.reset}
autoFocus
Expand Down Expand Up @@ -333,6 +334,7 @@ const TFMSwapForm = ({ chainID }: { chainID: string }) => {
})}
input={slippageInput} // to warn
inputMode="decimal"
type="number"
placeholder={getPlaceholder(2)}
error={errors.slippageInput?.message}
/>
Expand Down
1 change: 1 addition & 0 deletions src/txs/wasm/ExecuteContractForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const ExecuteContractForm = () => {
valueAsNumber: true,
})}
inputMode="decimal"
type="number"
placeholder={getPlaceholder(decimals)}
selectBefore={
<Select {...register(`coins.${index}.denom`)} before>
Expand Down
2 changes: 2 additions & 0 deletions src/txs/wasm/InstantiateContractForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const InstantiateContractForm = ({ chainID }: { chainID: string }) => {
},
})}
inputMode="decimal"
type="number"
placeholder="1"
autoFocus
/>
Expand Down Expand Up @@ -156,6 +157,7 @@ const InstantiateContractForm = ({ chainID }: { chainID: string }) => {
valueAsNumber: true,
})}
inputMode="decimal"
type="number"
placeholder={getPlaceholder(decimals)}
selectBefore={
<Select {...register(`coins.${index}.denom`)} before>
Expand Down
1 change: 1 addition & 0 deletions src/txs/wasm/MigrateContractForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const MigrateContractForm = ({ contract }: { contract: AccAddress }) => {
},
})}
inputMode="decimal"
type="number"
placeholder="1"
autoFocus
/>
Expand Down