Skip to content

Commit

Permalink
Merge branch 'development' into 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Sep 14, 2018
2 parents e157470 + e71527b commit a7e8418
Show file tree
Hide file tree
Showing 24 changed files with 339 additions and 90 deletions.
2 changes: 1 addition & 1 deletion i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"Height": "Height",
"Help": "Help",
"Help Center": "Help Center",
"Here you see your address and balance. You can click your account avatar to see all your saved IDs.": "Here you see your address and balance. You can click your account avatar to see all your saved IDs.",
"Here you see your address, balance, and avatar.": "Here you see your address, balance, and avatar.",
"Hide passphrase": "Hide passphrase",
"How do you like the hub?": "How do you like the hub?",
"How is Lisk transparent?": "How is Lisk transparent?",
Expand Down
18 changes: 12 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ module.exports = {
// '<rootDir>/src/utils/app.test.js',
// '<rootDir>/src/utils/similarWord.test.js',
// '<rootDir>/src/utils/api/search.test.js',
// '<rootDir>/src/utils/api/account.test.js',
'<rootDir>/src/utils/api/account.test.js',
// '<rootDir>/src/utils/api/transactions.test.js',
// '<rootDir>/src/utils/api/peers.test.js',
// '<rootDir>/src/utils/api/nethash.test.js',
// '<rootDir>/src/utils/api/delegate.test.js',
'<rootDir>/src/utils/api/delegate.test.js',
// '<rootDir>/src/utils/generateUniqueId.test.js',
// '<rootDir>/src/utils/login.test.js',
'<rootDir>/src/utils/hacks.test.js',
// '<rootDir>/src/components/searchBar/index.test.js',
// '<rootDir>/src/components/accountTransactions/index.test.js',
// '<rootDir>/src/components/multiStep/index.test.js',
Expand Down Expand Up @@ -127,7 +128,7 @@ module.exports = {
// '<rootDir>/src/components/passphraseCreation/index.test.js',
// '<rootDir>/src/components/authInputs/authInputs.test.js',
// '<rootDir>/src/components/authInputs/index.test.js',
// '<rootDir>/src/components/account/account.test.js',
'<rootDir>/src/components/account/account.test.js',
// '<rootDir>/src/components/account/index.test.js',
// '<rootDir>/src/components/setting/index.test.js',
// '<rootDir>/src/components/setting/setting.test.js',
Expand Down Expand Up @@ -161,11 +162,11 @@ module.exports = {
// '<rootDir>/src/actions/savedAccounts.test.js',
// '<rootDir>/src/actions/toaster.test.js',
// '<rootDir>/src/actions/dialog.test.js',
// '<rootDir>/src/actions/voting.test.js',
// '<rootDir>/src/actions/account.test.js',
'<rootDir>/src/actions/voting.test.js',
'<rootDir>/src/actions/account.test.js',
// '<rootDir>/src/actions/loding.test.js',
// '<rootDir>/src/actions/followedAccounts.test.js',
// '<rootDir>/src/actions/transactions.test.js',
'<rootDir>/src/actions/transactions.test.js',
// '<rootDir>/src/actions/peers.test.js',
// '<rootDir>/src/actions/delegate.test.js',
// '<rootDir>/src/actions/setting.test.js',
Expand Down Expand Up @@ -195,6 +196,7 @@ module.exports = {
// '<rootDir>/src/store/reducers/settings.test.js',
// '<rootDir>/src/store/reducers/delegate.test.js',
// '<rootDir>/src/store/reducers/transaction.test.js',
'<rootDir>/src/store/reducers/blocks.test.js',

// integration

Expand Down Expand Up @@ -238,4 +240,8 @@ module.exports = {
'^.+\\.js$': 'babel-jest',
},
testURL: 'http://localhost',
globals: {
PRODUCTION: true,
TEST: true,
},
};
7 changes: 5 additions & 2 deletions src/actions/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { loadTransactionsFinish, transactionsUpdated } from './transactions';
import { delegateRegisteredFailure } from './delegate';
import { errorAlertDialogDisplayed } from './dialog';
import { activePeerUpdate } from './peers';
import { getTimeOffset } from '../utils/hacks';
import Fees from '../constants/fees';
import transactionTypes from '../constants/transactionTypes';

Expand Down Expand Up @@ -96,7 +97,8 @@ export const accountVotersFetched = ({ publicKey }) =>
export const secondPassphraseRegistered = ({ secondPassphrase, account, passphrase }) =>
(dispatch, getState) => {
const activePeer = getState().peers.data;
setSecondPassphrase(activePeer, secondPassphrase, account.publicKey, passphrase)
const timeOffset = getTimeOffset(getState());
setSecondPassphrase(activePeer, secondPassphrase, account.publicKey, passphrase, timeOffset)
.then((data) => {
dispatch({
data: {
Expand Down Expand Up @@ -135,8 +137,9 @@ export const delegateRegistered = ({
account, passphrase, username, secondPassphrase,
}) =>
(dispatch, getState) => {
const timeOffset = getTimeOffset(getState());
const activePeer = getState().peers.data;
registerDelegate(activePeer, username, passphrase, secondPassphrase)
registerDelegate(activePeer, username, passphrase, secondPassphrase, timeOffset)
.then((data) => {
// dispatch to add to pending transaction
dispatch({
Expand Down
29 changes: 18 additions & 11 deletions src/actions/account.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { spy, stub } from 'sinon';
import i18next from 'i18next';
import actionTypes from '../constants/actions';
import {
accountUpdated,
Expand Down Expand Up @@ -52,11 +53,13 @@ describe('actions: account', () => {

describe('secondPassphraseRegistered', () => {
let accountApiMock;
let i18nextMock;
const data = {
secondPassphrase: 'sample second passphrase',
passphrase: accounts['second passphrase account'].passphrase,
secondPassphrase: accounts['second passphrase account'].secondPassphrase,
account: {
publicKey: 'test_public-key',
address: 'test_address',
publicKey: accounts['second passphrase account'].publicKey,
address: accounts['second passphrase account'].address,
},
};
const actionFunction = secondPassphraseRegistered(data);
Expand All @@ -69,10 +72,13 @@ describe('actions: account', () => {
getState = () => ({
peers: { data: {} },
});
i18nextMock = stub(i18next, 't');
i18next.t = key => key;
});

afterEach(() => {
accountApiMock.restore();
i18nextMock.restore();
});

it('should create an action function', () => {
Expand All @@ -83,8 +89,8 @@ describe('actions: account', () => {
accountApiMock.returnsPromise().resolves({ id: '15626650747375562521' });
const expectedAction = {
id: '15626650747375562521',
senderPublicKey: 'test_public-key',
senderId: 'test_address',
senderPublicKey: accounts['second passphrase account'].publicKey,
senderId: accounts['second passphrase account'].address,
amount: 0,
fee: Fees.setSecondPassphrase,
type: transactionTypes.setSecondPassphrase,
Expand Down Expand Up @@ -119,8 +125,8 @@ describe('actions: account', () => {
passphrase: accounts.genesis.passphrase,
secondPassphrase: null,
account: {
publicKey: 'test_public-key',
address: 'test_address',
publicKey: accounts['second passphrase account'].publicKey,
address: accounts['second passphrase account'].address,
},
};
const actionFunction = delegateRegistered(data);
Expand All @@ -132,6 +138,7 @@ describe('actions: account', () => {
dispatch = spy();
getState = () => ({
peers: { data: {} },
blocks: { latestBlocks: [] },
});
});

Expand All @@ -147,8 +154,8 @@ describe('actions: account', () => {
delegateApiMock.returnsPromise().resolves({ id: '15626650747375562521' });
const expectedAction = {
id: '15626650747375562521',
senderPublicKey: 'test_public-key',
senderId: 'test_address',
senderPublicKey: accounts['second passphrase account'].publicKey,
senderId: accounts['second passphrase account'].address,
username: data.username,
amount: 0,
fee: Fees.registerDelegate,
Expand Down Expand Up @@ -329,7 +336,7 @@ describe('actions: account', () => {
id: 12498250891724098,
}],
confirmed: [],
account: { address: 'test_address', balance: 0 },
account: { address: accounts['second passphrase account'].address, balance: 0 },
},
account: { address: accounts.genesis.address, balance: 0 },
};
Expand All @@ -347,7 +354,7 @@ describe('actions: account', () => {
transactions: {
pending: [{ id: 12498250891724098 }],
confirmed: [],
account: { address: 'test_address', balance: 0 },
account: { address: accounts['second passphrase account'].address, balance: 0 },
},
account: { address: accounts.genesis.address },
};
Expand Down
4 changes: 3 additions & 1 deletion src/actions/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getDelegate } from '../utils/api/delegate';
import { loadDelegateCache } from '../utils/delegates';
import { extractAddress } from '../utils/account';
import { loadAccount, passphraseUsed } from './account';
import { getTimeOffset } from '../utils/hacks';
import Fees from '../constants/fees';
import { toRawLsk } from '../utils/lsk';
import transactionTypes from '../constants/transactionTypes';
Expand Down Expand Up @@ -215,7 +216,8 @@ export const sent = ({
}) =>
(dispatch, getState) => {
const activePeer = getState().peers.data;
send(activePeer, recipientId, toRawLsk(amount), passphrase, secondPassphrase, data)
const timeOffset = getTimeOffset(getState());
send(activePeer, recipientId, toRawLsk(amount), passphrase, secondPassphrase, data, timeOffset)
.then((response) => {
dispatch({
data: {
Expand Down
4 changes: 3 additions & 1 deletion src/actions/voting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
listDelegates,
vote,
} from '../utils/api/delegate';
import { getTimeOffset } from '../utils/hacks';
import { updateDelegateCache } from '../utils/delegates';
import { passphraseUsed } from './account';
import Fees from '../constants/fees';
Expand Down Expand Up @@ -81,7 +82,7 @@ export const votePlaced = ({
const activePeer = getState().peers.data;
const votedList = [];
const unvotedList = [];

const timeOffset = getTimeOffset(getState());
Object.keys(votes).forEach((username) => {
/* istanbul ignore else */
if (!votes[username].confirmed && votes[username].unconfirmed) {
Expand All @@ -98,6 +99,7 @@ export const votePlaced = ({
votedList,
unvotedList,
secondSecret,
timeOffset,
).then((response) => {
// Add to list
dispatch(pendingVotesAdded());
Expand Down
6 changes: 4 additions & 2 deletions src/components/account/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ const Account = ({ peers, t, showNetworkIndicator }) => {
<FontIcon className={`${styles.network} online`} value={iconMap[iconCode]} /> :
<FontIcon className='offline' value='error' />;

return ((showNetworkIndicator && peers.data &&
peers.options.code !== networks.mainnet.code) ?
const shouldShowNetworkIndicator = (peers.data &&
(showNetworkIndicator || peers.options.code !== networks.mainnet.code));

return (shouldShowNetworkIndicator ?
<section className={styles.peer}>
<div className={`${styles.title} ${`${styles[`${iconMap[iconCode]}Title`]}`} inner primary peer-network ${iconMap[iconCode]}-title`}>
<span id="accountStatus" className={`${styles.status} network-status`}>
Expand Down
1 change: 1 addition & 0 deletions src/components/account/account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ describe('Account', () => {

it('shows network indicator online', () => {
props.peers.status.online = true;
props.peers.options.code = networks.mainnet.code;
const wrapper = shallow(<Account {...props} />);
wrapper.update();
expect(wrapper).to.have.exactly(1).descendants('.online');
Expand Down
2 changes: 1 addition & 1 deletion src/components/onboarding/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const steps = t => ([
// },
{
title: t('Lisk ID'),
text: t('Here you see your address and balance. You can click your account avatar to see all your saved IDs.'),
text: t('Here you see your address, balance, and avatar.'),
selector: '.account',
position: 'bottom',
style: styles.step,
Expand Down
2 changes: 1 addition & 1 deletion src/components/request/confirmRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ConfirmRequest extends React.Component {
value={link}
className={styles.copy}/>
<a className={styles.emailLink}
href={`mailto:?subject=Request ${amount} LSK to ${address}&body=Hey there, here is a link you can use to send me ${amount} LSK via your wallet: ${link}`}>
href={`mailto:?subject=Request ${amount} LSK to ${address}&body=Hey there, here is a link you can use to send me ${amount} LSK via your wallet: ${encodeURIComponent(link)}`}>
{t('Send request via E-mail')} <FontIcon value='arrow-right'/>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/request/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Request extends React.Component {
value={account.address}
className={styles.copy}/>
<a className={`${styles.emailLink} ${styles.paddingLeft}`}
href={`mailto:?subject=Request LSK to ${account.address}&body=Hey there, here is a link you can use to send me LSK via your wallet: ${link}`}>
href={`mailto:?subject=Request LSK to ${account.address}&body=Hey there, here is a link you can use to send me LSK via your wallet: ${encodeURIComponent(link)}`}>
{t('Send request via E-mail')} <FontIcon value='arrow-right'/>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('ExplorerTransactions Component', () => {
address: accounts.genesis.address,
activeFilter: txFilters.all,
history: { push: spy(), location: { search: ' ' } },
pendingTransactions: [],
t: key => key,
};

Expand Down
Loading

0 comments on commit a7e8418

Please sign in to comment.