Skip to content

Commit

Permalink
Merge pull request #17 from echoprotocol/develop
Browse files Browse the repository at this point in the history
0.6.1
  • Loading branch information
Anastasia Rudenko authored Oct 23, 2019
2 parents 8289c17 + eb69595 commit 94f1bbf
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 27 deletions.
25 changes: 14 additions & 11 deletions app/actions/account-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import Services from '../services';
import CryptoService from '../services/crypto-service';
import { FORM_SIGN_IN, FORM_SIGN_UP } from '../constants/form-constants';
import {
ECHO_PROXY_TO_SELF_ACCOUNT,
ECHO_ASSET_ID,
GLOBAL_ID_1,
EXPIRATION_INFELICITY,
} from '../constants/global-constants';
import { toggleLoading, setValue } from './form-actions';
import { setValue as setGlobal, setValue as setValueGlobal, setAccounts } from './global-actions';
import { getOperationFee } from './transaction-actions';
import ValidateAccountHelper from '../helpers/validate-account-helper';
import ViewHelper from '../helpers/view-helper';
import GlobalReducer from '../reducers/global-reducer';
Expand Down Expand Up @@ -119,40 +117,45 @@ export const registerAccount = (accountName) => async (dispatch, getState) => {

} else {
const account = await Services.getEcho().api.getAccountByName(registrator.account);
const config = await Services.getEcho().api.getConfig();

const options = {
echorand_key: publicKey,
registrar: account.id,
name: accountName,
active: {
weight_threshold: 1,
account_auths: [],
key_auths: [[publicKey, 1]],
key_auths: [[
publicKey,
1,
]],
},
echorand_key: publicKey,
options: {
voting_account: ECHO_PROXY_TO_SELF_ACCOUNT,
voting_account: config.ECHO_PROXY_TO_SELF_ACCOUNT,
delegating_account: account.id,
num_committee: 0,
delegate_share: 0,
votes: [],
extensions: [],
},
extensions: [],
};

const balance = getState().echoCache.getIn([
CACHE_MAPS.OBJECTS_BY_ID,
getState().echoCache.getIn([CACHE_MAPS.FULL_ACCOUNTS, account.id, 'balances', ECHO_ASSET_ID]),
'balance',
]);
const fee = await getOperationFee(OPERATIONS_IDS.ACCOUNT_CREATE, options);

if (BN(fee).gt(balance)) {
const tx = Services.getEcho().api.createTransaction();
tx.addOperation(OPERATIONS_IDS.ACCOUNT_CREATE, options);
await tx.setRequiredFees();

if (BN(tx.operations[0][1].fee.amount).gt(balance)) {
dispatch(setValue(FORM_SIGN_UP, 'error', 'Insufficient funds'));
return resolve(false);
}

const tx = Services.getEcho().api.createTransaction();
tx.addOperation(OPERATIONS_IDS.ACCOUNT_CREATE, options);

const dynamicGlobalChainData = await Services.getEcho().api.getObject(GLOBAL_ID_1, true);

const headBlockTimeSeconds = Math.ceil(new Date(`${dynamicGlobalChainData.time}Z`).getTime() / 1000);
Expand Down
11 changes: 7 additions & 4 deletions app/actions/auth-actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OPERATIONS_IDS } from 'echojs-lib';

import { ECHO_PROXY_TO_SELF_ACCOUNT, TEMPLATE_ECHO_KEY } from '../constants/global-constants';
import { TEMPLATE_ECHO_KEY } from '../constants/global-constants';
import { FORM_SIGN_UP } from '../constants/form-constants';
import { getOperationFee } from './transaction-actions';
import { setInValue } from './form-actions';
Expand Down Expand Up @@ -34,7 +34,9 @@ export const changeActiveTabIndex = (value) => (dispatch) => {
* @param {String} accountId
* @returns {Function}
*/
export const getAccountCreateFee = (accountId, name = '') => {
export const getAccountCreateFee = async (accountId, name = '') => {
const config = await Services.getEcho().api.getConfig();

const options = {
echorand_key: TEMPLATE_ECHO_KEY,
registrar: accountId,
Expand All @@ -45,12 +47,13 @@ export const getAccountCreateFee = (accountId, name = '') => {
key_auths: [[TEMPLATE_ECHO_KEY, 1]],
},
options: {
voting_account: ECHO_PROXY_TO_SELF_ACCOUNT,
voting_account: config.ECHO_PROXY_TO_SELF_ACCOUNT,
delegating_account: accountId,
num_committee: 0,
delegate_share: 0,
votes: [],
extensions: [],
},
extensions: [],
};

return getOperationFee(OPERATIONS_IDS.ACCOUNT_CREATE, options);
Expand Down
10 changes: 6 additions & 4 deletions app/components/wallet/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ class Wallet extends React.Component {
});
}

changeVisibilityAsset(idAsset) {
changeVisibilityAsset(e, idAsset) {
e.stopPropagation();

this.props.toggleVisibiltyAsset(idAsset);
}

Expand Down Expand Up @@ -200,7 +202,7 @@ class Wallet extends React.Component {
content={
<Icon className="icon-close-big" />
}
onClick={() => this.changeVisibilityAsset(token.getIn(['contract', 'id']))}
onClick={(e) => this.changeVisibilityAsset(e, token.getIn(['contract', 'id']))}
/>
</div>
</div>
Expand Down Expand Up @@ -250,7 +252,7 @@ class Wallet extends React.Component {
content={
<Icon className="icon-close-big" />
}
onClick={() => this.changeVisibilityAsset(id)}
onClick={(e) => this.changeVisibilityAsset(e, id)}
/>
</div>
</div>
Expand Down Expand Up @@ -343,7 +345,7 @@ class Wallet extends React.Component {
updateBalance={updBalance}
assets={this.getAssets(balances) || []}
hiddenAssets={hiddenAssets}
changeVisibilityAsset={(id) => this.changeVisibilityAsset(id)}
changeVisibilityAsset={(e, id) => this.changeVisibilityAsset(e, id)}
tokens={stateTokens}
/>

Expand Down
4 changes: 2 additions & 2 deletions app/components/wallet/settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class Settings extends React.Component {
</div>
<div className="col">
<Button
onClick={() => changeVisibilityAsset(token.getIn(['contract', 'id']))}
onClick={(e) => changeVisibilityAsset(e, token.getIn(['contract', 'id']))}
className="btn-inversed"
content="Unarchive"
/>
Expand Down Expand Up @@ -270,7 +270,7 @@ class Settings extends React.Component {
</div>
<div className="col">
<Button
onClick={() => changeVisibilityAsset(asset.id)}
onClick={(e) => changeVisibilityAsset(e, asset.id)}
className="btn-inversed"
content="Unarchive"
/>
Expand Down
1 change: 0 additions & 1 deletion app/constants/global-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export const ECHO_ASSET_PRECISION = 8;
export const ECHO_ASSET_SYMBOL = 'ECHO';
export const MAX_ASSET_SYMBOL_LENGTH = 5;
export const GLOBAL_ID_1 = constants.DYNAMIC_GLOBAL_OBJECT_ID;
export const ECHO_PROXY_TO_SELF_ACCOUNT = '1.2.5';
export const CONTRACT_ID_PREFIX = `1.${constants.PROTOCOL_OBJECT_TYPE_ID.CONTRACT}`;
export const EETH_ASSET_SYMBOL = 'EETH';
export const ERC20_TOKEN_PRECISION = 18;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class AccountCreated extends React.Component {

</div>
</div>
<span classNames="hints">
<span classnames="hints">
{hint1}
<br />
{hint2}
Expand Down
2 changes: 1 addition & 1 deletion app/containers/authorization/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CreateAccount from './create-account';

import ImportAccount from './import-account';
import blipLogo from '../../assets/images/blip-logo.svg';
import AccountCreated from '../account-сreated';
import AccountCreated from '../account-created';
import AccountImported from '../account-imported';

import { startAnimation } from '../../actions/animation-actions';
Expand Down
2 changes: 1 addition & 1 deletion app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { Switch, Route } from 'react-router-dom';
import App from './containers/app';
import Authorization from './containers/authorization';
import accountCreated from './containers/account-сreated';
import accountCreated from './containers/account-created';
import accountImported from './containers/account-imported';
import CreatePassword from './containers/create-password';
import RestorePassword from './containers/restore-password';
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "blip-wallet",
"productName": "BlipWallet",
"version": "0.6.0-rc.1",
"version": "0.6.1-rc.1",
"description": "Blip Wallet",
"scripts": {
"web": "cross-env NODE_ENV=development node --trace-warnings -r @babel/register ./node_modules/webpack-dev-server/bin/webpack-dev-server --config configs/webpack.config.web.babel.js --mode development --progress --colors --history-api-fallback --hot --inline",
Expand Down Expand Up @@ -271,7 +271,7 @@
"connected-react-router": "^5.0.1",
"crypto-random-string": "^1.0.0",
"devtron": "^1.4.0",
"echojs-lib": "^1.8.1-rc.5",
"echojs-lib": "^1.9.0",
"echojs-ping": "^0.1.5",
"electron-debug": "^2.0.0",
"electron-log": "^2.2.17",
Expand Down

0 comments on commit 94f1bbf

Please sign in to comment.