From 0dfc1ee4e1dd0116cd8fec45204a95448f51231b Mon Sep 17 00:00:00 2001 From: Jack Hamer Date: Sun, 7 Apr 2024 18:34:04 +0300 Subject: [PATCH] fix: add failed transactions storage --- store/zksync/transactionStatus.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/store/zksync/transactionStatus.ts b/store/zksync/transactionStatus.ts index f52b78cf8..bb760b149 100644 --- a/store/zksync/transactionStatus.ts +++ b/store/zksync/transactionStatus.ts @@ -30,6 +30,14 @@ export const useZkSyncTransactionStatusStore = defineStore("zkSyncTransactionSta const { account } = storeToRefs(onboardStore); const { eraNetwork } = storeToRefs(providerStore); + const failedTransaction = useStorage("zksync-bridge-failed-transaction", []); + const addFailedTransaction = (transaction: TransactionInfo) => { + if (failedTransaction.value.some((tx) => tx.transactionHash === transaction.transactionHash)) { + return; + } + failedTransaction.value = [...failedTransaction.value, transaction]; + }; + const storageSavedTransactions = useStorage<{ [networkKey: string]: TransactionInfo[] }>( "zksync-bridge-transactions", {} @@ -88,6 +96,7 @@ export const useZkSyncTransactionStatusStore = defineStore("zkSyncTransactionSta transaction.info.withdrawalFinalizationAvailable = false; transaction.info.failed = true; transaction.info.completed = true; + addFailedTransaction(transaction); return transaction; } if (transactionDetails.status !== "verified") { @@ -106,10 +115,11 @@ export const useZkSyncTransactionStatusStore = defineStore("zkSyncTransactionSta const transactionReceipt = await providerStore.requestProvider().getTransactionReceipt(transaction.transactionHash); if (!transactionReceipt) return transaction; const transactionDetails = await providerStore.requestProvider().getTransactionDetails(transaction.transactionHash); + transaction.info.completed = true; if (transactionDetails.status === "failed") { transaction.info.failed = true; + addFailedTransaction(transaction); } - transaction.info.completed = true; return transaction; }; const waitForCompletion = async (transaction: TransactionInfo) => {