urbit_ob 1.0.0

  • Readme
  • Changelog
  • Installing
  • 47

urbit-ob, but in Dart #

This is urbit-ob but in dart, and only implementing the functions I care about:

  • String ob.patp(BigInt)
  • BigInt ob.patp2dec(String)
  • String ob.patq(List<int>)
  • List<int> ob.patq2buf(String)
  • Clan clan(BigInt)

Features #

  • works
  • works in VM & JS runtimes
  • test suite that matches urbit-ob

Example #

import 'package:urbit_ob/urbit_ob.dart' as ob;

final point = BigInt.from(19268096);
final data = BigInt.from(2884880786);
final name = "~bosnyt-raddux";

// patp
assert(ob.patp(point) == name);
assert(ob.patp2dec(name) == point);

// patq
assert(ob.patq(encodeBigInt(data)) == name);
assert(ob.patq2buf(name) == encodeBigInt(data));

Missing #

idk how to encode strings that match BN.js's encoding, so string patqs won't be compatible between dart and js until that works

for example, if you encode 'hello world' as a utf8 byte list in dart, you'll get

utf8.encode('hello world');
// -> [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]

but when you encode a string as a byte array using BN.js you get

new BN('hello world').toArray()
// -> [ 4, 86, 168, 105, 235 ]

it seems like this encoding is done here in BN.js and i've tried to port it over in test/cases.dart but it's confusing to me.

Tests #

look they work in the vm!

pub run test

whoa, they work in chrome!

puh run test -p chrome

1.0.0 #

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

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


dependencies:
  urbit_ob: ^1.0.0

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

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

  • Dart: 2.6.1
  • pana: 0.13.1+4

Health suggestions

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

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

line 10 col 14: The declaration '_log' isn't referenced.

Format lib/src/helpers.dart.

Run dartfmt to format lib/src/helpers.dart.

Format lib/src/muk.dart.

Run dartfmt to format lib/src/muk.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and urbit_ob.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
logging ^0.11.3 0.11.3+2
pointycastle ^1.0.1 1.0.2
quiver >=2.0.0 <3.0.0 2.1.2+1
Transitive dependencies
matcher 0.12.6
meta 1.1.8
path 1.6.4
stack_trace 1.9.3
Dev dependencies
pedantic ^1.8.0
test ^1.6.0