toCbor method

  1. @override
CborObject toCbor()
override

Converts the object to a CBOR object.

Implementation

@override
CborObject toCbor() {
  return CborMapValue.fixedLength({
    0: CborListValue.fixedLength(inputs.map((e) => e.toCbor()).toList()),
    1: CborListValue.fixedLength(outputs.map((e) => e.toCbor()).toList()),
    2: CborUnsignedValue.u64(fee),
    if (ttl != null) ...{const CborIntValue(3): CborUnsignedValue.u64(ttl!)},
    if (certs?.isNotEmpty ?? false) ...{
      const CborIntValue(4):
          CborListValue.fixedLength(certs!.map((e) => e.toCbor()).toList())
    },
    if (withdrawals != null) ...{
      const CborIntValue(5): withdrawals!.toCbor(),
    },
    if (update != null) ...{const CborIntValue(6): update!.toCbor()},
    if (auxiliaryDataHash != null) ...{7: auxiliaryDataHash!.toCbor()},
    if (validityStartInterval != null) ...{
      const CborIntValue(8): CborUnsignedValue.u64(validityStartInterval!)
    },
    if (mint != null) ...{const CborIntValue(9): mint!.toCbor()},
    if (scriptDataHash != null) ...{
      const CborIntValue(11): scriptDataHash!.toCbor()
    },
    if (collateral?.isNotEmpty ?? false) ...{
      const CborIntValue(13): CborListValue.fixedLength(
          collateral!.map((e) => e.toCbor()).toList())
    },
    if (requiredSigners?.isNotEmpty ?? false) ...{
      const CborIntValue(14): CborListValue.fixedLength(
          requiredSigners!.map((e) => e.toCbor()).toList())
    },
    if (network != null) ...{
      const CborIntValue(15): CborIntValue(network!.value),
    },
    if (collateralReturn != null) ...{
      const CborIntValue(16): collateralReturn!.toCbor()
    },
    if (totalCollateral != null) ...{
      const CborIntValue(17): CborUnsignedValue.u64(totalCollateral!),
    },
    if (referenceInputs?.isNotEmpty ?? false) ...{
      const CborIntValue(18): CborListValue.fixedLength(
          referenceInputs!.map((e) => e.toCbor()).toList())
    }
  });
}