DataOptionData.deserialize constructor

DataOptionData.deserialize(
  1. CborListValue cbor
)

Deserializes a DataOptionData object from its CBOR representation.

Implementation

factory DataOptionData.deserialize(CborListValue cbor) {
  TransactionDataOptionType.deserialize(cbor.getIndex(0),
      validate: TransactionDataOptionType.data);
  final CborTagValue cborTag = cbor.getIndex(1);
  if (!BytesUtils.bytesEqual(cborTag.tags, _plutusDataOptionTag)) {
    throw MessageException("Invalid date option tag.",
        details: {"Tag": cborTag.tags, "Excepted": _plutusDataOptionTag});
  }
  final List<int> plutusBytes = cborTag.getValue();
  return DataOptionData(PlutusData.fromCborBytes(plutusBytes));
}