Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Publish parity.js to npmjs registry #2978

Merged
merged 27 commits into from
Oct 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ed2be65
Skeleton packages
jacogr Oct 29, 2016
9efaabf
Merge branch 'master' into jg-npmjs
jacogr Oct 29, 2016
f5ba24d
Publish parity.js package to npm
jacogr Oct 29, 2016
a5f6740
[ci skip] js-precompiled 20161029-190427
jacogr Oct 29, 2016
7424c96
Extra step information
jacogr Oct 29, 2016
f69ac13
[ci skip] js-precompiled 20161029-192209
jacogr Oct 29, 2016
d3508ee
Use autToken for npmjs (cannot run headless in docker)
jacogr Oct 29, 2016
e31c7c1
[ci skip] js-precompiled 20161029-193414
jacogr Oct 29, 2016
2d6f6d7
Correct package.json structure
jacogr Oct 29, 2016
fbec0a6
[ci skip] js-precompiled 20161029-194003
jacogr Oct 29, 2016
3229948
Scope package to public
jacogr Oct 29, 2016
0a57dfd
[ci skip] js-precompiled 20161029-194529
jacogr Oct 29, 2016
527f9a8
Merge branch 'master' into jg-npmjs
jacogr Oct 29, 2016
cb93375
Start package version at 0.1.0
jacogr Oct 29, 2016
c5ed4cf
Build proper umd library
jacogr Oct 29, 2016
3331fdf
[ci skip] js-precompiled 20161029-231233
jacogr Oct 29, 2016
3173f37
Update build/release stage
jacogr Oct 30, 2016
8e32df1
[ci skip] js-precompiled 20161030-071454
jacogr Oct 30, 2016
2447839
Basic README.md to satisfy npmjs
jacogr Oct 30, 2016
ca69a2b
[ci skip] js-precompiled 20161030-073150
jacogr Oct 30, 2016
eea4021
CommonJs format
jacogr Oct 30, 2016
587163b
[ci skip] js-precompiled 20161030-075034
jacogr Oct 30, 2016
ab1ee73
Update README.md
jacogr Oct 30, 2016
0c63155
update dependencies
jacogr Oct 30, 2016
3d69cbd
[ci skip] js-precompiled 20161030-075727
jacogr Oct 30, 2016
aee830f
Starting package version
jacogr Oct 30, 2016
f55237c
Build only on master
jacogr Oct 30, 2016
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
23 changes: 10 additions & 13 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ stages:
- test
variables:
GIT_DEPTH: "3"
SIMPLECOV: "true"
SIMPLECOV: "true"
RUST_BACKTRACE: "1"
RUSTFLAGS: "-D warnings"
cache:
Expand All @@ -26,7 +26,7 @@ linux-stable:
- export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n")
- dpkg-deb -b deb "parity_"$VER"_amd64.deb"
- md5sum "parity_"$VER"_amd64.deb" >> "parity_"$VER"_amd64.deb.md5"
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_secret_access_key $s3_secret
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity --body target/release/parity
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity.md5 --body parity.md5
Expand Down Expand Up @@ -56,7 +56,7 @@ linux-stable-14.04:
- export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n")
- dpkg-deb -b deb "parity_"$VER"_amd64.deb"
- md5sum "parity_"$VER"_amd64.deb" >> "parity_"$VER"_amd64.deb.md5"
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_secret_access_key $s3_secret
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-ubuntu_14_04-gnu/parity --body target/release/parity
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-ubuntu_14_04-gnu/parity.md5 --body parity.md5
Expand Down Expand Up @@ -121,7 +121,7 @@ linux-centos:
- cargo build --release --verbose
- strip target/release/parity
- md5sum target/release/parity >> parity.md5
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_secret_access_key $s3_secret
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity --body target/release/parity
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity.md5 --body parity.md5
Expand Down Expand Up @@ -158,7 +158,7 @@ linux-armv7:
- export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n")
- dpkg-deb -b deb "parity_"$VER"_armhf.deb"
- md5sum "parity_"$VER"_armhf.deb" >> "parity_"$VER"_armhf.deb.md5"
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_secret_access_key $s3_secret
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity --body target/armv7-unknown-linux-gnueabihf/release/parity
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity.md5 --body parity.md5
Expand Down Expand Up @@ -198,7 +198,7 @@ linux-arm:
- export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n")
- dpkg-deb -b deb "parity_"$VER"_armhf.deb"
- md5sum "parity_"$VER"_armhf.deb" >> "parity_"$VER"_armhf.deb.md5"
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_secret_access_key $s3_secret
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity --body target/arm-unknown-linux-gnueabihf/release/parity
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity.md5 --body parity.md5
Expand Down Expand Up @@ -231,8 +231,8 @@ linux-armv6:
- cat .cargo/config
- cargo build --target arm-unknown-linux-gnueabi --release --verbose
- arm-linux-gnueabi-strip target/arm-unknown-linux-gnueabi/release/parity
- md5sum target/arm-unknown-linux-gnueabi/release/parity >> parity.md5
- aws configure set aws_access_key_id $s3_key
- md5sum target/arm-unknown-linux-gnueabi/release/parity >> parity.md5
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_secret_access_key $s3_secret
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity --body target/arm-unknown-linux-gnueabi/release/parity
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity.md5 --body parity.md5
Expand Down Expand Up @@ -270,7 +270,7 @@ linux-aarch64:
- export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n")
- dpkg-deb -b deb "parity_"$VER"_arm64.deb"
- md5sum "parity_"$VER"_arm64.deb" >> "parity_"$VER"_arm64.deb.md5"
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_secret_access_key $s3_secret
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity --body target/aarch64-unknown-linux-gnu/release/parity
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity.md5 --body parity.md5
Expand All @@ -295,7 +295,7 @@ darwin:
- cargo build --release --verbose
- rm -rf parity.md5
- md5sum target/release/parity >> parity.md5
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_access_key_id $s3_key
- aws configure set aws_secret_access_key $s3_secret
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity --body target/release/parity
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity.md5 --body parity.md5
Expand Down Expand Up @@ -391,9 +391,6 @@ js-release:
image: ethcore/javascript:latest
only:
- master
- beta
- tags
- stable
before_script:
- ./js/scripts/install-deps.sh
script:
Expand Down
1 change: 1 addition & 0 deletions js/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build
.coverage
.dist
.happypack
.npmjs
13 changes: 6 additions & 7 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "parity.js",
"version": "0.0.1",
"version": "0.1.0",
"main": "release/index.js",
"jsnext:main": "src/index.js",
"author": "Ethcore Team <admin@ethcore.io>",
"author": "Parity Team <admin@parity.io>",
"maintainers": [
"Jaco Greeff"
],
"contributors": [],
"license": "GPL-3.0",
"repository": {
"type": "git",
"url": "git+https://github.com/ethcore/parity.js.git"
"url": "git+https://github.com/ethcore/parity.git"
},
"keywords": [
"Ethereum",
Expand All @@ -27,15 +27,13 @@
"build:app": "webpack --progress",
"build:lib": "webpack --config webpack.libraries --progress",
"build:dll": "webpack --config webpack.vendor --progress",

"ci:build": "npm run ci:build:dll && npm run ci:build:app && npm run ci:build:lib",
"ci:build:app": "NODE_ENV=production webpack",
"ci:build:lib": "NODE_ENV=production webpack --config webpack.libraries",
"ci:build:dll": "NODE_ENV=production webpack --config webpack.vendor",

"ci:build:npm": "NODE_ENV=production webpack --config webpack.npm",
"start": "npm install && npm run build:dll && npm run start:app",
"start:app": "webpack-dev-server -d --history-api-fallback --open --hot --inline --progress --colors --port 3000",

"clean": "rm -rf ./build ./coverage",
"coveralls": "npm run testCoverage && coveralls < coverage/lcov.info",
"lint": "eslint --ignore-path .gitignore ./src/",
Expand Down Expand Up @@ -65,7 +63,7 @@
"chai": "^3.5.0",
"chai-enzyme": "0.4.2",
"cheerio": "0.20.0",
"copy-webpack-plugin": "^3.0.1",
"copy-webpack-plugin": "^4.0.0",
"core-js": "^2.4.1",
"coveralls": "^2.11.11",
"css-loader": "^0.23.1",
Expand All @@ -79,6 +77,7 @@
"eslint-plugin-standard": "^2.0.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"fs-extra": "^0.30.0",
"happypack": "^2.2.1",
"history": "^2.0.0",
"html-loader": "^0.4.3",
Expand Down
81 changes: 81 additions & 0 deletions js/parity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# parity.js

Parity.js is a thin, fast, Promise-based wrapper around the Ethereum APIs.

## 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.
32 changes: 32 additions & 0 deletions js/parity.package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@parity/parity.js",
"description": "The Parity Promise-base 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"
}
}
71 changes: 47 additions & 24 deletions js/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#!/bin/bash
set -e

# variables
UTCDATE=`date -u "+%Y%m%d-%H%M%S"`
PACKAGES=( "parity.js" )
BRANCH=$CI_BUILD_REF_NAME
GIT_JS_PRECOMPILED="https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/js-precompiled.git"
GIT_PARITY="https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/parity.git"

# setup the git user defaults for the current repo
function setup_git_user {
git config push.default simple
git config merge.ours.driver true
git config user.email "jaco+gitlab@ethcore.io"
git config user.email "$GITHUB_EMAIL"
git config user.name "GitLab Build Bot"
}

Expand All @@ -15,47 +22,63 @@ GITLOG=./.git/gitcommand.log
pushd $BASEDIR
cd ../.dist

# variables
UTCDATE=`date -u "+%Y%m%d-%H%M%S"`

# init git
# add local files and send it up
echo "*** Setting up GitHub config for js-precompiled"
rm -rf ./.git
git init

# add local files and send it up
echo "Setting up GitHub config for js-precompiled"
setup_git_user

echo "Checking out $CI_BUILD_REF_NAME branch"
git remote add origin https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/js-precompiled.git
echo "*** Checking out $BRANCH branch"
git remote add origin $GIT_JS_PRECOMPILED
git fetch origin 2>$GITLOG
git checkout -b $CI_BUILD_REF_NAME
git checkout -b $BRANCH

echo "Committing compiled files for $UTCDATE"
echo "*** Committing compiled files for $UTCDATE"
git add .
git commit -m "$UTCDATE"

echo "Merging remote"
git merge origin/$CI_BUILD_REF_NAME -X ours --commit -m "$UTCDATE [release]"
git push origin HEAD:refs/heads/$CI_BUILD_REF_NAME 2>$GITLOG
echo "*** Merging remote"
git merge origin/$BRANCH -X ours --commit -m "$UTCDATE [release]"
git push origin HEAD:refs/heads/$BRANCH 2>$GITLOG
PRECOMPILED_HASH=`git rev-parse HEAD`

# back to root
popd
# move to root
cd ../..

echo "Setting up GitHub config for parity"
echo "*** Setting up GitHub config for parity"
setup_git_user
git remote set-url origin https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/parity.git
git reset --hard origin/$CI_BUILD_REF_NAME 2>$GITLOG
git remote set-url origin $GIT_PARITY
git reset --hard origin/$BRANCH 2>$GITLOG

echo "*** Bumping package.json patch version"
cd js
npm --no-git-tag-version version
npm version patch
cd ..

echo "Updating cargo package parity-ui-precompiled#$PRECOMPILED_HASH"
echo "*** Updating cargo parity-ui-precompiled#$PRECOMPILED_HASH"
cargo update -p parity-ui-precompiled
# --precise "$PRECOMPILED_HASH"

echo "Committing updated files"
git add .
echo "*** Committing updated files"
git add Cargo.lock js/package.json
git commit -m "[ci skip] js-precompiled $UTCDATE"
git push origin HEAD:refs/heads/$CI_BUILD_REF_NAME 2>$GITLOG
git push origin HEAD:refs/heads/$BRANCH 2>$GITLOG

echo "*** Building packages for npmjs"
cd js
# echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login
echo "$NPM_TOKEN" >> ~/.npmrc
npm run ci:build:npm

echo "*** Publishing $PACKAGE to npmjs"
cd .npmjs
npm publish --access public
cd ..

# back to root
echo "*** Release completed"
popd

# exit with exit code
exit 0
23 changes: 23 additions & 0 deletions js/src/library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 Abi from './abi';
import Api from './api';

export {
Abi,
Api
};
Loading