Skip to content

Commit

Permalink
[BLP-408] Local chain (#40)
Browse files Browse the repository at this point in the history
* [BLP-408] Echo node

* [BLP-408] Chain

* [BLP-408] Chain

* [BLP-408] Chain

* [BLP-408] Chain

* [BLP-408] Chain

* [BLP-408] Refactor

* [BLP-408] Refactor

* [BLP-408] Chain

* [BLP-408] Chain

* [BLP-481] echo 0.13

* [BLP-452] add default delegate_share

* devnet

* change network

* [BLP-408] Local chain

* [BLP-408] Local chain

* [BLP-408] Local chain

* [BLP-408] Local chain

* Fix path whitespace, add travis mac, only testnet

* Fix path whitespace, add travis mac, only testnet

* Fix path whitespace, add travis mac, only testnet

* Up echo_node version

* rm unused param
  • Loading branch information
vital-33 committed Nov 26, 2019
1 parent 89d0b47 commit 4314f40
Show file tree
Hide file tree
Showing 17 changed files with 417 additions and 255 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,17 @@ jobs:
- npm run build
- npm run test
- npm run lint




- stage: build
name: "Build Linux App"
env:
- DOWNLOAD_ECHO_NODE_URL= "https://github.com/echoprotocol/echo/releases/download/0.6.1/echo_node"
- DOWNLOAD_ECHO_NODE_URL= "https://d14s13k07yt1gw.cloudfront.net/echo-linux.0.13.5.tar"
if: tag IS present
script:
- sudo apt-get install rpm
- npm config set unsafe-perm true
- rm -rf node_modules/node-sass
- npm i
- DEBUG_PROD=true npm run package-linux
- DEBUG_PROD=true npm run package-linux-with-download-build
deploy:
provider: releases
api_key: $GITHUB_OAUTH_TOKEN
Expand Down Expand Up @@ -77,11 +73,13 @@ jobs:
- stage: build
os: osx
name: "Build macOS App"
env:
- DOWNLOAD_ECHO_NODE_URL= "https://d14s13k07yt1gw.cloudfront.net/echo-mac.0.13.5.tar"
if: tag IS present
script:
- npm config set unsafe-perm true
- npm i
- DEBUG_PROD=true npm run package-mac
- DEBUG_PROD=true npm run package-mac-with-download-build
deploy:
provider: releases
api_key: $GITHUB_OAUTH_TOKEN
Expand Down
2 changes: 2 additions & 0 deletions app/actions/account-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ export const logoutAccount = (accountId) => async (dispatch, getState) => {
dispatch(WalletReducer.actions.set({ field: 'tokens', value: tokens }));

dispatch(subscribeTokens());
dispatch(setAccounts());
};
/**
*
Expand Down Expand Up @@ -441,4 +442,5 @@ export const removeAllAccounts = () => async (dispatch) => {
dispatch(WalletReducer.actions.clear({ field: 'hiddenAssets' }));

dispatch(subscribeTokens());
dispatch(setAccounts());
};
1 change: 1 addition & 0 deletions app/actions/auth-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const loadRegistrators = () => async (dispatch, getState) => {
], []);

await Services.getEcho().api.getObjects(objectIds);

};

/**
Expand Down
12 changes: 9 additions & 3 deletions app/actions/balance-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export const initTokens = () => async (dispatch, getState) => {
try {
const tokens = await getBalances(accounts);

if (!tokens || !tokens.data.getBalances.length) {
if (!tokens || !tokens.data || !tokens.data.getBalances.length) {
return false;
}

dispatch(setValue('tokens', fromJS(tokens.data.getBalances.filter((t) => t.type === TOKEN_TYPE))));
} catch (e) {
console.log(e);
console.error(e);
}

return true;
Expand Down Expand Up @@ -92,7 +92,13 @@ export const clear = (field) => (dispatch) => {
export const updateBalance = () => async (dispatch, getState) => {
const accounts = getState().global.get('accounts');

const selectedAccounts = await Services.getEcho().api.getFullAccounts([...accounts.keys()]);
if (!Services.getEcho().api) {
return;
}

let selectedAccounts = await Services.getEcho().api.getFullAccounts([...accounts.keys()]);

selectedAccounts = selectedAccounts.filter((account) => account);

const objectIds = selectedAccounts.reduce((balances, account) => {
const result = Object.entries(account.balances).reduce((arr, b) => [...arr, ...b], []);
Expand Down
6 changes: 3 additions & 3 deletions app/actions/global-actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-undef */
import { Map, fromJS } from 'immutable';
import { PrivateKey } from 'echojs-lib';

import GlobalReducer from '../reducers/global-reducer';
import Services from '../services';
Expand Down Expand Up @@ -102,14 +101,15 @@ export const setAccounts = () => (async () => {
const userStorage = Services.getUserStorage();
const accounts = await userStorage.getAllAccounts();
const networkId = await userStorage.getNetworkId();
const chainToken = await userStorage.getChainToken();

const keyPromises = accounts.map((account) => new Promise(async (resolve) => {

const keys = await userStorage.getAllWIFKeysForAccount(account.id);

return resolve(keys.map((key) => ({
id: account.id,
key: PrivateKey.fromWif(key.wif).toPrivateKeyString(),
key: key.wif,
})));

}));
Expand All @@ -123,7 +123,7 @@ export const setAccounts = () => (async () => {
});
});

Services.getEcho().setOptions(accountsKeys, networkId);
Services.getEcho().setOptions(accountsKeys, networkId, chainToken);

});

Expand Down
3 changes: 1 addition & 2 deletions app/constants/chain-constants.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export const DATA_DIR = 'echo/data';
export const SEED_NODE = 'node1.devnet.echo-dev.io:6310';
export const RESTART_PAUSE_MS = 5000;
export const DIFF_TIME_SYNC_MS = 30000;
export const SYNC_MONITOR_MS = 1000;
export const SYNC_MONITOR_MS = 2000;
export const RESTART_TIME_CHECKING_NODE_MS = 5000;
export const CHAIN_MIN_RANGE_PORT = 3000;
export const CHAIN_MAX_RANGE_PORT = 5000;
2 changes: 1 addition & 1 deletion app/constants/global-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ export const APP_WINDOW_WIDTH = 1024;
export const APP_WINDOW_HEIGHT = 728;
export const APP_WINDOW_MIN_WIDTH = 1024;
export const APP_WINDOW_MIN_HEIGHT = 728;
export const TIMEOUT_BEFORE_APP_PROCESS_EXITS_MS = 12000;
export const TIMEOUT_BEFORE_APP_PROCESS_EXITS_MS = 30000;
13 changes: 10 additions & 3 deletions app/logic-components/db/models/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ class Network {
*
* @param {Array} accounts
* @param {Array} keys
* @param {Object} chainToken
*/
constructor(accounts, keys) {
constructor(accounts, keys, chainToken = null) {
this.accounts = accounts;
this.keys = keys;
this.chainToken = chainToken;
}

/**
*
* @param {Array} accounts
* @param {Array} keys
* @param {Object} chainToken
*/
static create(accounts, keys) {
return new Network(accounts, keys);
static create(accounts, keys, chainToken = null) {
return new Network(accounts, keys, chainToken);
}

/**
Expand Down Expand Up @@ -76,6 +79,10 @@ class Network {
return this.keys;
}

getChainToken() {
return this.chainToken;
}

}

export default Network;
Loading

0 comments on commit 4314f40

Please sign in to comment.