getBlockchainVersion method

Future<BlockchainVersionModel> getBlockchainVersion()

Query the network to find the protocol, transaction and code versions Returns a BlockchainVersionModel with blockchain's versions information

Implementation

Future<BlockchainVersionModel> getBlockchainVersion() async {
  const body = 'query { version {code protocol transaction} }';

  final result = await _client
      .withLogger(
        'getBlockchainVersion',
        logsActivation: logsActivation,
      )
      .query(
        QueryOptions(
          document: gql(body),
          parserFn: (json) => BlockchainVersionModel.fromJson(json),
        ),
      );

  if (result.exception?.linkException != null) {
    throw ArchethicConnectionException(
      result.exception!.linkException.toString(),
    );
  }

  return result.parsedData ??
      const BlockchainVersionModel(
        version: BlockchainVersion(protocol: '', transaction: ''),
      );
}