Skip to content

Commit 21bd316

Browse files
authored
fix: SendTransaction should enqueue call to onNewTx (#854)
1 parent 3fa525d commit 21bd316

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/new/sendTransaction.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ export default class SendTransaction extends EventEmitter {
447447
// This just returns if the transaction is not a CREATE_TOKEN_TX
448448
await addCreatedTokenFromTx(transaction as CreateTokenTransaction, storage);
449449
// Add new transaction to the wallet's storage.
450-
await wallet.onNewTx({ history: historyTx });
450+
wallet.enqueueOnNewTx({ history: historyTx });
451451
})(this.wallet, this.storage, this.transaction);
452452
}
453453
this.emit('send-tx-success', this.transaction);

src/new/wallet.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ class HathorWallet extends EventEmitter {
675675
// So we will enqueue this message to be processed later
676676
this.wsTxQueue.enqueue(wsData);
677677
} else {
678-
this.newTxPromise = this.newTxPromise.then(() => this.onNewTx(wsData));
678+
this.enqueueOnNewTx(wsData);
679679
}
680680
}
681681
}
@@ -1330,6 +1330,14 @@ class HathorWallet extends EventEmitter {
13301330
this.emit('state', state);
13311331
}
13321332

1333+
/**
1334+
* Enqueue the call for onNewTx with the given data.
1335+
* @param {{ history: import('../types').IHistoryTx }} wsData
1336+
*/
1337+
enqueueOnNewTx(wsData) {
1338+
this.newTxPromise = this.newTxPromise.then(() => this.onNewTx(wsData));
1339+
}
1340+
13331341
/**
13341342
* @param {{ history: import('../types').IHistoryTx }} wsData
13351343
*/

0 commit comments

Comments
 (0)