getCurrentSystemState method

Future<SystemState> getCurrentSystemState()

Implementation

Future<SystemState> getCurrentSystemState() async {
  final response = await _client.ledgerService.getEpoch(
    GetEpochRequest(
      readMask: FieldMask(
        paths: ['epoch', 'reference_gas_price', 'system_state', 'start', 'end'],
      ),
    ),
  );

  final epoch = response.epoch;
  return SystemState(
    epoch: epoch.epoch.toString(),
    referenceGasPrice: epoch.referenceGasPrice.toString(),
    systemState: epoch.hasSystemState() ? epoch.systemState.writeToJsonMap() : null,
    epochStartTimestampMs: epoch.hasStart() ? epoch.start.seconds.toString() : null,
  );
}