laksadart 0.1.18

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 66

Laksa, Dart Version #

Waiting for Usage example and docs

Porting from Laksa and ZilliqaJS #

  • Account

    • [x] create
    • [x] toFile
    • [x] fromFile
    • [x] signTransaction
  • Wallet

    • [x] add
    • [x] remove
    • [x] getAccount
    • [x] encryptAccount
    • [x] decryptAccount
    • [x] setDefaultAccount
    • [x] getDefaultAccount
  • crypto

    • [x] getDerivedKey ((keystore))
    • [x] encrypt(keystore)
    • [x] decrypt(keystore)
    • [x] sign(Schnorr function)
    • [x] verify(Schnorr function)
    • [x] SchnorrSign(Schnorr function with protobuf encodation)
    • [x] generatePrivateKey
    • [x] getPublicKeyFromPrivateKey
    • [x] getPublicKeyFromPrivateKey
    • [x] getAddressFromPublicKey
    • [x] getAddressFromPrivateKey
    • [x] hmac-drbg(HMAC update digest)
    • [x] getDRBG(inner function)
    • [x] generateNewPrivateKey(inner function)
    • [x] privateKeyToPublic(inner function)
    • [x] getPublic(inner function)
  • Messenger

    • [x] send
    • [x] sendServer(Scilla runner)
    • [x] setNodeProvider
    • [x] setScillaProvider
    • [x] setMiddleware
    • [x] useMiddleware
  • Blockchain(RPC methods)

    • [x] getBalance
    • [x] getBlockchainInfo
    • [x] getDSBlock
    • [x] getTxBlock
    • [x] getLatestDSBlock
    • [x] getNumDSBlocks
    • [x] getDSBlockRate
    • [x] getDSBlockListing
    • [x] getLatestTxBlock
    • [x] getNumTxBlocks
    • [x] getTxBlockRate
    • [x] getTxBlockListing
    • [x] getNumTransactions
    • [x] getTransactionRate
    • [x] getCurrentMiniEpoch
    • [x] getCurrentDSEpoch
    • [x] getPrevDifficulty
    • [x] getPrevDSDifficulty
    • [x] getRecentTransactions
    • [x] getNumTxnsTxEpoch
    • [x] getNumTxnsDSEpoch
    • [x] getMinimumGasPrice
    • [x] createTransaction
    • [x] checkCode(Scilla runner)
    • [x] testCall(Scilla runner)
  • Provider

    • BaseProvider
    • HttpProvider
      • [x] buildPayload
      • [x] buildEndpointPayload
      • [x] performRPC
      • [x] send
      • [x] sendServer(Scilla runner)
    • RPCMiddleware
      • [x] RPCResponseBody
      • [x] SuccessMiddleware
      • [x] ErrorMiddleware
    • RPCMehod
    • Endpoint
  • Transaction

    • [x] Factory
    • [x] sendTransaction
    • [x] trackTx
    • [x] confirm
    • [x] getVersion(calculate version number)
  • Contract

    • [x] Factory
    • [x] deploy
    • [x] call
    • [x] confirmTx
    • [x] sendContract
    • [x] signTxn
    • [x] getState
    • [x] setInitParamsValues
    • [x] setDeployPayload
    • [x] setCallPayload
  • utils

    • [x] numbers.strip0x
    • [x] numbers.toHex
    • [x] numbers.bytesToHex
    • [x] numbers.numberToBytes
    • [x] numbers.hexToBytes
    • [x] numbers.intToBytes
    • [x] numbers.hexToInt
    • [x] validators.isUrl
    • [x] validators.isByteString
    • [x] validators.isAddres
    • [x] validators.isPublicKey
    • [x] validators.isPrivateKey
    • [x] validators.isSignature
    • [x] unit.fromQa
    • [x] unit.toQa
    • [x] encodeTransactionProto

Thanks to #

  • Zilliqa, who make the js lib originally.
  • PointyCastle, who make the dart crypto packages.
  • Web3Dart, who make the web3 dart version.

Change Log #

Feb-20-2019 #

  • added isolates to account.encryptAccount/decryptAccount
  • replace angel_validate to validators

Jan-19-2019 #

  • dartfmt the proto package
  • edit testScilla.dart, eliminate the == type warning
  • update description
  • move example.dart to example folder

Jan-18-2019 #

initial added to pub

example/example.dart

import 'dart:convert';
import 'dart:io';
import 'package:laksadart/src/utils/unit.dart' as unit;
import 'package:laksadart/laksadart.dart';

main() async {
  var laksa = new Laksa(
      nodeUrl: 'https://dev-api.zilliqa.com', // 'https://api.zilliqa.com',
      scillaUrl: 'https://scilla-runner.zilliqa.com',
      networkID: 'DevNet');

  var acc = laksa.wallet
      .add('e19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930');

  void autoTransaction() async {
    await acc.encryptAccount('111');
    await acc.updateBalance();
    var nonce = acc.nonce;
    var txn = laksa.transactions.newTx({
      'toAddr': '2E3C9B415B19AE4035503A06192A0FAD76E04243',
      'amount': unit.Unit.Li(nonce + 1).qa,
      'gasPrice': unit.Unit.Li(1000).qa,
      'gasLimit': 1,
      'version':
          laksa.messenger.setTransactionVersion(1, laksa.messenger.Network_ID)
    });

    var signed = await acc.signTransaction(txn, passphrase: '111');
    print(json.encode(signed.toPayload));
    var sent = await signed.sendTransaction();
    print(sent.transaction.TranID);
    var sendTime = DateTime.now();
    var result = await sent.transaction.confirm(
        txHash: sent.transaction.TranID, maxAttempts: 33, interval: 1000);
    print(result.receipt['success']);
    if (result != null) {
      var during = DateTime.now().difference(sendTime);
      print('confirmed during:$during');
    }
  }

  void deploy() async {
    File contract = new File('test/contracts/helloworldversion.txt');
    await contract.readAsString().then((contractString) async {
      Laksa laksa = new Laksa(
          nodeUrl:
              'https://dev-api.zilliqa.com', //'https://staging-api.aws.z7a.xyz'
          scillaUrl: 'https://scilla-runner.zilliqa.com',
          networkID: 'DevNet');
      var init = [
        {
          'vname': '_scilla_version',
          'type': 'Uint32',
          'value': '0',
        },
        {
          'value': '0x9bfec715a6bd658fcb62b0f8cc9bfa2ade71434a',
          'vname': 'owner',
          'type': 'ByStr20'
        }
      ];

      laksa.wallet.add(
          'e19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930');

      var newContract = laksa.contracts
          .newContract(code: contractString, init: init, version: 0);
      newContract.setDeployPayload(
          gasLimit: 10000, gasPrice: BigInt.from(1000000000), toDS: true);
      var sent = await newContract.sendContract();
      print(sent.transaction.toPayload);
      var sendTime = DateTime.now();
      print('sent contract at:$sendTime');
      print(sent.transaction.TranID);
      var deployed = await sent.confirmTx(maxAttempts: 33, interval: 1000);
      print(deployed.ContractAddress);
      if (deployed != null) {
        var during = DateTime.now().difference(sendTime);
        print('deployed confirmed during:$during');
      }

      // test call contract

      deployed.setCallPayload(
          transition: 'setHello',
          params: [
            {'vname': "msg", 'type': "String", 'value': "Test World"}
          ],
          gasLimit: 8000,
          gasPrice: unit.Unit.Li(1000).qa,
          amount: unit.Unit.Qa(0).qa,
          toDS: true);
      var sentCall = await deployed.sendContract();
      print(sentCall.transaction.toPayload);
      var calledTime = DateTime.now();
      print('sent called time:$calledTime');
      print(sentCall.transaction.TranID);

      await sentCall.confirmTx(maxAttempts: 33, interval: 1000);
      print(sentCall.ContractAddress);
      if (sentCall != null) {
        var during2 = DateTime.now().difference(calledTime);
        print('called confirmed during:$during2');
      }
      var state = await sentCall.getState();
      print("The state of the contract is:$state");
    });
  }

  void wallet() async {
    Laksa laksa = new Laksa(
        nodeUrl:
            'https://dev-api.zilliqa.com', //'https://staging-api.aws.z7a.xyz'
        scillaUrl: 'https://scilla-runner.zilliqa.com',
        networkID: 'DevNet');
    var newAcc = laksa.wallet.create();
    await newAcc.encryptAccount('passphrase');
    print(newAcc);
    // await newAcc.updateBalance();
    // print(newAcc.balance);
  }

  // await wallet();
  await autoTransaction();
  // await deploy();
}

Use this package as a library

1. Depend on it

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


dependencies:
  laksadart: ^0.1.18

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:laksadart/laksadart.dart';
  
Version Uploaded Documentation Archive
0.1.18 Mar 7, 2019 Go to the documentation of laksadart 0.1.18 Download laksadart 0.1.18 archive
0.1.17 Mar 7, 2019 Go to the documentation of laksadart 0.1.17 Download laksadart 0.1.17 archive
0.1.16 Mar 6, 2019 Go to the documentation of laksadart 0.1.16 Download laksadart 0.1.16 archive
0.1.15 Mar 4, 2019 Go to the documentation of laksadart 0.1.15 Download laksadart 0.1.15 archive
0.1.14 Mar 1, 2019 Go to the documentation of laksadart 0.1.14 Download laksadart 0.1.14 archive
0.1.13 Feb 27, 2019 Go to the documentation of laksadart 0.1.13 Download laksadart 0.1.13 archive
0.1.12 Feb 27, 2019 Go to the documentation of laksadart 0.1.12 Download laksadart 0.1.12 archive
0.1.11 Feb 23, 2019 Go to the documentation of laksadart 0.1.11 Download laksadart 0.1.11 archive
0.1.10 Feb 23, 2019 Go to the documentation of laksadart 0.1.10 Download laksadart 0.1.10 archive
0.1.9 Feb 21, 2019 Go to the documentation of laksadart 0.1.9 Download laksadart 0.1.9 archive

All 25 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

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

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, other

Primary library: package:laksadart/laksadart.dart with components: isolate.

Health suggestions

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

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

line 208 col 3: Prefer using /// for doc comments.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <3.0.0
bip32 ^1.0.5 1.0.5
bip39 ^1.0.3 1.0.3
collection ^1.14.11 1.14.11
convert ^2.1.1 2.1.1
crypto ^2.0.6 2.0.6
fixnum ^0.10.9 0.10.9
http ^0.12.0 0.12.0+2
json_serializable ^2.0.1 2.2.2
meta ^1.1.6 1.1.7
pointycastle ^1.0.0-rc4 1.0.1
protobuf ^0.10.5 0.10.8 0.13.11
tuple ^1.0.2 1.0.2
uuid ^1.0.3 1.0.3 2.0.1
validators ^1.0.0+1 1.0.0+1 2.0.0+1
Transitive dependencies
analyzer 0.36.2
args 1.5.1
async 2.2.0
boolean_selector 1.0.4
bs58check 1.0.1
build 1.1.3
build_config 0.4.0
charcode 1.1.2
csslib 0.16.0
dart_style 1.2.7
front_end 0.1.17
glob 1.1.7
hex 0.1.2
html 0.14.0+2
http_multi_server 2.0.5
http_parser 3.1.3
io 0.3.3
js 0.6.1+1
json_annotation 2.2.0
json_rpc_2 2.1.0
kernel 0.3.17
logging 0.11.3+2
matcher 0.12.5
mime 0.9.6+2
multi_server_socket 1.0.2
node_preamble 1.4.4
package_config 1.0.5
package_resolver 1.0.10
path 1.6.2
pedantic 1.5.0
pool 1.4.0
pub_semver 1.4.2
pubspec_parse 0.1.4
quiver 2.0.3
shelf 0.7.5
shelf_packages_handler 1.0.4
shelf_static 0.2.8
shelf_web_socket 0.2.3
source_gen 0.9.4+2
source_map_stack_trace 1.1.5
source_maps 0.10.8
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.4
term_glyph 1.1.0
test_api 0.2.5
test_core 0.2.4
typed_data 1.1.6
vm_service_client 0.2.6+1
watcher 0.9.7+10
web_socket_channel 1.0.12
yaml 2.1.15
Dev dependencies
test ^1.3.2 1.6.2