How to use the @dfuse/client.flattenActionTraces function in @dfuse/client

To help you get started, we’ve selected a few @dfuse/client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dfuse-io / client-js / examples / advanced / track-ram-usage.ts View on Github external
* with a particular action trace. For example, a database operation
         * backlink through an `action_idx` property to the actual action
         * trace that generates this operation.
         *
         * The `action_idx` is not easy to work with at the transaction
         * level since the dfuse API consumer needs to perform a depth-first
         * traversal of the execution tree to determine the actual action.
         *
         * To ease that process, the helper `flattenActionTraces` can be used
         * to get a flattened list of action traces, where each index of the list
         * map to the correct `action_idx` value.
         *
         * This can than later be used to easily find the action representing
         * a given `action_idx` value. See below for usage with RAM op.
         */
        const flattenedActionTraces = flattenActionTraces(result.lifecycle)

        // /**
        //  * Using dfuse Search API, you received the full transaction as a result.
        //  * However a transaction may contain 10 different actions,
        //  * while only 2 out of the 10 actually matches the query.
        //  *
        //  * The `matchingActionTraces` helper can easily be used to extract
        //  * only the matching action traces out of a `SearchTransactionRow`
        //  * result.
        //  */
        // const actionTraces = matchingActionTraces(result)

        result.lifecycle.ramops!.forEach((ramOp: RamOp) => {
          // FIXME: Right logic for RAM op!

          runningTotal += ramOp.delta