CostModel.deserialize constructor

CostModel.deserialize(
  1. CborObject cbor
)

Deserializes a CostModel instance from CBOR object.

Implementation

factory CostModel.deserialize(CborObject cbor) {
  if (cbor is CborBytesValue) {
    final viewDecoding = CborObject.fromCbor(cbor.value)
        .cast<CborListValue<CborObject>>(
            "Invalid CostModel view encoding cbor bytes.");
    return CostModel(viewDecoding.value.map((e) => e.getInteger()).toList());
  }
  return CostModel(cbor
      .cast<CborListValue<CborObject>>()
      .value
      .map((e) => e.getInteger())
      .toList());
}