revert-flags.ts 507 Bytes
Newer Older
Kelvin Fichter's avatar
Kelvin Fichter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
import { ethers } from '@nomiclabs/buidler'

export const encodeRevertData = (
  flag: number,
  data: string = '0x',
  nuisanceGasLeft: number = 0,
  ovmGasRefund: number = 0
): string => {
  return ethers.utils.defaultAbiCoder.encode(
    ['uint256','uint256','uint256','bytes'],
    [flag, nuisanceGasLeft, ovmGasRefund, data]
  )
}

export const REVERT_FLAGS = {
  DID_NOT_REVERT: 0,
  OUT_OF_GAS: 1,
  INTENTIONAL_REVERT: 2,
  EXCEEDS_NUISANCE_GAS: 3,
  INVALID_STATE_ACCESS: 4,
  UNSAFE_BYTECODE: 5
}