TransactionWitnessSet.deserialize constructor

TransactionWitnessSet.deserialize(
  1. CborMapValue cbor
)

Implementation

factory TransactionWitnessSet.deserialize(CborMapValue cbor) {
  final v1 = cbor
      .getValueFromIntKey<CborListValue?>(3)
      ?.castTo<List<PlutusScript>, CborListValue<CborObject>>((e) {
    return e.value.map((i) => PlutusScript.deserialize(i.cast())).toList();
  });
  final v2 = cbor
      .getValueFromIntKey<CborListValue?>(6)
      ?.castTo<List<PlutusScript>, CborListValue<CborObject>>((e) => e.value
          .map((i) =>
              PlutusScript.deserialize(i.cast(), language: Language.plutusV2))
          .toList());
  return TransactionWitnessSet(
      vKeys: cbor
          .getValueFromIntKey<CborListValue?>(0)
          ?.value
          .map((e) => Vkeywitness.deserialize(e))
          .toList(),
      nativeScripts: cbor.getValueFromIntKey<CborListValue?>(1)?.castTo<List<NativeScript>, CborListValue<CborObject>>((e) =>
          e.value.map((e) => NativeScript.deserialize(e.cast())).toList()),
      bootstraps: cbor
          .getValueFromIntKey<CborListValue?>(2)
          ?.castTo<List<BootstrapWitness>, CborListValue<CborObject>>((e) => e.value
              .map((e) => BootstrapWitness.deserialize(e.cast()))
              .toList()),
      plutusScripts:
          v1 == null && v2 == null ? null : [...v1 ?? [], ...v2 ?? []],
      plutusData: cbor.getValueFromIntKey<CborListValue?>(4)?.castTo<PlutusList, CborListValue>(
          (e) => PlutusList.deserialize(e)),
      redeemers: cbor
          .getValueFromIntKey<CborListValue?>(5)
          ?.castTo<List<Redeemer>, CborListValue<CborObject>>(
              (e) => e.value.map((i) => Redeemer.deserialize(i.cast())).toList()));
}