toCbor method
Converts the object to a CBOR object.
Implementation
@override
CborObject toCbor() {
final plutusVersion1 = plutusScripts
?.where((element) => element.language == Language.plutusV1)
.toList() ??
[];
final plutusVersion2 = plutusScripts
?.where((element) => element.language == Language.plutusV2)
.toList() ??
[];
return CborMapValue.fixedLength({
if (vKeys?.isNotEmpty ?? false) ...{
const CborIntValue(0):
CborListValue.fixedLength(vKeys!.map((e) => e.toCbor()).toList())
},
if (nativeScripts?.isNotEmpty ?? false) ...{
const CborIntValue(1): CborListValue.fixedLength(
nativeScripts!.map((e) => e.toCbor()).toList()),
},
if (bootstraps?.isNotEmpty ?? false) ...{
const CborIntValue(2): CborListValue.fixedLength(
bootstraps!.map((e) => e.toCbor()).toList()),
},
if (plutusScripts != null) ...{
const CborIntValue(3): CborListValue.fixedLength(
plutusVersion1.map((e) => e.toCbor()).toList()),
if (plutusVersion2.isNotEmpty)
const CborIntValue(6): CborListValue.fixedLength(
plutusVersion2.map((e) => e.toCbor()).toList()),
},
if (plutusData != null) ...{const CborIntValue(4): plutusData!.toCbor()},
if (redeemers?.isNotEmpty ?? false) ...{
const CborIntValue(5): CborListValue.fixedLength(
redeemers!.map((e) => e.toCbor()).toList()),
},
});
}