TransactionReceipt.fromJson constructor

TransactionReceipt.fromJson(
  1. Map<String, dynamic> map
)

Implementation

factory TransactionReceipt.fromJson(Map<String, dynamic> map) {
  _validateFields(map);

  final data = map['data'] != null
      ? const Latin1Converter().fromJson(map['data'] as String)
      : null;

  // ignore: unnecessary_null_comparison
  if (!isValidMetadata(data)) {
    throw ArgumentError('Invalid data: ${data?.show}');
  }

  return TransactionReceipt(
      from: (map['from'] as List)
          .map((i) => Sender.fromJson(i as List))
          .toList(),
      to: decodeTo(map['to'] as List),
      fee: PolyAmount.fromUnitAndValue(
          PolyUnit.nanopoly, map['fee'] as String),
      timestamp: map['timestamp'] as int,
      propositionType: PropositionType(
          map['propositionType'] as String,
          propositionMap[map['propositionType'] as String] ??
              PropositionType.curve25519().propositionPrefix),
      id: ModifierId.create(
          Base58Data.validated(map['txId'] as String).value),
      txType: map['txType'] as String,
      messageToSign:
          Uint8List.fromList(map['messageToSign'] as List<int>? ?? []),
      data: data,
      newBoxes: decodeBoxes(map['newBoxes'] as List<dynamic>),
      boxesToRemove: (map['boxesToRemove'] as List)
          .map((boxId) => const BoxIdConverter().fromJson(boxId as String))
          .toList(),
      signatures: decodeSignatures(map['signatures'] as Map<String, dynamic>),
      blockId: map.containsKey('blockId')
          ? ModifierId.create(
              Base58Data.validated(map['blockId'] as String).value)
          : null,
      blockNumber: map['blockNumber'] != null
          ? BlockNum.exact(map['blockNumber'] as int)
          : const BlockNum.pending(),
      minting: map['minting'] != null ? map['minting'] as bool : null);
}