@dashevo/dapi-client 0.21.6 → 0.22.0-dev.6
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/README.md +3 -3
- package/docs/_sidebar.md +20 -14
- package/docs/getting-started/quickstart.md +4 -2
- package/docs/usage/application/DAPIClient.md +29 -0
- package/docs/usage/application/core/broadcastTransaction.md +15 -0
- package/docs/usage/application/core/generateToAddress.md +13 -0
- package/docs/usage/application/core/getBestBlockHash.md +10 -0
- package/docs/usage/application/core/getBlockByHash.md +11 -0
- package/docs/usage/application/core/getBlockByHeight.md +11 -0
- package/docs/usage/application/core/getBlockHash.md +11 -0
- package/docs/usage/application/core/getMnListDiff.md +12 -0
- package/docs/usage/application/core/getStatus.md +29 -0
- package/docs/usage/application/core/getTransaction.md +11 -0
- package/docs/usage/application/platform/broadcastStateTransition.md +11 -0
- package/docs/usage/utils/subscribeToTransactionsWithProofs.md +1 -1
- package/lib/methods/core/CoreMethodsFacade.js +4 -0
- package/lib/methods/core/subscribeToBlockHeadersWithChainLocksFactory.js +69 -0
- package/lib/methods/platform/getIdentitiesByPublicKeyHashes/GetIdentitiesByPublicKeyHashesResponse.js +10 -3
- package/lib/methods/platform/getIdentityIdsByPublicKeyHashes/GetIdentityIdsByPublicKeyHashesResponse.js +10 -3
- package/package.json +4 -4
- package/docs/usage/application/applyStateTransition.md +0 -11
- package/docs/usage/payment/getBestBlockHash.md +0 -10
- package/docs/usage/payment/getBlockHash.md +0 -11
- package/docs/usage/payment/getUTXO.md +0 -15
- package/docs/usage/utils/getMnListDiff.md +0 -12
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Platform via the decentralized API ([DAPI](https://github.com/dashevo/dapi))
|
|
|
12
12
|
hosted on Dash masternodes.
|
|
13
13
|
|
|
14
14
|
- `DAPI-Client` provides automatic server (masternode) discovery using either a default seed node or a user-supplied one
|
|
15
|
-
- `DAPI-Client` maps to DAPI's [RPC](https://github.com/dashevo/
|
|
15
|
+
- `DAPI-Client` maps to DAPI's [RPC](https://github.com/dashevo/platform/tree/master/packages/dapi/lib/rpcServer/commands) and [gRPC](https://github.com/dashevo/platform/tree/master/packages/dapi/lib/grpcServer/handlers) endpoints
|
|
16
16
|
|
|
17
17
|
## Table of Contents
|
|
18
18
|
- [Install](#install)
|
|
@@ -101,12 +101,12 @@ client.core.getBestBlockHash(options).then((r) => {
|
|
|
101
101
|
|
|
102
102
|
## Documentation
|
|
103
103
|
|
|
104
|
-
More extensive documentation available at https://dashevo.github.io/
|
|
104
|
+
More extensive documentation available at https://dashevo.github.io/platform/DAPI-Client/.
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
## Contributing
|
|
108
108
|
|
|
109
|
-
Feel free to dive in! [Open an issue](https://github.com/dashevo/
|
|
109
|
+
Feel free to dive in! [Open an issue](https://github.com/dashevo/platform/issues/new/choose) or submit PRs.
|
|
110
110
|
|
|
111
111
|
## License
|
|
112
112
|
|
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
|
-
-
|
|
5
|
-
- [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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**: `
|
|
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
|
|
|
@@ -8,6 +8,7 @@ const getMnListDiffFactory = require('./getMnListDiffFactory');
|
|
|
8
8
|
const getStatusFactory = require('./getStatusFactory');
|
|
9
9
|
const getTransactionFactory = require('./getTransaction/getTransactionFactory');
|
|
10
10
|
const subscribeToTransactionsWithProofsFactory = require('./subscribeToTransactionsWithProofsFactory');
|
|
11
|
+
const subscribeToBlockHeadersWithChainLocksFactory = require('./subscribeToBlockHeadersWithChainLocksFactory');
|
|
11
12
|
|
|
12
13
|
class CoreMethodsFacade {
|
|
13
14
|
/**
|
|
@@ -27,6 +28,9 @@ class CoreMethodsFacade {
|
|
|
27
28
|
this.subscribeToTransactionsWithProofs = subscribeToTransactionsWithProofsFactory(
|
|
28
29
|
grpcTransport,
|
|
29
30
|
);
|
|
31
|
+
this.subscribeToBlockHeadersWithChainLocks = subscribeToBlockHeadersWithChainLocksFactory(
|
|
32
|
+
grpcTransport,
|
|
33
|
+
);
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const {
|
|
2
|
+
v0: {
|
|
3
|
+
BlockHeadersWithChainLocksRequest,
|
|
4
|
+
CorePromiseClient,
|
|
5
|
+
},
|
|
6
|
+
} = require('@dashevo/dapi-grpc');
|
|
7
|
+
|
|
8
|
+
const DAPIClientError = require('../../errors/DAPIClientError');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {GrpcTransport} grpcTransport
|
|
12
|
+
* @returns {subscribeToBlockHeadersWithChainLocks}
|
|
13
|
+
*/
|
|
14
|
+
function subscribeToBlockHeadersWithChainLocksFactory(grpcTransport) {
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {subscribeToBlockHeadersWithChainLocks}
|
|
17
|
+
* @param {DAPIClientOptions & subscribeToBlockHeadersWithChainLocksOptions} [options]
|
|
18
|
+
* @returns {
|
|
19
|
+
* EventEmitter|!grpc.web.ClientReadableStream<!BlockHeadersWithChainLocksResponse>
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
async function subscribeToBlockHeadersWithChainLocks(options = { }) {
|
|
23
|
+
// eslint-disable-next-line no-param-reassign
|
|
24
|
+
options = {
|
|
25
|
+
count: 0,
|
|
26
|
+
// Override global timeout option
|
|
27
|
+
// and timeout for this method by default
|
|
28
|
+
timeout: undefined,
|
|
29
|
+
...options,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (options.fromBlockHeight === 0) {
|
|
33
|
+
throw new DAPIClientError('Invalid argument: minimum value for `fromBlockHeight` is 1');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const request = new BlockHeadersWithChainLocksRequest();
|
|
37
|
+
|
|
38
|
+
if (options.fromBlockHeight !== undefined) {
|
|
39
|
+
request.setFromBlockHeight(options.fromBlockHeight);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (options.fromBlockHash) {
|
|
43
|
+
request.setFromBlockHash(
|
|
44
|
+
Buffer.from(options.fromBlockHash, 'hex'),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
request.setCount(options.count);
|
|
49
|
+
|
|
50
|
+
return grpcTransport.request(
|
|
51
|
+
CorePromiseClient,
|
|
52
|
+
'subscribeToBlockHeadersWithChainLocks',
|
|
53
|
+
request,
|
|
54
|
+
options,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return subscribeToBlockHeadersWithChainLocks;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @typedef {object} subscribeToBlockHeadersWithChainLocksOptions
|
|
63
|
+
* @property {string} [fromBlockHash] - Specifies block hash to start syncing from
|
|
64
|
+
* @property {number} [fromBlockHeight] - Specifies block height to start syncing from
|
|
65
|
+
* @property {number} [count=0] - Number of blocks to sync,
|
|
66
|
+
* if set to 0 syncing is continuously sends new data as well
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
module.exports = subscribeToBlockHeadersWithChainLocksFactory;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const cbor = require('cbor');
|
|
2
|
+
|
|
1
3
|
const AbstractResponse = require('../response/AbstractResponse');
|
|
2
4
|
|
|
3
5
|
class GetIdentitiesByPublicKeyHashesResponse extends AbstractResponse {
|
|
@@ -13,7 +15,7 @@ class GetIdentitiesByPublicKeyHashesResponse extends AbstractResponse {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
|
-
* @returns {Buffer[]}
|
|
18
|
+
* @returns {Array<Buffer[]>}
|
|
17
19
|
*/
|
|
18
20
|
getIdentities() {
|
|
19
21
|
return this.identities;
|
|
@@ -27,8 +29,13 @@ class GetIdentitiesByPublicKeyHashesResponse extends AbstractResponse {
|
|
|
27
29
|
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
28
30
|
|
|
29
31
|
return new GetIdentitiesByPublicKeyHashesResponse(
|
|
30
|
-
proto.getIdentitiesList()
|
|
31
|
-
|
|
32
|
+
proto.getIdentitiesList().map((identitiesSerialized) => {
|
|
33
|
+
const identities = cbor.decode(identitiesSerialized);
|
|
34
|
+
|
|
35
|
+
return identities.map((identity) => (
|
|
36
|
+
(identity.length > 0 ? Buffer.from(identity) : null)
|
|
37
|
+
));
|
|
38
|
+
}),
|
|
32
39
|
metadata,
|
|
33
40
|
proof,
|
|
34
41
|
);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const cbor = require('cbor');
|
|
2
|
+
|
|
1
3
|
const AbstractResponse = require('../response/AbstractResponse');
|
|
2
4
|
|
|
3
5
|
class GetIdentityIdsByPublicKeyHashesResponse extends AbstractResponse {
|
|
@@ -13,7 +15,7 @@ class GetIdentityIdsByPublicKeyHashesResponse extends AbstractResponse {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
|
-
* @returns {Buffer[]}
|
|
18
|
+
* @returns {Array<Buffer[]>}
|
|
17
19
|
*/
|
|
18
20
|
getIdentityIds() {
|
|
19
21
|
return this.identityIds;
|
|
@@ -27,8 +29,13 @@ class GetIdentityIdsByPublicKeyHashesResponse extends AbstractResponse {
|
|
|
27
29
|
const { metadata, proof } = AbstractResponse.createMetadataAndProofFromProto(proto);
|
|
28
30
|
|
|
29
31
|
return new GetIdentityIdsByPublicKeyHashesResponse(
|
|
30
|
-
proto.getIdentityIdsList()
|
|
31
|
-
|
|
32
|
+
proto.getIdentityIdsList().map((identityIdsSerialized) => {
|
|
33
|
+
const identityIds = cbor.decode(identityIdsSerialized);
|
|
34
|
+
|
|
35
|
+
return identityIds.map((identityId) => (
|
|
36
|
+
(identityId.length > 0 ? Buffer.from(identityId) : null)
|
|
37
|
+
));
|
|
38
|
+
}),
|
|
32
39
|
metadata,
|
|
33
40
|
proof,
|
|
34
41
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/dapi-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0-dev.6",
|
|
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.
|
|
29
|
+
"@dashevo/dapi-grpc": "~0.22.0-dev.6",
|
|
30
30
|
"@dashevo/dashcore-lib": "~0.19.28",
|
|
31
|
-
"@dashevo/dpp": "~0.
|
|
32
|
-
"@dashevo/grpc-common": "~0.
|
|
31
|
+
"@dashevo/dpp": "~0.22.0-dev.6",
|
|
32
|
+
"@dashevo/grpc-common": "~0.22.0-dev.6",
|
|
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
|
-
|