Skip to content

Commit

Permalink
Merge pull request #474 from MoMannn/bitski-provider
Browse files Browse the repository at this point in the history
Bitski
  • Loading branch information
xpepermint authored May 16, 2019
2 parents 0ced126 + 0884bb5 commit 1dfeee0
Show file tree
Hide file tree
Showing 37 changed files with 4,000 additions and 212 deletions.
2,374 changes: 2,205 additions & 169 deletions common/config/rush/npm-shrinkwrap.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/0xcert-cert.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-ethereum-asset-ledger.min.js

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions dist/0xcert-ethereum-bitski-frontend-provider.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-ethereum-http-provider.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-ethereum-metamask-provider.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-ethereum-order-gateway.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-ethereum-value-ledger.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-ethereum.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-wanchain-asset-ledger.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-wanchain-http-provider.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-wanchain-order-gateway.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-wanchain-value-ledger.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/0xcert-wanchain.min.js

Large diffs are not rendered by default.

660 changes: 652 additions & 8 deletions docs/api/ethereum.md

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/0xcert-ethereum-bitski-backend-provider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<img src="https://github.com/0xcert/framework/raw/master/assets/cover-sub.png" />

> Implementation of Bitski back-end communication provider for the Ethereum blockchain.
The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.

This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
4 changes: 4 additions & 0 deletions packages/0xcert-ethereum-bitski-backend-provider/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"ignore": ["dist/*"],
"ext": "js,ts"
}
80 changes: 80 additions & 0 deletions packages/0xcert-ethereum-bitski-backend-provider/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "@0xcert/ethereum-bitski-backend-provider",
"version": "1.5.2",
"description": "Implementation of Bitski back-end communication provider for the Ethereum blockchain.",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "npm run clean && npx tsc",
"clean": "rm -Rf ./dist",
"lint": "npx tslint 'src/**/*.ts?(x)'",
"test": "npm run lint && npx nyc npx hayspec test"
},
"hayspec": {
"require": [
"ts-node/register"
],
"match": [
"./src/tests/**/*.test.ts"
]
},
"nyc": {
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"exclude": [
"src/tests"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/0xcert/framework.git"
},
"bugs": {
"url": "https://github.com/0xcert/framework/issues"
},
"homepage": "https://github.com/0xcert/framework#readme",
"keywords": [
"0xcert",
"framework",
"protocol",
"asset",
"value",
"values",
"currency",
"token",
"non-fungible",
"fungible",
"erc-721",
"erc-20",
"blockchain",
"javascript",
"typescript",
"nodejs",
"vuejs",
"nuxtjs",
"npm",
"libraries",
"smart-contract",
"ethereum",
"zxc"
],
"license": "MIT",
"devDependencies": {
"@hayspec/cli": "^0.8.3",
"@hayspec/spec": "^0.8.3",
"nyc": "^13.1.0",
"solc": "0.5.5",
"ts-node": "^7.0.1",
"tslint": "^5.12.1",
"typescript": "^3.1.1",
"web3": "1.0.0-beta.37"
},
"dependencies": {
"@0xcert/ethereum-generic-provider": "1.5.2",
"bitski-node": "0.5.0"
}
}
143 changes: 143 additions & 0 deletions packages/0xcert-ethereum-bitski-backend-provider/src/core/provider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { GenericProvider, SignMethod } from '@0xcert/ethereum-generic-provider';
import * as Bitski from 'bitski-node';

/**
* Configuration interface for generic provider.
*/
export interface BitskiProviderOptions {

/**
* Default account from which all mutations are made.
*/
accountId?: string;

/**
* Type of signature that will be used in making claims etc.
*/
signMethod?: SignMethod;

/**
* List of addresses where normal transfer not safeTransfer smart contract methods will be used.
*/
unsafeRecipientIds?: string[];

/**
* Source where assetLedger compiled smart contract is located.
*/
assetLedgerSource?: string;

/**
* Source where valueLedger compiled smart contract is located.
*/
valueLedgerSource?: string;

/**
* Number of confirmations (blocks in blockchain after mutation is accepted) are necessary to mark
* a mutation complete.
*/
requiredConfirmations?: number;

/**
* ID (address) of order gateway.
*/
orderGatewayId?: string;

/**
* The number of milliseconds in which a mutation times out.
*/
mutationTimeout?: number;

/**
* Bitski client ID.
*/
clientId: string;

/**
* Bitski credentials ID.
*/
credentialsId: string;

/**
* Bitski credentials secret.
*/
credentialsSecret: string;

/**
* Ethereum network Bitski is connected to. Mainnet by default.
*/
networkName?: string;
}

/**
* Bitski RPC client.
*/
export class BitskiProvider extends GenericProvider {

/**
* Default options set from constructor.
*/
protected _options: BitskiProviderOptions;

/**
* Bitski provider instance.
*/
protected _provider: any;

/**
* Returns a new provider instance.
* @param options HTTP provider options.
*/
public static getInstance(options: BitskiProviderOptions): BitskiProvider {
return new this(options);
}

/**
* Class constructor.
* @param options.accountId Optional coinbase account.
* @param options.signMethod Optional setting of signature kind used in claims.
* @param options.unsafeRecipientIds Optional list of addresses where normal transfer not
* safeTransfer smart contract methods will be used.
* @param options.assetLedgerSource Optional source where assetLedger compiled smart contracts are
* located.
* @param options.valueLedgerSource Optional source where valueLedger compiled smart contracts are
* located.
* @param options.requiredConfirmations Optional number of confirmations that are necessary to
* mark a mutation complete.
* @param options.orderGatewayId Optional ID (address) of order gateway.
* @param options.mutationTimeout Optional number of milliseconds in which a mutation times out.
* @param options.clientId Required Bitski client ID.
* @param options.credentialsId Required Bitski credentials ID.
* @param options.credentialsSecret Required Bitski credentials secret.
* @param options.networkName Optional name of Ethereum network Bitski is connected to. Mainnet by
* default.
*/
public constructor(options: BitskiProviderOptions) {
super(options);

this._options = options;
this._client = this;
this._provider = Bitski.getProvider(options.clientId, {
networkName: typeof options.networkName === 'undefined' ? 'mainnet' : options.networkName,
credentials: {
id: options.credentialsId,
secret: options.credentialsSecret,
},
});
}

/**
* Is provider supported.
*/
public isSupported() {
return !!this._provider;
}

/**
* Sends the RPC call.
* @param data JSON-RPC ethereum call.
* @param callback Callback function to be executed.
*/
public send(data: any, callback: (err, data) => any) {
this._provider.sendAsync(data, callback);
}
}
2 changes: 2 additions & 0 deletions packages/0xcert-ethereum-bitski-backend-provider/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from '@0xcert/ethereum-generic-provider';
export * from './core/provider';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Spec } from '@hayspec/spec';
import * as view from '..';

const spec = new Spec();

spec.test('exposes objects', (ctx) => {
ctx.true(!!view.BitskiProvider);
});

export default spec;
13 changes: 13 additions & 0 deletions packages/0xcert-ethereum-bitski-backend-provider/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"removeComments": true,
"sourceMap": true,
"outDir": "dist",
"declaration": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true
}
}
Loading

0 comments on commit 1dfeee0

Please sign in to comment.