@dashevo/dapi-client 0.21.6 → 0.22.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/_sidebar.md CHANGED
@@ -1,18 +1,24 @@
1
1
  - Getting started
2
2
  - [Quick start](getting-started/quickstart.md)
3
3
  - Usage
4
- - Application
5
- - [`.applyStateTransition()`](usage/application/applyStateTransition.md)
6
- - [`.getDataContract()`](usage/application/getDataContract.md)
7
- - [`.getDocuments()`](usage/application/getDocuments.md)
8
- - [`.getIdentity()`](usage/application/getIdentity.md)
9
- - [`.getIdentityByFirstPublicKey()`](usage/application/getIdentityByFirstPublicKey.md)
10
- - [`.getIdentityIdByFirstPublicKey()`](usage/application/getIdentityIdByFirstPublicKey.md)
11
- - Payment
12
- - [`.getBestBlockHash()`](usage/payment/getBestBlockHash.md)
13
- - [`.getBlockHash()`](usage/payment/getBlockHash.md)
14
- - [`.getUTXO()`](usage/payment/getUTXO.md)
15
- - Utilities
16
- - [`.getMnListDiff()`](usage/utils/getMnListDiff.md)
17
- - [`.subscribeToTransactionsWithProofs()`](usage/utils/subscribeToTransactionsWithProofs.md)
4
+ - DAPIClient
5
+ - [new DAPIClient()](usage/application/DAPIClient.md)
6
+ - Core
7
+ - [.broadcastTransaction()](usage/application/core/broadcastTransaction.md)
8
+ - [.generateToAddress()](usage/application/core/generateToAddress.md)
9
+ - [.getBestBlockHash()](usage/application/core/getBestBlockHash.md)
10
+ - [.getBlockByHash()](usage/application/core/getBlockByHash.md)
11
+ - [.getBlockByHeight()](usage/application/core/getBlockByHeight.md)
12
+ - [.getBlockHash()](usage/application/core/getBlockHash.md)
13
+ - [.getMnListDiff()](usage/application/core/getMnListDiff.md)
14
+ - [.getStatus()](usage/application/core/getStatus.md)
15
+ - [.getTransaction()](usage/application/core/getTransaction.md)
16
+ - [.subscribeToTransactionsWithProofs()](usage/application/core/subscribeToTransactionsWithProofs.md)
17
+ - Platform
18
+ - [.broadcastStateTransition()](usage/application/platform/broadcastStateTransition.md)
19
+ - [.getDataContract()](usage/application/platform/getDataContract.md)
20
+ - [.getDocuments()](usage/application/platform/getDocuments.md)
21
+ - [.getIdentityByFirstPublicKey()](usage/application/platform/getIdentityByFirstPublicKey.md)
22
+ - [.getIdentity()](usage/application/platform/getIdentity.md)
23
+ - [.getIdentityIdByFirstPublicKey()](usage/application/platform/getIdentityIdByFirstPublicKey.md)
18
24
  - [License](https://github.com/dashevo/dapi-client/blob/master/LICENSE)
@@ -1,6 +1,6 @@
1
1
  # Quick start
2
2
 
3
- ### ES5/ES6 via NPM
3
+ ## ES5/ES6 via NPM
4
4
 
5
5
  In order to use this library in Node, you will need to add it to your project as a dependency.
6
6
 
@@ -10,7 +10,7 @@ Having [NodeJS](https://nodejs.org/) installed, just type in your terminal :
10
10
  npm install @dashevo/dapi-client
11
11
  ```
12
12
 
13
- ### CDN Standalone
13
+ ## CDN Standalone
14
14
 
15
15
  For browser usage, you can also directly rely on unpkg :
16
16
 
@@ -18,6 +18,8 @@ For browser usage, you can also directly rely on unpkg :
18
18
  <script src="https://unpkg.com/@dashevo/dapi-client"></script>
19
19
  ```
20
20
 
21
+ You can see an [example usage here](https://github.com/dashevo/js-dapi-client/blob/master/examples/web/web.usage.html)
22
+
21
23
  ## Initialization
22
24
 
23
25
  ```js
@@ -0,0 +1,29 @@
1
+ **Usage**: `new DAPIClient(options)`
2
+ **Description**: This method creates a new DAPIClient instance.
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required[def value] | Description |
7
+ |-------------------------------------------|---------------------|-----------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
8
+ | **options** | Object | | |
9
+ | **options.dapiAddressProvider** | DAPIAddressProvider | no[ListDAPIAddressProvider] | Allow to override the default dapiAddressProvider (do not allow seeds or dapiAddresses params) |
10
+ | **options.seeds** | string[] | no[seeds] | Allow to override default seeds (to connect to specific node) |
11
+ | **options.network** | string|Network | no[=evonet] | Allow to setup the network to be used (livenet, testnet, evonet,..) |
12
+ | **options.timeout** | number | no[=2000] | Used to specify the timeout time in milliseconds. |
13
+ | **options.retries** | number | no[=3] | Used to specify the number of retries before aborting and erroring a request. |
14
+ | **options.baseBanTime** | number | no[=6000] | |
15
+
16
+ Returns : DAPIClient instance.
17
+
18
+ ```js
19
+ const DAPIClient = require('@dashevo/dapi-client');
20
+ const client = new DAPIClient({
21
+ timeout: 5000,
22
+ retries: 3,
23
+ network: 'livenet'
24
+ });
25
+ ```
26
+
27
+ **Notes**:
28
+ - Accessing the SimplifiedMasternodeListDAPIAddressProvider (or its overwrote instance), can be accessed via `client.dapiAddressProvider`.
29
+
@@ -0,0 +1,15 @@
1
+ **Usage**: `await client.core.broadcastTransaction(transaction)`
2
+ **Description**: Allow to broadcast a valid **signed** transaction to the network.
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |---------------------------|---------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
+ | **transaction** | Buffer | yes | A valid Buffer representation of a transaction |
9
+ | **options** | Object | | |
10
+ | **options.allowHighFees** | Boolean | no[=false] | As safety measure, "absurd" fees are rejected when considered to high. This allow to overwrite that comportement |
11
+ | **options.bypassLimits** | Boolean | no[=false] | Allow to bypass default transaction policy rules limitation |
12
+
13
+ Returns : transactionId (string).
14
+
15
+ N.B : The TransactionID provided is subject to [transaction malleability](https://dashcore.readme.io/docs/core-guide-transactions-transaction-malleability), and is not a source of truth (the transaction might be included in a block with a different txid).
@@ -0,0 +1,13 @@
1
+ **Usage**: `await client.core.generateToAddress(blockMumber, address, options)`
2
+ **Description**: Allow to broadcast a valid **signed** transaction to the network.
3
+ **Notes**: Will only works on regtest.
4
+
5
+ Parameters:
6
+
7
+ | parameters | type | required | Description |
8
+ |---------------------------|---------------------|----------------| ------------------------------------------------------------------------------------------------ |
9
+ | **blocksNumber** | Number | yes | A number of block to see generated on the regtest network |
10
+ | **address** | String | yes | The address that will receive the newly generated Dash |
11
+ | **options** | DAPIClientOptions | no | |
12
+
13
+ Returns : {Promise<string[]>} - a set of generated blockhashes.
@@ -0,0 +1,10 @@
1
+ **Usage**: `await client.core.getBestBlockHash(options)`
2
+ **Description**: Allow to fetch the best (highest/latest block hash) from the network
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |---------------------------|---------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
+ | **options** | DAPIClientOptions | no | |
9
+
10
+ Returns : {Promise<string>} - The best block hash
@@ -0,0 +1,11 @@
1
+ **Usage**: `await client.core.getBlockByHash(hash, options)`
2
+ **Description**: Allow to fetch a specific block by its hash
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |---------------------------|---------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
+ | **hash** | String | yes | A valid block hash |
9
+ | **options** | DAPIClientOptions | no | |
10
+
11
+ Returns : {Promise<null|Buffer>} - The specified bufferized block
@@ -0,0 +1,11 @@
1
+ **Usage**: `await client.core.getBlockByHeight(height, options)`
2
+ **Description**: Allow to fetch a specific block by its height
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |---------------------------|---------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
+ | **height** | Number | yes | A valid block height |
9
+ | **options** | DAPIClientOptions | no | |
10
+
11
+ Returns : {Promise<null|Buffer>} - The specified bufferized block
@@ -0,0 +1,11 @@
1
+ **Usage**: `await client.core.getBlockHash(height, options)`
2
+ **Description**: Allow to fetch a specific block hash from its height
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |---------------------------|---------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
+ | **height** | Number | yes | A valid block height |
9
+ | **options** | DAPIClientOptions | no | |
10
+
11
+ Returns : {Promise<null|string>} - the corresponding block hash
@@ -0,0 +1,12 @@
1
+ **Usage**: `await client.core.getMnListDiff(baseBlockHash, blockHash, options)`
2
+ **Description**: Allow to fetch a specific block hash from its height
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |---------------------------|---------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
+ | **baseBlockHash** | String | yes | hash or height of start block |
9
+ | **blockHash** | String | yes | hash or height of end block |
10
+ | **options** | DAPIClientOptions | no | |
11
+
12
+ Returns : {Promise<object>} - The Masternode List Diff of the specified period
@@ -0,0 +1,29 @@
1
+ **Usage**: `await client.core.getStatus(options)`
2
+ **Description**: Allow to fetch a specific block hash from its height
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |---------------------------|---------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
+ | **options** | DAPIClientOptions | no | |
9
+
10
+ Returns : {Promise<object>} - Status object
11
+
12
+ ```js
13
+ const status = await client.core.getStatus()
14
+ /**
15
+ {
16
+ coreVersion: 150000,
17
+ protocolVersion: 70216,
18
+ blocks: 10630,
19
+ timeOffset: 0,
20
+ connections: 58,
21
+ proxy: '',
22
+ difficulty: 0.001745769130443678,
23
+ testnet: false,
24
+ relayFee: 0.00001,
25
+ errors: '',
26
+ network: 'testnet'
27
+ }
28
+ **/
29
+ ```
@@ -0,0 +1,11 @@
1
+ **Usage**: `await client.core.getTransaction(id, options)`
2
+ **Description**: Allow to fetch a transaction by ID
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |---------------------------|---------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
+ | **id** | string | yes | A valid transaction id to fetch |
9
+ | **options** | DAPIClientOptions | no | |
10
+
11
+ Returns : {Promise<null|Buffer>} - The bufferized transaction
@@ -0,0 +1,11 @@
1
+ **Usage**: `async client.platform.broadcastStateTransition(stateTransition, options)`
2
+ **Description**: Send State Transition to machine
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |------------------------|-------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
+ | **stateTransition** | Buffer | yes | A valid bufferized state transition |
9
+ | **options** | DAPIClientOptions | no | A valid state transition |
10
+
11
+ Returns : Promise<!BroadcastStateTransitionResponse>
@@ -1,4 +1,4 @@
1
- **Usage**: `async client.core.subscribeToTransactionsWithProofs(bloomFilter, options = { count: 0 })`\
1
+ **Usage**: `await client.core.subscribeToTransactionsWithProofs(bloomFilter, options = { count: 0 })`\
2
2
  **Description**: For any provided bloomfilter, it will return a ClientReadableStream streaming the transaction matching the filter.
3
3
 
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dapi-client",
3
- "version": "0.21.6",
3
+ "version": "0.22.0-dev.3",
4
4
  "description": "Client library used to access Dash DAPI endpoints",
5
5
  "main": "lib/DAPIClient.js",
6
6
  "contributors": [
@@ -26,10 +26,10 @@
26
26
  }
27
27
  ],
28
28
  "dependencies": {
29
- "@dashevo/dapi-grpc": "~0.21.6",
29
+ "@dashevo/dapi-grpc": "~0.22.0-dev.3",
30
30
  "@dashevo/dashcore-lib": "~0.19.28",
31
- "@dashevo/dpp": "~0.21.6",
32
- "@dashevo/grpc-common": "~0.21.6",
31
+ "@dashevo/dpp": "~0.22.0-dev.3",
32
+ "@dashevo/grpc-common": "~0.22.0-dev.3",
33
33
  "@grpc/grpc-js": "^1.3.7",
34
34
  "axios": "^0.21.1",
35
35
  "bs58": "^4.0.1",
@@ -1,11 +0,0 @@
1
- **Usage**: `async client.platform.applyStateTransition(stateTransition)`
2
- **Description**: Send State Transition to machine
3
-
4
- Parameters:
5
-
6
- | parameters | type | required | Description |
7
- |------------------------|------------------------------------------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
- | **stateTransition** | DataContractStateTransition/DocumentsStateTransition | yes | A valid state transition |
9
-
10
- Returns : Promise<!ApplyStateTransitionResponse>
11
-
@@ -1,10 +0,0 @@
1
- **Usage**: `async client.core.getBestBlockHash()`
2
- **Description**: Returns block hash of chaintip
3
-
4
- Parameters:
5
-
6
- | parameters | type | required | Description |
7
- |------------------------|--------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
-
9
- Returns : Promise<string>
10
-
@@ -1,11 +0,0 @@
1
- **Usage**: `client.core.getBlockHash(height)`
2
- **Description**: Returns block hash for the given height
3
-
4
- Parameters:
5
-
6
- | parameters | type | required | Description |
7
- |------------------------|--------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
- | **height** | Number | yes | Any valid height value |
9
-
10
- Returns : Promise<string>
11
-
@@ -1,15 +0,0 @@
1
- **Usage**: `async client.core.getUTXO(address, from, to, fromHeight, toHeight)`
2
- **Description**: Returns UTXO for a given address or multiple addresses (max result 1000)
3
-
4
- Parameters:
5
-
6
- | parameters | type | required | Description |
7
- |------------------------|--------------------|----------------| ------------------------------------------------------------------------------------------------ |
8
- | **address** | String/[String] | yes | address or array of addresses |
9
- | **from** | Number | no | start of range in the ordered list of latest UTXO |
10
- | **to** | Number | no | end of range in the ordered list of latest UTXO |
11
- | **fromHeight** | Number | no | which height to start from (optional, overriding from/to) |
12
- | **toHeight** | Number | no | on which height to end (optional, overriding from/to) |
13
-
14
- Returns : Promise<object> - Object with pagination info and array of unspent outputs
15
-
@@ -1,12 +0,0 @@
1
- **Usage**: `async client.core.getMnListDiff(baseBlockHash, blockHash)`
2
- **Description**: Get deterministic masternodelist diff
3
-
4
- Parameters:
5
-
6
- | parameters | type | required | Description |
7
- |------------------------|--------|----------------| ------------------------------------------------------------------------------------------------ |
8
- | **baseBlockHash** | String | yes | Hash or height of start block |
9
- | **blockHash** | String | yes | Hash or height of end block |
10
-
11
- Returns : Promise<object>
12
-