grpc_bchrpc 0.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

BCHD gRPC Client for Dart and Flutter #

This package provides a gRPC client for connecting directly to a BCHD full node.

Usage #

import "package:grpc_bchrpc/grpc_bchrpc.dart";
final client = GrpcClient();
const txid = "11556da6ee3cb1d14727b3a8f4b37093b6fecd2bc7d577a02b4e98b7be58a7e8";
final res = await client.getRawTransaction(hash: hex.decode(txid), reversedHashOrder: true);
expect(res.transaction.length, 441);
client.close();

Test #

$ dart test/client.spec.dart

Regenerate the stubs #

If you want to regenerate the corresponding Dart files for protos/bchrpc.proto, you will need to have protoc version 3.0.0 or higher and the Dart protoc plugin version 0.7.9 or higher on your PATH.

To install protoc, see the instructions on the Protocol Buffers website.

The easiest way to get the Dart protoc plugin is by running

$ pub global activate protoc_plugin

and follow the directions to add ~/.pub-cache/bin to your PATH, if you haven't already done so.

You can now regenerate the Dart files by running

$ protoc --dart_out=grpc:lib/src/generated -Iprotos protos/bchrpc.proto

0.0.4 #

* Update getAddressTransactions call signature

0.0.3 #

* Moved required parameters out of destructured/named part of method calls
* More linting

0.0.2 #

* Linting

0.0.1 #

* Init commit

example/main.dart

import "package:grpc_bchrpc/grpc_bchrpc.dart";
import 'package:convert/convert.dart';

main() async {
  final client = GrpcClient();
  const txid = "11556da6ee3cb1d14727b3a8f4b37093b6fecd2bc7d577a02b4e98b7be58a7e8";
  final res = await client.getRawTransaction(hex.decode(txid), reversedHashOrder: true);
  print(hex.encode(res.transaction));
  client.close();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  grpc_bchrpc: ^0.0.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:grpc_bchrpc/grpc_bchrpc.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
9
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Analysis suggestions

Package not compatible with runtime flutter-web on web

Because:

  • package:grpc_bchrpc/grpc_bchrpc.dart that imports:
  • package:grpc_bchrpc/src/client.dart that imports:
  • package:grpc/grpc.dart that imports:
  • package:grpc/src/shared/streams.dart that imports:
  • package:http2/transport.dart that imports:
  • package:http2/src/hpack/hpack.dart that imports:
  • package:http2/src/hpack/huffman_table.dart that imports:
  • package:http2/src/hpack/huffman.dart that imports:
  • dart:io

Package not compatible with runtime js

Because:

  • package:grpc_bchrpc/grpc_bchrpc.dart that imports:
  • package:grpc_bchrpc/src/client.dart that imports:
  • package:grpc/grpc.dart that imports:
  • package:grpc/src/shared/streams.dart that imports:
  • package:http2/transport.dart that imports:
  • package:http2/src/hpack/hpack.dart that imports:
  • package:http2/src/hpack/huffman_table.dart that imports:
  • package:http2/src/hpack/huffman.dart that imports:
  • dart:io

Health suggestions

Fix lib/src/client.dart. (-0.50 points)

Analysis of lib/src/client.dart reported 1 hint:

line 100 col 36: Use isNotEmpty for Iterables and Maps.

Format lib/src/generated/bchrpc.pb.dart.

Run dartfmt to format lib/src/generated/bchrpc.pb.dart.

Format lib/src/generated/bchrpc.pbenum.dart.

Run dartfmt to format lib/src/generated/bchrpc.pbenum.dart.

Format lib/src/generated/bchrpc.pbjson.dart.

Run dartfmt to format lib/src/generated/bchrpc.pbjson.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
fixnum ^0.10.11 0.10.11
grpc ^2.1.3 2.2.0
protobuf ^1.0.1 1.0.1
Transitive dependencies
async 2.4.2
charcode 1.1.3
collection 1.14.13 1.15.0-nnbd
crypto 2.1.5
googleapis_auth 0.2.12
http 0.12.1
http2 1.0.0
http_parser 3.1.4
meta 1.2.1
path 1.7.0
pedantic 1.9.1
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0 1.3.0-nnbd
Dev dependencies
convert ^2.1.1 2.1.1
test ^1.14.2