alan-sdk / alan.dart

@@ -1,24 +1,28 @@
Loading
1 -
import 'package:alan/alan.dart';
2 -
import 'package:http/http.dart' as http;
1 +
import 'package:alan/proto/cosmos/base/tendermint/v1beta1/export.dart'
2 +
    as tendermint;
3 +
import 'package:alan/proto/tendermint/p2p/types.pb.dart';
4 +
import 'package:grpc/grpc.dart' as grpc;
3 5
4 6
/// Allows to query a full node for its information.
5 -
class NodeQuerier extends QueryHelper {
6 -
  NodeQuerier._({
7 -
    required http.Client httpClient,
8 -
  }) : super(httpClient: httpClient);
7 +
class NodeQuerier {
8 +
  final tendermint.ServiceClient _client;
9 9
10 -
  factory NodeQuerier.build(http.Client httpClient) {
11 -
    return NodeQuerier._(httpClient: httpClient);
10 +
  NodeQuerier({required tendermint.ServiceClient client}) : _client = client;
11 +
12 +
  /// Builds a new [NodeQuerier] given a [ClientChannel].
13 +
  factory NodeQuerier.build(grpc.ClientChannel channel) {
14 +
    return NodeQuerier(client: tendermint.ServiceClient(channel));
12 15
  }
13 16
14 17
  /// Queries the node info of the chain based on the given [lcdEndpoint].
15 -
  Future<NodeInfo> getNodeInfo(String lcdEndpoint) async {
16 -
    final result = await queryChain('$lcdEndpoint/node_info');
17 -
    if (!result.isSuccessful) {
18 -
      throw Exception(result.error);
18 +
  Future<DefaultNodeInfo> getNodeInfo() async {
19 +
    final request = tendermint.GetNodeInfoRequest();
20 +
21 +
    final response = await _client.getNodeInfo(request);
22 +
    if (!response.hasDefaultNodeInfo()) {
23 +
      throw Exception('Invalid node info response');
19 24
    }
20 25
21 -
    final value = result.value as Map<String, dynamic>;
22 -
    return NodeInfoResponse.fromJson(value).nodeInfo;
26 +
    return response.defaultNodeInfo;
23 27
  }
24 28
}

@@ -25,7 +25,7 @@
Loading
25 25
  ) {
26 26
    return TxSigner(
27 27
      authQuerier: AuthQuerier.build(clientChannel),
28 -
      nodeQuerier: NodeQuerier.build(httpClient),
28 +
      nodeQuerier: NodeQuerier.build(clientChannel),
29 29
    );
30 30
  }
31 31
@@ -64,9 +64,7 @@
Loading
64 64
    }
65 65
66 66
    // Get the node info data
67 -
    final nodeInfo = await _nodeQuerier.getNodeInfo(
68 -
      wallet.networkInfo.restEndpoint,
69 -
    );
67 +
    final nodeInfo = await _nodeQuerier.getNodeInfo();
70 68
71 69
    // Get the public key from the account, or generate it if the
72 70
    // chain does not have it yet
Files Coverage
lib 76.39%
Project Totals (26 files) 76.39%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading