pascaldart 0.1.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

This is BETA software, use at your own risk

A PascalCoin library written in Dart, ported based on the sbx JavaScript library for PascalCoin.

PointyCastle APIs are used for ecdsa, sha256/512, hmac, etc.

Features #

  • 'pascaldart/common.dart' - Basic models for PascalCoin objects such as PrivateKey, PublicKey, AccountName, AccountNumber, etc. Also several "Coder" objects which encode and decode these objects to byte arrays.
  • 'pascaldart/crypto.dart' - PascalCoin cryptography. Generate keys, sign messages, encrypt/decrypt private keys (PrivateKeyCrypt), and encrypt/decrypt payloads (EciesCrypt)
  • 'pascaldart/signing.dart' - PascalCoin signing. Includes operation models (such as TransactionOperation), encodes and decodes operations to raw format, and can sign operations using a PrivateKey
  • 'pascaldart/json_rpc.dart' - An implementation of PascalCoin's json-rpc API.

If you want to import everything, import pascaldart/pascaldart.dart

TODO #

  • Support multi-operation
  • Add parser for walletkeys.dat (from desktop wallet)
  • Support Extended PASA (EPASA)
  • Support more json-rpc methods
  • Support sect283k1 curve
  • More tests (particularly for operation digests)

Issues and contributing #

Contributions are welcome and encouraged. Simply fork this repository, make changes, and create a pull request.

For issues, create an issue on GitHub

0.1.6 #

  • Add another special PascalAccount field for blaise

0.1.5 #

  • Add special PascalAccount field for Blaise
  • Update LICENSE

0.1.4 #

  • Fix handling negative Currency values

0.1.3 #

  • Fix changeaccountinfo, listforsale, changekey, and changekeysigned operations

0.1.1 (ALPHA) #

  • Update homepage to point to github

0.1.0 (ALPHA) #

  • Provide example
  • Re-format pub.dev suggestions

0.0.1 (ALPHA) #

  • Initial Release
  • This software is not yet production-ready, use at your own risk.

example/pascaldart_example.dart

import 'dart:typed_data';

import 'package:pascaldart/pascaldart.dart';

main() async {
  // Generating a keypair
  KeyPair kp = Keys.generate(curve: Curve.getDefaultCurve());
  // RPC client
  RPCClient rpc = RPCClient(rpcAddress: 'http://127.0.0.1:4003');
  // Creating transaction operation and signing it
  TransactionOperation op = TransactionOperation(
      sender: AccountNumber.fromInt(1234),
      target: AccountNumber.fromInt(1000),
      amount: Currency('10'))
    ..withNOperation(2)
    ..withPayload(PDUtil.stringToBytesUtf8('Hello Payload'))
    ..withFee(Currency('0'))
    ..sign(kp.privateKey);
  // Executing operation
  Uint8List encodedRawOp = RawOperationCoder.encodeToBytes(op);
  ExecuteOperationsRequest request =
      ExecuteOperationsRequest(rawOperations: PDUtil.byteToHex(encodedRawOp));
  RPCResponse rawResp = await rpc.makeRpcRequest(request);
  if (rawResp.isError) {
    // Handling an error
    ErrorResponse errResp = rawResp;
    print(errResp.errorMessage);
  } else {
    OperationsResponse opResp = rawResp;
    opResp.operations.forEach((op) {
      print(op.amount.toStringOpt());
    });
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  pascaldart: ^0.1.6

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:pascaldart/pascaldart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
81
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
88
Learn more about scoring.

We analyzed this package on Dec 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.1+4

Health suggestions

Fix lib/src/common/pascaldart_util.dart. (-0.50 points)

Analysis of lib/src/common/pascaldart_util.dart reported 1 hint:

line 100 col 21: Unnecessary new keyword.

Fix lib/src/signing/operations/buyaccount_operation.dart. (-0.50 points)

Analysis of lib/src/signing/operations/buyaccount_operation.dart reported 1 hint:

line 75 col 9: The value of the local variable 'fixedType' isn't used.

Fix lib/src/signing/operations/changeaccountinfo_operation.dart. (-0.50 points)

Analysis of lib/src/signing/operations/changeaccountinfo_operation.dart reported 1 hint:

line 90 col 9: The value of the local variable 'changeType' isn't used.

Fix additional 5 files with analysis or formatting issues. (-1.50 points)

Additional issues in the following files:

  • lib/src/signing/operations/delist_forsale_operation.dart (1 hint)
  • lib/src/signing/operations/list_forsale_operation.dart (1 hint)
  • lib/src/signing/rawop_coder.dart (1 hint)
  • lib/src/crypto/model/signature.dart (Run dartfmt to format lib/src/crypto/model/signature.dart.)
  • lib/src/json_rpc/model/request/getaccountoperations_request.dart (Run dartfmt to format lib/src/json_rpc/model/request/getaccountoperations_request.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (json_annotation).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
collection ^1.14.11 1.14.12
hex ^0.1.2 0.1.2
http ^0.12.0+2 0.12.0+2
json_annotation ^2.4.0 2.4.0 3.0.0
meta ^1.1.6 1.1.8
pointycastle ^1.0.1 1.0.2
quiver ^2.0.2 2.1.2+1
Transitive dependencies
async 2.4.0
charcode 1.1.2
http_parser 3.1.3
matcher 0.12.6
path 1.6.4
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
build_runner ^1.4.0
json_serializable ^3.0.0
pedantic ^1.0.0 1.9.0
test ^1.0.0