@bloks/utils
Advanced tools
Comparing version 3.5.64 to 3.5.65
{ | ||
"name": "@bloks/utils", | ||
"version": "3.5.64", | ||
"version": "3.5.65", | ||
"description": "", | ||
@@ -21,3 +21,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "8f4c209943b403c83621e467734d85fafe1a56ed" | ||
"gitHead": "04994431850d2cf458e253d6121b921e05e64fbf" | ||
} |
@@ -181,3 +181,6 @@ import { constants } from '@bloks/constants' | ||
if (action.parent !== 0) { | ||
actionsByGlobalSequence[action.parent].traces = [actionsByGlobalSequence[action.global_sequence]].concat(actionsByGlobalSequence[action.parent].traces || []) | ||
actionsByGlobalSequence[action.parent].traces = [ | ||
actionsByGlobalSequence[action.global_sequence], | ||
...(actionsByGlobalSequence[action.parent].traces || []) | ||
] | ||
} | ||
@@ -197,2 +200,26 @@ } | ||
export function hyperionTransformFlatTraces (traces) { | ||
const tracesByOrdinal = traces.reduce((acc, trace) => { | ||
acc[trace.action_ordinal] = { | ||
...trace, | ||
traces: [], | ||
account_ram_deltas: trace.account_ram_deltas, | ||
receivers: trace.notified | ||
} | ||
return acc | ||
}, {}) | ||
for (const trace of traces.reverse()) { | ||
if (trace.creator_action_ordinal !== 0) { | ||
tracesByOrdinal[trace.creator_action_ordinal].traces = [tracesByOrdinal[trace.action_ordinal]].concat(tracesByOrdinal[trace.creator_action_ordinal].traces || []) | ||
} | ||
} | ||
const result = Object.values(tracesByOrdinal) | ||
.filter(trace => trace.creator_action_ordinal === 0) | ||
console.log(result) | ||
return result | ||
} | ||
export function hyperionTransformTransaction (transaction) { | ||
@@ -202,4 +229,5 @@ const { actions, lib, trx_id } = transaction | ||
const firstAction = actions[0] | ||
const transformedActions = actions.filter(trace => trace.parent === 0) | ||
const traces = hyperionTransformActions(actions) | ||
// Parent only on < 1.8 | ||
const transformedActions = firstAction.parent ? actions.filter(trace => trace.parent === 0) : actions | ||
const traces = hyperionTransformFlatTraces(actions) | ||
@@ -206,0 +234,0 @@ return { |
32397
957