@parity/electron
v5.1.13
Published
Control the Parity Ethereum node from Electron.
Downloads
19
Readme
@parity/electron
Control the Parity Ethereum client from 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
yarn add @parity/electron
Usage
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
Functions
- checkClockSync
- defaultParityPath
- deleteParity
- fetchParity
- getParityPath
- isParityRunning
- killParity
- parityElectron
- runParity
- signerNewToken
Functions
checkClockSync
▸ checkClockSync(): Promise
<CheckClockSyncResult>
Defined in checkClockSync.ts:21
Use SNTP to check if the local clock is synchronized; return the time drift.
Returns: Promise
<CheckClockSyncResult>
defaultParityPath
▸ defaultParityPath(): Promise
<string
>
Defined in getParityPath.ts:23
The default path to install parity, in case there's no other instance found on the machine.
Returns: Promise
<string
>
deleteParity
▸ deleteParity(): Promise
<void
>
Defined in fetchParity.ts:84
Remove parity binary or partial binary in the userData folder, if it exists.
Returns: Promise
<void
>
fetchParity
▸ fetchParity(mainWindow: BrowserWindow
, options?: FetchParityOptions): Promise
<string
>
Defined in fetchParity.ts:106
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 | {onProgress: () => {/_ Do nothing by defaut. _/},parityChannel: 'beta'} |
Returns: Promise
<string
>
getParityPath
▸ getParityPath(): Promise
<string
>
Defined in getParityPath.ts:104
Returns the path to Parity, or throws if parity is not found.
Returns: Promise
<string
>
isParityRunning
▸ isParityRunning(options?: IsParityRunningOptions): Promise
<boolean
>
Defined in isParityRunning.ts:20
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 | {wsInterface: '127.0.0.1',wsPort: '8546'} |
Returns: Promise
<boolean
>
killParity
▸ killParity(): Promise
<void
>
Defined in runParity.ts:118
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
>
parityElectron
▸ parityElectron(options?: ParityElectronOptions): void
Defined in index.ts:25
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 | { logger: debug } |
Returns: void
runParity
▸ runParity(options?: RunParityOptions): Promise
<void
>
Defined in runParity.ts:44
Spawns a child process to run Parity.
Parameters:
| Param | Type | Default value |
| ----------------------- | ------------------------------------------------------- | --------------------------------------------------------------------- |
| Default value
options | RunParityOptions | {flags: [],onParityError: () => {/_ Do nothing if error. _/}} |
Returns: Promise
<void
>
signerNewToken
▸ signerNewToken(): Promise
<string
>
Defined in signerNewToken.ts:16
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
>