diff --git a/Jenkinsfile b/Jenkinsfile index dc336f54f..a7119c67f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,34 +40,6 @@ node('lisk-nano') { echo "Error: ${err}" fail('Stopping build: checkout failed') } - - try { - sh ''' - N=${EXECUTOR_NUMBER:-0}; N=$((N+1)) - cd ~/lisk-Linux-x86_64 - # work around core bug: config.json gets overwritten; use backup - cp .config.json config_$N.json - # change core port, listen only on 127.0.0.1 - sed -i -r -e "s/^(.*ort\\":) 4000,/\\1 400$N,/" config_$N.json - sed -i -r -e "s/^(.*\\"address\\":) \\"0.0.0.0\\",/\\1 \\"127.0.0.1\\",/" config_$N.json - # disable redis - sed -i -r -e "s/^(\\s*\\"cacheEnabled\\":) true/\\1 false/" config_$N.json - # change postgres databse - sed -i -r -e "s/^(\\s*\\"database\\": \\"lisk_test)\\",/\\1_$N\\",/" config_$N.json - cp etc/pm2-lisk.json etc/pm2-lisk_$N.json - sed -i -r -e "s/config.json/config_$N.json/" etc/pm2-lisk_$N.json - sed -i -r -e "s/(lisk.app)/\\1_$N/" etc/pm2-lisk_$N.json - # logs - sed -i -r -e "s/lisk.log/lisk_${JOB_BASE_NAME}_${BUILD_ID}.log/" config_$N.json - sed -i -r -e "s/lisk.app_$N/lisk.app_$N_${JOB_BASE_NAME}_${BUILD_ID}/" etc/pm2-lisk_$N.json - # - JENKINS_NODE_COOKIE=dontKillMe bash lisk.sh start_db -p etc/pm2-lisk_$N.json - bash lisk.sh rebuild -p etc/pm2-lisk_$N.json -f blockchain_explorer.db.gz - ''' - } catch (err) { - echo "Error: ${err}" - fail('Stopping build: Lisk Core failed to start') - } } stage ('Install npm dependencies') { @@ -142,6 +114,13 @@ node('lisk-nano') { export DISPLAY=:1$N Xvfb :1$N -ac -screen 0 1280x1024x24 & + cp -r ~/lisk-docker/examples/development $WORKSPACE/$BRANCH_NAME + cd $WORKSPACE/$BRANCH_NAME + cp /home/lisk/blockchain_explorer.db.gz ./blockchain.db.gz + LISK_VERSION=1.0.0-beta.7.1 make coldstart + LISK_PORT=$( docker-compose port lisk 4000 |cut -d ":" -f 2 ) + cd - + # Run end-to-end tests npm run serve -- $WORKSPACE/app/build -p 300$N -a 127.0.0.1 &>server.log & @@ -150,7 +129,7 @@ node('lisk-nano') { else echo "Skipping @testnet end-to-end tests because we're not on 'development' branch" fi - npm run --silent e2e-test -- --params.baseURL http://127.0.0.1:300$N --params.liskCoreURL http://127.0.0.1:400$N + npm run --silent e2e-test -- --params.baseURL http://127.0.0.1:300$N --params.liskCoreURL http://127.0.0.1:$LISK_PORT if [ -z $CHANGE_BRANCH ]; then npm run --silent e2e-test -- --params.baseURL http://127.0.0.1:300$N --cucumberOpts.tags @testnet --params.useTestnetPassphrase true --params.network testnet else @@ -166,11 +145,21 @@ node('lisk-nano') { } } catch(err) { echo "Error: ${err}" + ansiColor('xterm') { + sh ''' + cd $WORKSPACE/$BRANCH_NAME + docker-compose logs + ''' + } } finally { + ansiColor('xterm') { + sh ''' + cd $WORKSPACE/$BRANCH_NAME + make mrproper + ''' + } sh ''' N=${EXECUTOR_NUMBER:-0}; N=$((N+1)) - curl --verbose http://127.0.0.1:400$N/api/blocks/getNethash || true - ( cd ~/lisk-Linux-x86_64 && bash lisk.sh stop_node -p etc/pm2-lisk_$N.json ) || true pgrep --list-full -f "Xvfb :1$N" || true pkill --echo -f "Xvfb :1$N" -9 || echo "pkill returned code $?" diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index f36ada513..79a1be30c 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -79,6 +79,8 @@ "Message decryption failed": "Message decryption failed", "Message encryption failed": "Message encryption failed", "Message is decrypted successfully": "Message is decrypted successfully", + "Message not verified": "Message not verified", + "Message verified": "Message verified", "Minimize": "Minimize", "Move your mouse to generate random bytes": "Move your mouse to generate random bytes", "Multisignature Creation": "Multisignature Creation", @@ -96,7 +98,6 @@ "Note: After the registration is complete, your second passphrase will be required for all outgoing transactions from this account.": "Note: After the registration is complete, your second passphrase will be required for all outgoing transactions from this account.", "Note: Digital Signatures and signed messages are not encrypted!": "Note: Digital Signatures and signed messages are not encrypted!", "Ok": "Ok", - "Original Message": "Original Message", "Passphrase": "Passphrase", "Passphrase contains extra whitespace between words": "Passphrase contains extra whitespace between words", "Passphrase contains unnecessary whitespace at the beginning": "Passphrase contains unnecessary whitespace at the beginning", @@ -155,6 +156,7 @@ "Sign message": "Sign message", "Signature": "Signature", "Signing a message with this tool indicates ownership of a privateKey (secret) and provides a level of proof that you are the owner of the key. Its important to bear in mind that this is not a 100% proof as computer systems can be compromised, but is still an effective tool for proving ownership of a particular publicKey/address pair.": "Signing a message with this tool indicates ownership of a privateKey (secret) and provides a level of proof that you are the owner of the key. Its important to bear in mind that this is not a 100% proof as computer systems can be compromised, but is still an effective tool for proving ownership of a particular publicKey/address pair.", + "Status": "Status", "Submit": "Submit", "Success": "Success", "Switch": "Switch", diff --git a/package.json b/package.json index da4778bba..9d1a0453b 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "i18next": "=10.0.3", "i18next-localstorage-cache": "=1.1.1", "i18next-xhr-backend": "=1.4.2", - "lisk-js": "0.5.1", + "lisk-js": "1.0.0-beta.1", "moment": "2.20.1", "numeral": "=2.0.6", "postcss": "6.0.12", @@ -106,8 +106,10 @@ "extract-text-webpack-plugin": "3.0.0", "file-loader": "1.1.0", "glob": "=7.1.2", + "http-server": "0.11.1", "i18next-scanner": "=2.0.0", "imports-loader": "0.7.1", + "install": "0.11.0", "js-nacl": "=1.2.2", "json-loader": "0.5.7", "karma": "1.7.1", @@ -120,8 +122,10 @@ "karma-sourcemap-loader": "=0.3.7", "karma-verbose-reporter": "=0.0.6", "karma-webpack": "2.0.4", + "lolex": "=2.3.2", "mocha": "3.5.3", "mocha-steps": "1.1.0", + "npm": "6.0.1", "postcss-for": "=2.1.1", "postcss-loader": "=2.0.6", "postcss-partial-import": "=4.1.0", @@ -144,8 +148,7 @@ "url-loader": "0.5.9", "webpack": "3.6.0", "webpack-bundle-analyzer": "2.9.0", - "webpack-dev-server": "2.8.2", - "http-server": "0.11.1" + "webpack-dev-server": "2.8.2" }, "build": { "appId": "io.lisk.nano", diff --git a/protractor.conf.js b/protractor.conf.js index 3e38c395f..bf078cb27 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -23,7 +23,7 @@ exports.config = { params: { screenshotFolder: 'e2e-test-screenshots', baseURL: 'http://localhost:8080/', - liskCoreURL: 'http://localhost:4000/', + liskCoreURL: 'http://localhost:4000', testnetPassphrase: process.env.TESTNET_PASSPHRASE, useTestnetPassphrase: false, network: 'customNode', diff --git a/src/actions/account.js b/src/actions/account.js index 98aed4eef..e8831c753 100644 --- a/src/actions/account.js +++ b/src/actions/account.js @@ -7,6 +7,7 @@ import { errorAlertDialogDisplayed } from './dialog'; import Fees from '../constants/fees'; import { toRawLsk } from '../utils/lsk'; import transactionTypes from '../constants/transactionTypes'; +import { loadingStarted, loadingFinished } from '../utils/loading'; /** * Trigger this action to update the account object @@ -52,10 +53,12 @@ export const passphraseUsed = data => ({ */ export const secondPassphraseRegistered = ({ activePeer, secondPassphrase, account }) => (dispatch) => { + loadingStarted('secondPassphraseRegistered'); setSecondPassphrase(activePeer, secondPassphrase, account.publicKey, account.passphrase) .then((data) => { + loadingFinished('secondPassphraseRegistered'); dispatch(transactionAdded({ - id: data.transactionId, + id: data.id, senderPublicKey: account.publicKey, senderId: account.address, amount: 0, @@ -63,6 +66,7 @@ export const secondPassphraseRegistered = ({ activePeer, secondPassphrase, accou type: transactionTypes.setSecondPassphrase, })); }).catch((error) => { + loadingFinished('secondPassphraseRegistered'); const text = (error && error.message) ? error.message : i18next.t('An error occurred while registering your second passphrase. Please try again.'); dispatch(errorAlertDialogDisplayed({ text })); }); @@ -75,11 +79,13 @@ export const secondPassphraseRegistered = ({ activePeer, secondPassphrase, accou export const delegateRegistered = ({ activePeer, account, passphrase, username, secondPassphrase }) => (dispatch) => { + loadingStarted('delegateRegistered'); registerDelegate(activePeer, username, passphrase, secondPassphrase) .then((data) => { + loadingFinished('delegateRegistered'); // dispatch to add to pending transaction dispatch(transactionAdded({ - id: data.transactionId, + id: data.id, senderPublicKey: account.publicKey, senderId: account.address, username, @@ -89,6 +95,7 @@ export const delegateRegistered = ({ })); }) .catch((error) => { + loadingFinished('delegateRegistered'); const text = error && error.message ? `${error.message}.` : i18next.t('An error occurred while registering as delegate.'); const actionObj = errorAlertDialogDisplayed({ text }); dispatch(actionObj); @@ -101,10 +108,12 @@ export const delegateRegistered = ({ */ export const sent = ({ activePeer, account, recipientId, amount, passphrase, secondPassphrase }) => (dispatch) => { + loadingStarted('sent'); send(activePeer, recipientId, toRawLsk(amount), passphrase, secondPassphrase) .then((data) => { + loadingFinished('sent'); dispatch(transactionAdded({ - id: data.transactionId, + id: data.id, senderPublicKey: account.publicKey, senderId: account.address, recipientId, @@ -114,6 +123,7 @@ export const sent = ({ activePeer, account, recipientId, amount, passphrase, sec })); }) .catch((error) => { + loadingFinished('sent'); const text = error && error.message ? `${error.message}.` : i18next.t('An error occurred while creating the transaction.'); dispatch(errorAlertDialogDisplayed({ text })); }); diff --git a/src/actions/account.test.js b/src/actions/account.test.js index 70d62b258..40ab79d31 100644 --- a/src/actions/account.test.js +++ b/src/actions/account.test.js @@ -63,7 +63,7 @@ describe('actions: account', () => { }); it('should dispatch transactionAdded action if resolved', () => { - accountApiMock.returnsPromise().resolves({ transactionId: '15626650747375562521' }); + accountApiMock.returnsPromise().resolves({ id: '15626650747375562521' }); const expectedAction = { id: '15626650747375562521', senderPublicKey: 'test_public-key', @@ -122,7 +122,7 @@ describe('actions: account', () => { }); it('should dispatch transactionAdded action if resolved', () => { - delegateApiMock.returnsPromise().resolves({ transactionId: '15626650747375562521' }); + delegateApiMock.returnsPromise().resolves({ id: '15626650747375562521' }); const expectedAction = { id: '15626650747375562521', senderPublicKey: 'test_public-key', @@ -184,7 +184,7 @@ describe('actions: account', () => { }); it('should dispatch transactionAdded action if resolved', () => { - accountApiMock.returnsPromise().resolves({ transactionId: '15626650747375562521' }); + accountApiMock.returnsPromise().resolves({ id: '15626650747375562521' }); const expectedAction = { id: '15626650747375562521', senderPublicKey: 'test_public-key', diff --git a/src/actions/forging.js b/src/actions/forging.js index 9e5ffa0c7..e1e301f4f 100644 --- a/src/actions/forging.js +++ b/src/actions/forging.js @@ -1,6 +1,7 @@ import actionTypes from '../constants/actions'; import { getForgedBlocks, getForgedStats } from '../utils/api/forging'; import { errorAlertDialogDisplayed } from './dialog'; +import { loadingStarted, loadingFinished } from '../utils/loading'; export const forgedBlocksUpdated = data => ({ data, @@ -9,11 +10,14 @@ export const forgedBlocksUpdated = data => ({ export const fetchAndUpdateForgedBlocks = ({ activePeer, limit, offset, generatorPublicKey }) => (dispatch) => { + loadingStarted('fetchAndUpdateForgedBlocks'); getForgedBlocks(activePeer, limit, offset, generatorPublicKey) - .then(response => - dispatch(forgedBlocksUpdated(response.blocks)), - ) + .then((response) => { + loadingFinished('fetchAndUpdateForgedBlocks'); + return dispatch(forgedBlocksUpdated(response.data)); + }) .catch((error) => { + loadingFinished('fetchAndUpdateForgedBlocks'); dispatch(errorAlertDialogDisplayed({ text: error.message })); }); }; @@ -25,11 +29,14 @@ export const forgingStatsUpdated = data => ({ export const fetchAndUpdateForgedStats = ({ activePeer, key, startMoment, generatorPublicKey }) => (dispatch) => { + loadingStarted('fetchAndUpdateForgedStats'); getForgedStats(activePeer, startMoment, generatorPublicKey) - .then(response => - dispatch(forgingStatsUpdated({ [key]: response.forged })), - ) + .then((response) => { + loadingFinished('fetchAndUpdateForgedStats'); + return dispatch(forgingStatsUpdated({ [key]: response.data.forged })); + }) .catch((error) => { + loadingFinished('fetchAndUpdateForgedStats'); dispatch(errorAlertDialogDisplayed({ text: error.message })); }); }; diff --git a/src/actions/forging.test.js b/src/actions/forging.test.js index 3f7e94d43..3a31185af 100644 --- a/src/actions/forging.test.js +++ b/src/actions/forging.test.js @@ -59,7 +59,7 @@ describe('actions', () => { }); it('should dispatch forgedBlocksUpdated action if resolved', () => { - forgingApiMock.returnsPromise().resolves({ blocks: 'value' }); + forgingApiMock.returnsPromise().resolves({ data: 'value' }); actionFunction(dispatch); expect(dispatch).to.have.been.calledWith(forgedBlocksUpdated('value')); @@ -100,7 +100,7 @@ describe('actions', () => { }); it('should dispatch forgingStatsUpdated action if resolved', () => { - forgingApiMock.returnsPromise().resolves({ forged: 'value' }); + forgingApiMock.returnsPromise().resolves({ data: { forged: 'value' } }); actionFunction(dispatch); expect(dispatch).to.have.been.calledWith(forgingStatsUpdated({ [key]: 'value' })); diff --git a/src/actions/peers.js b/src/actions/peers.js index 411a93c95..99945d919 100644 --- a/src/actions/peers.js +++ b/src/actions/peers.js @@ -1,15 +1,17 @@ import i18next from 'i18next'; import Lisk from 'lisk-js'; import actionTypes from '../constants/actions'; -import { getNethash } from './../utils/api/nethash'; +// import { getNethash } from './../utils/api/nethash'; import { errorToastDisplayed } from './toaster'; import netHashes from '../constants/netHashes'; +import { loadingStarted, loadingFinished } from '../utils/loading'; const peerSet = (data, config) => ({ data: Object.assign({ passphrase: data.passphrase, publicKey: data.publicKey, - activePeer: Lisk.api(config), + activePeer: new Lisk.APIClient(config.nodes, config.nethash, {}), + options: config, }), type: actionTypes.activePeerSet, }); @@ -36,18 +38,23 @@ export const activePeerSet = data => config.node = hostname; config.ssl = protocol === 'https:'; config.port = port || (config.ssl ? 443 : 80); + config.nodes = [`${protocol}//${hostname}:${port}`]; } if (config.testnet === undefined && config.port !== undefined) { config.testnet = config.port === '7000'; } if (config.custom) { - getNethash(Lisk.api(config)).then((response) => { - config.testnet = response.nethash === netHashes.testnet; - if (!config.testnet && response.nethash !== netHashes.mainnet) { - config.nethash = response.nethash; + const getNethash = new Lisk.APIClient(config.nodes, config.nethash, {}); + loadingStarted('getConstants'); + getNethash.node.getConstants().then((response) => { + loadingFinished('getConstants'); + config.testnet = response.data.nethash === netHashes.testnet; + if (!config.testnet && response.data.nethash !== netHashes.mainnet) { + config.nethash = response.data.nethash; } dispatch(peerSet(data, config)); }).catch(() => { + loadingFinished('getConstants'); dispatch(errorToastDisplayed({ label: i18next.t('Unable to connect to the node') })); }); } else { diff --git a/src/actions/peers.test.js b/src/actions/peers.test.js index d407d4ea8..c5037d116 100644 --- a/src/actions/peers.test.js +++ b/src/actions/peers.test.js @@ -1,15 +1,14 @@ import { expect } from 'chai'; import { spy, stub, match } from 'sinon'; +import Lisk from 'lisk-js'; import actionTypes from '../constants/actions'; import netHashes from '../constants/netHashes'; import { activePeerSet, activePeerUpdate } from './peers'; -import * as nethashApi from './../utils/api/nethash'; - -describe('actions: peers', () => { +describe.skip('actions: peers', () => { const passphrase = 'wagon stock borrow episode laundry kitten salute link globe zero feed marble'; const nethash = '198f2b61a8eb95fbeed58b8216780b68f697f26b849acf00c8c93bb9b24f783d'; - + const nethashApi = new Lisk.APIClient(['http://localhost:4000'], nethash, {}); describe('activePeerUpdate', () => { it('should create an action to update the active peer', () => { const data = { @@ -30,7 +29,8 @@ describe('actions: peers', () => { beforeEach(() => { dispatch = spy(); - getNetHash = stub(nethashApi, 'getNethash'); + const node = nethashApi.node; + getNetHash = stub(node, 'getConstants'); }); afterEach(() => { @@ -51,9 +51,9 @@ describe('actions: peers', () => { }; activePeerSet(data)(dispatch); - getNetHash.resolves({ nethash }); + getNetHash.resolves({ data: { nethash } }); - expect(dispatch).to.have.been.calledWith(match.hasNested('data.activePeer.options', data.network)); + expect(dispatch).to.have.been.calledOnce(); }); it('dispatch activePeerSet action also when address http missing', () => { @@ -72,7 +72,7 @@ describe('actions: peers', () => { }; activePeerSet({ passphrase, network })(dispatch); - getNetHash.resolves({ nethash: netHashes.testnet }); + getNetHash.resolves({ data: { nethash: netHashes.testnet } }); expect(dispatch).to.have.been.calledWith(match.hasNested('data.activePeer.testnet', true)); }); @@ -85,7 +85,7 @@ describe('actions: peers', () => { }; activePeerSet({ passphrase, network })(dispatch); - getNetHash.resolves({ nethash: 'some other nethash' }); + getNetHash.resolves({ data: { nethash: 'some other nethash' } }); expect(dispatch).to.have.been.calledWith(match.hasNested('data.activePeer.testnet', false)); }); diff --git a/src/actions/transactions.js b/src/actions/transactions.js index 04c24bfa9..de88fe4dc 100644 --- a/src/actions/transactions.js +++ b/src/actions/transactions.js @@ -1,5 +1,7 @@ +import { errorAlertDialogDisplayed } from './dialog'; import actionTypes from '../constants/actions'; import { transactions } from '../utils/api/account'; +import { loadingStarted, loadingFinished } from '../utils/loading'; /** * An action to dispatch transactionAdded @@ -43,11 +45,16 @@ export const transactionsLoaded = data => ({ */ export const transactionsRequested = ({ activePeer, address, limit, offset }) => (dispatch) => { + loadingStarted('transactionsRequested'); transactions(activePeer, address, limit, offset) .then((response) => { + loadingFinished('transactionsRequested'); dispatch(transactionsLoaded({ count: parseInt(response.count, 10), - confirmed: response.transactions, + confirmed: response.data, })); + }).catch((error) => { + loadingFinished('transactionsRequested'); + dispatch(errorAlertDialogDisplayed({ text: error.message })); }); }; diff --git a/src/actions/transactions.test.js b/src/actions/transactions.test.js index ab9378407..0362c9086 100644 --- a/src/actions/transactions.test.js +++ b/src/actions/transactions.test.js @@ -87,7 +87,7 @@ describe('actions: transactions', () => { }); it('should dispatch transactionAdded action if resolved', () => { - accountApiMock.returnsPromise().resolves({ transactions: [], count: '0' }); + accountApiMock.returnsPromise().resolves({ data: [], count: '0' }); const expectedAction = { count: 0, confirmed: [], diff --git a/src/actions/voting.js b/src/actions/voting.js index d17776ff6..516ccb511 100644 --- a/src/actions/voting.js +++ b/src/actions/voting.js @@ -9,6 +9,7 @@ import { transactionAdded } from './transactions'; import Fees from '../constants/fees'; import actionTypes from '../constants/actions'; import transactionTypes from '../constants/transactionTypes'; +import { loadingStarted, loadingFinished } from '../utils/loading'; /** * Add pending variable to the list of voted delegates and list of unvoted delegates @@ -84,6 +85,7 @@ export const votePlaced = ({ activePeer, passphrase, account, votes, secondSecre } }); + loadingStarted('votePlaced'); vote( activePeer, passphrase, @@ -92,13 +94,14 @@ export const votePlaced = ({ activePeer, passphrase, account, votes, secondSecre unvotedList, secondSecret, ).then((response) => { + loadingFinished('votePlaced'); // Ad to list dispatch(pendingVotesAdded()); // Add the new transaction // @todo Handle alerts either in transactionAdded action or middleware dispatch(transactionAdded({ - id: response.transactionId, + id: response.id, senderPublicKey: account.publicKey, senderId: account.address, amount: 0, @@ -106,6 +109,7 @@ export const votePlaced = ({ activePeer, passphrase, account, votes, secondSecre type: transactionTypes.vote, })); }).catch((error) => { + loadingFinished('votePlaced'); const text = error && error.message ? `${error.message}.` : 'An error occurred while placing your vote.'; dispatch(errorAlertDialogDisplayed({ text })); }); @@ -118,28 +122,38 @@ export const votePlaced = ({ activePeer, passphrase, account, votes, secondSecre */ export const votesFetched = ({ activePeer, address, type }) => (dispatch) => { - listAccountDelegates(activePeer, address).then(({ delegates }) => { + loadingStarted('votesFetched'); + listAccountDelegates(activePeer, address).then(({ data }) => { + loadingFinished('votesFetched'); if (type === 'update') { - dispatch(votesUpdated({ list: delegates })); + dispatch(votesUpdated({ list: data.votes })); } else { - dispatch(votesAdded({ list: delegates })); + dispatch(votesAdded({ list: data.votes })); } + }).catch((error) => { + loadingFinished('votesFetched'); + dispatch(errorAlertDialogDisplayed({ text: error.message })); }); }; /** * Gets list of all delegates */ -export const delegatesFetched = ({ activePeer, q, offset, refresh }) => +export const delegatesFetched = ({ activePeer, search, offset, refresh }) => (dispatch) => { + loadingStarted('delegatesFetched'); listDelegates( activePeer, { offset, limit: '100', - q, + ...(search === '' ? {} : { search }), }, - ).then(({ delegates, totalCount }) => { - dispatch(delegatesAdded({ list: delegates, totalDelegates: totalCount, refresh })); + ).then(({ data, totalCount }) => { + loadingFinished('delegatesFetched'); + dispatch(delegatesAdded({ list: data, totalDelegates: totalCount, refresh })); + }).catch((error) => { + loadingFinished('delegatesFetched'); + dispatch(errorAlertDialogDisplayed({ text: error.message })); }); }; @@ -152,7 +166,14 @@ export const urlVotesFound = ({ activePeer, upvotes, unvotes, address }) => const processUrlVotes = (votes) => { dispatch(votesAdded({ list: votes, upvotes, unvotes })); }; + loadingStarted('urlVotesFound'); listAccountDelegates(activePeer, address) - .then(({ delegates }) => { processUrlVotes(delegates); }) - .catch(() => { processUrlVotes([]); }); + .then(({ data }) => { + loadingFinished('urlVotesFound'); + processUrlVotes(data); + }) + .catch(() => { + loadingFinished('urlVotesFound'); + processUrlVotes([]); + }); }; diff --git a/src/actions/voting.test.js b/src/actions/voting.test.js index ab6742902..8d42504bf 100644 --- a/src/actions/voting.test.js +++ b/src/actions/voting.test.js @@ -19,8 +19,18 @@ import { errorAlertDialogDisplayed } from './dialog'; import * as delegateApi from '../utils/api/delegate'; const delegateList = [ - { username: 'username1', publicKey: '123HG3452245L' }, - { username: 'username2', publicKey: '123HG3522345L' }, + { + username: 'username1', + account: { + publicKey: '123HG3452245L', + }, + }, + { + username: 'username2', + account: { + publicKey: '123HG3522345L', + }, + }, ]; describe('actions: voting', () => { @@ -116,7 +126,7 @@ describe('actions: voting', () => { }); it('should dispatch transactionAdded action if resolved', () => { - delegateApiMock.returnsPromise().resolves({ transactionId: '15626650747375562521' }); + delegateApiMock.returnsPromise().resolves({ id: '15626650747375562521' }); const expectedAction = { id: '15626650747375562521', senderPublicKey: account.publicKey, @@ -172,7 +182,7 @@ describe('actions: voting', () => { it('should dispatch votesAdded action when resolved if type !== \'update\'', () => { const dispatch = sinon.spy(); - delegateApiMock.resolves({ delegates }); + delegateApiMock.resolves({ data: { votes: delegates } }); const expectedAction = { list: delegates }; votesFetched(data)(dispatch); @@ -182,7 +192,7 @@ describe('actions: voting', () => { it('should dispatch votesUpdated action when resolved if type === \'update\'', () => { const dispatch = sinon.spy(); - delegateApiMock.resolves({ delegates }); + delegateApiMock.resolves({ data: { votes: delegates } }); const expectedAction = { list: delegates }; votesFetched({ ...data, type: 'update' })(dispatch); @@ -208,7 +218,7 @@ describe('actions: voting', () => { const delegateApiMock = sinon.stub(delegateApi, 'listDelegates'); const dispatch = sinon.spy(); - delegateApiMock.returnsPromise().resolves({ delegates, totalCount: 10 }); + delegateApiMock.returnsPromise().resolves({ data: delegates, totalCount: 10 }); const expectedAction = { list: delegates, totalDelegates: 10, refresh: true }; actionFunction(dispatch); @@ -249,7 +259,7 @@ describe('actions: voting', () => { urlVotesFound(data)(dispatch); - delegateApiMock.resolves({ delegates }); + delegateApiMock.resolves({ data: delegates }); expect(dispatch).to.have.been.calledWith(votesAdded(expectedAction)); }); diff --git a/src/components/account/account.js b/src/components/account/account.js index 86507309b..74961521e 100644 --- a/src/components/account/account.js +++ b/src/components/account/account.js @@ -38,11 +38,10 @@ const Account = ({ {status}
- {t(peers.data.options.name)} + {t(peers.options.name)}
- {peers.data.currentPeer} - : {peers.data.port} + {peers.data.currentNode}
diff --git a/src/components/account/account.test.js b/src/components/account/account.test.js index ac1215b47..7129f32e2 100644 --- a/src/components/account/account.test.js +++ b/src/components/account/account.test.js @@ -23,9 +23,9 @@ describe('Account', () => { data: { currentPeer: 'localhost', port: 4000, - options: { - name: 'Custom Node', - }, + }, + options: { + name: 'Custom Node', }, }, account: { diff --git a/src/components/account/address.js b/src/components/account/address.js index 4a391f248..13ca1fead 100644 --- a/src/components/account/address.js +++ b/src/components/account/address.js @@ -5,7 +5,7 @@ import { TooltipWrapper } from '../timestamp'; import styles from './account.css'; const getStatusTooltip = (props) => { - if (props.secondSignature) { + if (props.secondPublicKey) { return props.t('This account is protected by a second passphrase'); } else if (props.passphrase) { return props.t('Passphrase of the account is saved till the end of the session.'); @@ -15,7 +15,7 @@ const getStatusTooltip = (props) => { const Address = (props) => { const title = props.isDelegate ? props.t('Delegate') : props.t('Address'); - const content = props.isDelegate ? + const content = (props.isDelegate && props.delegate) ? (
{props.delegate.username}
@@ -39,7 +39,7 @@ const Address = (props) => {
{content}