Adds transaction failed error

This commit is contained in:
Kieran Gillen 2022-03-31 13:45:19 +02:00
parent 5e9cd4219d
commit 9ee5d54f53
5 changed files with 40 additions and 7 deletions

View File

@ -104,6 +104,11 @@ export default function AccountInfo() {
txid,
})
}
} else {
notify({
title: t('redeem-failure'),
description: 'Transaction failed',
})
}
} catch (e) {
notify({

View File

@ -139,12 +139,15 @@ const BalancesTable = ({
spotMarkets,
wallet?.adapter
)
// FIXME: Add error if txids is undefined
if (txids) {
for (const txid of txids) {
notify({ title: t('settle-success'), txid })
}
} else {
notify({
title: t('settle-error'),
type: 'error',
})
}
} catch (e) {
console.warn('Error settling all:', e)

View File

@ -121,7 +121,6 @@ const CloseAccountModal: FunctionComponent<CloseAccountModalProps> = ({
})
onClose?.()
// FIXME: Throw error if txids is undefined
if (txids) {
for (const txid of txids) {
notify({
@ -129,6 +128,12 @@ const CloseAccountModal: FunctionComponent<CloseAccountModalProps> = ({
txid,
})
}
} else {
notify({
title: t('close-account:error-deleting-account'),
description: 'Transaction failed',
type: 'error',
})
}
} catch (err) {
console.warn('Error deleting account:', err)

View File

@ -50,14 +50,24 @@ export const settlePosPnl = async (
mangoAccounts
)
actions.reloadMangoAccount()
for (const txid of txids) {
if (txid) {
// FIXME: Remove filter when settlePosPnl return type is undefined or string[]
const filteredTxids = txids?.filter(
(x) => typeof x === 'string'
) as string[]
if (filteredTxids) {
for (const txid of filteredTxids) {
notify({
title: t('pnl-success'),
description: '',
txid,
})
}
} else {
notify({
title: t('pnl-error'),
description: 'Transaction failed',
type: 'error',
})
}
} catch (e) {
console.log('Error settling PNL: ', `${e}`, `${perpAccount}`)
@ -106,13 +116,18 @@ export const settlePnl = async (
mangoAccounts
)
actions.reloadMangoAccount()
// FIXME: If no txid throw error
if (txid) {
notify({
title: t('pnl-success'),
description: '',
txid,
})
} else {
notify({
title: t('pnl-error'),
description: 'Transaction failed',
type: 'error',
})
}
} catch (e) {
console.log('Error settling PNL: ', `${e}`, `${perpAccount}`)

View File

@ -232,7 +232,6 @@ export default function Account() {
)
actions.reloadMangoAccount()
setMngoAccrued(ZERO_BN)
// FIXME: Throw error if txids is undefined
if (txids) {
for (const txid of txids) {
notify({
@ -241,6 +240,12 @@ export default function Account() {
txid,
})
}
} else {
notify({
title: t('redeem-failure'),
description: 'Transaction failed',
type: 'error',
})
}
} catch (e) {
notify({