async deserialize(valueEncoded, typeName) {
          const valueBuffer =
            typeof valueEncoded === "string"
              ? utils_1.decodeBase64(valueEncoded)
              : valueEncoded;
          const protobufType =
            this.defaultType || this.root.lookupType(typeName);
          const message = protobufType.decode(valueBuffer);
          const object = protobufType.toObject(message, { longs: String });
          if (!this.bytesConversion) return object;
          // TODO: format from Buffer to base58/base64 for nested fields
          Object.keys(protobufType.fields).forEach((fieldName) => {
            const { options, name, type } = protobufType.fields[fieldName];
            // No byte conversion
            if (type !== "bytes") return;
            // Default byte conversion
            if (!options || !options[OP_BYTES]) {
              object[name] = utils_1.encodeBase64(object[name]);
              return;
            }
            // Specific byte conversion
            switch (options[OP_BYTES]) {
              case "BASE58":
              case "CONTRACT_ID":
              case "ADDRESS":
                object[name] = utils_1.encodeBase58(object[name]);
                break;
              case "BASE64":
                object[name] = utils_1.encodeBase64(object[name]);
                break;
              case "HEX":
              case "BLOCK_ID":
              case "TRANSACTION_ID":
                object[name] = `0x${utils_1.toHexString(object[name])}`;
                break;
              default:
                throw new Error(
                  `unknown koinos_byte_type ${options[OP_BYTES]}`
                );
            }
          });
          return object;
        }
/**
         * Function to decode bytes using the protobuffer definitions
         * It also encodes the bytes for special cases (base58, hex string)
         * when bytesConversion param is true.
         */
Function to decode bytes using the protobuffer definitions
It also encodes the bytes for special cases (base58, hex string)
when bytesConversion param is true.
Function to decode bytes using the protobuffer definitions It also encodes the bytes for special cases ( base58 hex string ) when bytesConversion param is true .
async deserialize(valueEncoded, typeName) {
          const valueBuffer =
            typeof valueEncoded === "string"
              ? utils_1.decodeBase64(valueEncoded)
              : valueEncoded;
          const protobufType =
            this.defaultType || this.root.lookupType(typeName);
          const message = protobufType.decode(valueBuffer);
          const object = protobufType.toObject(message, { longs: String });
          if (!this.bytesConversion) return object;
          Object.keys(protobufType.fields).forEach((fieldName) => {
            const { options, name, type } = protobufType.fields[fieldName];
            if (type !== "bytes") return;
            if (!options || !options[OP_BYTES]) {
              object[name] = utils_1.encodeBase64(object[name]);
              return;
            }
            switch (options[OP_BYTES]) {
              case "BASE58":
              case "CONTRACT_ID":
              case "ADDRESS":
                object[name] = utils_1.encodeBase58(object[name]);
                break;
              case "BASE64":
                object[name] = utils_1.encodeBase64(object[name]);
                break;
              case "HEX":
              case "BLOCK_ID":
              case "TRANSACTION_ID":
                object[name] = `0x${utils_1.toHexString(object[name])}`;
                break;
              default:
                throw new Error(
                  `unknown koinos_byte_type ${options[OP_BYTES]}`
                );
            }
          });
          return object;
        }
async deserialize ( valueEncoded , typeName ) { const valueBuffer = typeof valueEncoded === "string" ? utils_1 . decodeBase64 ( valueEncoded ) : valueEncoded ; const protobufType = this . defaultType || this . root . lookupType ( typeName ) ; const message = protobufType . decode ( valueBuffer ) ; const object = protobufType . toObject ( message , { longs : String } ) ; if ( ! this . bytesConversion ) return object ; Object . keys ( protobufType . fields ) . forEach ( ( fieldName ) => { const { options , name , type } = protobufType . fields [ fieldName ] ; if ( type !== "bytes" ) return ; if ( ! options || ! options [ OP_BYTES ] ) { object [ name ] = utils_1 . encodeBase64 ( object [ name ] ) ; return ; } switch ( options [ OP_BYTES ] ) { case "BASE58" : case "CONTRACT_ID" : case "ADDRESS" : object [ name ] = utils_1 . encodeBase58 ( object [ name ] ) ; break ; case "BASE64" : object [ name ] = utils_1 . encodeBase64 ( object [ name ] ) ; break ; case "HEX" : case "BLOCK_ID" : case "TRANSACTION_ID" : object [ name ] = ` ${ utils_1 . toHexString ( object [ name ] ) } ` ; break ; default : throw new Error ( ` ${ options [ OP_BYTES ] } ` ) ; } } ) ; return object ; }
Function to decode bytes using the protobuffer definitions
 It also encodes the bytes for special cases (base58, hex string)
 when bytesConversion param is true.
Function to decode bytes using the protobuffer definitions It also encodes the bytes for special cases ( base58 hex string ) when bytesConversion param is true .
// TODO: format from Buffer to base58/base64 for nested fields // No byte conversion // Default byte conversion // Specific byte conversion