AuxiliaryData.deserialize constructor
AuxiliaryData.deserialize(
- CborObject cbor
Implementation
factory AuxiliaryData.deserialize(CborObject cbor) {
TransactionMetadataUtils.validateAuxiliaryDataCbor(cbor);
if (cbor is CborMapValue) {
return AuxiliaryData(
metadata: GeneralTransactionMetadata.deserialize(cbor));
} else if (cbor is CborListValue) {
return AuxiliaryData(
metadata: cbor
.getIndex<CborObject?>(0)
?.castTo<GeneralTransactionMetadata, CborMapValue>(
(e) => GeneralTransactionMetadata.deserialize(e)),
nativeScripts: cbor
.getIndex<CborObject?>(1)
?.castTo<List<NativeScript>, CborListValue>((e) =>
e.value.map((i) => NativeScript.deserialize(i)).toList()),
);
} else {
cbor as CborTagValue;
final CborMapValue cobrList = cbor.getValue();
return AuxiliaryData(
preferAlonzoFormat: true,
metadata: cobrList
.getValueFromIntKey<CborObject?>(0)
?.castTo<GeneralTransactionMetadata, CborMapValue>(
(e) => GeneralTransactionMetadata.deserialize(e)),
nativeScripts: cobrList
.getValueFromIntKey<CborObject?>(1)
?.castTo<List<NativeScript>, CborListValue>((e) =>
e.value.map((i) => NativeScript.deserialize(i)).toList()),
plutusScripts: cobrList
.getValueFromIntKey<CborObject?>(2)
?.castTo<List<PlutusScript>, CborListValue>((e) {
final v1 = e.value.map((i) => PlutusScript.deserialize(i)).toList();
final v2 = cobrList
.getValueFromIntKey<CborObject?>(3)
?.castTo<List<PlutusScript>, CborListValue>((e) {
return e.value
.map((i) =>
PlutusScript.deserialize(i, language: Language.plutusV2))
.toList();
});
return [...v1, ...v2 ?? <PlutusScript>[]];
}));
}
}