diff --git a/apps/namadillo/package.json b/apps/namadillo/package.json index de603a6d79..ba8b8e907d 100644 --- a/apps/namadillo/package.json +++ b/apps/namadillo/package.json @@ -1,6 +1,6 @@ { "name": "@namada/namadillo", - "version": "1.1.7", + "version": "1.1.8", "description": "Namadillo", "repository": "https://github.com/anoma/namada-interface/", "author": "Heliax Dev ", diff --git a/apps/namadillo/src/hooks/useTransactionNotifications.tsx b/apps/namadillo/src/hooks/useTransactionNotifications.tsx index a4fd088e9c..fb2bc06d9f 100644 --- a/apps/namadillo/src/hooks/useTransactionNotifications.tsx +++ b/apps/namadillo/src/hooks/useTransactionNotifications.tsx @@ -11,7 +11,10 @@ import { import { searchAllStoredTxByHash } from "atoms/transactions"; import BigNumber from "bignumber.js"; import { useSetAtom } from "jotai"; -import { useTransactionEventListener } from "utils"; +import { + useTransactionEventListener, + useTransactionEventListListener, +} from "utils"; type TxWithAmount = { amount: BigNumber }; @@ -344,45 +347,70 @@ export const useTransactionNotifications = (): void => { }); }); - const handleTransferNotification = ( - tx: TxProps, - data: TxWithAmount[] - ): void => { - const { id } = parseTxsData(tx, data); - clearPendingNotifications(id); - const storedTx = searchAllStoredTxByHash(tx.hash); - if (storedTx) { + useTransactionEventListListener( + [ + "TransparentTransfer.Error", + "ShieldedTransfer.Error", + "ShieldingTransfer.Error", + "UnshieldingTransfer.Error", + ], + (e) => { + const tx = e.detail.tx; + const data: TxWithAmount[] = e.detail.data[0].data; + const { id } = parseTxsData(tx, data); + clearPendingNotifications(id); + const storedTx = searchAllStoredTxByHash(tx.hash); + dispatchNotification({ + id, + type: "error", + title: "Transfer transaction failed", + description: + storedTx ? + <> + Your transfer transaction of{" "} + {" "} + to {shortenAddress(storedTx.destinationAddress, 8, 8)} has failed + + : "Your transfer transaction has failed", + details: + e.detail.error?.message && failureDetails(e.detail.error.message), + }); + } + ); + + useTransactionEventListListener( + [ + "TransparentTransfer.Success", + "ShieldedTransfer.Success", + "ShieldingTransfer.Success", + "UnshieldingTransfer.Success", + ], + (e) => { + const tx = e.detail.tx; + const data: TxWithAmount[] = e.detail.data[0].data; + const { id } = parseTxsData(tx, data); + clearPendingNotifications(id); + const storedTx = searchAllStoredTxByHash(tx.hash); dispatchNotification({ id, title: "Transfer transaction succeeded", - description: ( - <> - Your transfer transaction of{" "} - {" "} - to {shortenAddress(storedTx.destinationAddress, 8, 8)} has succeeded - - ), + description: + storedTx ? + <> + Your transfer transaction of{" "} + {" "} + to {shortenAddress(storedTx.destinationAddress, 8, 8)} has + succeeded + + : "Your transfer transaction has succeeded", type: "success", }); } - }; - - useTransactionEventListener("TransparentTransfer.Success", (e) => { - handleTransferNotification(e.detail.tx, e.detail.data[0].data); - }); - - useTransactionEventListener("ShieldedTransfer.Success", (e) => { - handleTransferNotification(e.detail.tx, e.detail.data[0].data); - }); - - useTransactionEventListener("ShieldingTransfer.Success", (e) => { - handleTransferNotification(e.detail.tx, e.detail.data[0].data); - }); - - useTransactionEventListener("UnshieldingTransfer.Success", (e) => { - handleTransferNotification(e.detail.tx, e.detail.data[0].data); - }); + ); }; diff --git a/apps/namadillo/src/types/events.ts b/apps/namadillo/src/types/events.ts index cdef7a5756..1928f29739 100644 --- a/apps/namadillo/src/types/events.ts +++ b/apps/namadillo/src/types/events.ts @@ -60,9 +60,13 @@ declare global { "VoteProposal.Success": EventData; "VoteProposal.Error": EventData; "TransparentTransfer.Success": EventData; + "TransparentTransfer.Error": EventData; "ShieldedTransfer.Success": EventData; + "ShieldedTransfer.Error": EventData; "ShieldingTransfer.Success": EventData; + "ShieldingTransfer.Error": EventData; "UnshieldingTransfer.Success": EventData; + "UnshieldingTransfer.Error": EventData; "IbcTransfer.Success": EventData; "IbcTransfer.Error": EventData; }