Skip to content

Commit 7c9557f

Browse files
author
lukaw3d
committed
wrap: Show error message if amount can not be parsed
1 parent 46f2639 commit 7c9557f

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

.changelog/303.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
wrap: Show error message if amount can not be parsed

wrap/src/components/WrapForm/index.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,23 @@ export const WrapForm: FC = () => {
9090
setError('')
9191
e.preventDefault()
9292

93-
const amount = NumberUtils.BigIntToBN(parseEther(value || '0'))
94-
95-
if (
96-
formType === WrapFormType.WRAP &&
97-
NumberUtils.shouldShowWrapFeeWarningModal({
98-
fee: estimatedFee,
99-
amount,
100-
accountBalanceAmount: balance,
101-
})
102-
) {
103-
setIsWrapFeeModalOpen(true)
104-
} else {
105-
submitTransaction(amount)
93+
try {
94+
const amount = NumberUtils.BigIntToBN(parseEther(value || '0'))
95+
96+
if (
97+
formType === WrapFormType.WRAP &&
98+
NumberUtils.shouldShowWrapFeeWarningModal({
99+
fee: estimatedFee,
100+
amount,
101+
accountBalanceAmount: balance,
102+
})
103+
) {
104+
setIsWrapFeeModalOpen(true)
105+
} else {
106+
submitTransaction(amount)
107+
}
108+
} catch (ex) {
109+
setError((ex as BaseError)?.shortMessage || (ex as Error)?.message || JSON.stringify(ex))
106110
}
107111
}
108112

0 commit comments

Comments
 (0)