From 754a8180b24997c85e7cd835e2619307226905a7 Mon Sep 17 00:00:00 2001 From: Sergey Chystiakov Date: Thu, 15 Feb 2024 17:55:14 +0100 Subject: [PATCH 1/7] fix: feerate error handling --- .../SendTransaction/SendTransaction.js | 26 ++++++++++++++----- .../SendTransactionConfirmation.js | 7 +++-- src/services/API/Mintlayer/Mintlayer.js | 19 +++++++++++++- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/components/containers/SendTransaction/SendTransaction.js b/src/components/containers/SendTransaction/SendTransaction.js index ad5623bd..0997d6b6 100644 --- a/src/components/containers/SendTransaction/SendTransaction.js +++ b/src/components/containers/SendTransaction/SendTransaction.js @@ -44,6 +44,7 @@ const SendTransaction = ({ const [passValidity, setPassValidity] = useState(false) const [passPristinity, setPassPristinity] = useState(true) const [passErrorMessage, setPassErrorMessage] = useState('') + const [txErrorMessage, setTxErrorMessage] = useState('') const [sendingTransaction, setSendingTransaction] = useState(false) const [transactionTxid, setTransactionTxid] = useState(false) const [allowClosing, setAllowClosing] = useState(true) @@ -90,14 +91,26 @@ const SendTransaction = ({ setTransactionTxid(txid) setPassValidity(true) setPassErrorMessage('') + setTxErrorMessage('') setAskPassword(false) } catch (e) { - console.error(e) - setPassPristinity(false) - setPassValidity(false) - setPass('') - setPassErrorMessage('Incorrect password. Account could not be unlocked') - setAllowClosing(true) + console.log('=========000========') + if (e.address && e.address === '') { + // password is not correct + setPassErrorMessage('Incorrect password. Account could not be unlocked') + setPassPristinity(false) + setPassValidity(false) + setPass('') + setAllowClosing(true) + } else { + // handle other errors + setAskPassword(false) + setPassPristinity(false) + setPassValidity(false) + setPass('') + setTxErrorMessage(e.message) + setAllowClosing(true) + } } finally { setSendingTransaction(false) } @@ -270,6 +283,7 @@ const SendTransaction = ({ fiatName={fiatName} totalFeeFiat={totalFeeFiat} totalFeeCrypto={totalFeeCrypto} + txErrorMessage={txErrorMessage} fee={fee} onConfirm={handleConfirm} onCancel={handleCancel} diff --git a/src/components/containers/SendTransaction/SendTransactionConfirmation.js b/src/components/containers/SendTransaction/SendTransactionConfirmation.js index 184d5474..13155023 100644 --- a/src/components/containers/SendTransaction/SendTransactionConfirmation.js +++ b/src/components/containers/SendTransaction/SendTransactionConfirmation.js @@ -1,5 +1,5 @@ -import { useContext } from 'react' -import { Button } from '@BasicComponents' +import React, { useContext } from 'react' +import { Button, Error } from '@BasicComponents' import { CenteredLayout, VerticalGroup } from '@LayoutComponents' import { AccountContext, SettingsContext } from '@Contexts' import { AppInfo } from '@Constants' @@ -12,6 +12,7 @@ const SendFundConfirmation = ({ amountInCrypto, cryptoName, fiatName, + txErrorMessage, totalFeeFiat, totalFeeCrypto, fee, @@ -62,6 +63,8 @@ const SendFundConfirmation = ({ + {txErrorMessage ? : <>} +