ADAByronAddrPayload.deserialize constructor

ADAByronAddrPayload.deserialize(
  1. List<int> serPayloadBytes
)

Implementation

factory ADAByronAddrPayload.deserialize(List<int> serPayloadBytes) {
  final addrPayload = CborObject.fromCbor(serPayloadBytes);
  if (addrPayload is! CborListValue || addrPayload.value.length != 3) {
    throw const AddressConverterException("Invalid address payload");
  }
  if (addrPayload.value[0] is! CborBytesValue ||
      addrPayload.value[1] is! CborMapValue ||
      addrPayload.value[2] is! CborIntValue) {
    throw const AddressConverterException("Invalid address payload");
  }
  final cborBytes = addrPayload.value[0] as CborBytesValue;
  // Check key hash length
  AddrDecUtils.validateBytesLength(
      cborBytes.value, QuickCrypto.blake2b224DigestSize);

  return ADAByronAddrPayload(
    rootHashBytes: cborBytes.value,
    attrs: ADAByronAddrAttrs.fromCbor(addrPayload.value[1]),
    type: ADAByronAddrTypes.fromCbor(addrPayload.value[2]),
  );
}