Skip to content

Commit

Permalink
0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Anastasia Rudenko authored Oct 16, 2019
2 parents 320ded3 + 2b281cd commit 8289c17
Show file tree
Hide file tree
Showing 11 changed files with 364 additions and 85 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
4 changes: 2 additions & 2 deletions app/actions/transfer-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const setFeeFormValue = () => async (dispatch, getState) => {
const asset = selectedBalance
? objectsById.get(objectsById.getIn([selectedBalance, 'asset_type']))
: objectsById.get(ECHO_ASSET_ID);
type = 'transfer';
type = OPERATIONS_IDS.TRANSFER;

options = {
amount: {
Expand Down Expand Up @@ -384,7 +384,7 @@ export const send = () => async (dispatch, getState) => {
};
} else {

type = 'transfer';
type = OPERATIONS_IDS.TRANSFER;
options = {
amount: {
amount: parseFloat(amount),
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
2 changes: 1 addition & 1 deletion app/constants/global-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ 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.OBJECT_TYPES.CONTRACT}`;
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
Loading

0 comments on commit 8289c17

Please sign in to comment.