fix the transaction deadline errors

This commit is contained in:
Moody Salem 2021-05-12 13:01:31 -05:00
parent 27094c87f2
commit 8bea95fab2
No known key found for this signature in database
GPG Key ID: 8CB5CD10385138DB
3 changed files with 17 additions and 5 deletions

@ -94,6 +94,8 @@ const MenuFlyout = styled.span`
${({ theme }) => theme.mediaWidth.upToMedium` ${({ theme }) => theme.mediaWidth.upToMedium`
min-width: 18.125rem; min-width: 18.125rem;
`}; `};
user-select: none;
` `
const Break = styled.div` const Break = styled.div`

@ -136,11 +136,16 @@ export default function TransactionSettings({ placeholderSlippage }: Transaction
if (value.length === 0) { if (value.length === 0) {
setDeadline(DEFAULT_DEADLINE_FROM_NOW) setDeadline(DEFAULT_DEADLINE_FROM_NOW)
} else { } else {
const parsed: number = Math.floor(Number.parseFloat(value) * 60) try {
if (!Number.isInteger(parsed) || parsed < 60) { const parsed: number = Math.floor(Number.parseFloat(value) * 60)
if (!Number.isInteger(parsed) || parsed < 60 || parsed > 180 * 60) {
setDeadlineError(DeadlineError.InvalidInput)
} else {
setDeadline(parsed)
}
} catch (error) {
console.error(error)
setDeadlineError(DeadlineError.InvalidInput) setDeadlineError(DeadlineError.InvalidInput)
} else {
setDeadline(parsed)
} }
} }
} }

@ -96,7 +96,12 @@ export default createReducer(initialState, (builder) =>
// deadline isnt being tracked in local storage, reset to default // deadline isnt being tracked in local storage, reset to default
// noinspection SuspiciousTypeOfGuard // noinspection SuspiciousTypeOfGuard
if (typeof state.userDeadline !== 'number' || !Number.isInteger(state.userDeadline) || state.userDeadline < 60) { if (
typeof state.userDeadline !== 'number' ||
!Number.isInteger(state.userDeadline) ||
state.userDeadline < 60 ||
state.userDeadline > 180 * 60
) {
state.userDeadline = DEFAULT_DEADLINE_FROM_NOW state.userDeadline = DEFAULT_DEADLINE_FROM_NOW
} }