This repository was archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Add @parity/electron #14
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fe0791e
Add electron package
amaury1093 206a47e
Add some tests
amaury1093 67fa654
Update README.md
amaury1093 937a957
Make docs pretty
amaury1093 d249f6f
Update docs
amaury1093 5bb5fa4
Update docs
amaury1093 f3c5e36
Update docs
amaury1093 a1c568b
Update docs
amaury1093 a16645f
Bump version
amaury1093 45a0f03
Update README
amaury1093 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| docs/README.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
|
|
||
| @parity/electron | ||
| ================ | ||
|
|
||
| Control the Parity Ethereum client from electron. | ||
|
|
||
| [](https://travis-ci.org/paritytech/js-libs) [](https://www.npmjs.com/package/@parity/electron) [](https://www.npmjs.com/package/@parity/electron) [](https://david-dm.org/paritytech/js-libs?path=packages/electron) | ||
|
|
||
| Description | ||
| ----------- | ||
|
|
||
| With this library, you will be able, from Electron, to: | ||
|
|
||
| * download Parity Ethereum locally in Electron's user data folder. | ||
| * run/stop/check if Parity Ethereum is running. | ||
| * get a secure token from Parity Ethereum to access secure RPCs. | ||
|
|
||
| Getting Started | ||
| --------------- | ||
|
|
||
| ```bash | ||
| yarn add @parity/electron | ||
| ``` | ||
|
|
||
| Usage | ||
| ----- | ||
|
|
||
| ```javascript | ||
| import parityElectron, { isParityRunning } from '@parity/electron'; | ||
|
|
||
| // Optional: override default options | ||
| parityElectron({ | ||
| logger: myCustomLoggerFunction // How do we want to log @parity/electron logs? Default is `debug` | ||
| }) | ||
|
|
||
| isParityRunning() | ||
| .then(() => ...); | ||
| ``` | ||
|
|
||
| ## Index | ||
|
|
||
| ### Interfaces | ||
|
|
||
| * [CheckClockSyncResult](interfaces/checkclocksyncresult.md) | ||
| * [FetchParityOptions](interfaces/fetchparityoptions.md) | ||
| * [IsParityRunningOptions](interfaces/isparityrunningoptions.md) | ||
| * [ParityElectronOptions](interfaces/parityelectronoptions.md) | ||
| * [RunParityOptions](interfaces/runparityoptions.md) | ||
|
|
||
| ### Functions | ||
|
|
||
| * [checkClockSync](#checkclocksync) | ||
| * [defaultParityPath](#defaultparitypath) | ||
| * [deleteParity](#deleteparity) | ||
| * [fetchParity](#fetchparity) | ||
| * [getParityPath](#getparitypath) | ||
| * [isParityRunning](#isparityrunning) | ||
| * [killParity](#killparity) | ||
| * [parityElectron](#parityelectron) | ||
| * [runParity](#runparity) | ||
| * [signerNewToken](#signernewtoken) | ||
|
|
||
| --- | ||
|
|
||
| ## Functions | ||
|
|
||
| <a id="checkclocksync"></a> | ||
|
|
||
| ### checkClockSync | ||
|
|
||
| ▸ **checkClockSync**(): `Promise`<[CheckClockSyncResult](interfaces/checkclocksyncresult.md)> | ||
|
|
||
| *Defined in [checkClockSync.ts:21](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/checkClockSync.ts#L21)* | ||
|
|
||
| Use SNTP to check if the local clock is synchronized; return the time drift. | ||
|
|
||
| **Returns:** `Promise`<[CheckClockSyncResult](interfaces/checkclocksyncresult.md)> | ||
|
|
||
| ___ | ||
| <a id="defaultparitypath"></a> | ||
|
|
||
| ### defaultParityPath | ||
|
|
||
| ▸ **defaultParityPath**(): `Promise`<`string`> | ||
|
|
||
| *Defined in [getParityPath.ts:23](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/getParityPath.ts#L23)* | ||
|
|
||
| The default path to install parity, in case there's no other instance found on the machine. | ||
|
|
||
| **Returns:** `Promise`<`string`> | ||
|
|
||
| ___ | ||
| <a id="deleteparity"></a> | ||
|
|
||
| ### deleteParity | ||
|
|
||
| ▸ **deleteParity**(): `Promise`<`void`> | ||
|
|
||
| *Defined in [fetchParity.ts:84](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/fetchParity.ts#L84)* | ||
|
|
||
| Remove parity binary or partial binary in the userData folder, if it exists. | ||
|
|
||
| **Returns:** `Promise`<`void`> | ||
|
|
||
| ___ | ||
| <a id="fetchparity"></a> | ||
|
|
||
| ### fetchParity | ||
|
|
||
| ▸ **fetchParity**(mainWindow: *`BrowserWindow`*, options?: *[FetchParityOptions](interfaces/fetchparityoptions.md)*): `Promise`<`string`> | ||
|
|
||
| *Defined in [fetchParity.ts:106](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/fetchParity.ts#L106)* | ||
|
|
||
| Downloads Parity, saves it to Electron's `userData` folder, and returns the path to the downloaded binary once finished. | ||
|
|
||
| **Parameters:** | ||
|
|
||
| | Param | Type | Default value | | ||
| | ------ | ------ | ------ | | ||
| | mainWindow | `BrowserWindow` | - | | ||
| | `Default value` options | [FetchParityOptions](interfaces/fetchparityoptions.md) | {onProgress: () => {/* Do nothing by defaut. */},parityChannel: 'beta'} | | ||
|
|
||
| **Returns:** `Promise`<`string`> | ||
|
|
||
| ___ | ||
| <a id="getparitypath"></a> | ||
|
|
||
| ### getParityPath | ||
|
|
||
| ▸ **getParityPath**(): `Promise`<`string`> | ||
|
|
||
| *Defined in [getParityPath.ts:119](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/getParityPath.ts#L119)* | ||
|
|
||
| Returns the path to Parity, or throws if parity is not found. | ||
|
|
||
| **Returns:** `Promise`<`string`> | ||
|
|
||
| ___ | ||
| <a id="isparityrunning"></a> | ||
|
|
||
| ### isParityRunning | ||
|
|
||
| ▸ **isParityRunning**(options?: *[IsParityRunningOptions](interfaces/isparityrunningoptions.md)*): `Promise`<`boolean`> | ||
|
|
||
| *Defined in [isParityRunning.ts:20](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/isParityRunning.ts#L20)* | ||
|
|
||
| Detect if another instance of parity is already running or not. To achieve that, we just ping on the common hosts. | ||
|
|
||
| **Parameters:** | ||
|
|
||
| | Param | Type | Default value | | ||
| | ------ | ------ | ------ | | ||
| | `Default value` options | [IsParityRunningOptions](interfaces/isparityrunningoptions.md) | {wsInterface: '127.0.0.1',wsPort: '8546'} | | ||
|
|
||
| **Returns:** `Promise`<`boolean`> | ||
|
|
||
| ___ | ||
| <a id="killparity"></a> | ||
|
|
||
| ### killParity | ||
|
|
||
| ▸ **killParity**(): `Promise`<`void`> | ||
|
|
||
| *Defined in [runParity.ts:112](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/runParity.ts#L112)* | ||
|
|
||
| If a Parity process has been spawned with runParity, then it kills this process. However, there's no guarantee that Parity has been cleanly killed, and the Promise resolves instantly. | ||
|
|
||
| **Returns:** `Promise`<`void`> | ||
|
|
||
| ___ | ||
| <a id="parityelectron"></a> | ||
|
|
||
| ### parityElectron | ||
|
|
||
| ▸ **parityElectron**(options?: *[ParityElectronOptions](interfaces/parityelectronoptions.md)*): `void` | ||
|
|
||
| *Defined in [index.ts:25](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/index.ts#L25)* | ||
|
|
||
| Set default options for @parity/electron. Can be skipped if we don't want to override default options. | ||
|
|
||
| **Parameters:** | ||
|
|
||
| | Param | Type | Default value | | ||
| | ------ | ------ | ------ | | ||
| | `Default value` options | [ParityElectronOptions](interfaces/parityelectronoptions.md) | { logger: debug } | | ||
|
|
||
| **Returns:** `void` | ||
|
|
||
| ___ | ||
| <a id="runparity"></a> | ||
|
|
||
| ### runParity | ||
|
|
||
| ▸ **runParity**(options?: *[RunParityOptions](interfaces/runparityoptions.md)*): `Promise`<`void`> | ||
|
|
||
| *Defined in [runParity.ts:44](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/runParity.ts#L44)* | ||
|
|
||
| Spawns a child process to run Parity. | ||
|
|
||
| **Parameters:** | ||
|
|
||
| | Param | Type | Default value | | ||
| | ------ | ------ | ------ | | ||
| | `Default value` options | [RunParityOptions](interfaces/runparityoptions.md) | {flags: [],onParityError: () => {/* Do nothing if error. */}} | | ||
|
|
||
| **Returns:** `Promise`<`void`> | ||
|
|
||
| ___ | ||
| <a id="signernewtoken"></a> | ||
|
|
||
| ### signerNewToken | ||
|
|
||
| ▸ **signerNewToken**(): `Promise`<`string`> | ||
|
|
||
| *Defined in [signerNewToken.ts:16](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/signerNewToken.ts#L16)* | ||
|
|
||
| Runs parity signer new-token and resolves with a new secure token to be used in a dapp. Rejects if no token could be extracted. | ||
|
|
||
| **Returns:** `Promise`<`string`> | ||
|
|
||
| ___ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| [@parity/electron](../README.md) > [CheckClockSyncResult](../interfaces/checkclocksyncresult.md) | ||
|
|
||
| # Interface: CheckClockSyncResult | ||
|
|
||
| ## Hierarchy | ||
|
|
||
| **CheckClockSyncResult** | ||
|
|
||
| ## Index | ||
|
|
||
| ### Properties | ||
|
|
||
| * [isClockSync](checkclocksyncresult.md#isclocksync) | ||
| * [timeDrift](checkclocksyncresult.md#timedrift) | ||
|
|
||
| --- | ||
|
|
||
| ## Properties | ||
|
|
||
| <a id="isclocksync"></a> | ||
|
|
||
| ### isClockSync | ||
|
|
||
| **● isClockSync**: *`boolean`* | ||
|
|
||
| *Defined in [checkClockSync.ts:9](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/checkClockSync.ts#L9)* | ||
|
|
||
| ___ | ||
| <a id="timedrift"></a> | ||
|
|
||
| ### timeDrift | ||
|
|
||
| **● timeDrift**: *`number`* | ||
|
|
||
| *Defined in [checkClockSync.ts:10](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/checkClockSync.ts#L10)* | ||
|
|
||
| ___ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| [@parity/electron](../README.md) > [FetchParityOptions](../interfaces/fetchparityoptions.md) | ||
|
|
||
| # Interface: FetchParityOptions | ||
|
|
||
| ## Hierarchy | ||
|
|
||
| **FetchParityOptions** | ||
|
|
||
| ## Index | ||
|
|
||
| ### Properties | ||
|
|
||
| * [onProgress](fetchparityoptions.md#onprogress) | ||
| * [parityChannel](fetchparityoptions.md#paritychannel) | ||
|
|
||
| --- | ||
|
|
||
| ## Properties | ||
|
|
||
| <a id="onprogress"></a> | ||
|
|
||
| ### onProgress | ||
|
|
||
| **● onProgress**: *`function`* | ||
|
|
||
| *Defined in [fetchParity.ts:18](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/fetchParity.ts#L18)* | ||
|
|
||
| #### Type declaration | ||
| ▸(progress: *`number`*): `void` | ||
|
|
||
| **Parameters:** | ||
|
|
||
| | Param | Type | | ||
| | ------ | ------ | | ||
| | progress | `number` | | ||
|
|
||
| **Returns:** `void` | ||
|
|
||
| ___ | ||
| <a id="paritychannel"></a> | ||
|
|
||
| ### parityChannel | ||
|
|
||
| **● parityChannel**: *`string`* | ||
|
|
||
| *Defined in [fetchParity.ts:19](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/fetchParity.ts#L19)* | ||
|
|
||
| ___ | ||
|
|
39 changes: 39 additions & 0 deletions
39
packages/electron/docs/interfaces/isparityrunningoptions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| [@parity/electron](../README.md) > [IsParityRunningOptions](../interfaces/isparityrunningoptions.md) | ||
|
|
||
| # Interface: IsParityRunningOptions | ||
|
|
||
| ## Hierarchy | ||
|
|
||
| **IsParityRunningOptions** | ||
|
|
||
| ## Index | ||
|
|
||
| ### Properties | ||
|
|
||
| * [wsInterface](isparityrunningoptions.md#wsinterface) | ||
| * [wsPort](isparityrunningoptions.md#wsport) | ||
|
|
||
| --- | ||
|
|
||
| ## Properties | ||
|
|
||
| <a id="wsinterface"></a> | ||
|
|
||
| ### wsInterface | ||
|
|
||
| **● wsInterface**: *`string`* | ||
|
|
||
| *Defined in [isParityRunning.ts:12](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/isParityRunning.ts#L12)* | ||
|
|
||
| ___ | ||
| <a id="wsport"></a> | ||
|
|
||
| ### wsPort | ||
|
|
||
| **● wsPort**: * `number` | `string` | ||
| * | ||
|
|
||
| *Defined in [isParityRunning.ts:13](https://github.com/paritytech/js-libs/blob/f3c5e36/packages/electron/src/isParityRunning.ts#L13)* | ||
|
|
||
| ___ | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still missing escaping the dot for
light.jsandlight.js-reactbut it doesn't make a difference for all intents and purposes ^^