Skip to content
This repository was archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1075 from LiskHQ/1067-replace-lisk-js-with-lisk-e…
Browse files Browse the repository at this point in the history
…lements

Replace lisk-js with lisk-elements - Closes #1067
  • Loading branch information
yasharAyari authored May 23, 2018
2 parents 49d1cfa + 6f7335c commit b06ba23
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"i18next": "=10.0.3",
"i18next-localstorage-cache": "=1.1.1",
"i18next-xhr-backend": "=1.4.2",
"lisk-js": "1.0.0-beta.1",
"lisk-elements": "1.0.0-beta.3",
"moment": "2.20.1",
"numeral": "=2.0.6",
"postcss": "6.0.12",
Expand Down
6 changes: 3 additions & 3 deletions src/actions/peers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import i18next from 'i18next';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import actionTypes from '../constants/actions';
// import { getNethash } from './../utils/api/nethash';
import { errorToastDisplayed } from './toaster';
Expand All @@ -10,7 +10,7 @@ const peerSet = (data, config) => ({
data: Object.assign({
passphrase: data.passphrase,
publicKey: data.publicKey,
activePeer: new Lisk.APIClient(config.nodes, config.nethash, {}),
activePeer: new Lisk.APIClient(config.nodes, { nethash: config.nethash }),
options: config,
}),
type: actionTypes.activePeerSet,
Expand Down Expand Up @@ -44,7 +44,7 @@ export const activePeerSet = data =>
config.testnet = config.port === '7000';
}
if (config.custom) {
const getNethash = new Lisk.APIClient(config.nodes, config.nethash, {});
const getNethash = new Lisk.APIClient(config.nodes, { nethash: config.nethash });
loadingStarted('getConstants');
getNethash.node.getConstants().then((response) => {
loadingFinished('getConstants');
Expand Down
4 changes: 2 additions & 2 deletions src/actions/peers.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { expect } from 'chai';
import { spy, stub, match } from 'sinon';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import actionTypes from '../constants/actions';
import netHashes from '../constants/netHashes';
import { activePeerSet, activePeerUpdate } from './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, {});
const nethashApi = new Lisk.APIClient(['http://localhost:4000'], { nethash });
describe('activePeerUpdate', () => {
it('should create an action to update the active peer', () => {
const data = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/decryptMessage/decryptMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Input from 'react-toolbox/lib/input';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import { translate } from 'react-i18next';
import ActionBar from '../actionBar';
import Authenticate from '../authenticate';
Expand Down
2 changes: 1 addition & 1 deletion src/components/decryptMessage/decryptMessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mount } from 'enzyme';
import sinon from 'sinon';
import { Provider } from 'react-redux';
import { I18nextProvider } from 'react-i18next';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import i18n from '../../i18n';
import store from '../../store';
import DecryptMessage from './decryptMessage';
Expand Down
2 changes: 1 addition & 1 deletion src/components/encryptMessage/encryptMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Input from 'react-toolbox/lib/input';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import { translate } from 'react-i18next';
import ActionBar from '../actionBar';
import Authenticate from '../authenticate';
Expand Down
2 changes: 1 addition & 1 deletion src/components/encryptMessage/encryptMessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from 'chai';
import { mount } from 'enzyme';
import sinon from 'sinon';
import PropTypes from 'prop-types';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import i18n from '../../i18n';
import store from '../../store';
import Authenticate from '../authenticate';
Expand Down
5 changes: 2 additions & 3 deletions src/components/login/login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { spy } from 'sinon';
import { mount, shallow } from 'enzyme';
import { BrowserRouter as Router } from 'react-router-dom';
import configureMockStore from 'redux-mock-store';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import PropTypes from 'prop-types';
import i18n from '../../i18n';
import Login from './login';
Expand Down Expand Up @@ -32,7 +32,6 @@ describe('Login', () => {
},
replace: spy(),
};
const nethash = '198f2b61a8eb95fbeed58b8216780b68f697f26b849acf00c8c93bb9b24f783d';
const props = {
peers,
account,
Expand All @@ -42,7 +41,7 @@ describe('Login', () => {
onAccountUpdated: () => {},
setActiveDialog: spy(),
activePeerSet: () => {
props.peers.data = new Lisk.APIClient(['http://localhost:4000'], nethash, {});
props.peers.data = new Lisk.APIClient(['http://localhost:4000'], {});
},
};
const options = {
Expand Down
3 changes: 1 addition & 2 deletions src/components/registerDelegate/registerDelegate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import sinon from 'sinon';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import { Provider } from 'react-redux';
import { I18nextProvider } from 'react-i18next';
import i18n from '../../i18n'; // initialized i18next instance
Expand Down Expand Up @@ -41,7 +41,6 @@ const withSecondSecretAccount = {
const props = {
peers: {
data: new Lisk.APIClient(['http://localhost:4000'],
'198f2b61a8eb95fbeed58b8216780b68f697f26b849acf00c8c93bb9b24f783d',
{
name: 'Custom Node',
custom: true,
Expand Down
2 changes: 1 addition & 1 deletion src/components/signMessage/signMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Input from 'react-toolbox/lib/input';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';

import InfoParagraph from '../infoParagraph';
import SignVerifyResult from '../signVerifyResult';
Expand Down
2 changes: 1 addition & 1 deletion src/components/verifyMessage/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { translate } from 'react-i18next';
import Input from 'react-toolbox/lib/input';
import React from 'react';
import lisk from 'lisk-js';
import lisk from 'lisk-elements';

import InfoParagraph from '../infoParagraph';
import SignVerifyResult from '../signVerifyResult';
Expand Down
4 changes: 2 additions & 2 deletions src/components/voting/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';
import { I18nextProvider } from 'react-i18next';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import i18n from '../../i18n';
import VotingHOC from './';
import store from '../../store';
Expand All @@ -15,7 +15,7 @@ describe('VotingHOC', () => {
beforeEach(() => {
store.getState = () => ({
peers: {
data: new Lisk.APIClient(['http://localhost:4000'], 'nethash', {}),
data: new Lisk.APIClient(['http://localhost:4000'], {}),
},
transactions: {
pending: [],
Expand Down
4 changes: 2 additions & 2 deletions src/store/middlewares/login.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import { expect } from 'chai';
import { spy, stub, mock } from 'sinon';
import middleware from './login';
Expand All @@ -11,7 +11,7 @@ describe('Login middleware', () => {
let next;
const passphrase = 'wagon stock borrow episode laundry kitten salute link globe zero feed marble';
const nethash = '198f2b61a8eb95fbeed58b8216780b68f697f26b849acf00c8c93bb9b24f783d';
const activePeer = new Lisk.APIClient(['http://localhost:4000'], nethash, {});
const activePeer = new Lisk.APIClient(['http://localhost:4000'], {});

const activePeerSetAction = {
type: actionTypes.activePeerSet,
Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const peers = (state = { status: {}, options: {} }, action) => {
case actionTypes.activePeerSet:
return Object.assign({}, state, {
data: action.data.activePeer,
// options are duplicated here because lisk-js later on removes it from the 'data' object
// options are duplicated here because lisk-elements doesn't expose it as lisk-js did
options: action.data.options,
});
case actionTypes.activePeerUpdate:
Expand Down
7 changes: 3 additions & 4 deletions src/utils/api/account.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';

export const getAccount = (activePeer, address) =>
new Promise((resolve) => {
Expand Down Expand Up @@ -69,8 +69,7 @@ export const extractPublicKey = passphrase =>
*/
export const extractAddress = (data) => {
if (data.indexOf(' ') < 0) {
return Lisk.cryptography.getAddress(data);
return Lisk.cryptography.getAddressFromPublicKey(data);
}
const { publicKey } = Lisk.cryptography.getKeys(data);
return Lisk.cryptography.getAddress(publicKey);
return Lisk.cryptography.getAddressFromPassphrase(data);
};
2 changes: 1 addition & 1 deletion src/utils/api/delegate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';

export const listAccountDelegates = (activePeer, address) =>
activePeer.votes.get({ address, limit: 101 });
Expand Down
5 changes: 2 additions & 3 deletions src/utils/api/delegate.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import sinon from 'sinon';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import { listAccountDelegates,
listDelegates,
getDelegate,
Expand All @@ -19,8 +19,7 @@ describe('Utils: Delegate', () => {
let activePeer;

beforeEach(() => {
const nethash = '198f2b61a8eb95fbeed58b8216780b68f697f26b849acf00c8c93bb9b24f783d';
activePeer = new Lisk.APIClient(['http://localhost:4000'], nethash, {});
activePeer = new Lisk.APIClient(['http://localhost:4000'], {});
peersMock = sinon.mock(activePeer.delegates);
});

Expand Down
5 changes: 2 additions & 3 deletions src/utils/api/forging.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import Lisk from 'lisk-js';
import Lisk from 'lisk-elements';
import { mock } from 'sinon';
import moment from 'moment';
import { getForgedBlocks, getForgedStats } from './forging';
Expand All @@ -10,8 +10,7 @@ describe('Utils: Forging', () => {
const publicKey = 'c094ebee7ec0c50ebee32918655e089f6e1a604b83bcaa760293c61e0f18ab6f';

beforeEach(() => {
const nethash = '198f2b61a8eb95fbeed58b8216780b68f697f26b849acf00c8c93bb9b24f783d';
activePeer = new Lisk.APIClient(['http://localhost:4000'], nethash, {});
activePeer = new Lisk.APIClient(['http://localhost:4000'], {});
});

describe('getForgedBlocks', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/voteDialog/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const peers = {
'Content-Type': 'application/json',
nethash: 'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba',
broadhash: 'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba',
os: 'lisk-js-api',
os: 'lisk-elements-api',
version: '1.0.0',
minVersion: '>=0.5.0',
port: 443,
Expand Down

0 comments on commit b06ba23

Please sign in to comment.