Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Code correction for code examples in address.md #169

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Dashcore Library

[![Build Status](https://img.shields.io/travis/dashevo/dashcore-lib.svg?branch=master)](https://travis-ci.org/dashevo/dashcore-lib)
[![NPM Package](https://img.shields.io/npm/v/@dashevo/dashcore-lib.svg)](https://www.npmjs.org/package/@dashevo/dashcore-lib)
[![NPM Version](https://img.shields.io/npm/v/@dashevo/dashcore-lib)](https://www.npmjs.com/package/@dashevo/dashcore-lib)
[![Build Status](https://img.shields.io/travis/com/dashevo/dashcore-lib)](https://travis-ci.org/dashevo/dashcore-lib)
[![Release Date](https://img.shields.io/github/release-date/dashevo/dashcore-lib)](https://github.com/dashevo/dashcore-lib/releases/latest)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen)](https://github.com/RichardLitt/standard-readme)

> A pure and powerful JavaScript Dash library.
A pure and powerful JavaScript Dash library.

Dash is a powerful new peer-to-peer platform for the next generation of financial technology. The decentralized nature of the Dash network allows for highly resilient Dash infrastructure, and the developer community needs reliable, open-source tools to implement Dash apps and services.

Expand Down Expand Up @@ -56,7 +58,6 @@ Some functionality is implemented as a module that can be installed separately:
* [Payment Protocol Support](https://github.com/dashevo/dashcore-payment-protocol)
* [Peer to Peer Networking](https://github.com/dashevo/dashcore-p2p)
* [Dash Core JSON-RPC](https://github.com/dashevo/dashd-rpc)
* [Payment Channels](https://github.com/dashevo/dashcore-channel)
* [Mnemonics](https://github.com/dashevo/dashcore-mnemonic)
* [Elliptical Curve Integrated Encryption Scheme](https://github.com/dashevo/bitcore-ecies-dash)
* [Signed Messages](https://github.com/dashevo/bitcore-message-dash)
Expand Down Expand Up @@ -100,7 +101,7 @@ You can also run just the Node.js tests with `npm run test:node`, just the brows
Some examples can be found [here](docs/examples.md), below is a list of direct links for some of them.

* [Generate a random address](docs/examples.md#generate-a-random-address)
* [Generate an address from a SHA256 hash](docs/examples.md#generate-a-address-from-a-sha256-hash)
* [Generate an address from a SHA256 hash](docs/examples.md#generate-an-address-from-a-sha256-hash)
* [Import an address via WIF](docs/examples.md#import-an-address-via-wif)
* [Create a Transaction](docs/examples.md#create-a-transaction)
* [Sign a Dash message](docs/examples.md#sign-a-bitcoin-message)
Expand All @@ -119,4 +120,4 @@ Code released under [the MIT license](LICENSE).

Copyright 2013-2017 BitPay, Inc. Bitcore is a trademark maintained by BitPay, Inc.
Copyright 2016-2017 The Dash Foundation, Inc.
Copyright 2017-2018 Dash Core Group, Inc.
Copyright 2017-2020 Dash Core Group, Inc.
6 changes: 3 additions & 3 deletions docs/address.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ The code to do these validations looks like this:

```javascript
// validate an address
if (Address.isValid(input){
if (Address.isValid(input)) {
...
}

// validate that an input field is a valid testnet address
if (Address.isValid(input, Networks.testnet){
if (Address.isValid(input, Networks.testnet)) {
...
}

// validate that an input field is a valid livenet pubkeyhash
if (Address.isValid(input, Networks.livenet, Address.PayToPublicKeyHash){
if (Address.isValid(input, Networks.livenet, Address.PayToPublicKeyHash)) {
...
}

Expand Down
7 changes: 5 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// TODO: Remove previous line and work through linting issues at next edit

'use strict';
var path = require('path')

var src = './index.js',
tests = './test.spec.js';
Expand All @@ -11,7 +10,8 @@ var karmaConfig = {
frameworks: ['mocha', 'chai'],
files: [
src,
tests
tests,
{ pattern: 'node_modules/bls-signatures/blsjs.wasm', included: false }
],
preprocessors: {},
webpack: {
Expand Down Expand Up @@ -46,6 +46,9 @@ var karmaConfig = {
flags: ['-headless'],
},
},
proxies: {
'/base/blsjs.wasm': `/base/node_modules/bls-signatures/blsjs.wasm`,
}
};
karmaConfig.preprocessors[src] = ['webpack'];
karmaConfig.preprocessors[tests] = ['webpack'];
Expand Down
42 changes: 42 additions & 0 deletions lib/crypto/bls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-disable */
// TODO: Remove previous line and work through linting issues at next edit

'use strict';

var EventEmitter = require('events');
var BlsSignatures = require('bls-signatures');

var bls = {
isLoading: false,
instance: null,
events: new EventEmitter(),
LOADED: 'LOADED',
load() {
this.isLoading = true;
return BlsSignatures()
.then((instance) => {
this.instance = instance;
this.isLoading = false;
this.events.emit(this.LOADED);
});
},
getInstance() {
return new Promise((resolve) => {
if (this.instance) {
resolve(this.instance);
}

if (this.isLoading) {
this.events.once(this.LOADED, () => {
resolve(this.instance);
});
} else {
this.load().then(() => {
resolve(this.instance);
});
}
});
}
};

module.exports = bls;
Loading