diff options
author | kumavis <kumavis@users.noreply.github.com> | 2016-04-21 13:07:00 +0800 |
---|---|---|
committer | kumavis <kumavis@users.noreply.github.com> | 2016-04-21 13:07:00 +0800 |
commit | db85827b2be19d7bfc7dfaeec4786c4d051b6629 (patch) | |
tree | 39075d39ddcfbcb80016d61a22942451dbc745b9 /app/scripts | |
parent | f82a4de725e384ab4bb39c57f83a3dbb406c8db6 (diff) | |
parent | 532edf670e8c30db958765141974f3fb0f5ec44c (diff) | |
download | tangerine-wallet-browser-db85827b2be19d7bfc7dfaeec4786c4d051b6629.tar tangerine-wallet-browser-db85827b2be19d7bfc7dfaeec4786c4d051b6629.tar.gz tangerine-wallet-browser-db85827b2be19d7bfc7dfaeec4786c4d051b6629.tar.bz2 tangerine-wallet-browser-db85827b2be19d7bfc7dfaeec4786c4d051b6629.tar.lz tangerine-wallet-browser-db85827b2be19d7bfc7dfaeec4786c4d051b6629.tar.xz tangerine-wallet-browser-db85827b2be19d7bfc7dfaeec4786c4d051b6629.tar.zst tangerine-wallet-browser-db85827b2be19d7bfc7dfaeec4786c4d051b6629.zip |
Merge pull request #125 from MetaMask/TransactionList
Add transaction history to account detail view
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/lib/config-manager.js | 18 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 8 | ||||
-rw-r--r-- | app/scripts/popup.js | 11 |
3 files changed, 32 insertions, 5 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index 356d53c22..c79dc7a8f 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -170,14 +170,26 @@ ConfigManager.prototype.rejectTx = function(txId) { } ConfigManager.prototype._setTxStatus = function(txId, status) { + var tx = this.getTx(txId) + tx.status = status + this.updateTx(tx) +} + +ConfigManager.prototype.updateTx = function(tx) { var transactions = this.getTxList() - transactions.forEach((tx) => { - if (tx.id === txId) { - tx.status = status + var found, index + transactions.forEach((otherTx, i) => { + if (otherTx.id === tx.id) { + found = true + index = i } }) + if (found) { + transactions[index] = tx + } this._saveTxList(transactions) } + ConfigManager.prototype.unconfirmedTxs = function() { var transactions = this.getTxList() return transactions.filter(tx => tx.status === 'unconfirmed') diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index b451fd6d4..7763d33d8 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -135,6 +135,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function(txParams, cb){ // create txData obj with parameters and meta data var time = (new Date()).getTime() var txId = createId() + txParams.metamaskId = txId var txData = { id: txId, txParams: txParams, @@ -337,6 +338,13 @@ function IdManagement(opts) { txParams.gasLimit = ethUtil.addHexPrefix(txParams.gasLimit || txParams.gas) txParams.nonce = ethUtil.addHexPrefix(txParams.nonce) var tx = new Transaction(txParams) + + // Add the tx hash to the persisted meta-tx object + var hash = '0x' + tx.hash().toString('hex') + var metaTx = configManager.getTx(txParams.metamaskId) + metaTx.hash = hash + configManager.updateTx(metaTx) + var rawTx = '0x'+tx.serialize().toString('hex') return '0x'+LightwalletSigner.signTx(this.keyStore, this.derivedKey, rawTx, txParams.from, this.hdPathString) } diff --git a/app/scripts/popup.js b/app/scripts/popup.js index 85b3e30f9..6a39da661 100644 --- a/app/scripts/popup.js +++ b/app/scripts/popup.js @@ -17,7 +17,7 @@ injectCss(css) async.parallel({ currentDomain: getCurrentDomain, accountManager: connectToAccountManager, -}, setupApp) +}, getNetworkVersion) function connectToAccountManager(cb){ // setup communication with background @@ -65,6 +65,13 @@ function getCurrentDomain(cb){ }) } +function getNetworkVersion(cb, results) { + web3.version.getNetwork(function(err, result) { + results.networkVersion = result + setupApp(err, results) + }) +} + function setupApp(err, opts){ if (err) { alert(err.stack) @@ -78,6 +85,6 @@ function setupApp(err, opts){ container: container, accountManager: opts.accountManager, currentDomain: opts.currentDomain, + networkVersion: opts.networkVersion, }) - } |