diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | app/scripts/lib/config-manager.js | 6 | ||||
-rw-r--r-- | test/unit/account-link-test.js | 12 | ||||
-rw-r--r-- | test/unit/config-manager-test.js | 11 | ||||
-rw-r--r-- | ui/app/account-detail.js | 1 | ||||
-rw-r--r-- | ui/app/components/transaction-list.js | 34 | ||||
-rw-r--r-- | ui/lib/account-link.js | 18 |
7 files changed, 77 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index bf5255497..23d5b3af3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ - Added ShapeShift to the transaction history - Added affiliate key to Shapeshift requests - Added feature to reflect current conversion rates of current vault balance. +- Transaction history now has a hard limit. +- Added a link to view more account info after transaction history. - Modify balance display logic. ## 2.8.0 2016-08-15 diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index 6f5cb3a4a..4d270bcdb 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -5,6 +5,7 @@ const rp = require('request-promise') const TESTNET_RPC = MetamaskConfig.network.testnet const MAINNET_RPC = MetamaskConfig.network.mainnet +const txLimit = 40 /* The config-manager is a convenience object * wrapping a pojo-migrator. @@ -15,6 +16,8 @@ const MAINNET_RPC = MetamaskConfig.network.mainnet */ module.exports = ConfigManager function ConfigManager (opts) { + this.txLimit = txLimit + // ConfigManager is observable and will emit updates this._subs = [] @@ -181,6 +184,9 @@ ConfigManager.prototype._saveTxList = function (txList) { ConfigManager.prototype.addTx = function (tx) { var transactions = this.getTxList() + while (transactions.length > this.txLimit - 1) { + transactions.shift() + } transactions.push(tx) this._saveTxList(transactions) } diff --git a/test/unit/account-link-test.js b/test/unit/account-link-test.js new file mode 100644 index 000000000..39889b6be --- /dev/null +++ b/test/unit/account-link-test.js @@ -0,0 +1,12 @@ +var assert = require('assert') +var linkGen = require('../../ui/lib/account-link') + +describe('account-link', function() { + + it('adds testnet prefix to morden test network', function() { + var result = linkGen('account', '2') + assert.notEqual(result.indexOf('testnet'), -1, 'testnet injected') + assert.notEqual(result.indexOf('account'), -1, 'account included') + }) + +}) diff --git a/test/unit/config-manager-test.js b/test/unit/config-manager-test.js index b34089163..eaa5376fd 100644 --- a/test/unit/config-manager-test.js +++ b/test/unit/config-manager-test.js @@ -233,6 +233,17 @@ describe('config-manager', function() { assert.equal(result.length, 1) assert.equal(result[0].id, 1) }) + + it('cuts off early txs beyond a limit', function() { + const limit = configManager.txLimit + for (let i = 0; i < limit + 1; i++) { + let tx = { id: i } + configManager.addTx(tx) + } + var result = configManager.getTxList() + assert.equal(result.length, limit, `limit of ${limit} txs enforced`) + assert.equal(result[0].id, 1, 'early txs truncted') + }) }) describe('#confirmTx', function() { diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js index 836f4bcb9..e00a34c4a 100644 --- a/ui/app/account-detail.js +++ b/ui/app/account-detail.js @@ -244,6 +244,7 @@ AccountDetailScreen.prototype.transactionList = function () { network, unconfTxs, unconfMsgs, + address, shapeShiftTxList, viewPendingTx: (txId) => { this.props.dispatch(actions.viewPendingTx(txId)) diff --git a/ui/app/components/transaction-list.js b/ui/app/components/transaction-list.js index 9bf0f6d81..9348b9fc4 100644 --- a/ui/app/components/transaction-list.js +++ b/ui/app/components/transaction-list.js @@ -1,6 +1,8 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits +const genAccountLink = require('../../lib/account-link') +const extension = require('../../../app/scripts/lib/extension') const TransactionListItem = require('./transaction-list-item') @@ -13,13 +15,15 @@ function TransactionList () { } TransactionList.prototype.render = function () { - const { txsToRender, network, unconfMsgs } = this.props + const { txsToRender, network, unconfMsgs, address } = this.props + const transactions = txsToRender.concat(unconfMsgs) var shapeShiftTxList if (network === '1'){ shapeShiftTxList = this.props.shapeShiftTxList } const transactions = !shapeShiftTxList ? txsToRender.concat(unconfMsgs) : txsToRender.concat(unconfMsgs, shapeShiftTxList) .sort((a, b) => b.time - a.time) + const accountLink = genAccountLink(address, network) return ( @@ -49,11 +53,11 @@ TransactionList.prototype.render = function () { h('.tx-list', { style: { overflowY: 'auto', - height: '305px', + height: '300px', padding: '0 20px', textAlign: 'center', }, - }, ( + }, [ transactions.length ? transactions.map((transaction, i) => { @@ -63,13 +67,29 @@ TransactionList.prototype.render = function () { this.props.viewPendingTx(txId) }, }) - }) - : [h('.flex-center', { + }).concat(viewMoreButton(accountLink)) + : h('.flex-center', { style: { + flexDirection: 'column', height: '100%', }, - }, 'No transaction history...')] - )), + }, [ + 'No transaction history.', + viewMoreButton(accountLink), + ]), + ]), ]) ) } + +function viewMoreButton(url) { + return url ? h('button', { + style: { + margin: '10px', + }, + onClick: (ev) => { + ev.preventDefault() + extension.tabs.create({ url }) + }, + }, 'Show More') : null +} diff --git a/ui/lib/account-link.js b/ui/lib/account-link.js new file mode 100644 index 000000000..eb958e22d --- /dev/null +++ b/ui/lib/account-link.js @@ -0,0 +1,18 @@ +module.exports = function(address, network) { + const net = parseInt(network) + let link + + switch (net) { + case 1: // main net + link = `http://etherscan.io/address/${address}` + break + case 2: // morden test net + link = `http://testnet.etherscan.io/address/${address}` + break + default: + link = '' + break + } + + return link +} |