es/tx/builder/index.js
function deserializeField (value, type, prefix) {
  if (!value) return ''
  switch (type) {
    case FIELD_TYPES.int:
      return readInt(value)
    case FIELD_TYPES.id:
      return readId(value)
    case FIELD_TYPES.ids:
      return value.map(readId)
    case FIELD_TYPES.bool:
      return value[0] === 1
    case FIELD_TYPES.binary:
      return encode(value, prefix)
    case FIELD_TYPES.string:
      return value.toString()
    case FIELD_TYPES.pointers:
      return readPointers(value)
    case FIELD_TYPES.rlpBinary:
      return unpackTx(value, true)
    case FIELD_TYPES.rlpBinaries:
      return value.map(v => unpackTx(v, true))
    case FIELD_TYPES.rawBinary:
      return value
    case FIELD_TYPES.hex:
      return value.toString('hex')
    case FIELD_TYPES.offChainUpdates:
      return value.map(v => unpackTx(v, true))
    case FIELD_TYPES.callStack:
      // TODO: fix this
      return [readInt(value)]
    case FIELD_TYPES.mptree:
      return value.map(mpt.deserialize)
    case FIELD_TYPES.callReturnType:
      switch (readInt(value)) {
        case '0': return 'ok'
        case '1': return 'error'
        case '2': return 'revert'
        default: return value
      }
    default:
      return value
  }
}
function deserializeField (value, type, prefix) {
  if (!value) return ''
  switch (type) {
    case FIELD_TYPES.int:
      return readInt(value)
    case FIELD_TYPES.id:
      return readId(value)
    case FIELD_TYPES.ids:
      return value.map(readId)
    case FIELD_TYPES.bool:
      return value[0] === 1
    case FIELD_TYPES.binary:
      return encode(value, prefix)
    case FIELD_TYPES.string:
      return value.toString()
    case FIELD_TYPES.pointers:
      return readPointers(value)
    case FIELD_TYPES.rlpBinary:
      return unpackTx(value, true)
    case FIELD_TYPES.rlpBinaries:
      return value.map(v => unpackTx(v, true))
    case FIELD_TYPES.rawBinary:
      return value
    case FIELD_TYPES.hex:
      return value.toString('hex')
    case FIELD_TYPES.offChainUpdates:
      return value.map(v => unpackTx(v, true))
    case FIELD_TYPES.callStack:
      // TODO: fix this
      return [readInt(value)]
    case FIELD_TYPES.mptree:
      return value.map(mpt.deserialize)
    case FIELD_TYPES.callReturnType:
      switch (readInt(value)) {
        case '0': return 'ok'
        case '1': return 'error'
        case '2': return 'revert'
        default: return value
      }
    default:
      return value
  }
}
function deserializeField ( value , type , prefix ) { if ( ! value ) return '' switch ( type ) { case FIELD_TYPES . int : return readInt ( value ) case FIELD_TYPES . id : return readId ( value ) case FIELD_TYPES . ids : return value . map ( readId ) case FIELD_TYPES . bool : return value [ 0 ] === 1 case FIELD_TYPES . binary : return encode ( value , prefix ) case FIELD_TYPES . string : return value . toString ( ) case FIELD_TYPES . pointers : return readPointers ( value ) case FIELD_TYPES . rlpBinary : return unpackTx ( value , true ) case FIELD_TYPES . rlpBinaries : return value . map ( v => unpackTx ( v , true ) ) case FIELD_TYPES . rawBinary : return value case FIELD_TYPES . hex : return value . toString ( 'hex' ) case FIELD_TYPES . offChainUpdates : return value . map ( v => unpackTx ( v , true ) ) case FIELD_TYPES . callStack : // TODO: fix this return [ readInt ( value ) ] case FIELD_TYPES . mptree : return value . map ( mpt . deserialize ) case FIELD_TYPES . callReturnType : switch ( readInt ( value ) ) { case '0' : return 'ok' case '1' : return 'error' case '2' : return 'revert' default : return value } default : return value } }
SERIALIZE AND DESERIALIZE PART
SERIALIZE AND DESERIALIZE PART