# All files / src/api/methods txResponse.js

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30

    6x

    6x
    12x

    12x

    12x

     /**
     * Copyright (c) 2019-present, Leap DAO (leapdao.org)
     *
     * This source code is licensed under the Mozilla Public License Version 2.0
     * found in the LICENSE file in the root directory of this source tree.
     */
    const getPrevTx = require('./utils/getPrevTx');

    module.exports = async (db, tx, blockHash, height, txPos) => {
      const prevTx = await getPrevTx(db, tx);

      const { value, color } = tx.value(prevTx);

      return {
        value: `0x${value.toString(16)}`,
        color,
        hash: tx.hash(),
        from: tx.from(prevTx),
        raw: tx.hex(),
        blockHash,
        blockNumber: `0x${height.toString(16)}`,
        transactionIndex: txPos,
        to: tx.to(),
        gas: '0x0',
        gasPrice: '0x0',
        nonce: 0,
        input: '0x',
      };
    };