function fixProps(tx, data) {
  // ethereumjs-tx doesn't allow for a `0` value in fields, but we want it to
  // in order to differentiate between a value that isn't set and a value
  // that is set to 0 in a fake transaction.
  // Once https://github.com/ethereumjs/ethereumjs-tx/issues/112 is figured
  // out we can probably remove this fix/hack.
  // We keep track of the original value and return that value when
  // referenced by its property name. This lets us properly encode a `0` as
  // an empty buffer while still being able to differentiate between a `0`
  // and `null`/`undefined`.
  tx._originals = [];
  const fieldNames = ["nonce", "gasPrice", "gasLimit", "value"];
  fieldNames.forEach((fieldName) => configZeroableField(tx, fieldName, 32));

  // Ethereumjs-tx doesn't set the _chainId value whenever the v value is set,
  // which causes transaction signing to fail on transactions that include a
  // chain id in the v value (like ethers.js does).
  // Whenever the v value changes we need to make sure the chainId is also set.
  const vDescriptors = Object.getOwnPropertyDescriptor(tx, "v");
  // eslint-disable-next-line accessor-pairs
  Object.defineProperty(tx, "v", {
    set: (v) => {
      vDescriptors.set.call(tx, v);
      // calculate chainId from signature
      const sigV = ethUtil.bufferToInt(tx.v);
      let chainId = Math.floor((sigV - 35) / 2);
      if (chainId < 0) {
        chainId = 0;
      }
      tx._chainId = chainId || 0;
    }
  });

  if (tx.isFake()) {
    /**
     * @prop {Buffer} from (read/write) Set from address to bypass transaction
     * signing on fake transactions.
     */
    Object.defineProperty(tx, "from", {
      enumerable: true,
      configurable: true,
      get: tx.getSenderAddress.bind(tx),
      set: (val) => {
        if (val) {
          tx._from = ethUtil.toBuffer(val);
        } else {
          tx._from = null;
        }
      }
    });

    if (data && data.from) {
      tx.from = data.from;
    }

    tx.hash = fakeHash;
  }
}
function fixProps(tx, data) {
  // ethereumjs-tx doesn't allow for a `0` value in fields, but we want it to
  // in order to differentiate between a value that isn't set and a value
  // that is set to 0 in a fake transaction.
  // Once https://github.com/ethereumjs/ethereumjs-tx/issues/112 is figured
  // out we can probably remove this fix/hack.
  // We keep track of the original value and return that value when
  // referenced by its property name. This lets us properly encode a `0` as
  // an empty buffer while still being able to differentiate between a `0`
  // and `null`/`undefined`.
  tx._originals = [];
  const fieldNames = ["nonce", "gasPrice", "gasLimit", "value"];
  fieldNames.forEach((fieldName) => configZeroableField(tx, fieldName, 32));

  // Ethereumjs-tx doesn't set the _chainId value whenever the v value is set,
  // which causes transaction signing to fail on transactions that include a
  // chain id in the v value (like ethers.js does).
  // Whenever the v value changes we need to make sure the chainId is also set.
  const vDescriptors = Object.getOwnPropertyDescriptor(tx, "v");
  // eslint-disable-next-line accessor-pairs
  Object.defineProperty(tx, "v", {
    set: (v) => {
      vDescriptors.set.call(tx, v);
      // calculate chainId from signature
      const sigV = ethUtil.bufferToInt(tx.v);
      let chainId = Math.floor((sigV - 35) / 2);
      if (chainId < 0) {
        chainId = 0;
      }
      tx._chainId = chainId || 0;
    }
  });

  if (tx.isFake()) {
    /**
     * @prop {Buffer} from (read/write) Set from address to bypass transaction
     * signing on fake transactions.
     */
    Object.defineProperty(tx, "from", {
      enumerable: true,
      configurable: true,
      get: tx.getSenderAddress.bind(tx),
      set: (val) => {
        if (val) {
          tx._from = ethUtil.toBuffer(val);
        } else {
          tx._from = null;
        }
      }
    });

    if (data && data.from) {
      tx.from = data.from;
    }

    tx.hash = fakeHash;
  }
}
function fixProps ( tx , data ) { // ethereumjs-tx doesn't allow for a `0` value in fields, but we want it to // in order to differentiate between a value that isn't set and a value // that is set to 0 in a fake transaction. // Once https://github.com/ethereumjs/ethereumjs-tx/issues/112 is figured // out we can probably remove this fix/hack. // We keep track of the original value and return that value when // referenced by its property name. This lets us properly encode a `0` as // an empty buffer while still being able to differentiate between a `0` // and `null`/`undefined`. tx . _originals = [ ] ; const fieldNames = [ "nonce" , "gasPrice" , "gasLimit" , "value" ] ; fieldNames . forEach ( ( fieldName ) => configZeroableField ( tx , fieldName , 32 ) ) ; // Ethereumjs-tx doesn't set the _chainId value whenever the v value is set, // which causes transaction signing to fail on transactions that include a // chain id in the v value (like ethers.js does). // Whenever the v value changes we need to make sure the chainId is also set. const vDescriptors = Object . getOwnPropertyDescriptor ( tx , "v" ) ; // eslint-disable-next-line accessor-pairs Object . defineProperty ( tx , "v" , { set : ( v ) => { vDescriptors . set . call ( tx , v ) ; // calculate chainId from signature const sigV = ethUtil . bufferToInt ( tx . v ) ; let chainId = Math . floor ( ( sigV - 35 ) / 2 ) ; if ( chainId < 0 ) { chainId = 0 ; } tx . _chainId = chainId || 0 ; } } ) ; if ( tx . isFake ( ) ) { /**
     * @prop {Buffer} from (read/write) Set from address to bypass transaction
     * signing on fake transactions.
     */ Object . defineProperty ( tx , "from" , { enumerable : true , configurable : true , get : tx . getSenderAddress . bind ( tx ) , set : ( val ) => { if ( val ) { tx . _from = ethUtil . toBuffer ( val ) ; } else { tx . _from = null ; } } } ) ; if ( data && data . from ) { tx . from = data . from ; } tx . hash = fakeHash ; } }
etheruemjs-tx's Transactions don't behave quite like we need them to, so
we're monkey-patching them to do what we want here.
@param {Transaction} tx The Transaction to fix
@param {Object} [data] The data object
etheruemjs - tx s Transactions don t behave quite like we need them to so we re monkey - patching them to do what we want here .