Skip to content

Commit

Permalink
[BRG-481] add echo 0.11.1 operations (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anastasia Rudenko authored Oct 15, 2019
1 parent 44ebcd6 commit c64702d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 45 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "echo-bridge",
"description": "The bridge between your web site and the Echo",
"version": "1.12.0-rc.2",
"version": "1.12.0-rc.3",
"scripts": {
"start": "cross-env NODE_ENV=local webpack-dev-server --mode development --progress --colors --history-api-fallback --hot --inline --port 8081",
"build": "cross-env NODE_ENV=production webpack --progress --display-error-details --colors --mode production",
Expand All @@ -24,7 +24,7 @@
"classnames": "^2.2.6",
"config": "^1.30.0",
"crypto-random-string": "^1.0.0",
"echojs-lib": "^1.8.0",
"echojs-lib": "^1.8.1-rc.5",
"events": "^3.0.0",
"file-loader": "^1.1.11",
"focus-trap-react": "^4.0.1",
Expand Down
28 changes: 14 additions & 14 deletions src/actions/HistoryActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { validators } from 'echojs-lib';
import GlobalReducer from '../reducers/GlobalReducer';

import operations from '../constants/TransactionConstants';
import { CORE_SYMBOL } from '../constants/GlobalConstants';
import { CORE_SYMBOL, CORE_ID } from '../constants/GlobalConstants';
import { historyOperations } from '../constants/OperationConstants';

import FormatHelper from '../helpers/FormatHelper';
Expand All @@ -30,8 +30,6 @@ const formatOperation = async (data, result, accountName) => {

const block = await echoService.getChainLib().api.getBlock(data.get('block_num'));

const feeAsset = await echoService.getChainLib().api.getObject(operation.getIn(['fee', 'asset_id']));

const { name, options } = Object.values(operations).find((i) => i.value === type);

const typeOperation = historyOperations.find((item) => item.value.includes(name));
Expand All @@ -42,9 +40,14 @@ const formatOperation = async (data, result, accountName) => {
.setIn(['transaction', 'blockNumber'], block.round)
.setIn(['transaction', 'date'], moment.utc(block.timestamp).local().format('DD MMM, HH:mm'))
.setIn(['transaction', 'value'], 0)
.setIn(['transaction', 'currency'], CORE_SYMBOL)
.setIn(['content', 'fee'], FormatHelper.formatAmount(operation.getIn(['fee', 'amount']), feeAsset.precision))
.setIn(['content', 'feeCurrency'], feeAsset.symbol);
.setIn(['transaction', 'currency'], CORE_SYMBOL);

if (operation.getIn(['fee', 'asset_id'])) {
const asset = await echoService.getChainLib().api.getObject(operation.getIn(['fee', 'asset_id']));
result = result
.setIn(['content', 'fee'], FormatHelper.formatAmount(operation.getIn(['fee', 'amount']), asset.precision))
.setIn(['content', 'feeCurrency'], asset.symbol);
}

if (options.subject) {
if (options.subject[1]) {
Expand Down Expand Up @@ -83,16 +86,13 @@ const formatOperation = async (data, result, accountName) => {
}

if (options.value) {
result = result.setIn(['transaction', 'value'], operation.getIn(options.value.split('.')));
}

if (options.asset) {
const request = operation.getIn(options.asset.split('.'));

const value = operation.getIn(options.value.split('.'));
const request = options.asset ? operation.getIn(options.asset.split('.')) : CORE_ID;
const response = await echoService.getChainLib().api.getObject(request);

const resultValue = result.getIn(['transaction', 'value']) !== 0 ? `${numberSign} ${FormatHelper.formatAmount(result.getIn(['transaction', 'value']), response.precision)}` :
FormatHelper.formatAmount(result.getIn(['transaction', 'value']), response.precision);
let resultValue = value !== 0 ? `${numberSign} ` : '';
resultValue = `${resultValue}${FormatHelper.formatAmount(value, response.precision)}`;

result = result.setIn(['transaction', 'value'], resultValue);
result = result.setIn(['transaction', 'currency'], response.symbol);
}
Expand Down
68 changes: 44 additions & 24 deletions src/constants/TransactionConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ export default {
asset: 'amount.asset_id',
},
},
balance_unfreeze: {
value: OPERATIONS_IDS.BALANCE_UNFREEZE,
name: 'Unfreeze balance',
options: {
from: 'account',
subject: null,
value: 'amount.amount',
asset: 'amount.asset_id',
},
},
override_transfer: {
value: OPERATIONS_IDS.OVERRIDE_TRANSFER,
name: 'Override transfer',
Expand Down Expand Up @@ -277,7 +287,7 @@ export default {
options: {
from: 'sender',
subject: ['contract'],
amount: null,
value: null,
asset: 'fee',
},
},
Expand All @@ -287,7 +297,7 @@ export default {
options: {
from: 'owner',
subject: null,
amount: null,
value: null,
asset: null,
},
},
Expand All @@ -297,7 +307,7 @@ export default {
options: {
from: 'from',
subject: ['to'],
amount: 'amount.amount',
value: 'amount.amount',
asset: 'amount.asset_id',
},
},
Expand All @@ -307,7 +317,7 @@ export default {
options: {
from: 'account',
subject: null,
amount: null,
value: null,
asset: null,
},
},
Expand All @@ -317,7 +327,7 @@ export default {
options: {
from: 'account',
subject: null,
amount: null,
value: null,
asset: null,
},
},
Expand All @@ -327,7 +337,7 @@ export default {
options: {
from: 'committee_member_id',
subject: ['account', 'name'],
amount: 'value',
value: 'value',
asset: null,
},
},
Expand All @@ -337,7 +347,7 @@ export default {
options: {
from: 'account',
subject: ['eth_addr'],
amount: 'value',
value: 'value',
asset: null,
},
},
Expand All @@ -347,7 +357,7 @@ export default {
options: {
from: 'committee_member_id',
subject: ['withdraw_id'],
amount: null,
value: null,
asset: null,
},
},
Expand All @@ -357,7 +367,7 @@ export default {
options: {
from: 'sender',
subject: ['contract'],
amount: 'value',
value: 'value',
asset: 'fee',
},
},
Expand All @@ -367,7 +377,7 @@ export default {
options: {
from: 'sender',
subject: ['contract'],
amount: 'value',
value: 'value',
asset: 'fee',
},
},
Expand All @@ -377,7 +387,7 @@ export default {
options: {
from: 'account',
subject: ['deposit_id'],
amount: 'value',
value: 'value',
asset: 'fee',
},
},
Expand All @@ -387,7 +397,7 @@ export default {
options: {
from: 'account',
subject: ['withdraw_id'],
amount: 'value',
value: 'value',
asset: 'fee',
},
},
Expand All @@ -397,7 +407,7 @@ export default {
options: {
from: 'account',
subject: ['eth_addr'],
amount: null,
value: null,
asset: 'fee',
},
},
Expand All @@ -407,7 +417,7 @@ export default {
options: {
from: 'account',
subject: ['erc20_token_addr'],
amount: 'value',
value: 'value',
asset: 'fee',
},
},
Expand All @@ -417,7 +427,7 @@ export default {
options: {
from: 'account',
subject: ['to'],
amount: 'value',
value: 'value',
asset: 'fee',
},
},
Expand All @@ -427,7 +437,7 @@ export default {
options: {
from: 'account',
subject: ['to'],
amount: 'value',
value: 'value',
asset: 'fee',
},
},
Expand All @@ -437,7 +447,7 @@ export default {
options: {
from: 'account',
subject: ['token'],
amount: 'amount',
value: 'amount',
asset: null,
},
},
Expand All @@ -447,7 +457,7 @@ export default {
options: {
from: 'account',
subject: ['token'],
amount: 'amount',
value: 'amount',
asset: null,
},
},
Expand All @@ -457,7 +467,7 @@ export default {
options: {
from: 'account',
subject: null,
amount: null,
value: null,
asset: null,
},
},
Expand All @@ -467,7 +477,7 @@ export default {
options: {
from: 'account',
subject: ['intermediate_address'],
amount: null,
value: null,
asset: null,
},
},
Expand All @@ -477,7 +487,7 @@ export default {
options: {
from: 'account',
subject: ['intermediate_deposit_id'],
amount: null,
value: null,
asset: null,
},
},
Expand All @@ -487,7 +497,7 @@ export default {
options: {
from: 'account',
subject: ['btc_addr'],
amount: 'value',
value: 'value',
asset: null,
},
},
Expand All @@ -497,7 +507,7 @@ export default {
options: {
from: 'committee_member_id',
subject: ['withdraw_id'],
amount: null,
value: null,
asset: null,
},
},
Expand All @@ -507,7 +517,17 @@ export default {
options: {
from: null,
subject: ['transaction_id'],
amount: null,
value: null,
asset: null,
},
},
block_reward: {
value: OPERATIONS_IDS.BLOCK_REWARD,
name: 'Block reward',
options: {
from: null,
subject: ['reciever', 'name'],
value: 'amount',
asset: null,
},
},
Expand Down
14 changes: 9 additions & 5 deletions src/containers/Transactions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Transactions extends React.Component {
<div className="content">
<div className="transaction-element-content">
{
accountName !== elem.getIn(['content', 'sender']) ?
elem.getIn(['content', 'sender']) && accountName !== elem.getIn(['content', 'sender']) ?
<div className="row">
<div className="left-block">Sender</div>
<div className="right-block">{elem.getIn(['content', 'sender'])}</div>
Expand All @@ -113,10 +113,14 @@ class Transactions extends React.Component {
<div className="right-block">{elem.getIn(['content', 'receiver'])}</div>
</div> : null
}
<div className="row">
<div className="left-block">Fee</div>
<div className="right-block">{elem.getIn(['content', 'fee'])}<span className="currency">{elem.getIn(['content', 'feeCurrency'])}</span></div>
</div>
{
elem.getIn(['content', 'fee']) ? (
<div className="row">
<div className="left-block">Fee</div>
<div className="right-block">{elem.getIn(['content', 'fee'])}<span className="currency">{elem.getIn(['content', 'feeCurrency'])}</span></div>
</div>
) : null
}
{NETWORKS.find((item) => item.name === network.get('name')) &&
<div className="row">
<a
Expand Down

0 comments on commit c64702d

Please sign in to comment.