Skip to content

Commit

Permalink
fix: add failed transactions storage
Browse files Browse the repository at this point in the history
  • Loading branch information
JackHamer09 committed Apr 7, 2024
1 parent bfbc1a5 commit 0dfc1ee
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion store/zksync/transactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ export const useZkSyncTransactionStatusStore = defineStore("zkSyncTransactionSta
const { account } = storeToRefs(onboardStore);
const { eraNetwork } = storeToRefs(providerStore);

const failedTransaction = useStorage<TransactionInfo[]>("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",
{}
Expand Down Expand Up @@ -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") {
Expand All @@ -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) => {
Expand Down

0 comments on commit 0dfc1ee

Please sign in to comment.