BlockInformation.fromJson constructor

BlockInformation.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory BlockInformation.fromJson(Map<String, dynamic> json) {
  return BlockInformation(
    baseFeePerEnergy:
        json.containsKey('baseFeePerEnergy')
            ? XCBAmount.fromUnitAndValue(
              XCBUnit.ore,
              hexToInt(json['baseFeePerEnergy'] as String),
            )
            : null,
    transactions:
        json.containsKey('transactions')
            ? (json["transactions"] as List<dynamic>)
                .map(
                  (e) => TransactionInformation.fromMap(
                    e as Map<String, dynamic>,
                  ),
                )
                .toList()
            : [],

    timestamp: DateTime.fromMillisecondsSinceEpoch(
      hexToDartInt(json['timestamp'] as String) * 1000,
      isUtc: true,
    ),
  );
}