getEpochSummary method

Future<EpochSummary> getEpochSummary({
  1. int? epochId,
})

Summary of an epoch (defaults to the current epoch).

Implementation

Future<EpochSummary> getEpochSummary({int? epochId}) async {
  const q = r'''
    query ($id: UInt53) {
      epoch(epochId: $id) {
        epochId
        referenceGasPrice
        totalTransactions
        startTimestamp
        endTimestamp
      }
    }
  ''';
  final data = await transport.query(q, variables: {
    if (epochId != null) 'id': epochId,
  });
  final e = data['epoch'] as Map<String, dynamic>;
  return EpochSummary(
    epochId: (e['epochId'] as num).toInt(),
    referenceGasPrice: BigInt.parse(e['referenceGasPrice'].toString()),
    totalTransactions: (e['totalTransactions'] as num?)?.toInt(),
    startTimestamp: e['startTimestamp'] as String?,
    endTimestamp: e['endTimestamp'] as String?,
  );
}