From f5be6cf949cce23be683d1f87cffe6e36b925cbc Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 6 Mar 2017 08:54:59 +0100 Subject: [PATCH 1/4] Etherscan links (#4772) --- js/src/3rdparty/etherscan/account.js | 22 ++-- js/src/3rdparty/etherscan/call.js | 24 +++- js/src/3rdparty/etherscan/helpers.spec.js | 4 +- js/src/3rdparty/etherscan/links.js | 33 +++++- js/src/dapps/basiccoin/services.js | 14 ++- js/src/dapps/registry/actions.js | 8 +- js/src/dapps/registry/reducers.js | 8 +- js/src/dapps/registry/ui/address.js | 10 +- js/src/dapps/registry/ui/hash.js | 8 +- js/src/dapps/registry/util/etherscan-url.js | 6 +- .../modals/ExecuteContract/executeContract.js | 1 - js/src/redux/providers/status.js | 1 + js/src/redux/providers/statusReducer.js | 1 + js/src/ui/TxHash/txHash.js | 12 +- js/src/ui/TxHash/txHash.spec.js | 4 +- js/src/ui/TxList/TxRow/txRow.js | 24 +++- js/src/ui/TxList/TxRow/txRow.spec.js | 2 +- js/src/ui/TxList/txList.js | 10 +- js/src/ui/TxList/txList.spec.js | 2 +- js/src/views/Account/Transactions/store.js | 12 +- .../views/Account/Transactions/store.spec.js | 18 +-- .../Account/Transactions/transactions.js | 8 +- js/src/views/Account/account.test.js | 2 +- js/src/views/Application/TabBar/tabBar.js | 2 - js/src/views/Application/application.js | 13 +- js/src/views/Contract/Events/Event/event.js | 6 +- js/src/views/Contract/Events/events.js | 13 +- js/src/views/Contract/contract.js | 12 +- .../Account/AccountLink/accountLink.js | 14 +-- .../Signer/components/Account/account.js | 15 ++- .../RequestPending/requestPending.js | 8 +- .../RequestPending/requestPending.spec.js | 112 ++++++++++++++++++ .../components/SignRequest/signRequest.js | 7 +- .../transactionMainDetails.js | 6 +- .../TransactionPending/transactionPending.js | 6 +- .../components/TxHashLink/txHashLink.js | 9 +- .../Signer/containers/Embedded/embedded.js | 10 +- .../containers/RequestsPage/requestsPage.js | 10 +- .../Wallet/Confirmations/confirmations.js | 8 +- .../views/Wallet/Transactions/transactions.js | 6 +- js/src/views/Wallet/wallet.js | 25 ++-- 41 files changed, 345 insertions(+), 171 deletions(-) create mode 100644 js/src/views/Signer/components/RequestPending/requestPending.spec.js diff --git a/js/src/3rdparty/etherscan/account.js b/js/src/3rdparty/etherscan/account.js index 52a08ef4b6b..27aefadb0f9 100644 --- a/js/src/3rdparty/etherscan/account.js +++ b/js/src/3rdparty/etherscan/account.js @@ -21,15 +21,15 @@ const PAGE_SIZE = 25; import util from '../../api/util'; import { call } from './call'; -function _call (method, params, test) { - return call('account', method, params, test); +function _call (method, params, test, netVersion) { + return call('account', method, params, test, netVersion); } -function balance (address, test = false) { +function balance (address, test, netVersion) { return _call('balance', { address: address, tag: 'latest' - }, test).then((balance) => { + }, test, netVersion).then((balance) => { // same format as balancemulti below return { account: address, @@ -38,21 +38,21 @@ function balance (address, test = false) { }); } -function balances (addresses, test = false) { +function balances (addresses, test, netVersion) { return _call('balancemulti', { address: addresses.join(','), tag: 'latest' - }, test); + }, test, netVersion); } -function transactions (address, page, test = false) { +function transactions (address, page, test, netVersion) { // page offset from 0 return _call('txlist', { address: address, offset: PAGE_SIZE, page: (page || 0) + 1, sort: 'desc' - }, test).then((transactions) => { + }, test, netVersion).then((transactions) => { return transactions.map((tx) => { return { blockNumber: new BigNumber(tx.blockNumber || 0), @@ -67,9 +67,9 @@ function transactions (address, page, test = false) { } const account = { - balance: balance, - balances: balances, - transactions: transactions + balance, + balances, + transactions }; export { account }; diff --git a/js/src/3rdparty/etherscan/call.js b/js/src/3rdparty/etherscan/call.js index 69c45a902c8..8f1a0ab73d1 100644 --- a/js/src/3rdparty/etherscan/call.js +++ b/js/src/3rdparty/etherscan/call.js @@ -23,14 +23,32 @@ const options = { } }; -export function call (module, action, _params, test) { - const host = test ? 'testnet.etherscan.io' : 'api.etherscan.io'; +export function call (module, action, _params, test, netVersion) { + let prefix = 'api.'; + + switch (netVersion) { + case '2': + case '3': + prefix = 'testnet.'; + break; + + case '42': + prefix = 'kovan.'; + break; + + case '0': + default: + if (test) { + prefix = 'testnet.'; + } + break; + } const query = stringify(Object.assign({ module, action }, _params || {})); - return fetch(`https://${host}/api?${query}`, options) + return fetch(`https://${prefix}etherscan.io/api?${query}`, options) .then((response) => { if (!response.ok) { throw { code: response.status, message: response.statusText }; // eslint-disable-line diff --git a/js/src/3rdparty/etherscan/helpers.spec.js b/js/src/3rdparty/etherscan/helpers.spec.js index 508a7b47a96..e48f76250b9 100644 --- a/js/src/3rdparty/etherscan/helpers.spec.js +++ b/js/src/3rdparty/etherscan/helpers.spec.js @@ -19,8 +19,8 @@ import { stringify } from 'qs'; import { url } from './links'; -function mockget (requests, test) { - let scope = nock(url(test)); +function mockget (requests, test, netVersion) { + let scope = nock(url(test, netVersion)); requests.forEach((request) => { scope = scope diff --git a/js/src/3rdparty/etherscan/links.js b/js/src/3rdparty/etherscan/links.js index 15893935684..a6b129ae524 100644 --- a/js/src/3rdparty/etherscan/links.js +++ b/js/src/3rdparty/etherscan/links.js @@ -14,14 +14,35 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -export const url = (isTestnet = false) => { - return `https://${isTestnet ? 'testnet.' : ''}etherscan.io`; +// NOTE: Keep 'isTestnet' for backwards library compatibility +export const url = (isTestnet = false, netVersion = '0') => { + let prefix = ''; + + switch (netVersion) { + case '2': + case '3': + prefix = 'testnet.'; + break; + + case '42': + prefix = 'kovan.'; + break; + + case '0': + default: + if (isTestnet) { + prefix = 'testnet.'; + } + break; + } + + return `https://${prefix}etherscan.io`; }; -export const txLink = (hash, isTestnet = false) => { - return `${url(isTestnet)}/tx/${hash}`; +export const txLink = (hash, isTestnet = false, netVersion = '0') => { + return `${url(isTestnet, netVersion)}/tx/${hash}`; }; -export const addressLink = (address, isTestnet = false) => { - return `${url(isTestnet)}/address/${address}`; +export const addressLink = (address, isTestnet = false, netVersion = '0') => { + return `${url(isTestnet, netVersion)}/address/${address}`; }; diff --git a/js/src/dapps/basiccoin/services.js b/js/src/dapps/basiccoin/services.js index f3e83c4822d..721de200bf7 100644 --- a/js/src/dapps/basiccoin/services.js +++ b/js/src/dapps/basiccoin/services.js @@ -16,6 +16,7 @@ import BigNumber from 'bignumber.js'; +import { url as etherscanUrl } from '~/3rdparty/etherscan/links'; import * as abis from '~/contracts/abi'; import { api } from './parity'; @@ -28,7 +29,7 @@ const subscriptions = {}; let defaultSubscriptionId; let nextSubscriptionId = 1000; -let isTest = false; +let netVersion = '0'; export function subscribeEvents (addresses, callback) { const subscriptionId = nextSubscriptionId++; @@ -117,14 +118,15 @@ export function attachInstances () { return Promise .all([ api.parity.registryAddress(), - api.parity.netChain() + api.parity.netChain(), + api.partiy.netVersion() ]) - .then(([registryAddress, netChain]) => { + .then(([registryAddress, netChain, _netVersion]) => { const registry = api.newContract(abis.registry, registryAddress).instance; - isTest = ['kovan', 'morden', 'ropsten', 'testnet'].includes(netChain); + netVersion = _netVersion; console.log(`contract was found at registry=${registryAddress}`); - console.log(`running on ${netChain}, isTest=${isTest}`); + console.log(`running on ${netChain}, network ${netVersion}`); return Promise .all([ @@ -282,5 +284,5 @@ export function loadTokenBalance (tokenAddress, address) { } export function txLink (txHash) { - return `https://${isTest ? 'testnet.' : ''}etherscan.io/tx/${txHash}`; + return `https://${etherscanUrl(false, netVersion)}/tx/${txHash}`; } diff --git a/js/src/dapps/registry/actions.js b/js/src/dapps/registry/actions.js index a798dd363c0..84671b81f58 100644 --- a/js/src/dapps/registry/actions.js +++ b/js/src/dapps/registry/actions.js @@ -32,16 +32,12 @@ const REGISTRY_V1_HASHES = [ '0x64c3ee34851517a9faecd995c102b339f03e564ad6772dc43a26f993238b20ec' // homestead ]; -export const setIsTestnet = (isTestnet) => ({ type: 'set isTestnet', isTestnet }); +export const setNetVersion = (netVersion) => ({ type: 'set netVersion', netVersion }); export const fetchIsTestnet = () => (dispatch) => api.net.version() .then((netVersion) => { - dispatch(setIsTestnet([ - '2', // morden - '3', // ropsten - '42' // kovan - ].includes(netVersion))); + dispatch(setNetVersion(netVersion)); }) .catch((err) => { console.error('could not check if testnet'); diff --git a/js/src/dapps/registry/reducers.js b/js/src/dapps/registry/reducers.js index 45ca9642ea1..f06452ef0bc 100644 --- a/js/src/dapps/registry/reducers.js +++ b/js/src/dapps/registry/reducers.js @@ -22,8 +22,8 @@ import namesReducer from './Names/reducers.js'; import recordsReducer from './Records/reducers.js'; import reverseReducer from './Reverse/reducers.js'; -const isTestnetReducer = (state = null, action) => - action.type === 'set isTestnet' ? action.isTestnet : state; +const netVersionReducer = (state = null, action) => + action.type === 'set netVersion' ? action.netVersion : state; const contractReducer = (state = null, action) => action.type === 'set contract' ? action.contract : state; @@ -35,7 +35,7 @@ const ownerReducer = (state = null, action) => action.type === 'set owner' ? action.owner : state; const initialState = { - isTestnet: isTestnetReducer(undefined, { type: '' }), + netVersion: netVersionReducer(undefined, { type: '' }), accounts: accountsReducer(undefined, { type: '' }), contacts: contactsReducer(undefined, { type: '' }), contract: contractReducer(undefined, { type: '' }), @@ -49,7 +49,7 @@ const initialState = { }; export default (state = initialState, action) => ({ - isTestnet: isTestnetReducer(state.isTestnet, action), + netVersion: netVersionReducer(state.netVersion, action), accounts: accountsReducer(state.accounts, action), contacts: contactsReducer(state.contacts, action), contract: contractReducer(state.contract, action), diff --git a/js/src/dapps/registry/ui/address.js b/js/src/dapps/registry/ui/address.js index d8e98c220e8..12640d921b4 100644 --- a/js/src/dapps/registry/ui/address.js +++ b/js/src/dapps/registry/ui/address.js @@ -28,7 +28,7 @@ class Address extends Component { static propTypes = { address: PropTypes.string.isRequired, account: nullableProptype(PropTypes.object.isRequired), - isTestnet: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, key: PropTypes.string, shortenHash: PropTypes.bool }; @@ -56,7 +56,7 @@ class Address extends Component { } renderCaption () { - const { address, account, isTestnet, shortenHash } = this.props; + const { address, account, netVersion, shortenHash } = this.props; if (account) { const { name } = account; @@ -64,7 +64,7 @@ class Address extends Component { return ( { - const { isTestnet } = state; + const { netVersion } = state; const { address = '' } = props; const account = allAccounts[address] || null; return { account, - isTestnet + netVersion }; }; } diff --git a/js/src/dapps/registry/ui/hash.js b/js/src/dapps/registry/ui/hash.js index 6eeaab7b2f8..792a1cb0712 100644 --- a/js/src/dapps/registry/ui/hash.js +++ b/js/src/dapps/registry/ui/hash.js @@ -26,7 +26,7 @@ const leading0x = /^0x/; class Hash extends Component { static propTypes = { hash: PropTypes.string.isRequired, - isTestnet: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, linked: PropTypes.bool } @@ -35,7 +35,7 @@ class Hash extends Component { } render () { - const { hash, isTestnet, linked } = this.props; + const { hash, netVersion, linked } = this.props; let shortened = hash.toLowerCase().replace(leading0x, ''); shortened = shortened.length > (6 + 6) @@ -46,7 +46,7 @@ class Hash extends Component { return ( { shortened } @@ -60,7 +60,7 @@ class Hash extends Component { export default connect( (state) => ({ // mapStateToProps - isTestnet: state.isTestnet + netVersion: state.netVersion }), null // mapDispatchToProps )(Hash); diff --git a/js/src/dapps/registry/util/etherscan-url.js b/js/src/dapps/registry/util/etherscan-url.js index 26fb9a84fd6..aa3556e9a2a 100644 --- a/js/src/dapps/registry/util/etherscan-url.js +++ b/js/src/dapps/registry/util/etherscan-url.js @@ -14,13 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +import { url as externalUrl } from '~/3rdparty/etherscan/links'; + const leading0x = /^0x/; -const etherscanUrl = (hash, isTestnet) => { +const etherscanUrl = (hash, isTestnet, netVersion) => { hash = hash.toLowerCase().replace(leading0x, ''); const type = hash.length === 40 ? 'address' : 'tx'; - return `https://${isTestnet ? 'testnet.' : ''}etherscan.io/${type}/0x${hash}`; + return `https://${externalUrl(isTestnet, netVersion)}/${type}/0x${hash}`; }; export default etherscanUrl; diff --git a/js/src/modals/ExecuteContract/executeContract.js b/js/src/modals/ExecuteContract/executeContract.js index 0828a5f3ed7..07863843113 100644 --- a/js/src/modals/ExecuteContract/executeContract.js +++ b/js/src/modals/ExecuteContract/executeContract.js @@ -84,7 +84,6 @@ class ExecuteContract extends Component { contract: PropTypes.object.isRequired, fromAddress: PropTypes.string, gasLimit: PropTypes.object.isRequired, - isTest: PropTypes.bool, onClose: PropTypes.func.isRequired, onFromAddressChange: PropTypes.func.isRequired } diff --git a/js/src/redux/providers/status.js b/js/src/redux/providers/status.js index d1a17532bf3..1ffcc35fc1a 100644 --- a/js/src/redux/providers/status.js +++ b/js/src/redux/providers/status.js @@ -300,6 +300,7 @@ export default class Status { defaultExtraData, netChain, netPort, + netVersion, rpcSettings, isTest, enode diff --git a/js/src/redux/providers/statusReducer.js b/js/src/redux/providers/statusReducer.js index 4bef27b1bab..fff9344b22e 100644 --- a/js/src/redux/providers/statusReducer.js +++ b/js/src/redux/providers/statusReducer.js @@ -40,6 +40,7 @@ const initialState = { max: new BigNumber(0) }, netPort: new BigNumber(0), + netVersion: '0', rpcSettings: {}, syncing: true, isConnected: false, diff --git a/js/src/ui/TxHash/txHash.js b/js/src/ui/TxHash/txHash.js index 724004ae74f..c5342ccd39c 100644 --- a/js/src/ui/TxHash/txHash.js +++ b/js/src/ui/TxHash/txHash.js @@ -34,8 +34,8 @@ class TxHash extends Component { static propTypes = { hash: PropTypes.string.isRequired, - isTest: PropTypes.bool, maxConfirmations: PropTypes.number, + netVersion: PropTypes.string.isRequired, summary: PropTypes.bool } @@ -116,10 +116,10 @@ class TxHash extends Component { } render () { - const { hash, isTest, summary } = this.props; + const { hash, netVersion, summary } = this.props; const hashLink = ( - + ); @@ -255,9 +255,11 @@ class TxHash extends Component { } function mapStateToProps (state) { - const { isTest } = state.nodeStatus; + const { netVersion } = state.nodeStatus; - return { isTest }; + return { + netVersion + }; } export default connect( diff --git a/js/src/ui/TxHash/txHash.spec.js b/js/src/ui/TxHash/txHash.spec.js index 63d81b715af..409ede8b188 100644 --- a/js/src/ui/TxHash/txHash.spec.js +++ b/js/src/ui/TxHash/txHash.spec.js @@ -63,7 +63,9 @@ function createRedux () { subscribe: sinon.stub(), getState: () => { return { - nodeStatus: { isTest: true } + nodeStatus: { + netVersion: '42' + } }; } }; diff --git a/js/src/ui/TxList/TxRow/txRow.js b/js/src/ui/TxList/TxRow/txRow.js index 35a386df060..b8ab7007f12 100644 --- a/js/src/ui/TxList/TxRow/txRow.js +++ b/js/src/ui/TxList/TxRow/txRow.js @@ -16,6 +16,7 @@ import moment from 'moment'; import React, { Component, PropTypes } from 'react'; +import { connect } from 'react-redux'; import { txLink, addressLink } from '~/3rdparty/etherscan/links'; @@ -25,7 +26,7 @@ import MethodDecoding from '../../MethodDecoding'; import styles from '../txList.css'; -export default class TxRow extends Component { +class TxRow extends Component { static contextTypes = { api: PropTypes.object.isRequired }; @@ -34,6 +35,7 @@ export default class TxRow extends Component { tx: PropTypes.object.isRequired, address: PropTypes.string.isRequired, isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, block: PropTypes.object, historic: PropTypes.bool, @@ -45,7 +47,7 @@ export default class TxRow extends Component { }; render () { - const { tx, address, isTest, historic, className } = this.props; + const { address, className, historic, netVersion, tx } = this.props; return ( @@ -57,8 +59,9 @@ export default class TxRow extends Component {
+ href={ txLink(tx.hash, false, netVersion) } + target='_blank' + > { `${tx.hash.substr(2, 6)}...${tx.hash.slice(-6)}` }
@@ -131,3 +134,16 @@ export default class TxRow extends Component { ); } } + +function mapStateToProps (state) { + const { netVersion } = state.nodeStatus; + + return { + netVersion + }; +} + +export default connect( + mapStateToProps, + null +)(TxRow); diff --git a/js/src/ui/TxList/TxRow/txRow.spec.js b/js/src/ui/TxList/TxRow/txRow.spec.js index 030ff443299..b609b35d9bf 100644 --- a/js/src/ui/TxList/TxRow/txRow.spec.js +++ b/js/src/ui/TxList/TxRow/txRow.spec.js @@ -45,7 +45,7 @@ describe('ui/TxList/TxRow', () => { value: new BigNumber(1) }; - expect(render({ address: '0x123', block, isTest: true, tx })).to.be.ok; + expect(render({ address: '0x123', block, netVersion: '42', tx })).to.be.ok; }); }); }); diff --git a/js/src/ui/TxList/txList.js b/js/src/ui/TxList/txList.js index 5cc5618d6eb..3d1b3ad6757 100644 --- a/js/src/ui/TxList/txList.js +++ b/js/src/ui/TxList/txList.js @@ -35,7 +35,7 @@ class TxList extends Component { PropTypes.array, PropTypes.object ]).isRequired, - isTest: PropTypes.bool.isRequired + netVersion: PropTypes.string.isRequired } store = new Store(this.context.api); @@ -63,7 +63,7 @@ class TxList extends Component { } renderRows () { - const { address, isTest } = this.props; + const { address, netVersion } = this.props; return this.store.sortedHashes.map((txhash) => { const tx = this.store.transactions[txhash]; @@ -76,7 +76,7 @@ class TxList extends Component { tx={ tx } block={ block } address={ address } - isTest={ isTest } + netVersion={ netVersion } /> ); }); @@ -84,10 +84,10 @@ class TxList extends Component { } function mapStateToProps (state) { - const { isTest } = state.nodeStatus; + const { netVersion } = state.nodeStatus; return { - isTest + netVersion }; } diff --git a/js/src/ui/TxList/txList.spec.js b/js/src/ui/TxList/txList.spec.js index 11367fbce6a..076514c73df 100644 --- a/js/src/ui/TxList/txList.spec.js +++ b/js/src/ui/TxList/txList.spec.js @@ -30,7 +30,7 @@ const STORE = { getState: () => { return { nodeStatus: { - isTest: true + netVersion: '42' } }; } diff --git a/js/src/views/Account/Transactions/store.js b/js/src/views/Account/Transactions/store.js index d59595c441c..b1cc4145eaa 100644 --- a/js/src/views/Account/Transactions/store.js +++ b/js/src/views/Account/Transactions/store.js @@ -21,8 +21,8 @@ import etherscan from '~/3rdparty/etherscan'; export default class Store { @observable address = null; @observable isLoading = false; - @observable isTest = undefined; @observable isTracing = false; + @observable netVersion = '0'; @observable txHashes = []; constructor (api) { @@ -44,8 +44,8 @@ export default class Store { this.isLoading = isLoading; } - @action setTest = (isTest) => { - this.isTest = isTest; + @action setNetVersion = (netVersion) => { + this.netVersion = netVersion; } @action setTracing = (isTracing) => { @@ -55,7 +55,7 @@ export default class Store { @action updateProps = (props) => { transaction(() => { this.setAddress(props.address); - this.setTest(props.isTest); + this.setNetVersion(props.netVersion); // TODO: When tracing is enabled again, adjust to actually set this.setTracing(false && props.traceMode); @@ -65,7 +65,7 @@ export default class Store { } getTransactions () { - if (this.isTest === undefined) { + if (this.netVersion === '0') { return Promise.resolve(); } @@ -87,7 +87,7 @@ export default class Store { } fetchEtherscanTransactions () { - return etherscan.account.transactions(this.address, 0, this.isTest); + return etherscan.account.transactions(this.address, 0, false, this.netVersion); } fetchTraceTransactions () { diff --git a/js/src/views/Account/Transactions/store.spec.js b/js/src/views/Account/Transactions/store.spec.js index a25b58d2982..d35d8b19578 100644 --- a/js/src/views/Account/Transactions/store.spec.js +++ b/js/src/views/Account/Transactions/store.spec.js @@ -43,7 +43,7 @@ function mockQuery () { sort: 'desc' }, reply: [{ hash: '123' }] - }], true); + }], false, '42'); } describe('views/Account/Transactions/store', () => { @@ -94,10 +94,10 @@ describe('views/Account/Transactions/store', () => { }); }); - describe('setTest', () => { - it('sets the isTest flag', () => { - store.setTest(true); - expect(store.isTest).to.be.true; + describe('setNetVersion', () => { + it('sets the netVersion', () => { + store.setNetVersion('testing'); + expect(store.netVersion).to.equal('testing'); }); }); @@ -124,7 +124,7 @@ describe('views/Account/Transactions/store', () => { it('retrieves the hashes via etherscan', () => { sinon.spy(store, 'fetchEtherscanTransactions'); store.setAddress(ADDRESS); - store.setTest(true); + store.setNetVersion('42'); store.setTracing(false); return store.getTransactions().then(() => { @@ -137,7 +137,7 @@ describe('views/Account/Transactions/store', () => { it('retrieves the hashes via tracing', () => { sinon.spy(store, 'fetchTraceTransactions'); store.setAddress(ADDRESS); - store.setTest(true); + store.setNetVersion('42'); store.setTracing(true); return store.getTransactions().then(() => { @@ -151,7 +151,7 @@ describe('views/Account/Transactions/store', () => { describe('fetchEtherscanTransactions', () => { it('retrieves the transactions', () => { store.setAddress(ADDRESS); - store.setTest(true); + store.setNetVersion('42'); return store.fetchEtherscanTransactions().then((transactions) => { expect(transactions).to.deep.equal([{ @@ -169,7 +169,7 @@ describe('views/Account/Transactions/store', () => { describe('fetchTraceTransactions', () => { it('retrieves the transactions', () => { store.setAddress(ADDRESS); - store.setTest(true); + store.setNetVersion('42'); return store.fetchTraceTransactions().then((transactions) => { expect(transactions).to.deep.equal([ diff --git a/js/src/views/Account/Transactions/transactions.js b/js/src/views/Account/Transactions/transactions.js index 547c918d854..6977639bff6 100644 --- a/js/src/views/Account/Transactions/transactions.js +++ b/js/src/views/Account/Transactions/transactions.js @@ -32,7 +32,7 @@ class Transactions extends Component { static propTypes = { address: PropTypes.string.isRequired, - isTest: PropTypes.bool, + netVersion: PropTypes.string.isRequired, traceMode: PropTypes.bool } @@ -48,7 +48,7 @@ class Transactions extends Component { return; } - const hasChanged = ['isTest', 'address'] + const hasChanged = ['address', 'netVersion'] .map(key => newProps[key] !== this.props[key]) .reduce((truth, keyTruth) => truth || keyTruth, false); @@ -109,10 +109,10 @@ class Transactions extends Component { } function mapStateToProps (state) { - const { isTest, traceMode } = state.nodeStatus; + const { netVersion, traceMode } = state.nodeStatus; return { - isTest, + netVersion, traceMode }; } diff --git a/js/src/views/Account/account.test.js b/js/src/views/Account/account.test.js index d457bf7a154..a27e266ce33 100644 --- a/js/src/views/Account/account.test.js +++ b/js/src/views/Account/account.test.js @@ -31,7 +31,7 @@ function createRedux () { }, images: {}, nodeStatus: { - isTest: false, + netVersion: '1', traceMode: false }, personal: { diff --git a/js/src/views/Application/TabBar/tabBar.js b/js/src/views/Application/TabBar/tabBar.js index 81be1d294e2..417fe6c9e21 100644 --- a/js/src/views/Application/TabBar/tabBar.js +++ b/js/src/views/Application/TabBar/tabBar.js @@ -84,8 +84,6 @@ class TabBar extends Component { }; static propTypes = { - isTest: PropTypes.bool, - netChain: PropTypes.string, pending: PropTypes.array, views: PropTypes.array.isRequired }; diff --git a/js/src/views/Application/application.js b/js/src/views/Application/application.js index 684b7c3904f..d36c60c3923 100644 --- a/js/src/views/Application/application.js +++ b/js/src/views/Application/application.js @@ -46,8 +46,6 @@ class Application extends Component { static propTypes = { blockNumber: PropTypes.object, children: PropTypes.node, - isTest: PropTypes.bool, - netChain: PropTypes.string, pending: PropTypes.array } @@ -86,17 +84,14 @@ class Application extends Component { } renderApp () { - const { blockNumber, children, pending, netChain, isTest } = this.props; + const { blockNumber, children, pending } = this.props; return ( - +
{ children }
@@ -123,15 +118,13 @@ class Application extends Component { } function mapStateToProps (state) { - const { blockNumber, netChain, isTest } = state.nodeStatus; + const { blockNumber } = state.nodeStatus; const { hasAccounts } = state.personal; const { pending } = state.signer; return { blockNumber, hasAccounts, - isTest, - netChain, pending }; } diff --git a/js/src/views/Contract/Events/Event/event.js b/js/src/views/Contract/Events/Event/event.js index f5ca3491085..a66a63c5cf0 100644 --- a/js/src/views/Contract/Events/Event/event.js +++ b/js/src/views/Contract/Events/Event/event.js @@ -31,7 +31,7 @@ export default class Event extends Component { static propTypes = { event: PropTypes.object.isRequired, - isTest: PropTypes.bool + netVersion: PropTypes.string.isRequired } state = { @@ -43,11 +43,11 @@ export default class Event extends Component { } render () { - const { event, isTest } = this.props; + const { event, netVersion } = this.props; const { block, transaction } = this.state; const classes = `${styles.event} ${styles[event.state]}`; - const url = txLink(event.transactionHash, isTest); + const url = txLink(event.transactionHash, false, netVersion); const keys = Object.keys(event.params).join(', '); const values = Object.keys(event.params).map((name, index) => { const param = event.params[name]; diff --git a/js/src/views/Contract/Events/events.js b/js/src/views/Contract/Events/events.js index 1367624e856..e68c9c33394 100644 --- a/js/src/views/Contract/Events/events.js +++ b/js/src/views/Contract/Events/events.js @@ -28,9 +28,9 @@ export default class Events extends Component { }; static propTypes = { - isTest: PropTypes.bool.isRequired, isLoading: PropTypes.bool, - events: PropTypes.array + events: PropTypes.array, + netVersion: PropTypes.string.isRequired }; static defaultProps = { @@ -39,7 +39,7 @@ export default class Events extends Component { }; render () { - const { events, isTest, isLoading } = this.props; + const { events, isLoading, netVersion } = this.props; if (isLoading) { return ( @@ -67,7 +67,8 @@ export default class Events extends Component { + netVersion={ netVersion } + /> ); }); @@ -82,7 +83,9 @@ export default class Events extends Component { - { list } + + { list } +
); diff --git a/js/src/views/Contract/contract.js b/js/src/views/Contract/contract.js index 91f1436bb08..cb2c74efe3a 100644 --- a/js/src/views/Contract/contract.js +++ b/js/src/views/Contract/contract.js @@ -52,7 +52,7 @@ class Contract extends Component { accountsInfo: PropTypes.object, balances: PropTypes.object, contracts: PropTypes.object, - isTest: PropTypes.bool, + netVersion: PropTypes.string.isRequired, params: PropTypes.object }; @@ -119,7 +119,7 @@ class Contract extends Component { } render () { - const { accountsInfo, balances, contracts, params, isTest } = this.props; + const { accountsInfo, balances, contracts, netVersion, params } = this.props; const { allEvents, contract, queryValues, loadingEvents } = this.state; const account = contracts[params.address]; const balance = balances[params.address]; @@ -148,9 +148,9 @@ class Contract extends Component { values={ queryValues } /> { this.renderDetails(account) } @@ -484,14 +484,14 @@ class Contract extends Component { function mapStateToProps (state) { const { accounts, accountsInfo, contracts } = state.personal; const { balances } = state.balances; - const { isTest } = state.nodeStatus; + const { netVersion } = state.nodeStatus; return { - isTest, accounts, accountsInfo, + balances, contracts, - balances + netVersion }; } diff --git a/js/src/views/Signer/components/Account/AccountLink/accountLink.js b/js/src/views/Signer/components/Account/AccountLink/accountLink.js index c4bc362c116..af6c7e67e59 100644 --- a/js/src/views/Signer/components/Account/AccountLink/accountLink.js +++ b/js/src/views/Signer/components/Account/AccountLink/accountLink.js @@ -21,7 +21,7 @@ import styles from './accountLink.css'; export default class AccountLink extends Component { static propTypes = { - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, address: PropTypes.string.isRequired, className: PropTypes.string, children: PropTypes.node @@ -32,15 +32,15 @@ export default class AccountLink extends Component { }; componentWillMount () { - const { address, isTest } = this.props; + const { address, netVersion } = this.props; - this.updateLink(address, isTest); + this.updateLink(address, netVersion); } componentWillReceiveProps (nextProps) { - const { address, isTest } = nextProps; + const { address, netVersion } = nextProps; - this.updateLink(address, isTest); + this.updateLink(address, netVersion); } render () { @@ -56,8 +56,8 @@ export default class AccountLink extends Component { ); } - updateLink (address, isTest) { - const link = addressLink(address, isTest); + updateLink (address, netVersion) { + const link = addressLink(address, netVersion); this.setState({ link diff --git a/js/src/views/Signer/components/Account/account.js b/js/src/views/Signer/components/Account/account.js index dbe950b7500..f5a220f7d15 100644 --- a/js/src/views/Signer/components/Account/account.js +++ b/js/src/views/Signer/components/Account/account.js @@ -25,7 +25,7 @@ export default class Account extends Component { static propTypes = { className: PropTypes.string, address: PropTypes.string.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, balance: PropTypes.object // eth BigNumber, not required since it mght take time to fetch }; @@ -51,13 +51,14 @@ export default class Account extends Component { } render () { - const { address, isTest, className } = this.props; + const { address, netVersion, className } = this.props; return (
+ netVersion={ netVersion } + > @@ -76,14 +77,15 @@ export default class Account extends Component { } renderName () { - const { address, isTest } = this.props; + const { address, netVersion } = this.props; const name = ; if (!name) { return ( + netVersion={ netVersion } + > [{ this.shortAddress(address) }] ); @@ -92,7 +94,8 @@ export default class Account extends Component { return ( + netVersion={ netVersion } + > { name } [{ this.tinyAddress(address) }] diff --git a/js/src/views/Signer/components/RequestPending/requestPending.js b/js/src/views/Signer/components/RequestPending/requestPending.js index 3cce680ed0f..afb434e14c5 100644 --- a/js/src/views/Signer/components/RequestPending/requestPending.js +++ b/js/src/views/Signer/components/RequestPending/requestPending.js @@ -27,7 +27,7 @@ export default class RequestPending extends Component { gasLimit: PropTypes.object.isRequired, id: PropTypes.object.isRequired, isSending: PropTypes.bool.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, onConfirm: PropTypes.func.isRequired, onReject: PropTypes.func.isRequired, payload: PropTypes.oneOfType([ @@ -51,7 +51,7 @@ export default class RequestPending extends Component { }; render () { - const { className, date, focus, gasLimit, id, isSending, isTest, onReject, payload, store } = this.props; + const { className, date, focus, gasLimit, id, isSending, netVersion, onReject, payload, store } = this.props; if (payload.sign) { const { sign } = payload; @@ -65,7 +65,7 @@ export default class RequestPending extends Component { id={ id } isFinished={ false } isSending={ isSending } - isTest={ isTest } + netVersion={ netVersion } onConfirm={ this.onConfirm } onReject={ onReject } store={ store } /> @@ -82,7 +82,7 @@ export default class RequestPending extends Component { gasLimit={ gasLimit } id={ id } isSending={ isSending } - isTest={ isTest } + netVersion={ netVersion } onConfirm={ this.onConfirm } onReject={ onReject } store={ store } diff --git a/js/src/views/Signer/components/RequestPending/requestPending.spec.js b/js/src/views/Signer/components/RequestPending/requestPending.spec.js new file mode 100644 index 00000000000..686c23b6786 --- /dev/null +++ b/js/src/views/Signer/components/RequestPending/requestPending.spec.js @@ -0,0 +1,112 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +import BigNumber from 'bignumber.js'; +import { shallow } from 'enzyme'; +import React from 'react'; +import sinon from 'sinon'; + +import RequestPending from './'; + +const ADDRESS = '0x1234567890123456789012345678901234567890'; +const TRANSACTION = { + from: ADDRESS, + gas: new BigNumber(21000), + gasPrice: new BigNumber(20000000), + value: new BigNumber(1) +}; +const PAYLOAD_SENDTX = { + sendTransaction: TRANSACTION +}; +const PAYLOAD_SIGN = { + sign: { + address: ADDRESS, + data: 'testing' + } +}; +const PAYLOAD_SIGNTX = { + signTransaction: TRANSACTION +}; + +let component; +let onConfirm; +let onReject; + +function render (payload) { + onConfirm = sinon.stub(); + onReject = sinon.stub(); + + component = shallow( + + ); + + return component; +} + +describe('views/Signer/RequestPending', () => { + describe('sendTransaction', () => { + beforeEach(() => { + render(PAYLOAD_SENDTX); + }); + + it('renders defaults', () => { + expect(component).to.be.ok; + }); + + it('renders TransactionPending component', () => { + expect(component.find('Connect(TransactionPending)')).to.have.length(1); + }); + }); + + describe('sign', () => { + beforeEach(() => { + render(PAYLOAD_SIGN); + }); + + it('renders defaults', () => { + expect(component).to.be.ok; + }); + + it('renders SignRequest component', () => { + expect(component.find('SignRequest')).to.have.length(1); + }); + }); + + describe('signTransaction', () => { + beforeEach(() => { + render(PAYLOAD_SIGNTX); + }); + + it('renders defaults', () => { + expect(component).to.be.ok; + }); + + it('renders TransactionPending component', () => { + expect(component.find('Connect(TransactionPending)')).to.have.length(1); + }); + }); +}); diff --git a/js/src/views/Signer/components/SignRequest/signRequest.js b/js/src/views/Signer/components/SignRequest/signRequest.js index c26d67d2005..78c03c60a1b 100644 --- a/js/src/views/Signer/components/SignRequest/signRequest.js +++ b/js/src/views/Signer/components/SignRequest/signRequest.js @@ -44,8 +44,8 @@ export default class SignRequest extends Component { address: PropTypes.string.isRequired, data: PropTypes.string.isRequired, isFinished: PropTypes.bool.isRequired, - isTest: PropTypes.bool.isRequired, store: PropTypes.object.isRequired, + netVersion: PropTypes.string.isRequired, className: PropTypes.string, focus: PropTypes.bool, @@ -92,7 +92,7 @@ export default class SignRequest extends Component { renderDetails () { const { api } = this.context; - const { address, isTest, store, data } = this.props; + const { address, netVersion, store, data } = this.props; const balance = store.balances[address]; if (!balance) { @@ -105,7 +105,8 @@ export default class SignRequest extends Component { + netVersion={ netVersion } + />

A request to sign data using your account:

diff --git a/js/src/views/Signer/components/TransactionMainDetails/transactionMainDetails.js b/js/src/views/Signer/components/TransactionMainDetails/transactionMainDetails.js index 812d1fb355d..2d8627c57a8 100644 --- a/js/src/views/Signer/components/TransactionMainDetails/transactionMainDetails.js +++ b/js/src/views/Signer/components/TransactionMainDetails/transactionMainDetails.js @@ -31,7 +31,7 @@ export default class TransactionMainDetails extends Component { fromBalance: PropTypes.object, gasStore: PropTypes.object, id: PropTypes.object.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, totalValue: PropTypes.object.isRequired, transaction: PropTypes.object.isRequired, value: PropTypes.object.isRequired @@ -50,7 +50,7 @@ export default class TransactionMainDetails extends Component { } render () { - const { children, from, fromBalance, gasStore, isTest, transaction } = this.props; + const { children, from, fromBalance, gasStore, netVersion, transaction } = this.props; return (
@@ -59,7 +59,7 @@ export default class TransactionMainDetails extends Component {
diff --git a/js/src/views/Signer/components/TransactionPending/transactionPending.js b/js/src/views/Signer/components/TransactionPending/transactionPending.js index 4030eb82801..98be91d5fa3 100644 --- a/js/src/views/Signer/components/TransactionPending/transactionPending.js +++ b/js/src/views/Signer/components/TransactionPending/transactionPending.js @@ -39,7 +39,7 @@ export default class TransactionPending extends Component { gasLimit: PropTypes.object, id: PropTypes.object.isRequired, isSending: PropTypes.bool.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, nonce: PropTypes.number, onConfirm: PropTypes.func.isRequired, onReject: PropTypes.func.isRequired, @@ -87,7 +87,7 @@ export default class TransactionPending extends Component { } renderTransaction () { - const { className, focus, id, isSending, isTest, store, transaction } = this.props; + const { className, focus, id, isSending, netVersion, store, transaction } = this.props; const { totalValue } = this.state; const { from, value } = transaction; @@ -101,7 +101,7 @@ export default class TransactionPending extends Component { fromBalance={ fromBalance } gasStore={ this.gasStore } id={ id } - isTest={ isTest } + netVersion={ netVersion } totalValue={ totalValue } transaction={ transaction } value={ value } /> diff --git a/js/src/views/Signer/components/TxHashLink/txHashLink.js b/js/src/views/Signer/components/TxHashLink/txHashLink.js index be92828c1e7..00f9952d51b 100644 --- a/js/src/views/Signer/components/TxHashLink/txHashLink.js +++ b/js/src/views/Signer/components/TxHashLink/txHashLink.js @@ -22,18 +22,19 @@ export default class TxHashLink extends Component { static propTypes = { children: PropTypes.node, className: PropTypes.string, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, txHash: PropTypes.string.isRequired } render () { - const { children, className, isTest, txHash } = this.props; + const { children, className, netVersion, txHash } = this.props; return ( + href={ txLink(txHash, false, netVersion) } + target='_blank' + > { children || txHash } ); diff --git a/js/src/views/Signer/containers/Embedded/embedded.js b/js/src/views/Signer/containers/Embedded/embedded.js index b7965743083..555f412f68b 100644 --- a/js/src/views/Signer/containers/Embedded/embedded.js +++ b/js/src/views/Signer/containers/Embedded/embedded.js @@ -38,7 +38,7 @@ class Embedded extends Component { startRejectRequest: PropTypes.func.isRequired }).isRequired, gasLimit: PropTypes.object.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, signer: PropTypes.shape({ finished: PropTypes.array.isRequired, pending: PropTypes.array.isRequired @@ -79,7 +79,7 @@ class Embedded extends Component { } renderPending = (data, index) => { - const { actions, gasLimit, isTest } = this.props; + const { actions, gasLimit, netVersion } = this.props; const { date, id, isSending, payload } = data; return ( @@ -90,7 +90,7 @@ class Embedded extends Component { gasLimit={ gasLimit } id={ id } isSending={ isSending } - isTest={ isTest } + netVersion={ netVersion } key={ id } onConfirm={ actions.startConfirmRequest } onReject={ actions.startRejectRequest } @@ -106,13 +106,13 @@ class Embedded extends Component { } function mapStateToProps (state) { - const { gasLimit, isTest } = state.nodeStatus; + const { gasLimit, netVersion } = state.nodeStatus; const { actions, signer } = state; return { actions, gasLimit, - isTest, + netVersion, signer }; } diff --git a/js/src/views/Signer/containers/RequestsPage/requestsPage.js b/js/src/views/Signer/containers/RequestsPage/requestsPage.js index ebc955157a3..fe0d49b7303 100644 --- a/js/src/views/Signer/containers/RequestsPage/requestsPage.js +++ b/js/src/views/Signer/containers/RequestsPage/requestsPage.js @@ -40,7 +40,7 @@ class RequestsPage extends Component { startRejectRequest: PropTypes.func.isRequired }).isRequired, gasLimit: PropTypes.object.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, signer: PropTypes.shape({ pending: PropTypes.array.isRequired, finished: PropTypes.array.isRequired @@ -105,7 +105,7 @@ class RequestsPage extends Component { } renderPending = (data, index) => { - const { actions, gasLimit, isTest } = this.props; + const { actions, gasLimit, netVersion } = this.props; const { date, id, isSending, payload } = data; return ( @@ -116,7 +116,7 @@ class RequestsPage extends Component { gasLimit={ gasLimit } id={ id } isSending={ isSending } - isTest={ isTest } + netVersion={ netVersion } key={ id } onConfirm={ actions.startConfirmRequest } onReject={ actions.startRejectRequest } @@ -128,13 +128,13 @@ class RequestsPage extends Component { } function mapStateToProps (state) { - const { gasLimit, isTest } = state.nodeStatus; + const { gasLimit, netVersion } = state.nodeStatus; const { actions, signer } = state; return { actions, gasLimit, - isTest, + netVersion, signer }; } diff --git a/js/src/views/Wallet/Confirmations/confirmations.js b/js/src/views/Wallet/Confirmations/confirmations.js index 1c70a94e2da..c6e841bfa7c 100644 --- a/js/src/views/Wallet/Confirmations/confirmations.js +++ b/js/src/views/Wallet/Confirmations/confirmations.js @@ -36,7 +36,7 @@ class WalletConfirmations extends Component { static propTypes = { accounts: PropTypes.object.isRequired, address: PropTypes.string.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, owners: PropTypes.array.isRequired, require: PropTypes.object.isRequired, confirmOperation: PropTypes.func.isRequired, @@ -109,7 +109,7 @@ class WalletConfirmation extends Component { accounts: PropTypes.object.isRequired, confirmation: PropTypes.object.isRequired, address: PropTypes.string.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, owners: PropTypes.array.isRequired, require: PropTypes.object.isRequired, confirmOperation: PropTypes.func.isRequired, @@ -320,13 +320,14 @@ class WalletConfirmation extends Component { } renderTransactionRow (confirmation, className) { - const { address, isTest } = this.props; + const { address, netVersion } = this.props; const { operation, transactionHash, blockNumber, value, to, data } = confirmation; if (value && to && data) { return ( ); diff --git a/js/src/views/Wallet/Transactions/transactions.js b/js/src/views/Wallet/Transactions/transactions.js index 0f2558dfca1..b8d3b21b322 100644 --- a/js/src/views/Wallet/Transactions/transactions.js +++ b/js/src/views/Wallet/Transactions/transactions.js @@ -25,7 +25,7 @@ import txListStyles from '~/ui/TxList/txList.css'; export default class WalletTransactions extends Component { static propTypes = { address: PropTypes.string.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, transactions: PropTypes.array }; @@ -43,7 +43,7 @@ export default class WalletTransactions extends Component { ); } renderTransactions () { - const { address, isTest, transactions } = this.props; + const { address, netVersion, transactions } = this.props; if (!transactions) { return null; @@ -62,6 +62,7 @@ export default class WalletTransactions extends Component { return ( ); }); diff --git a/js/src/views/Wallet/wallet.js b/js/src/views/Wallet/wallet.js index a66b15c3e3e..d1843bff087 100644 --- a/js/src/views/Wallet/wallet.js +++ b/js/src/views/Wallet/wallet.js @@ -40,20 +40,23 @@ import styles from './wallet.css'; class WalletContainer extends Component { static propTypes = { - isTest: PropTypes.any + netVersion: PropTypes.string.isRequired }; render () { - const { isTest, ...others } = this.props; + const { netVersion, ...others } = this.props; - if (isTest !== false && isTest !== true) { + if (netVersion === '0') { return ( ); } return ( - + ); } } @@ -67,7 +70,7 @@ class Wallet extends Component { address: PropTypes.string.isRequired, balance: nullableProptype(PropTypes.object.isRequired), images: PropTypes.object.isRequired, - isTest: PropTypes.bool.isRequired, + netVersion: PropTypes.string.isRequired, owned: PropTypes.bool.isRequired, setVisibleAccounts: PropTypes.func.isRequired, wallet: PropTypes.object.isRequired, @@ -177,7 +180,7 @@ class Wallet extends Component { } renderDetails () { - const { address, isTest, wallet } = this.props; + const { address, netVersion, wallet } = this.props; const { owners, require, confirmations, transactions } = wallet; if (!owners || !require) { @@ -190,19 +193,19 @@ class Wallet extends Component { return [ , ]; } @@ -354,7 +357,7 @@ function mapStateToProps (_, initProps) { const { address } = initProps.params; return (state) => { - const { isTest } = state.nodeStatus; + const { netVersion } = state.nodeStatus; const { accountsInfo = {}, accounts = {} } = state.personal; const { balances } = state.balances; const { images } = state; @@ -372,7 +375,7 @@ function mapStateToProps (_, initProps) { address, balance, images, - isTest, + netVersion, owned, wallet, walletAccount From d2de1c8a97adfbe8ebe3b09376514a5fd76440a8 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 6 Mar 2017 11:18:02 +0100 Subject: [PATCH 2/4] Port tests --- js/src/ui/TxList/TxRow/txRow.spec.js | 18 ++++++++++++++++++ .../RequestPending/requestPending.spec.js | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/js/src/ui/TxList/TxRow/txRow.spec.js b/js/src/ui/TxList/TxRow/txRow.spec.js index b609b35d9bf..a8b95fd3fb0 100644 --- a/js/src/ui/TxList/TxRow/txRow.spec.js +++ b/js/src/ui/TxList/TxRow/txRow.spec.js @@ -25,9 +25,27 @@ import TxRow from './txRow'; const api = new Api({ execute: sinon.stub() }); +const STORE = { + dispatch: sinon.stub(), + subscribe: sinon.stub(), + getState: () => { + return { + nodeStatus: { + netVersion: '42' + }, + personal: { + accounts: { + '0x123': {} + } + } + }; + } +}; + function render (props) { return shallow( , { context: { api } } ); diff --git a/js/src/views/Signer/components/RequestPending/requestPending.spec.js b/js/src/views/Signer/components/RequestPending/requestPending.spec.js index 686c23b6786..b4c2b8afea1 100644 --- a/js/src/views/Signer/components/RequestPending/requestPending.spec.js +++ b/js/src/views/Signer/components/RequestPending/requestPending.spec.js @@ -78,7 +78,7 @@ describe('views/Signer/RequestPending', () => { }); it('renders TransactionPending component', () => { - expect(component.find('Connect(TransactionPending)')).to.have.length(1); + expect(component.find('TransactionPending')).to.have.length(1); }); }); @@ -106,7 +106,7 @@ describe('views/Signer/RequestPending', () => { }); it('renders TransactionPending component', () => { - expect(component.find('Connect(TransactionPending)')).to.have.length(1); + expect(component.find('TransactionPending')).to.have.length(1); }); }); }); From 221f6301559d9f2f78d5ba1306cbb1fdd898eb14 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 6 Mar 2017 11:36:58 +0100 Subject: [PATCH 3/4] update address links --- js/src/ui/TxList/TxRow/txRow.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/src/ui/TxList/TxRow/txRow.js b/js/src/ui/TxList/TxRow/txRow.js index b8ab7007f12..e9c75fcbf48 100644 --- a/js/src/ui/TxList/TxRow/txRow.js +++ b/js/src/ui/TxList/TxRow/txRow.js @@ -34,7 +34,6 @@ class TxRow extends Component { static propTypes = { tx: PropTypes.object.isRequired, address: PropTypes.string.isRequired, - isTest: PropTypes.bool.isRequired, netVersion: PropTypes.string.isRequired, block: PropTypes.object, @@ -78,13 +77,13 @@ class TxRow extends Component { } renderAddress (address) { - const { isTest } = this.props; + const { netVersion } = this.props; let esLink = null; if (address) { esLink = ( From bba0d3697609b5bcd74b53e9e6b955271a447607 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 6 Mar 2017 11:44:50 +0100 Subject: [PATCH 4/4] Signer accountlink isTest --- .../views/Signer/components/Account/AccountLink/accountLink.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/views/Signer/components/Account/AccountLink/accountLink.js b/js/src/views/Signer/components/Account/AccountLink/accountLink.js index af6c7e67e59..1b7de7ec740 100644 --- a/js/src/views/Signer/components/Account/AccountLink/accountLink.js +++ b/js/src/views/Signer/components/Account/AccountLink/accountLink.js @@ -57,7 +57,7 @@ export default class AccountLink extends Component { } updateLink (address, netVersion) { - const link = addressLink(address, netVersion); + const link = addressLink(address, false, netVersion); this.setState({ link