Skip to content

Commit

Permalink
clean up dashcore-lib in general (#75)
Browse files Browse the repository at this point in the history
* clean: remove unused old files

* clean: replace jshintignore

* clean: fix license

* clean: fix permissions on govobject.js (0644)

* clean: update jsdoc file for dashcore

* clean: update dependency versions

* docs: clean up examples

* docs: update README with std-readme format

* docs: update contributing

* clean: replace bitpay w/dcg as this module author
  • Loading branch information
nmarley authored and KamuelaFranco committed Nov 25, 2018
1 parent 0169119 commit 3faae98
Show file tree
Hide file tree
Showing 15 changed files with 2,989 additions and 6,194 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml

This file was deleted.

1 change: 1 addition & 0 deletions .eslintignore
@@ -0,0 +1 @@
./dist/*
4 changes: 2 additions & 2 deletions .jsdoc.conf
Expand Up @@ -23,8 +23,8 @@
"lenient": true
},
"templates": {
"systemName": "bitcore",
"copyright": "© 2013-2015, BitPay Inc.",
"systemName": "dashcore",
"copyright": "2017-2018 Dash Core Group, Inc.",
"navType": "vertical",
"theme": "journal",
"linenums": true,
Expand Down
5 changes: 0 additions & 5 deletions .jshintignore

This file was deleted.

45 changes: 0 additions & 45 deletions .jshintrc

This file was deleted.

12 changes: 0 additions & 12 deletions .zuul.yml

This file was deleted.

41 changes: 19 additions & 22 deletions CONTRIBUTING.md
@@ -1,26 +1,24 @@
Contributing to Bitcore
=======
# Contributing to dashcore-lib

We're working hard to make *bitcore* the most powerful JavaScript library for working with bitcoin. Our goal is to have *bitcore* be a library that can be used by anyone interested in bitcoin, and to level expertise differences with great design and documentation.
We're working hard to make *dashcore-lib* the most powerful JavaScript library for working with Dash. Our goal is to have *dashcore-lib* be a library that can be used by anyone interested in Dash, and to level expertise differences with great design and documentation.

## Community

If there are any questions, etc., please feel to ask in one of the community channels:

- https://labs.bitpay.com/c/bitcore (Support Forum)
- https://gitter.im/bitpay/bitcore (Development Chat)
- https://www.dash.org/forum (Support Forum)

## Quick Checklist

Ideally, please make sure to run:

* `gulp test` passes all the tests (We run tests against Node.js v0.10, v0.12, io.js, and modern browsers)
* `gulp coverage` covers 100% of the branches of your code (See `coverage/lcov-report/index.html` for details)
* `gulp lint` doesn't complain about your changes
* `npm run test` passes all the tests (We run tests against Node.js v6, v8, v10 and modern browsers)
* `npm run coverage` covers 100% of the branches of your code (See `coverage/lcov-report/index.html` for details)
* `npm run lint` doesn't complain about your changes

## Design Guidelines

These are some global design goals in bitcore that any change must adhere.
These are some global design goals in dashcore-lib that any change must adhere.

### D1 - Naming Matters

Expand Down Expand Up @@ -91,7 +89,7 @@ var bufferUtil = require('./util/buffer');

#### G7 - Standard Methods

When possible, bitcore objects should have standard methods on an instance prototype:
When possible, dashcore-lib objects should have standard methods on an instance prototype:
* `toObject/toJSON` - A plain JavaScript object that `JSON.stringify` can call
* `toString` - A string representation of the instance
* `toBuffer` - A hex Buffer
Expand All @@ -101,7 +99,7 @@ These should have a matching static method that can be used for instantiation:
* `fromString` - Should be able to instantiate with output from `toString`
* `fromBuffer` - Should likewise be able to instantiate from output from `toBuffer`

`JSON.stringify` and `JSON.parse` are expected to be handled outside of the scope of Bitcore methods. For example, calling `JSON.stringify` on an Bitcore object will behave as expected and call `transaction.toJSON()` and then stringify it:
`JSON.stringify` and `JSON.parse` are expected to be handled outside of the scope of dashcore-lib methods. For example, calling `JSON.stringify` on an dashcore-lib object will behave as expected and call `transaction.toJSON()` and then stringify it:

```javascript
var transactionString = JSON.stringify(transaction);
Expand All @@ -116,12 +114,11 @@ var tx = new Transaction(data);

### Errors

#### E1 - Use bitcore.Errors
#### E1 - Use dashcore.Errors

We've designed a structure for Errors to follow and are slowly migrating to it.

Usage:
* Errors are generated in the file `lib/errors/index.js` by invoking `gulp errors`.
* The specification for errors is written in the `lib/errors/spec.js` file.
* Whenever a new class is created, add a generic error for that class in `lib/errors/spec.js`.
* Specific errors for that class should subclass that error. Take a look at the structure in `lib/errors/spec.js`, it should be clear how subclasses are generated from that file.
Expand Down Expand Up @@ -206,14 +203,14 @@ Don't write long tests, write helper functions to make them be as short and conc

Inputs for tests should not be generated randomly. Also, the type and structure of outputs should be checked.

#### T3 - Require 'bitcore' and Look up Classes from There
#### T3 - Require 'dashcore' and Look up Classes from There

This helps to make tests more useful as examples, and more independent of where they are placed. This also helps prevent forgetting to include all submodules in the bitcore object.
This helps to make tests more useful as examples, and more independent of where they are placed. This also helps prevent forgetting to include all submodules in the dashcore object.

DO:
```javascript
var bitcore = require('../');
var PublicKey = bitcore.PublicKey;
var dashcore = require('../');
var PublicKey = dashcore.PublicKey;
```
DON'T:
```javascript
Expand Down Expand Up @@ -246,8 +243,8 @@ git checkout -b remove/some-file

We expect pull requests to be rebased to the master branch before merging:
```sh
git remote add bitpay git@github.com:bitpay/bitcore.git
git pull --rebase bitpay master
git remote add dashevo git@github.com:dashevo/dashcore-lib.git
git pull --rebase dashevo master
```

Note that we require rebasing your branch instead of merging it, for commit readability reasons.
Expand All @@ -258,11 +255,11 @@ git push origin your_branch_name
git push origin feature/some-new-stuff
git push origin fix/some-bug
```
Finally go to [github.com/bitpay/bitcore](https://github.com/bitpay/bitcore) in your web browser and issue a new pull request.
Finally go to [github.com/dashevo/dashcore-lib](https://github.com/dashevo/dashcore-lib) in your web browser and issue a new pull request.

Main contributors will review your code and possibly ask for changes before your code is pulled in to the main repository. We'll check that all tests pass, review the coding style, and check for general code correctness. If everything is OK, we'll merge your pull request and your code will be part of bitcore.
Main contributors will review your code and possibly ask for changes before your code is pulled in to the main repository. We'll check that all tests pass, review the coding style, and check for general code correctness. If everything is OK, we'll merge your pull request and your code will be part of dashcore-lib.

If you have any questions feel free to post them to
[github.com/bitpay/bitcore/issues](https://github.com/bitpay/bitcore/issues).
[github.com/dashevo/dashcore-lib/issues](https://github.com/dashevo/dashcore-lib/issues).

Thanks for your time and code!
3 changes: 3 additions & 0 deletions LICENSE
@@ -1,3 +1,6 @@
MIT License

Copyright (c) 2017-2018 Dash Core Group, Inc.
Copyright (c) 2013-2017 BitPay, Inc.

Parts of this software are based on Bitcoin Core
Expand Down
128 changes: 66 additions & 62 deletions README.md
@@ -1,18 +1,23 @@
Dashcore Library
================
# Dashcore Library

[![NPM Package](https://img.shields.io/npm/v/@dashevo/dashcore-lib.svg?style=flat-square)](https://www.npmjs.org/package/@dashevo/dashcore-lib)
[![Build Status](https://img.shields.io/travis/dashevo/dashcore-lib.svg?branch=master&style=flat-square)](https://travis-ci.org/dashevo/dashcore-lib)
[![Coverage Status](https://img.shields.io/coveralls/dashevo/dashcore-lib.svg?style=flat-square)](https://coveralls.io/github/dashevo/dashcore-lib?branch=master)
[![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)

A pure and powerful JavaScript Dash library.

## Principles
> 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.

## Get Started
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [License](#license)

## Install

### NodeJS

```
npm install @dashevo/dashcore-lib
```
Expand All @@ -21,8 +26,58 @@ npm install @dashevo/dashcore-lib

See the section below to generate your own bundle, or download the pre-generated [minified file](dist/dashcore-lib.min.js)

#### Building the Browser Bundle

To build a dashcore-lib full bundle for the browser:

```sh
npm run build
```

This will generate files named `dashcore-lib.js` and `dashcore-lib.min.js` in the `dist/` folder.

## Usage

### Browser

```
<script src='./dist/dashcore-lib.min.js' type="text/javascript"></script>
<script>
const PrivateKey = dashcore.PrivateKey;
const privateKey = new PrivateKey();
const address = privateKey.toAddress().toString();
</script>
```

### Modules

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)

### Development & Tests

```sh
git clone https://github.com/dashevo/dashcore-lib
cd dashcore-lib
npm install
```

Run all the tests:

```sh
npm test
```

You can also run just the Node.js tests with `npm run test:node`, just the browser tests with `npm run test:browser` or run a test coverage report with `npm run coverage`.

## Docs
## Documentation

* [Addresses](docs/address.md)
* [Block](docs/block.md)
Expand All @@ -39,11 +94,10 @@ See the section below to generate your own bundle, or download the pre-generated
* [URI](docs/uri.md)
* [Governance Object / Proposal](docs/govobject/govobject.md)

## Examples
### Examples

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)
* [Import an address via WIF](docs/examples.md#import-an-address-via-wif)
Expand All @@ -54,60 +108,10 @@ Some examples can be found [here](docs/examples.md), below is a list of direct l
* [Create a 2-of-3 multisig P2SH address](docs/examples.md#create-a-2-of-3-multisig-p2sh-address)
* [Spend from a 2-of-2 multisig P2SH address](docs/examples.md#spend-from-a-2-of-2-multisig-p2sh-address)

## Modules

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)

## Contributing

Please send pull requests for bug fixes, code optimization, and ideas for improvement. For more information on how to contribute, please refer to our [CONTRIBUTING](https://github.com/dashevo/dashcore-lib/blob/master/CONTRIBUTING.md) file.

## Building the Browser Bundle

To build a dashcore-lib full bundle for the browser:

```sh
npm run build
```

This will generate files named `dashcore-lib.js` and `dashcore-lib.min.js` in the `dist/` folder.

## Usage on Browser

```
<script src='./dist/dashcore-lib.min.js' type="text/javascript"></script>
<script>
const PrivateKey = dashcore.PrivateKey;
const privateKey = new PrivateKey();
const address = privateKey.toAddress().toString();
</script>
```

## Development & Tests

```sh
git clone https://github.com/dashevo/dashcore-lib
cd dashcore-lib
npm install
```

Run all the tests:

```sh
npm test
```

You can also run just the Node.js tests with `npm run test:node`, just the browser tests with `npm run test:browser`
or run a test coverage report with `npm run coverage`.

## License

Code released under [the MIT license](LICENSE).
Expand Down
31 changes: 0 additions & 31 deletions bower.json

This file was deleted.

0 comments on commit 3faae98

Please sign in to comment.