getBlockchainVersion method

Future<BlockchainVersionModel> getBlockchainVersion()

Query the network to find the protocol, transaction and code versions

Implementation

Future<BlockchainVersionModel> getBlockchainVersion() async {
  const methodName = 'getBlockchainVersion';
  return withRetry(
    actionName: methodName,
    action: () async {
      const body = 'query { version {code protocol transaction} }';

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

      manageLinkException(result);

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