aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/idStore.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-04-19 07:39:35 +0800
committerDan Finlay <dan@danfinlay.com>2016-04-19 07:39:35 +0800
commita441e635bd5ae47a6f5b835becf3a40aaaab899d (patch)
treefeb3bb443c0dca53c89e741363adfe7f684aac25 /app/scripts/lib/idStore.js
parent65d73d7bb4b091021988b6115d518cf3914952ed (diff)
downloadtangerine-wallet-browser-a441e635bd5ae47a6f5b835becf3a40aaaab899d.tar
tangerine-wallet-browser-a441e635bd5ae47a6f5b835becf3a40aaaab899d.tar.gz
tangerine-wallet-browser-a441e635bd5ae47a6f5b835becf3a40aaaab899d.tar.bz2
tangerine-wallet-browser-a441e635bd5ae47a6f5b835becf3a40aaaab899d.tar.lz
tangerine-wallet-browser-a441e635bd5ae47a6f5b835becf3a40aaaab899d.tar.xz
tangerine-wallet-browser-a441e635bd5ae47a6f5b835becf3a40aaaab899d.tar.zst
tangerine-wallet-browser-a441e635bd5ae47a6f5b835becf3a40aaaab899d.zip
Persist transactions to config-manager
Transactions are now stored, and are never deleted, they only have their status updated. We can add deleting later if we'd like. I've hacked on emitting the new unconfirmedTx key to the UI in the format it received before, I want Aaron's opinion on where I should actually do that.
Diffstat (limited to 'app/scripts/lib/idStore.js')
-rw-r--r--app/scripts/lib/idStore.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index f44300273..14e9b5769 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -31,7 +31,6 @@ function IdentityStore(ethStore) {
this._currentState = {
selectedAddress: null,
identities: {},
- unconfTxs: {},
}
// not part of serilized metamask state - only kept in memory
this._unconfTxCbs = {}
@@ -140,10 +139,11 @@ IdentityStore.prototype.addUnconfirmedTransaction = function(txParams, cb){
time: time,
status: 'unconfirmed',
}
- this._currentState.unconfTxs[txId] = txData
+ configManager.addTx(txData)
console.log('addUnconfirmedTransaction:', txData)
// keep the cb around for after approval (requires user interaction)
+ // This cb fires completion to the Dapp's write operation.
this._unconfTxCbs[txId] = cb
// signal update
@@ -154,7 +154,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function(txParams, cb){
// comes from metamask ui
IdentityStore.prototype.approveTransaction = function(txId, cb){
- var txData = this._currentState.unconfTxs[txId]
+ var txData = configManager.getTx(txId)
var txParams = txData.txParams
var approvalCb = this._unconfTxCbs[txId] || noop
@@ -162,20 +162,20 @@ IdentityStore.prototype.approveTransaction = function(txId, cb){
cb()
approvalCb(null, true)
// clean up
- delete this._currentState.unconfTxs[txId]
+ configManager.confirmTx(txId)
delete this._unconfTxCbs[txId]
this._didUpdate()
}
// comes from metamask ui
IdentityStore.prototype.cancelTransaction = function(txId){
- var txData = this._currentState.unconfTxs[txId]
+ var txData = configManager.getTx(txId)
var approvalCb = this._unconfTxCbs[txId] || noop
// reject tx
approvalCb(null, false)
// clean up
- delete this._currentState.unconfTxs[txId]
+ configManager.rejectTx(txId)
delete this._unconfTxCbs[txId]
this._didUpdate()
}