aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@users.noreply.github.com>2018-10-16 06:00:47 +0800
committerGitHub <noreply@github.com>2018-10-16 06:00:47 +0800
commitc821a8354c8eba05885ca219f39aedafbd4f8052 (patch)
tree880b60c46a0c3f0873a58f16077623211140ac0e /app
parent61dec4ea464607d32a5727bdf343a7d8a9af66fc (diff)
downloadtangerine-wallet-browser-c821a8354c8eba05885ca219f39aedafbd4f8052.tar
tangerine-wallet-browser-c821a8354c8eba05885ca219f39aedafbd4f8052.tar.gz
tangerine-wallet-browser-c821a8354c8eba05885ca219f39aedafbd4f8052.tar.bz2
tangerine-wallet-browser-c821a8354c8eba05885ca219f39aedafbd4f8052.tar.lz
tangerine-wallet-browser-c821a8354c8eba05885ca219f39aedafbd4f8052.tar.xz
tangerine-wallet-browser-c821a8354c8eba05885ca219f39aedafbd4f8052.tar.zst
tangerine-wallet-browser-c821a8354c8eba05885ca219f39aedafbd4f8052.zip
Add txReceipt data to transaction details (#5513)
Diffstat (limited to 'app')
-rw-r--r--app/_locales/en/messages.json3
-rw-r--r--app/scripts/controllers/transactions/index.js35
-rw-r--r--app/scripts/controllers/transactions/tx-state-manager.js5
3 files changed, 42 insertions, 1 deletions
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json
index d8467e9eb..13b0da230 100644
--- a/app/_locales/en/messages.json
+++ b/app/_locales/en/messages.json
@@ -424,6 +424,9 @@
"gasLimitTooLow": {
"message": "Gas limit must be at least 21000"
},
+ "gasUsed": {
+ "message": "Gas Used"
+ },
"generatingSeed": {
"message": "Generating Seed..."
},
diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js
index a57c85f50..9f2290924 100644
--- a/app/scripts/controllers/transactions/index.js
+++ b/app/scripts/controllers/transactions/index.js
@@ -366,7 +366,40 @@ class TransactionController extends EventEmitter {
this.txStateManager.setTxStatusSubmitted(txId)
}
- confirmTransaction (txId) {
+ /**
+ * Sets the status of the transaction to confirmed and sets the status of nonce duplicates as
+ * dropped if the txParams have data it will fetch the txReceipt
+ * @param {number} txId - The tx's ID
+ * @returns {Promise<void>}
+ */
+ async confirmTransaction (txId) {
+ // get the txReceipt before marking the transaction confirmed
+ // to ensure the receipt is gotten before the ui revives the tx
+ const txMeta = this.txStateManager.getTx(txId)
+
+ if (!txMeta) {
+ return
+ }
+
+ try {
+ const txReceipt = await this.query.getTransactionReceipt(txMeta.hash)
+
+ // It seems that sometimes the numerical values being returned from
+ // this.query.getTransactionReceipt are BN instances and not strings.
+ const gasUsed = typeof txReceipt.gasUsed !== 'string'
+ ? txReceipt.gasUsed.toString(16)
+ : txReceipt.gasUsed
+
+ txMeta.txReceipt = {
+ ...txReceipt,
+ gasUsed,
+ }
+
+ this.txStateManager.updateTx(txMeta, 'transactions#confirmTransaction - add txReceipt')
+ } catch (err) {
+ log.error(err)
+ }
+
this.txStateManager.setTxStatusConfirmed(txId)
this._markNonceDuplicatesDropped(txId)
}
diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js
index daa6cc388..58c48e34e 100644
--- a/app/scripts/controllers/transactions/tx-state-manager.js
+++ b/app/scripts/controllers/transactions/tx-state-manager.js
@@ -400,6 +400,11 @@ class TransactionStateManager extends EventEmitter {
*/
_setTxStatus (txId, status) {
const txMeta = this.getTx(txId)
+
+ if (!txMeta) {
+ return
+ }
+
txMeta.status = status
setTimeout(() => {
try {