aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-10-03 05:11:50 +0800
committerGitHub <noreply@github.com>2017-10-03 05:11:50 +0800
commitb7c195160238119291ce62b01db1c8f7e4f94568 (patch)
tree01e7afaf1ae3e374a1dd27e8ee564f3370d4463b /app/scripts/lib
parentbf390bd63d7642d5a4975c572eb928252122a79b (diff)
parent167ad729fdd4fa23a2ec66e648652f3379a2bb51 (diff)
downloadtangerine-wallet-browser-b7c195160238119291ce62b01db1c8f7e4f94568.tar.gz
tangerine-wallet-browser-b7c195160238119291ce62b01db1c8f7e4f94568.tar.zst
tangerine-wallet-browser-b7c195160238119291ce62b01db1c8f7e4f94568.zip
Merge pull request #2260 from MetaMask/history-notes
transaction - provide notes for history
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/tx-state-history-helper.js7
-rw-r--r--app/scripts/lib/tx-state-manager.js8
2 files changed, 9 insertions, 6 deletions
diff --git a/app/scripts/lib/tx-state-history-helper.js b/app/scripts/lib/tx-state-history-helper.js
index 5ebd78689..db6e3bc9f 100644
--- a/app/scripts/lib/tx-state-history-helper.js
+++ b/app/scripts/lib/tx-state-history-helper.js
@@ -20,8 +20,11 @@ function migrateFromSnapshotsToDiffs(longHistory) {
)
}
-function generateHistoryEntry(previousState, newState) {
- return jsonDiffer.compare(previousState, newState)
+function generateHistoryEntry(previousState, newState, note) {
+ const entry = jsonDiffer.compare(previousState, newState)
+ // Add a note to the first op, since it breaks if we append it to the entry
+ if (note && entry[0]) entry[0].note = note
+ return entry
}
function replayHistory(_shortHistory) {
diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js
index 4493889bf..cf8117864 100644
--- a/app/scripts/lib/tx-state-manager.js
+++ b/app/scripts/lib/tx-state-manager.js
@@ -82,7 +82,7 @@ module.exports = class TransactionStateManger extends EventEmitter {
return txMeta
}
- updateTx (txMeta) {
+ updateTx (txMeta, note) {
if (txMeta.txParams) {
Object.keys(txMeta.txParams).forEach((key) => {
let value = txMeta.txParams[key]
@@ -96,7 +96,7 @@ module.exports = class TransactionStateManger extends EventEmitter {
// recover previous tx state obj
const previousState = txStateHistoryHelper.replayHistory(txMeta.history)
// generate history entry and add to history
- const entry = txStateHistoryHelper.generateHistoryEntry(previousState, currentState)
+ const entry = txStateHistoryHelper.generateHistoryEntry(previousState, currentState, note)
txMeta.history.push(entry)
// commit txMeta to state
@@ -113,7 +113,7 @@ module.exports = class TransactionStateManger extends EventEmitter {
updateTxParams (txId, txParams) {
const txMeta = this.getTx(txId)
txMeta.txParams = extend(txMeta.txParams, txParams)
- this.updateTx(txMeta)
+ this.updateTx(txMeta, `txStateManager#updateTxParams`)
}
/*
@@ -233,7 +233,7 @@ module.exports = class TransactionStateManger extends EventEmitter {
if (status === 'submitted' || status === 'rejected') {
this.emit(`${txMeta.id}:finished`, txMeta)
}
- this.updateTx(txMeta)
+ this.updateTx(txMeta, `txStateManager: setting status to ${status}`)
this.emit('update:badge')
}