HeaderBody.deserialize constructor

HeaderBody.deserialize(
  1. CborListValue cbor
)

Implementation

factory HeaderBody.deserialize(CborListValue cbor) {
  final int leaderCertSize =
      cbor.getIndex<CborObject>(6).hasType<CborListValue>() ? 2 : 1;
  final int operationIndex = 5 + leaderCertSize + 2;
  final int protocolVersionIndex = operationIndex + 4;
  return HeaderBody(
      blockBodyHash:
          BlockHash.deserialize(cbor.getIndex(5 + leaderCertSize + 1)),
      slot: cbor.getIndex<CborObject>(1).getInteger(),
      blockBodySize: cbor.getIndex(5 + leaderCertSize),
      blockNumber: cbor.getIndex(0),
      issuerKey: AdaPublicKey.fromBytes(cbor.getIndex(3)),
      leaderCert:
          HeaderLeaderCert.deserialize(cbor.sublist(5, 5 + leaderCertSize)),
      operationalCert: OperationalCert.deserialize(
          cbor.sublist(operationIndex, operationIndex + 4)),
      prevHash: cbor
          .getIndex<CborObject?>(2)
          ?.castTo<BlockHash, CborBytesValue>(
              (e) => BlockHash.deserialize(e)),
      protocolVersion:
          ProtocolVersion.deserialize(cbor.sublist(protocolVersionIndex)),
      vrfvKey: VRFVKey.deserialize(cbor.getIndex(4)));
}