1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

Ensure custom slippage is a number (#9915)

This fixes a PropType error when using non-custom slippage, and it
fixes a type inconsistency when custom slippage is used.

Previously, `slippage` was being converted explicitly to a `Number` as
it was passed into `BuildQuote`, but not as it was passed into
`AwaitingSwap`. Also the PropType was set as `string`, despite the fact
that it's a number in most cases, and is used for math.

The PropType has been changed to `number`, and the selective casting to
`Number` has been removed. Instead, the `maxSlippage` value is cast to
a `Number` as it's being selected, so that the type is always
consistent.
This commit is contained in:
Mark Stacey 2020-11-19 11:56:55 -03:30 committed by GitHub
parent a9fcf0ea86
commit bb3a0423d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -299,7 +299,7 @@ export default function Swap() {
ethBalance={ethBalance}
setMaxSlippage={setMaxSlippage}
selectedAccountAddress={selectedAccountAddress}
maxSlippage={Number(maxSlippage)}
maxSlippage={maxSlippage}
/>
)
}}

View File

@ -10,7 +10,7 @@ export const QUOTE_DATA_ROWS_PROPTYPES_SHAPE = PropTypes.shape({
networkFees: PropTypes.string.isRequired,
quoteSource: PropTypes.string.isRequired,
rawNetworkFees: PropTypes.string.isRequired,
slippage: PropTypes.string.isRequired,
slippage: PropTypes.number.isRequired,
sourceTokenDecimals: PropTypes.number.isRequired,
sourceTokenSymbol: PropTypes.string.isRequired,
sourceTokenValue: PropTypes.string.isRequired,

View File

@ -116,7 +116,7 @@ export default function SlippageButtons({ onSelect }) {
<input
onChange={(event) => {
setCustomValue(event.target.value)
onSelect(event.target.value)
onSelect(Number(event.target.value))
}}
type="number"
step="0.1"