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:
parent
bfb684a641
commit
36b8e4b6a8
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"
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
# parity.js
|
# @parity/parity.js
|
||||||
|
|
||||||
Parity.js is a thin, fast, Promise-based wrapper around the Ethereum APIs.
|
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
|
## installation
|
||||||
|
|
||||||
Install the package with `npm install --save @parity/parity.js`
|
Install the package with `npm install --save @parity/parity.js`
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@parity/parity.js",
|
"name": "@parity/parity.js",
|
||||||
"description": "The Parity Promise-base API & ABI library for interfacing with Ethereum over RPC",
|
"description": "The Parity Promise-based API & ABI library for interfacing with Ethereum over RPC",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"main": "library.js",
|
"main": "library.js",
|
||||||
"author": "Parity Team <admin@parity.io>",
|
"author": "Parity Team <admin@parity.io>",
|
||||||
@ -26,8 +26,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bignumber.js": "^2.3.0",
|
"bignumber.js": "~2.3.0",
|
||||||
"js-sha3": "^0.5.2",
|
"js-sha3": "~0.5.2",
|
||||||
"node-fetch": "^1.6.3"
|
"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
|
@ -43,7 +43,7 @@
|
|||||||
"test": "NODE_ENV=test mocha 'src/**/*.spec.js'",
|
"test": "NODE_ENV=test mocha 'src/**/*.spec.js'",
|
||||||
"test:coverage": "NODE_ENV=test istanbul cover _mocha -- 'src/**/*.spec.js'",
|
"test:coverage": "NODE_ENV=test istanbul cover _mocha -- 'src/**/*.spec.js'",
|
||||||
"test:e2e": "NODE_ENV=test mocha 'src/**/*.e2e.js'",
|
"test:e2e": "NODE_ENV=test mocha 'src/**/*.e2e.js'",
|
||||||
"test:npm": "(cd .npmjs && npm i) && node test/npmLibrary && (rm -rf .npmjs/node_modules)",
|
"test:npm": "(cd .npmjs && npm i) && node test/npmParity && (rm -rf .npmjs/node_modules)",
|
||||||
"prepush": "npm run lint:cached"
|
"prepush": "npm run lint:cached"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
33
js/scripts/dryrun-npm.sh
Executable file
33
js/scripts/dryrun-npm.sh
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# variables
|
||||||
|
PACKAGES=( "Parity" "Etherscan" "ShapeShift" )
|
||||||
|
|
||||||
|
# change into the build directory
|
||||||
|
BASEDIR=`dirname $0`
|
||||||
|
cd $BASEDIR/..
|
||||||
|
|
||||||
|
# build all packages
|
||||||
|
echo "*** Building packages for npmjs"
|
||||||
|
echo "$NPM_TOKEN" >> ~/.npmrc
|
||||||
|
|
||||||
|
for PACKAGE in ${PACKAGES[@]}
|
||||||
|
do
|
||||||
|
echo "*** Building $PACKAGE"
|
||||||
|
LIBRARY=$PACKAGE npm run ci:build:npm
|
||||||
|
DIRECTORY=.npmjs/$(echo $PACKAGE | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
cd $DIRECTORY
|
||||||
|
echo "*** Executing $PACKAGE tests from $DIRECTORY"
|
||||||
|
npm test
|
||||||
|
|
||||||
|
echo "*** Publishing $PACKAGE from $DIRECTORY"
|
||||||
|
echo "npm publish --access public || true"
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
done
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# exit with exit code
|
||||||
|
exit 0
|
@ -3,7 +3,7 @@ set -e
|
|||||||
|
|
||||||
# variables
|
# variables
|
||||||
UTCDATE=`date -u "+%Y%m%d-%H%M%S"`
|
UTCDATE=`date -u "+%Y%m%d-%H%M%S"`
|
||||||
PACKAGES=( "parity.js" )
|
PACKAGES=( "Parity" "Etherscan" "ShapeShift" )
|
||||||
BRANCH=$CI_BUILD_REF_NAME
|
BRANCH=$CI_BUILD_REF_NAME
|
||||||
GIT_JS_PRECOMPILED="https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/js-precompiled.git"
|
GIT_JS_PRECOMPILED="https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/js-precompiled.git"
|
||||||
GIT_PARITY="https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/parity.git"
|
GIT_PARITY="https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/parity.git"
|
||||||
@ -59,19 +59,27 @@ git reset --hard origin/$BRANCH 2>$GITLOG
|
|||||||
|
|
||||||
if [ "$BRANCH" == "master" ]; then
|
if [ "$BRANCH" == "master" ]; then
|
||||||
cd js
|
cd js
|
||||||
|
|
||||||
echo "*** Bumping package.json patch version"
|
echo "*** Bumping package.json patch version"
|
||||||
npm --no-git-tag-version version
|
npm --no-git-tag-version version
|
||||||
npm version patch
|
npm version patch
|
||||||
|
|
||||||
echo "*** Building packages for npmjs"
|
echo "*** Building packages for npmjs"
|
||||||
# echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login
|
|
||||||
echo "$NPM_TOKEN" >> ~/.npmrc
|
echo "$NPM_TOKEN" >> ~/.npmrc
|
||||||
npm run ci:build:npm
|
|
||||||
|
|
||||||
echo "*** Publishing $PACKAGE to npmjs"
|
for PACKAGE in ${PACKAGES[@]}
|
||||||
cd .npmjs
|
do
|
||||||
npm publish --access public || true
|
echo "*** Building $PACKAGE"
|
||||||
cd ../..
|
LIBRARY=$PACKAGE npm run ci:build:npm
|
||||||
|
DIRECTORY=.npmjs/$(echo $PACKAGE | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
echo "*** Publishing $PACKAGE from $DIRECTORY"
|
||||||
|
cd $DIRECTORY
|
||||||
|
npm publish --access public || true
|
||||||
|
cd ../..
|
||||||
|
done
|
||||||
|
|
||||||
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "*** Updating cargo parity-ui-precompiled#$PRECOMPILED_HASH"
|
echo "*** Updating cargo parity-ui-precompiled#$PRECOMPILED_HASH"
|
||||||
|
6
js/src/3rdparty/etherscan/account.spec.js
vendored
6
js/src/3rdparty/etherscan/account.spec.js
vendored
@ -14,11 +14,13 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import etherscan from './';
|
const etherscan = require('./');
|
||||||
|
|
||||||
const TESTADDR = '0xbf885e2b55c6bcc84556a3c5f07d3040833c8d00';
|
const TESTADDR = '0xbf885e2b55c6bcc84556a3c5f07d3040833c8d00';
|
||||||
|
|
||||||
describe.skip('etherscan/account', () => {
|
describe.skip('etherscan/account', function () {
|
||||||
|
this.timeout(60 * 1000);
|
||||||
|
|
||||||
const checkBalance = function (balance, addr) {
|
const checkBalance = function (balance, addr) {
|
||||||
expect(balance).to.be.ok;
|
expect(balance).to.be.ok;
|
||||||
expect(balance.account).to.equal(addr);
|
expect(balance.account).to.equal(addr);
|
||||||
|
6
js/src/3rdparty/etherscan/stats.spec.js
vendored
6
js/src/3rdparty/etherscan/stats.spec.js
vendored
@ -14,9 +14,11 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import etherscan from './';
|
const etherscan = require('./');
|
||||||
|
|
||||||
|
describe.skip('etherscan/stats', function () {
|
||||||
|
this.timeout(60 * 1000);
|
||||||
|
|
||||||
describe.skip('etherscan/stats', () => {
|
|
||||||
it('retrieves the latest price', () => {
|
it('retrieves the latest price', () => {
|
||||||
return etherscan.stats
|
return etherscan.stats
|
||||||
.price()
|
.price()
|
||||||
|
17
js/src/3rdparty/shapeshift/helpers.spec.js
vendored
17
js/src/3rdparty/shapeshift/helpers.spec.js
vendored
@ -14,22 +14,15 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import chai from 'chai';
|
const nock = require('nock');
|
||||||
import nock from 'nock';
|
|
||||||
|
|
||||||
global.expect = chai.expect; // eslint-disable-line no-undef
|
const ShapeShift = require('./');
|
||||||
|
const initShapeshift = (ShapeShift.default || ShapeShift);
|
||||||
import 'isomorphic-fetch';
|
|
||||||
import es6Promise from 'es6-promise';
|
|
||||||
es6Promise.polyfill();
|
|
||||||
|
|
||||||
import initShapeshift from './';
|
|
||||||
import initRpc from './rpc';
|
|
||||||
|
|
||||||
const APIKEY = '0x123454321';
|
const APIKEY = '0x123454321';
|
||||||
|
|
||||||
const shapeshift = initShapeshift(APIKEY);
|
const shapeshift = initShapeshift(APIKEY);
|
||||||
const rpc = initRpc(APIKEY);
|
const rpc = shapeshift.getRpc();
|
||||||
|
|
||||||
function mockget (requests) {
|
function mockget (requests) {
|
||||||
let scope = nock(rpc.ENDPOINT);
|
let scope = nock(rpc.ENDPOINT);
|
||||||
@ -62,7 +55,7 @@ function mockpost (requests) {
|
|||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
module.exports = {
|
||||||
APIKEY,
|
APIKEY,
|
||||||
mockget,
|
mockget,
|
||||||
mockpost,
|
mockpost,
|
||||||
|
7
js/src/3rdparty/shapeshift/rpc.spec.js
vendored
7
js/src/3rdparty/shapeshift/rpc.spec.js
vendored
@ -14,7 +14,12 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import { APIKEY, mockget, mockpost, rpc } from './helpers.spec.js';
|
const helpers = require('./helpers.spec.js');
|
||||||
|
|
||||||
|
const APIKEY = helpers.APIKEY;
|
||||||
|
const mockget = helpers.mockget;
|
||||||
|
const mockpost = helpers.mockpost;
|
||||||
|
const rpc = helpers.rpc;
|
||||||
|
|
||||||
describe('shapeshift/rpc', () => {
|
describe('shapeshift/rpc', () => {
|
||||||
describe('GET', () => {
|
describe('GET', () => {
|
||||||
|
5
js/src/3rdparty/shapeshift/shapeshift.js
vendored
5
js/src/3rdparty/shapeshift/shapeshift.js
vendored
@ -26,6 +26,10 @@ export default function (rpc) {
|
|||||||
return rpc.get(`marketinfo/${pair}`);
|
return rpc.get(`marketinfo/${pair}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRpc () {
|
||||||
|
return rpc;
|
||||||
|
}
|
||||||
|
|
||||||
function getStatus (depositAddress) {
|
function getStatus (depositAddress) {
|
||||||
return rpc.get(`txStat/${depositAddress}`);
|
return rpc.get(`txStat/${depositAddress}`);
|
||||||
}
|
}
|
||||||
@ -103,6 +107,7 @@ export default function (rpc) {
|
|||||||
return {
|
return {
|
||||||
getCoins,
|
getCoins,
|
||||||
getMarketInfo,
|
getMarketInfo,
|
||||||
|
getRpc,
|
||||||
getStatus,
|
getStatus,
|
||||||
shift,
|
shift,
|
||||||
subscribe,
|
subscribe,
|
||||||
|
@ -14,7 +14,11 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import { mockget, mockpost, shapeshift } from './helpers.spec.js';
|
const helpers = require('./helpers.spec.js');
|
||||||
|
|
||||||
|
const mockget = helpers.mockget;
|
||||||
|
const mockpost = helpers.mockpost;
|
||||||
|
const shapeshift = helpers.shapeshift;
|
||||||
|
|
||||||
describe('shapeshift/calls', () => {
|
describe('shapeshift/calls', () => {
|
||||||
describe('getCoins', () => {
|
describe('getCoins', () => {
|
||||||
|
34
js/src/library.etherscan.js
Normal file
34
js/src/library.etherscan.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// 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/>.
|
||||||
|
|
||||||
|
import 'babel-polyfill/dist/polyfill.js';
|
||||||
|
import es6Promise from 'es6-promise';
|
||||||
|
es6Promise.polyfill();
|
||||||
|
|
||||||
|
const isNode = typeof global !== 'undefined' && typeof global !== 'undefined';
|
||||||
|
const isBrowser = typeof self !== 'undefined' && typeof self.window !== 'undefined';
|
||||||
|
|
||||||
|
if (isBrowser) {
|
||||||
|
require('whatwg-fetch');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNode) {
|
||||||
|
global.fetch = require('node-fetch');
|
||||||
|
}
|
||||||
|
|
||||||
|
import Etherscan from './3rdparty/etherscan';
|
||||||
|
|
||||||
|
module.exports = Etherscan;
|
34
js/src/library.shapeshift.js
Normal file
34
js/src/library.shapeshift.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// 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/>.
|
||||||
|
|
||||||
|
import 'babel-polyfill/dist/polyfill.js';
|
||||||
|
import es6Promise from 'es6-promise';
|
||||||
|
es6Promise.polyfill();
|
||||||
|
|
||||||
|
const isNode = typeof global !== 'undefined' && typeof global !== 'undefined';
|
||||||
|
const isBrowser = typeof self !== 'undefined' && typeof self.window !== 'undefined';
|
||||||
|
|
||||||
|
if (isBrowser) {
|
||||||
|
require('whatwg-fetch');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNode) {
|
||||||
|
global.fetch = require('node-fetch');
|
||||||
|
}
|
||||||
|
|
||||||
|
import ShapeShift from './3rdparty/shapeshift';
|
||||||
|
|
||||||
|
module.exports = ShapeShift;
|
@ -15,8 +15,8 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var Api = require('../.npmjs/library.js').Api;
|
var Api = require('../.npmjs/parity/library.js').Api;
|
||||||
var Abi = require('../.npmjs/library.js').Abi;
|
var Abi = require('../.npmjs/parity/library.js').Abi;
|
||||||
|
|
||||||
if (typeof Api !== 'function') {
|
if (typeof Api !== 'function') {
|
||||||
throw new Error('No Api');
|
throw new Error('No Api');
|
@ -23,14 +23,27 @@ const Shared = require('./shared');
|
|||||||
const ENV = process.env.NODE_ENV || 'development';
|
const ENV = process.env.NODE_ENV || 'development';
|
||||||
const isProd = ENV === 'production';
|
const isProd = ENV === 'production';
|
||||||
|
|
||||||
|
const LIBRARY = process.env.LIBRARY;
|
||||||
|
if (!LIBRARY) {
|
||||||
|
process.exit(-1);
|
||||||
|
}
|
||||||
|
const SRC = LIBRARY.toLowerCase();
|
||||||
|
const OUTPUT_PATH = path.join(__dirname, '../.npmjs', SRC);
|
||||||
|
|
||||||
|
const TEST_CONTEXT = SRC === 'parity'
|
||||||
|
? '../npm/parity/test/'
|
||||||
|
: `../src/3rdparty/${SRC}/`;
|
||||||
|
|
||||||
|
console.log(`Building ${LIBRARY} from library.${SRC}.js to .npmjs/${SRC}`);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
context: path.join(__dirname, '../src'),
|
context: path.join(__dirname, '../src'),
|
||||||
target: 'node',
|
target: 'node',
|
||||||
entry: 'library.js',
|
entry: `library.${SRC}.js`,
|
||||||
output: {
|
output: {
|
||||||
path: path.join(__dirname, '../.npmjs'),
|
path: OUTPUT_PATH,
|
||||||
filename: 'library.js',
|
filename: 'library.js',
|
||||||
library: 'Parity',
|
library: LIBRARY,
|
||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
umdNamedDefine: true
|
umdNamedDefine: true
|
||||||
},
|
},
|
||||||
@ -66,19 +79,52 @@ module.exports = {
|
|||||||
plugins: Shared.getPlugins().concat([
|
plugins: Shared.getPlugins().concat([
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
{
|
{
|
||||||
from: '../parity.package.json',
|
from: `../npm/${SRC}/package.json`,
|
||||||
to: 'package.json',
|
to: 'package.json',
|
||||||
transform: function (content, path) {
|
transform: function (content, path) {
|
||||||
const json = JSON.parse(content.toString());
|
const json = JSON.parse(content.toString());
|
||||||
json.version = packageJson.version;
|
json.version = packageJson.version;
|
||||||
|
|
||||||
|
// Add tests dependencies to Dev Deps
|
||||||
|
json.devDependencies.chai = packageJson.devDependencies.chai;
|
||||||
|
json.devDependencies.mocha = packageJson.devDependencies.mocha;
|
||||||
|
json.devDependencies.nock = packageJson.devDependencies.nock;
|
||||||
|
|
||||||
|
// Add test script
|
||||||
|
json.scripts.test = 'mocha \'test/*.spec.js\'';
|
||||||
|
|
||||||
return new Buffer(JSON.stringify(json, null, ' '), 'utf-8');
|
return new Buffer(JSON.stringify(json, null, ' '), 'utf-8');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: '../LICENSE'
|
from: '../LICENSE'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Copy the base test config
|
||||||
{
|
{
|
||||||
from: '../parity.md',
|
from: '../npm/test',
|
||||||
|
to: 'test'
|
||||||
|
},
|
||||||
|
|
||||||
|
// Copy the actual tests
|
||||||
|
{
|
||||||
|
context: TEST_CONTEXT,
|
||||||
|
from: '**/*.spec.js',
|
||||||
|
to: 'test',
|
||||||
|
transform: function (content, path) {
|
||||||
|
let output = content.toString();
|
||||||
|
|
||||||
|
// Don't skip tests
|
||||||
|
output = output.replace(/describe\.skip/, 'describe');
|
||||||
|
|
||||||
|
// Require parent library
|
||||||
|
output = output.replace('require(\'./\')', 'require(\'../\')');
|
||||||
|
|
||||||
|
return new Buffer(output, 'utf-8');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: `../npm/${SRC}/README.md`,
|
||||||
to: 'README.md'
|
to: 'README.md'
|
||||||
}
|
}
|
||||||
], { copyUnmodified: true })
|
], { copyUnmodified: true })
|
||||||
|
Loading…
Reference in New Issue
Block a user