transactions.ts 944 Bytes
Newer Older
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
import { constants, ethers } from 'ethers'

export interface Transaction {
  timestamp: number
  blockNumber: number
  l1QueueOrigin: number
  l1TxOrigin: string
  entrypoint: string
  gasLimit: number
  data: string
}

export const DUMMY_OVM_TRANSACTIONS: Array<Transaction> = [
  ...Array(10).keys(),
].map((i) => {
  return {
    timestamp: i,
    blockNumber: 0,
    l1QueueOrigin: 0,
    l1TxOrigin: constants.AddressZero,
    entrypoint: constants.AddressZero,
    gasLimit: 0,
    data: ethers.constants.HashZero,
  }
})

export const hashTransaction = ({
  timestamp,
  blockNumber,
  l1QueueOrigin,
  l1TxOrigin,
  entrypoint,
  gasLimit,
  data,
}: Transaction): string => {
  return ethers.utils.solidityKeccak256(
    ['uint256', 'uint256', 'uint8', 'address', 'address', 'uint256', 'bytes'],
    [
      timestamp,
      blockNumber,
      l1QueueOrigin,
      l1TxOrigin,
      entrypoint,
      gasLimit,
      data,
    ]
  )
}