Skip to content

Commit 121de52

Browse files
author
Matija Petrunic
committed
Delete transaction from storage if resubmit successful
1 parent a1b0b96 commit 121de52

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/monitorService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ export class TxMonitorService {
9292
chainId: transaction.chainId,
9393
gasPrice: newGasPrice
9494
});
95+
96+
this.logger.debug(`Deleting transaction ${transaction.hash} from storage`);
97+
await this.wallet.walletStorage.deleteTransaction(transaction.hash);
9598
} catch(error) {
9699
this.logger.error(`Resending transaction with hash ${transaction.hash} failed, ${error.message}`);
97100
}

test/monitorService.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ describe("Transaction monitor service", function () {
8989

9090
});
9191

92-
it("Check transaction ignores other transactions after resending", function (done) {
92+
it(
93+
"Check transaction ignores other transactions after resending and deletes transaction if resubmit successful",
94+
function (done)
95+
{
9396
walletStorage.getTransactions = async function getTransactions() {
9497
return [
9598
{nonce: 1, gasPrice: BigNumber.from(12), submitTime: new Date().getTime() - 300000} as SavedTransactionResponse,
@@ -106,6 +109,7 @@ describe("Transaction monitor service", function () {
106109

107110
setTimeout(() => {
108111
expect(stub.callCount).to.be.deep.equal(1);
112+
expect(deleteTransactionSpy.callCount).to.be.deep.equal(1);
109113
done();
110114
}, 30)
111115

0 commit comments

Comments
 (0)