Extended publishing of libraries to npm (#3786)
* Extended publishing of libraries to npm * Update source links * Add some tests before publishing NPM library * Fix Shapeshift tests
This commit is contained in:
34
js/npm/etherscan/README.md
Normal file
34
js/npm/etherscan/README.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# @parity/Etherscan
|
||||
|
||||
A thin, lightweight promise wrapper for the api.etherscan.io/apis service, exposing a common endpoint for use in JavaScript applications.
|
||||
|
||||
[https://github.com/ethcore/parity/tree/master/js/src/3rdparty/etherscan](https://github.com/ethcore/parity/tree/master/js/src/3rdparty/etherscan)
|
||||
|
||||
## usage
|
||||
|
||||
installation -
|
||||
|
||||
```
|
||||
npm install --save @parity/Etherscan
|
||||
```
|
||||
|
||||
Usage -
|
||||
|
||||
```
|
||||
const etherscan = require('@parity/Etherscan');
|
||||
|
||||
// api calls goes here
|
||||
```
|
||||
|
||||
## api
|
||||
|
||||
account (exposed on etherscan.account) -
|
||||
|
||||
- `balance(address)`
|
||||
- `balances(addresses)` (array or addresses)
|
||||
- `transactions(address, page)` (page offset starts at 0, returns 25)
|
||||
|
||||
stats (exposed on etherscan.stats) -
|
||||
|
||||
- `price()`
|
||||
- `supply()`
|
||||
33
js/npm/etherscan/package.json
Normal file
33
js/npm/etherscan/package.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@parity/Etherscan",
|
||||
"description": "The Parity Promise-based library for interfacing with Etherscan over HTTP",
|
||||
"version": "0.0.0",
|
||||
"main": "library.js",
|
||||
"author": "Parity Team <admin@parity.io>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff"
|
||||
],
|
||||
"contributors": [],
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ethcore/parity.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Ethereum",
|
||||
"ABI",
|
||||
"API",
|
||||
"RPC",
|
||||
"Parity",
|
||||
"Promise"
|
||||
],
|
||||
"scripts": {
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "3.5.0",
|
||||
"mocha": "3.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": "~1.6.3"
|
||||
}
|
||||
}
|
||||
83
js/npm/parity/README.md
Normal file
83
js/npm/parity/README.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# @parity/parity.js
|
||||
|
||||
Parity.js is a thin, fast, Promise-based wrapper around the Ethereum APIs.
|
||||
|
||||
[https://github.com/ethcore/parity/tree/master/js/src/api](https://github.com/ethcore/parity/tree/master/js/src/api)
|
||||
|
||||
## installation
|
||||
|
||||
Install the package with `npm install --save @parity/parity.js`
|
||||
|
||||
## usage
|
||||
|
||||
### initialisation
|
||||
|
||||
```javascript
|
||||
// import the actual Api class
|
||||
import { Api } from '@parity/parity.js';
|
||||
|
||||
// do the setup
|
||||
const transport = new Api.Transport.Http('http://localhost:8545');
|
||||
const api = new Api(transport);
|
||||
```
|
||||
|
||||
### making calls
|
||||
|
||||
perform a call
|
||||
|
||||
```javascript
|
||||
api.eth
|
||||
.coinbase()
|
||||
.then((coinbase) => {
|
||||
console.log(`The coinbase is ${coinbase}`);
|
||||
});
|
||||
```
|
||||
|
||||
multiple promises
|
||||
|
||||
```javascript
|
||||
Promise
|
||||
.all([
|
||||
api.eth.coinbase(),
|
||||
api.net.listening()
|
||||
])
|
||||
.then(([coinbase, listening]) => {
|
||||
// do stuff here
|
||||
});
|
||||
```
|
||||
|
||||
chaining promises
|
||||
|
||||
```javascript
|
||||
api.eth
|
||||
.newFilter({...})
|
||||
.then((filterId) => api.eth.getFilterChanges(filterId))
|
||||
.then((changes) => {
|
||||
console.log(changes);
|
||||
});
|
||||
```
|
||||
|
||||
### contracts
|
||||
|
||||
attach contract
|
||||
|
||||
```javascript
|
||||
const abi = [{ name: 'callMe', inputs: [{ type: 'bool', ...}, { type: 'string', ...}]}, ...abi...];
|
||||
const address = '0x123456...9abc';
|
||||
const contract = new api.newContract(abi, address);
|
||||
```
|
||||
|
||||
find & call a function
|
||||
|
||||
```javascript
|
||||
contract.instance
|
||||
.callMe
|
||||
.call({ gas: 21000 }, [true, 'someString']) // or estimateGas or postTransaction
|
||||
.then((result) => {
|
||||
console.log(`the result was ${result}`);
|
||||
});
|
||||
```
|
||||
|
||||
## apis
|
||||
|
||||
APIs implement the calls as exposed in the [Ethcore JSON Ethereum RPC](https://github.com/ethcore/ethereum-rpc-json/) definitions. Mapping follows the naming conventions of the originals, i.e. `eth_call` becomes `eth.call`, `personal_accounts` becomes `personal.accounts`, etc.
|
||||
33
js/npm/parity/package.json
Normal file
33
js/npm/parity/package.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@parity/parity.js",
|
||||
"description": "The Parity Promise-based API & ABI library for interfacing with Ethereum over RPC",
|
||||
"version": "0.0.0",
|
||||
"main": "library.js",
|
||||
"author": "Parity Team <admin@parity.io>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff"
|
||||
],
|
||||
"contributors": [],
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ethcore/parity.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Ethereum",
|
||||
"ABI",
|
||||
"API",
|
||||
"RPC",
|
||||
"Parity",
|
||||
"Promise"
|
||||
],
|
||||
"scripts": {
|
||||
},
|
||||
"devDependencies": {
|
||||
},
|
||||
"dependencies": {
|
||||
"bignumber.js": "~2.3.0",
|
||||
"js-sha3": "~0.5.2",
|
||||
"node-fetch": "~1.6.3"
|
||||
}
|
||||
}
|
||||
26
js/npm/parity/test/smoke.spec.js
Normal file
26
js/npm/parity/test/smoke.spec.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
const parity = require('../');
|
||||
|
||||
describe('load the Parity library', function () {
|
||||
it('should no throw any error', () => {
|
||||
expect(parity).to.be.ok;
|
||||
|
||||
expect(parity.Api).to.be.ok;
|
||||
expect(parity.Abi).to.be.ok;
|
||||
});
|
||||
});
|
||||
34
js/npm/shapeshift/README.md
Normal file
34
js/npm/shapeshift/README.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# @parity/ShapeShift
|
||||
|
||||
A thin ES6 promise wrapper around the shapeshift.io APIs as documented at https://shapeshift.io/api
|
||||
|
||||
[https://github.com/ethcore/parity/tree/master/js/src/3rdparty/shapeshift](https://github.com/ethcore/parity/tree/master/js/src/3rdparty/shapeshift)
|
||||
|
||||
## usage
|
||||
|
||||
installation -
|
||||
|
||||
```
|
||||
npm install --save @parity/ShapeShift
|
||||
```
|
||||
|
||||
Usage -
|
||||
|
||||
```
|
||||
const APIKEY = 'private affiliate key or undefined';
|
||||
const shapeshift = require('@parity/ShapeShift')(APIKEY);
|
||||
|
||||
// api calls goes here
|
||||
```
|
||||
|
||||
## api
|
||||
|
||||
queries -
|
||||
|
||||
- `getCoins()` [https://shapeshift.io/api#api-104](https://shapeshift.io/api#api-104)
|
||||
- `getMarketInfo(pair)` [https://shapeshift.io/api#api-103](https://shapeshift.io/api#api-103)
|
||||
- `getStatus(depositAddress)` [https://shapeshift.io/api#api-5](https://shapeshift.io/api#api-5)
|
||||
|
||||
transactions -
|
||||
|
||||
- `shift(toAddress, returnAddress, pair)` [https://shapeshift.io/api#api-7](https://shapeshift.io/api#api-7)
|
||||
31
js/npm/shapeshift/package.json
Normal file
31
js/npm/shapeshift/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@parity/ShapeShift",
|
||||
"description": "The Parity Promise-based library for interfacing with ShapeShift over HTTP",
|
||||
"version": "0.0.0",
|
||||
"main": "library.js",
|
||||
"author": "Parity Team <admin@parity.io>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff"
|
||||
],
|
||||
"contributors": [],
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ethcore/parity.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Ethereum",
|
||||
"ABI",
|
||||
"API",
|
||||
"RPC",
|
||||
"Parity",
|
||||
"Promise"
|
||||
],
|
||||
"scripts": {
|
||||
},
|
||||
"devDependencies": {
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": "~1.6.3"
|
||||
}
|
||||
}
|
||||
29
js/npm/test/mocha.config.js
Normal file
29
js/npm/test/mocha.config.js
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
const chai = require('chai');
|
||||
// const chaiAsPromised from 'chai-as-promised';
|
||||
// const chaiEnzyme from 'chai-enzyme';
|
||||
// const sinonChai from 'sinon-chai';
|
||||
|
||||
// chai.use(chaiAsPromised);
|
||||
// chai.use(chaiEnzyme());
|
||||
// chai.use(sinonChai);
|
||||
|
||||
// expose expect to global so we won't have to manually import & define it in every test
|
||||
global.expect = chai.expect;
|
||||
|
||||
module.exports = {};
|
||||
1
js/npm/test/mocha.opts
Normal file
1
js/npm/test/mocha.opts
Normal file
@@ -0,0 +1 @@
|
||||
-r ./test/mocha.config
|
||||
Reference in New Issue
Block a user