Skip to content

Commit

Permalink
[BLP-435] add operations echo 0.11.1 (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anastasia Rudenko authored Oct 15, 2019
1 parent 6bdc42e commit e5ca449
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 20 deletions.
27 changes: 14 additions & 13 deletions app/actions/transaction-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export const formatTransaction = async (type, operation, blockNumber, resultId,
}

const block = await Services.getEcho().api.getBlock(blockNumber);
const feeAsset = await Services.getEcho().api.getObject(operation.getIn(['fee', 'asset_id']));

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

Expand All @@ -98,12 +97,16 @@ export const formatTransaction = async (type, operation, blockNumber, resultId,
type,
name,
timestamp: block.timestamp,
fee: {
};

if (operation.get('fee')) {
const feeAsset = await Services.getEcho().api.getObject(operation.getIn(['fee', 'asset_id']));
object.fee = {
amount: operation.getIn(['fee', 'amount']),
precision: feeAsset.precision,
symbol: feeAsset.symbol,
},
};
};
}

if (CONTRACT_TYPES.includes(type)) {
const result = await Services.getEcho().api.getContractResult(resultId);
Expand Down Expand Up @@ -138,8 +141,9 @@ export const formatTransaction = async (type, operation, blockNumber, resultId,
value: field,
id: field,
};
case OPTION_TYPES.ECHO_ASSET:
case OPTION_TYPES.ASSET:
response = await Services.getEcho().api.getObject(field);
response = await Services.getEcho().api.getObject(field || ECHO_ASSET_ID);

return {
...base,
Expand Down Expand Up @@ -257,11 +261,11 @@ const getFilteredHistory = async (filter, offset = 0, count = DEFAULT_HISTORY_CO
);

let transactions = items.map(({
id, body, transaction, result,
id, body, transaction, result, virtual, block,
}) => formatTransaction(
Number(id),
fromJS(body),
transaction.block.round,
virtual ? block.round : transaction.block.round,
result,
selectedAccounts,
));
Expand Down Expand Up @@ -319,10 +323,7 @@ export const setDefaultFilters = () => async (dispatch, getState) => {
coins = coins.map((i) => ({ ...i, selected: true }));
filter = filter.set('coins', fromJS(coins));

// TODO: delete slice after adding new operation to graphql
const oldOperations = Object.keys(OPERATIONS).slice(0, Object.keys(OPERATIONS).length - 7);

filter = filter.set('types', fromJS(oldOperations.map((type) => ({
filter = filter.set('types', fromJS(Object.keys(OPERATIONS).map((type) => ({
type,
name: OPERATIONS[type].name,
selected: true,
Expand Down Expand Up @@ -449,7 +450,7 @@ export const loadMoreTransactions = () => async (dispatch, getState) => {
* @returns {Function}
*/
export const setNewTransaction = ({
id, body, transaction, result,
id, body, transaction, result, virtual, block,
}) => async (dispatch, getState) => {

const selectedAccounts = getState().wallet.getIn(['history', 'filter', 'accounts'])
Expand All @@ -459,7 +460,7 @@ export const setNewTransaction = ({
const operation = await formatTransaction(
Number(id),
fromJS(body),
transaction.block.round,
virtual ? block.round : transaction.block.round,
result,
selectedAccounts,
);
Expand Down
2 changes: 1 addition & 1 deletion app/components/history/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class History extends React.Component {
<li className="from-to-icon">
{
/* left */
transaction.get('subject') ? (
transaction.get('from') && transaction.get('subject') ? (
<Icon className="arrow-direction" />
) : null
}
Expand Down
43 changes: 41 additions & 2 deletions app/constants/transaction-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const OPTION_TYPES = {
CONTRACT_ADDRESS: 'eth_address',
EETH_ASSET: 'eEth',
ERC20_TOKEN: 'erc20_token',
ECHO_ASSET: 'ECHO',
};

export const CONTRACT_TYPES = [
Expand Down Expand Up @@ -147,7 +148,7 @@ export const OPERATIONS = {
asset: null,
},
},
asset_bitasset_update: {
asset_update_bitasset: {
value: OPERATIONS_IDS.ASSET_UPDATE_BITASSET,
name: 'operations.asset_bitasset_update.title',
options: {
Expand Down Expand Up @@ -429,6 +430,26 @@ export const OPERATIONS = {
},
},
},
balance_unfreeze: {
value: OPERATIONS_IDS.BALANCE_UNFREEZE,
name: 'operations.balance_unfreeze.title',
options: {
from: {
field: 'account',
type: OPTION_TYPES.ACCOUNT,
label: 'operations.balance_unfreeze.from',
},
subject: null,
amount: {
field: 'amount.amount',
type: OPTION_TYPES.NUMBER,
},
asset: {
field: 'amount.asset_id',
type: OPTION_TYPES.ASSET,
},
},
},
override_transfer: {
value: OPERATIONS_IDS.OVERRIDE_TRANSFER,
name: 'operations.override_transfer.title',
Expand Down Expand Up @@ -1011,5 +1032,23 @@ export const OPERATIONS = {
asset: null,
},
},

block_reward_operation: {
value: OPERATIONS_IDS.BLOCK_REWARD,
name: 'operations.block_reward.title',
options: {
from: null,
subject: {
field: 'reciever',
type: OPTION_TYPES.ACCOUNT,
label: 'operations.block_reward.subject',
},
amount: {
field: 'amount',
type: OPTION_TYPES.NUMBER,
},
asset: {
type: OPTION_TYPES.ECHO_ASSET,
},
},
},
};
6 changes: 5 additions & 1 deletion app/services/queries/transaction-queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export const getHistoryByAccounts = (accounts, assets, tokens, operations, offse
round
}
},
result
result,
block {
round
},
virtual
},
total
}
Expand Down
6 changes: 5 additions & 1 deletion app/services/subscriptions/transaction-subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export const newOperation = (filter) => {
round
}
},
result
result,
block {
round
},
virtual
}
}
`;
Expand Down
8 changes: 8 additions & 0 deletions app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@
"title": "Freeze balance",
"from": "Account"
},
"balance_unfreeze": {
"title": "Unfreeze balance",
"from": "Account"
},
"override_transfer": {
"title": "Override transfer",
"from": "From",
Expand Down Expand Up @@ -425,6 +429,10 @@
"sidechain_btc_aggregate": {
"title": "Aggregate BTC",
"subject": "Transaction ID"
},
"block_reward": {
"title": "Block reward",
"subject": "Account"
}
},

Expand Down
10 changes: 9 additions & 1 deletion app/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@
"title": "Заморозить баланс",
"from": "Аккаунт"
},
"balance_unfreeze": {
"title": "Разморозить баланс",
"from": "Аккаунт"
},
"override_transfer": {
"title": "Отменить перевод",
"from": "Отправитель",
Expand Down Expand Up @@ -444,7 +448,11 @@
"sidechain_btc_aggregate": {
"title": "Объединение BTC",
"subject": "ID транзакции"
}
},
"block_reward": {
"title": "Вознаграждение за блок",
"subject": "Аккаунт"
}
},

"send": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
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.3",
"echojs-lib": "^1.8.1-rc.5",
"echojs-ping": "^0.1.5",
"electron-debug": "^2.0.0",
"electron-log": "^2.2.17",
Expand Down

0 comments on commit e5ca449

Please sign in to comment.