-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
Bitski
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
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). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"ignore": ["dist/*"], | ||
"ext": "js,ts" | ||
} |
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" | ||
} | ||
} |
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); | ||
} | ||
} |
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; |
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 | ||
} | ||
} |