ethereumjs / ethereumjs-monorepo

@@ -1,23 +1,22 @@
Loading
1 1
import { TransactionFactory } from '@ethereumjs/tx'
2 -
import { setLengthLeft, toBuffer } from '@ethereumjs/util'
2 +
import { TypeOutput, setLengthLeft, toBuffer, toType } from '@ethereumjs/util'
3 3
4 4
import { blockHeaderFromRpc } from './header-from-rpc'
5 -
import { numberToHex } from './helpers'
6 5
7 6
import { Block } from './index'
8 7
9 8
import type { BlockOptions, JsonRpcBlock } from './index'
10 9
import type { TxData, TypedTransaction } from '@ethereumjs/tx'
11 10
12 -
function normalizeTxParams(_txParams: any) {
11 +
export function normalizeTxParams(_txParams: any) {
13 12
  const txParams = Object.assign({}, _txParams)
14 13
15 -
  txParams.gasLimit = txParams.gasLimit === undefined ? txParams.gas : txParams.gasLimit
14 +
  txParams.gasLimit = toType(txParams.gasLimit ?? txParams.gas, TypeOutput.BigInt)
16 15
  txParams.data = txParams.data === undefined ? txParams.input : txParams.data
17 16
18 17
  // check and convert gasPrice and value params
19 -
  txParams.gasPrice = numberToHex(txParams.gasPrice)
20 -
  txParams.value = numberToHex(txParams.value)
18 +
  txParams.gasPrice = txParams.gasPrice !== undefined ? BigInt(txParams.gasPrice) : undefined
19 +
  txParams.value = txParams.value !== undefined ? BigInt(txParams.value) : undefined
21 20
22 21
  // strict byte length checking
23 22
  txParams.to =
@@ -25,11 +24,7 @@
Loading
25 24
      ? setLengthLeft(toBuffer(txParams.to), 20)
26 25
      : null
27 26
28 -
  // v as raw signature value {0,1}
29 -
  // v is the recovery bit and can be either {0,1} or {27,28}.
30 -
  // https://ethereum.stackexchange.com/questions/40679/why-the-value-of-v-is-always-either-27-11011-or-28-11100
31 -
  const v: number = txParams.v
32 -
  txParams.v = v < 27 ? v + 27 : v
27 +
  txParams.v = toType(txParams.v, TypeOutput.BigInt)
33 28
34 29
  return txParams
35 30
}
@@ -50,7 +45,7 @@
Loading
50 45
51 46
  const transactions: TypedTransaction[] = []
52 47
  const opts = { common: header._common }
53 -
  for (const _txParams of blockParams.transactions) {
48 +
  for (const _txParams of blockParams.transactions ?? []) {
54 49
    const txParams = normalizeTxParams(_txParams)
55 50
    const tx = TransactionFactory.fromTxData(txParams as TxData, opts)
56 51
    transactions.push(tx)
Files Coverage
packages 87.60%
Project Totals (192 files) 87.60%
1
coverage:
2
  status:
3
    project:
4
      default:
5
        target: auto
6
        threshold: 2%
7
    patch:
8
      default:
9
        target: auto
10
        threshold: 5%
11
comment:
12
  layout: 'reach, flags'
13
flags:
14
  rlp:
15
    carryforward: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading