From 379c42483a2536ab5ad1ea49e83f79a7261db840 Mon Sep 17 00:00:00 2001 From: thephez Date: Wed, 30 Aug 2023 16:48:37 -0400 Subject: [PATCH 1/6] docs: import from readme backup --- docs/dapi-client-js/overview.md | 37 ++++++++++++++++ docs/dapi-client-js/quick-start.md | 37 ++++++++++++++++ .../usage/core/broadcasttransaction.md | 17 +++++++ docs/dapi-client-js/usage/core/core.md | 31 +++++++++++++ .../usage/core/generatetoaddress.md | 15 +++++++ .../usage/core/getbestblockhash.md | 10 +++++ .../usage/core/getblockbyhash.md | 11 +++++ .../usage/core/getblockbyheight.md | 11 +++++ .../dapi-client-js/usage/core/getblockhash.md | 11 +++++ .../usage/core/getmnlistdiff.md | 12 +++++ docs/dapi-client-js/usage/core/getstatus.md | 29 ++++++++++++ .../usage/core/gettransaction.md | 11 +++++ .../core/subscribetotransactionswithproofs.md | 44 +++++++++++++++++++ .../platform/broadcaststatetransition.md | 11 +++++ .../usage/platform/getdatacontract.md | 10 +++++ .../usage/platform/getdocuments.md | 16 +++++++ .../usage/platform/getidentity.md | 10 +++++ .../platform/getidentitybyfirstpublickey.md | 10 +++++ .../platform/getidentityidbyfirstpublickey.md | 10 +++++ .../dapi-client-js/usage/platform/platform.md | 29 ++++++++++++ 20 files changed, 372 insertions(+) create mode 100644 docs/dapi-client-js/overview.md create mode 100644 docs/dapi-client-js/quick-start.md create mode 100644 docs/dapi-client-js/usage/core/broadcasttransaction.md create mode 100644 docs/dapi-client-js/usage/core/core.md create mode 100644 docs/dapi-client-js/usage/core/generatetoaddress.md create mode 100644 docs/dapi-client-js/usage/core/getbestblockhash.md create mode 100644 docs/dapi-client-js/usage/core/getblockbyhash.md create mode 100644 docs/dapi-client-js/usage/core/getblockbyheight.md create mode 100644 docs/dapi-client-js/usage/core/getblockhash.md create mode 100644 docs/dapi-client-js/usage/core/getmnlistdiff.md create mode 100644 docs/dapi-client-js/usage/core/getstatus.md create mode 100644 docs/dapi-client-js/usage/core/gettransaction.md create mode 100644 docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.md create mode 100644 docs/dapi-client-js/usage/platform/broadcaststatetransition.md create mode 100644 docs/dapi-client-js/usage/platform/getdatacontract.md create mode 100644 docs/dapi-client-js/usage/platform/getdocuments.md create mode 100644 docs/dapi-client-js/usage/platform/getidentity.md create mode 100644 docs/dapi-client-js/usage/platform/getidentitybyfirstpublickey.md create mode 100644 docs/dapi-client-js/usage/platform/getidentityidbyfirstpublickey.md create mode 100644 docs/dapi-client-js/usage/platform/platform.md diff --git a/docs/dapi-client-js/overview.md b/docs/dapi-client-js/overview.md new file mode 100644 index 000000000..fdfc96efa --- /dev/null +++ b/docs/dapi-client-js/overview.md @@ -0,0 +1,37 @@ +## DAPI-Client + +[![NPM Version](https://img.shields.io/npm/v/@dashevo/dapi-client)](https://www.npmjs.com/package/@dashevo/dapi-client) +[![Build Status](https://github.com/dashevo/js-dapi-client/actions/workflows/test_and_release.yml/badge.svg)](https://github.com/dashevo/js-dapi-client/actions/workflows/test_and_release.yml) +[![Release Date](https://img.shields.io/github/release-date/dashpay/platform)](https://github.com/dashpay/platform/releases/latest) +[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen)](https://github.com/RichardLitt/standard-readme) + +Client library used to access Dash DAPI endpoints + +This library enables HTTP-based interaction with the Dash blockchain and Dash Platform via the decentralized API ([DAPI](https://github.com/dashpay/platform/tree/master/packages/dapi)) hosted on Dash masternodes. + +- `DAPI-Client` provides automatic server (masternode) discovery using either a default seed node or a user-supplied one +- `DAPI-Client` maps to DAPI's [RPC](https://github.com/dashpay/platform/tree/master/packages/dapi/lib/rpcServer/commands) and [gRPC](https://github.com/dashpay/platform/tree/master/packages/dapi/lib/grpcServer/handlers) endpoints + +### Install + +### ES5/ES6 via NPM + +In order to use this library in Node, you will need to add it to your project as a dependency. + +Having [NodeJS](https://nodejs.org/) installed, just type in your terminal : + +```sh +npm install @dashevo/dapi-client +``` + +### CDN Standalone + +For browser usage, you can also directly rely on unpkg : + +``` + +``` + +## Licence + +[MIT](https://github.com/dashevo/dapi-client/blob/master/LICENCE.md) © Dash Core Group, Inc. \ No newline at end of file diff --git a/docs/dapi-client-js/quick-start.md b/docs/dapi-client-js/quick-start.md new file mode 100644 index 000000000..411e04d37 --- /dev/null +++ b/docs/dapi-client-js/quick-start.md @@ -0,0 +1,37 @@ +# Quick start + +## ES5/ES6 via NPM + +In order to use this library in Node, you will need to add it to your project as a dependency. + +Having [NodeJS](https://nodejs.org/) installed, just type in your terminal : + +```sh +npm install @dashevo/dapi-client +``` + +## CDN Standalone + +For browser usage, you can also directly rely on unpkg : + +``` + +``` + +You can see an [example usage here](https://github.com/dashpay/platform/blob/master/packages/js-dapi-client/examples/web/web.usage.html) . + +## Initialization + +```js +const DAPIClient = require('@dashevo/dapi-client'); +const client = new DAPIClient(); + +(async () => { + const bestBlockHash = await client.core.getBestBlockHash(); + console.log(bestBlockHash); +})(); +``` + +## Quicknotes + +This package allows you to fetch & send information from both the payment chain (layer 1) and the application chain (layer 2, a.k.a Platform chain). \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/broadcasttransaction.md b/docs/dapi-client-js/usage/core/broadcasttransaction.md new file mode 100644 index 000000000..49cabc979 --- /dev/null +++ b/docs/dapi-client-js/usage/core/broadcasttransaction.md @@ -0,0 +1,17 @@ +# broadcasttransaction + +**Usage**: `await client.core.broadcastTransaction(transaction)` +**Description**: Allow to broadcast a valid **signed** transaction to the network. + +Parameters: + +| parameters | type | required | Description | +| ------------------------- | ------- | ---------- | ---------------------------------------------------------------------------------------------------------------- | +| **transaction** | Buffer | yes | A valid Buffer representation of a transaction | +| **options** | Object | | | +| **options.allowHighFees** | Boolean | no[=false] | As safety measure, "absurd" fees are rejected when considered to high. This allow to overwrite that comportement | +| **options.bypassLimits** | Boolean | no[=false] | Allow to bypass default transaction policy rules limitation | + +Returns : transactionId (string). + +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). \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/core.md b/docs/dapi-client-js/usage/core/core.md new file mode 100644 index 000000000..25366b81a --- /dev/null +++ b/docs/dapi-client-js/usage/core/core.md @@ -0,0 +1,31 @@ +# Core + +**Usage**: `new DAPIClient(options)` +**Description**: This method creates a new DAPIClient instance. + +Parameters: + +| parameters | type | required[def value] | Description | +| :------------------------------ | :------------------ | :-------------------------- | :--------------------------------------------------------------------------------------------- | +| **options** | Object | | | +| **options.dapiAddressProvider** | DAPIAddressProvider | no[ListDAPIAddressProvider] | Allow to override the default dapiAddressProvider (do not allow seeds or dapiAddresses params) | +| **options.seeds** | string\[] | no[seeds] | Allow to override default seeds (to connect to specific node) | +| **options.network** | string | no[=evonet] | Allow to setup the network to be used (livenet, testnet, evonet,..) | +| **options.timeout** | number | no[=2000] | Used to specify the timeout time in milliseconds. | +| **options.retries** | number | no[=3] | Used to specify the number of retries before aborting and erroring a request. | +| **options.baseBanTime** | number | no[=6000] | | + +Returns : DAPIClient instance. + +```js +const DAPIClient = require('@dashevo/dapi-client'); +const client = new DAPIClient({ + timeout: 5000, + retries: 3, + network: 'livenet' +}); +``` + +**Notes**: + +- Accessing the SimplifiedMasternodeListDAPIAddressProvider (or its overwrote instance), can be accessed via `client.dapiAddressProvider`. diff --git a/docs/dapi-client-js/usage/core/generatetoaddress.md b/docs/dapi-client-js/usage/core/generatetoaddress.md new file mode 100644 index 000000000..5e94781d5 --- /dev/null +++ b/docs/dapi-client-js/usage/core/generatetoaddress.md @@ -0,0 +1,15 @@ +# generatetoaddress + +**Usage**: `await client.core.generateToAddress(blockMumber, address, options)` +**Description**: Allow to broadcast a valid **signed** transaction to the network. +**Notes**: Will only works on regtest. + +Parameters: + +| parameters | type | required | Description | +| ---------------- | ----------------- | -------- | --------------------------------------------------------- | +| **blocksNumber** | Number | yes | A number of block to see generated on the regtest network | +| **address** | String | yes | The address that will receive the newly generated Dash | +| **options** | DAPIClientOptions | no | | + +Returns : {Promise\} - a set of generated blockhashes. \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/getbestblockhash.md b/docs/dapi-client-js/usage/core/getbestblockhash.md new file mode 100644 index 000000000..6a554f849 --- /dev/null +++ b/docs/dapi-client-js/usage/core/getbestblockhash.md @@ -0,0 +1,10 @@ +**Usage**: `await client.core.getBestBlockHash(options)` +**Description**: Allow to fetch the best (highest/latest block hash) from the network + +Parameters: + +| parameters | type | required | Description | +| ----------- | ----------------- | -------- | ----------- | +| **options** | DAPIClientOptions | no | | + +Returns : {Promise} - The best block hash \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/getblockbyhash.md b/docs/dapi-client-js/usage/core/getblockbyhash.md new file mode 100644 index 000000000..cc8a92a32 --- /dev/null +++ b/docs/dapi-client-js/usage/core/getblockbyhash.md @@ -0,0 +1,11 @@ +**Usage**: `await client.core.getBlockByHash(hash, options)` +**Description**: Allow to fetch a specific block by its hash + +Parameters: + +| parameters | type | required | Description | +| ----------- | ----------------- | -------- | ------------------ | +| **hash** | String | yes | A valid block hash | +| **options** | DAPIClientOptions | no | | + +Returns : {Promise\} - The specified bufferized block \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/getblockbyheight.md b/docs/dapi-client-js/usage/core/getblockbyheight.md new file mode 100644 index 000000000..3b44d8299 --- /dev/null +++ b/docs/dapi-client-js/usage/core/getblockbyheight.md @@ -0,0 +1,11 @@ +**Usage**: `await client.core.getBlockByHeight(height, options)` +**Description**: Allow to fetch a specific block by its height + +Parameters: + +| parameters | type | required | Description | +| ----------- | ----------------- | -------- | -------------------- | +| **height** | Number | yes | A valid block height | +| **options** | DAPIClientOptions | no | | + +Returns : {Promise\} - The specified bufferized block \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/getblockhash.md b/docs/dapi-client-js/usage/core/getblockhash.md new file mode 100644 index 000000000..bd6512580 --- /dev/null +++ b/docs/dapi-client-js/usage/core/getblockhash.md @@ -0,0 +1,11 @@ +**Usage**: `await client.core.getBlockHash(height, options)` +**Description**: Allow to fetch a specific block hash from its height + +Parameters: + +| parameters | type | required | Description | +| ----------- | ----------------- | -------- | -------------------- | +| **height** | Number | yes | A valid block height | +| **options** | DAPIClientOptions | no | | + +Returns : {Promise\} - the corresponding block hash \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/getmnlistdiff.md b/docs/dapi-client-js/usage/core/getmnlistdiff.md new file mode 100644 index 000000000..7f87f35f1 --- /dev/null +++ b/docs/dapi-client-js/usage/core/getmnlistdiff.md @@ -0,0 +1,12 @@ +**Usage**: `await client.core.getMnListDiff(baseBlockHash, blockHash, options)` +**Description**: Allow to fetch a specific block hash from its height + +Parameters: + +| parameters | type | required | Description | +| ----------------- | ----------------- | -------- | ----------------------------- | +| **baseBlockHash** | String | yes | hash or height of start block | +| **blockHash** | String | yes | hash or height of end block | +| **options** | DAPIClientOptions | no | | + +Returns : {Promise} - The Masternode List Diff of the specified period \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/getstatus.md b/docs/dapi-client-js/usage/core/getstatus.md new file mode 100644 index 000000000..ffe3f9a24 --- /dev/null +++ b/docs/dapi-client-js/usage/core/getstatus.md @@ -0,0 +1,29 @@ +**Usage**: `await client.core.getStatus(options)` +**Description**: Allow to fetch a specific block hash from its height + +Parameters: + +| parameters | type | required | Description | +| ----------- | ----------------- | -------- | ----------- | +| **options** | DAPIClientOptions | no | | + +Returns : {Promise} - Status object + +```js +const status = await client.core.getStatus() +/** +{ + coreVersion: 150000, + protocolVersion: 70216, + blocks: 10630, + timeOffset: 0, + connections: 58, + proxy: '', + difficulty: 0.001745769130443678, + testnet: false, + relayFee: 0.00001, + errors: '', + network: 'testnet' +} +**/ +``` \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/gettransaction.md b/docs/dapi-client-js/usage/core/gettransaction.md new file mode 100644 index 000000000..ad0ea7a0c --- /dev/null +++ b/docs/dapi-client-js/usage/core/gettransaction.md @@ -0,0 +1,11 @@ +**Usage**: `await client.core.getTransaction(id, options)` +**Description**: Allow to fetch a transaction by ID + +Parameters: + +| parameters | type | required | Description | +| ----------- | ----------------- | -------- | ------------------------------- | +| **id** | string | yes | A valid transaction id to fetch | +| **options** | DAPIClientOptions | no | | + +Returns : {Promise\} - The bufferized transaction \ No newline at end of file diff --git a/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.md b/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.md new file mode 100644 index 000000000..c1b94b30f --- /dev/null +++ b/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.md @@ -0,0 +1,44 @@ +**Usage**: `await client.core.subscribeToTransactionsWithProofs(bloomFilter, options = { count: 0 })` +**Description**: For any provided bloomfilter, it will return a ClientReadableStream streaming the transaction matching the filter. + +Parameters: + +| parameters | type | required | Description | +| --------------------------- | ---------------- | --------------- | --------------------------------------------------------------------------------------------------------- | +| **bloomFilter.vData** | Uint8Array/Array | yes | The filter itself is simply a bit field of arbitrary byte-aligned size. The maximum size is 36,000 bytes. | +| **bloomFilter.nHashFuncs** | Number | yes | The number of hash functions to use in this filter. The maximum value allowed in this field is 50. | +| **bloomFilter.nTweak** | Number | yes | A random value to add to the seed value in the hash function used by the bloom filter. | +| **bloomFilter.nFlags** | Number | yes | A set of flags that control how matched items are added to the filter. | +| **options.fromBlockHash** | String | yes | Specifies block hash to start syncing from | +| **options.fromBlockHeight** | Number | yes | Specifies block height to start syncing from | +| **options.count** | Number | no (default: 0) | Number of blocks to sync, if set to 0 syncing is continuously sends new data as well | + +Returns : Promise|!grpc.web.ClientReadableStream\ + +Example : + +```js +const filter; // A BloomFilter object +const stream = await client.subscribeToTransactionsWithProofs(filter, { fromBlockHeight: 0 }); + +stream + .on('data', (response) => { + const merkleBlock = response.getRawMerkleBlock(); + const transactions = response.getRawTransactions(); + + if (merkleBlock) { + const merkleBlockHex = Buffer.from(merkleBlock).toString('hex'); + } + + if (transactions) { + transactions.getTransactionsList() + .forEach((tx) => { + // tx are probabilistic, so you will have to verify it's yours + const tx = new Transaction(Buffer.from(tx)); + }); + } + }) + .on('error', (err) => { + // do something with err + }); +``` \ No newline at end of file diff --git a/docs/dapi-client-js/usage/platform/broadcaststatetransition.md b/docs/dapi-client-js/usage/platform/broadcaststatetransition.md new file mode 100644 index 000000000..c3c3cdd9f --- /dev/null +++ b/docs/dapi-client-js/usage/platform/broadcaststatetransition.md @@ -0,0 +1,11 @@ +**Usage**: `async client.platform.broadcastStateTransition(stateTransition, options)` +**Description**: Send State Transition to machine + +Parameters: + +| parameters | type | required | Description | +| ------------------- | ----------------- | -------- | ----------------------------------- | +| **stateTransition** | Buffer | yes | A valid bufferized state transition | +| **options** | DAPIClientOptions | no | A valid state transition | + +Returns : Promise\ \ No newline at end of file diff --git a/docs/dapi-client-js/usage/platform/getdatacontract.md b/docs/dapi-client-js/usage/platform/getdatacontract.md new file mode 100644 index 000000000..9f6a0e23d --- /dev/null +++ b/docs/dapi-client-js/usage/platform/getdatacontract.md @@ -0,0 +1,10 @@ +**Usage**: `async client.platform.getDataContract(contractId)` +**Description**: Fetch Data Contract by id + +Parameters: + +| parameters | type | required | Description | +| -------------- | ------ | -------- | ----------------------------- | +| **contractId** | String | yes | A valid registered contractId | + +Returns : Promise \ No newline at end of file diff --git a/docs/dapi-client-js/usage/platform/getdocuments.md b/docs/dapi-client-js/usage/platform/getdocuments.md new file mode 100644 index 000000000..a7af6a671 --- /dev/null +++ b/docs/dapi-client-js/usage/platform/getdocuments.md @@ -0,0 +1,16 @@ +**Usage**: `async client.platform.getDocuments(contractId, type, options)` +**Description**: Fetch Documents from Drive + +Parameters: + +| parameters | type | required | Description | +| ---------------------- | ------ | -------- | -------------------------------------------------- | +| **contractId** | String | yes | A valid registered contractId | +| **type** | String | yes | DAP object type to fetch (e.g: 'preorder' in DPNS) | +| **options.where** | Object | yes | Mongo-like query | +| **options.orderBy** | Object | yes | Mongo-like sort field | +| **options.limit** | Number | yes | Limit the number of object to fetch | +| **options.startAt** | Number | yes | number of objects to skip | +| **options.startAfter** | Number | yes | exclusive skip | + +Returns : Promise\ \ No newline at end of file diff --git a/docs/dapi-client-js/usage/platform/getidentity.md b/docs/dapi-client-js/usage/platform/getidentity.md new file mode 100644 index 000000000..aea63ee2f --- /dev/null +++ b/docs/dapi-client-js/usage/platform/getidentity.md @@ -0,0 +1,10 @@ +**Usage**: `async client.platform.getIdentity(id)` +**Description**: Fetch the identity by id + +Parameters: + +| parameters | type | required | Description | +| ---------- | ------ | -------- | --------------------------- | +| **id** | String | yes | A valid registered identity | + +Returns : Promise\ \ No newline at end of file diff --git a/docs/dapi-client-js/usage/platform/getidentitybyfirstpublickey.md b/docs/dapi-client-js/usage/platform/getidentitybyfirstpublickey.md new file mode 100644 index 000000000..e714d879c --- /dev/null +++ b/docs/dapi-client-js/usage/platform/getidentitybyfirstpublickey.md @@ -0,0 +1,10 @@ +**Usage**: `async client.platform.getIdentityByFirstPublicKey(publicKeyHash)` +**Description**: Fetch the identity using the public key hash of the identity's first key + +Parameters: + +| parameters | type | required | Description | +| ----------------- | ------ | -------- | ----------------------- | +| **publicKeyHash** | String | yes | A valid public key hash | + +Returns : Promise\ \ No newline at end of file diff --git a/docs/dapi-client-js/usage/platform/getidentityidbyfirstpublickey.md b/docs/dapi-client-js/usage/platform/getidentityidbyfirstpublickey.md new file mode 100644 index 000000000..428c2a895 --- /dev/null +++ b/docs/dapi-client-js/usage/platform/getidentityidbyfirstpublickey.md @@ -0,0 +1,10 @@ +**Usage**: `async client.platform.getIdentityIdByFirstPublicKey(publicKeyHash)` +**Description**: Fetch the identity ID using the public key hash of the identity's first key + +Parameters: + +| parameters | type | required | Description | +| ----------------- | ------ | -------- | ----------------------- | +| **publicKeyHash** | String | yes | A valid public key hash | + +Returns : Promise\ \ No newline at end of file diff --git a/docs/dapi-client-js/usage/platform/platform.md b/docs/dapi-client-js/usage/platform/platform.md new file mode 100644 index 000000000..ab4fe7011 --- /dev/null +++ b/docs/dapi-client-js/usage/platform/platform.md @@ -0,0 +1,29 @@ +**Usage**: `new DAPIClient(options)` +**Description**: This method creates a new DAPIClient instance. + +Parameters: + +| parameters | type | required[def value] | Description | +| :------------------------------ | :------------------ | :-------------------------- | :--------------------------------------------------------------------------------------------- | +| **options** | Object | | | +| **options.dapiAddressProvider** | DAPIAddressProvider | no[ListDAPIAddressProvider] | Allow to override the default dapiAddressProvider (do not allow seeds or dapiAddresses params) | +| **options.seeds** | string\[] | no[seeds] | Allow to override default seeds (to connect to specific node) | +| **options.network** | string | no[=evonet] | Allow to setup the network to be used (livenet, testnet, evonet,..) | +| **options.timeout** | number | no[=2000] | Used to specify the timeout time in milliseconds. | +| **options.retries** | number | no[=3] | Used to specify the number of retries before aborting and erroring a request. | +| **options.baseBanTime** | number | no[=6000] | | + +Returns : DAPIClient instance. + +```js +const DAPIClient = require('@dashevo/dapi-client'); +const client = new DAPIClient({ + timeout: 5000, + retries: 3, + network: 'livenet' +}); +``` + +**Notes**: + +- Accessing the SimplifiedMasternodeListDAPIAddressProvider (or its overwrote instance), can be accessed via `client.dapiAddressProvider`. \ No newline at end of file From 6b2564ca6147d49dcad2e61e1e148c1056d6af3e Mon Sep 17 00:00:00 2001 From: thephez Date: Wed, 30 Aug 2023 16:54:30 -0400 Subject: [PATCH 2/6] docs: add toc info and make updates to core section --- docs/dapi-client-js/usage/core/core.md | 39 ++++++------------ .../usage/core/getbestblockhash.md | 2 + .../usage/core/getblockbyhash.md | 2 + .../usage/core/getblockbyheight.md | 2 + .../dapi-client-js/usage/core/getblockhash.md | 2 + .../usage/core/getmnlistdiff.md | 2 + docs/dapi-client-js/usage/core/getstatus.md | 2 + .../usage/core/gettransaction.md | 2 + .../core/subscribetotransactionswithproofs.md | 2 + docs/dapi-client-js/usage/dapi-client.md | 40 +++++++++++++++++++ docs/index.md | 11 +++++ 11 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 docs/dapi-client-js/usage/dapi-client.md diff --git a/docs/dapi-client-js/usage/core/core.md b/docs/dapi-client-js/usage/core/core.md index 25366b81a..bb7ffee96 100644 --- a/docs/dapi-client-js/usage/core/core.md +++ b/docs/dapi-client-js/usage/core/core.md @@ -1,31 +1,18 @@ # Core -**Usage**: `new DAPIClient(options)` -**Description**: This method creates a new DAPIClient instance. +```{toctree} +:maxdepth: 2 +:titlesonly: -Parameters: -| parameters | type | required[def value] | Description | -| :------------------------------ | :------------------ | :-------------------------- | :--------------------------------------------------------------------------------------------- | -| **options** | Object | | | -| **options.dapiAddressProvider** | DAPIAddressProvider | no[ListDAPIAddressProvider] | Allow to override the default dapiAddressProvider (do not allow seeds or dapiAddresses params) | -| **options.seeds** | string\[] | no[seeds] | Allow to override default seeds (to connect to specific node) | -| **options.network** | string | no[=evonet] | Allow to setup the network to be used (livenet, testnet, evonet,..) | -| **options.timeout** | number | no[=2000] | Used to specify the timeout time in milliseconds. | -| **options.retries** | number | no[=3] | Used to specify the number of retries before aborting and erroring a request. | -| **options.baseBanTime** | number | no[=6000] | | - -Returns : DAPIClient instance. - -```js -const DAPIClient = require('@dashevo/dapi-client'); -const client = new DAPIClient({ - timeout: 5000, - retries: 3, - network: 'livenet' -}); +broadcasttransaction +generatetoaddress +getbestblockhash +getblockbyhash +getblockbyheight +getblockhash +getmnlistdiff +getstatus +gettransaction +subscribetotransactionswithproofs ``` - -**Notes**: - -- Accessing the SimplifiedMasternodeListDAPIAddressProvider (or its overwrote instance), can be accessed via `client.dapiAddressProvider`. diff --git a/docs/dapi-client-js/usage/core/getbestblockhash.md b/docs/dapi-client-js/usage/core/getbestblockhash.md index 6a554f849..7964a4203 100644 --- a/docs/dapi-client-js/usage/core/getbestblockhash.md +++ b/docs/dapi-client-js/usage/core/getbestblockhash.md @@ -1,3 +1,5 @@ +# getbestblockhash + **Usage**: `await client.core.getBestBlockHash(options)` **Description**: Allow to fetch the best (highest/latest block hash) from the network diff --git a/docs/dapi-client-js/usage/core/getblockbyhash.md b/docs/dapi-client-js/usage/core/getblockbyhash.md index cc8a92a32..949f1f329 100644 --- a/docs/dapi-client-js/usage/core/getblockbyhash.md +++ b/docs/dapi-client-js/usage/core/getblockbyhash.md @@ -1,3 +1,5 @@ +# getblockbyhash + **Usage**: `await client.core.getBlockByHash(hash, options)` **Description**: Allow to fetch a specific block by its hash diff --git a/docs/dapi-client-js/usage/core/getblockbyheight.md b/docs/dapi-client-js/usage/core/getblockbyheight.md index 3b44d8299..f73d9ce8a 100644 --- a/docs/dapi-client-js/usage/core/getblockbyheight.md +++ b/docs/dapi-client-js/usage/core/getblockbyheight.md @@ -1,3 +1,5 @@ +# getblockbyheight + **Usage**: `await client.core.getBlockByHeight(height, options)` **Description**: Allow to fetch a specific block by its height diff --git a/docs/dapi-client-js/usage/core/getblockhash.md b/docs/dapi-client-js/usage/core/getblockhash.md index bd6512580..e9aa91d47 100644 --- a/docs/dapi-client-js/usage/core/getblockhash.md +++ b/docs/dapi-client-js/usage/core/getblockhash.md @@ -1,3 +1,5 @@ +# getblockhash + **Usage**: `await client.core.getBlockHash(height, options)` **Description**: Allow to fetch a specific block hash from its height diff --git a/docs/dapi-client-js/usage/core/getmnlistdiff.md b/docs/dapi-client-js/usage/core/getmnlistdiff.md index 7f87f35f1..f6282e1e6 100644 --- a/docs/dapi-client-js/usage/core/getmnlistdiff.md +++ b/docs/dapi-client-js/usage/core/getmnlistdiff.md @@ -1,3 +1,5 @@ +# getmnlistdiff + **Usage**: `await client.core.getMnListDiff(baseBlockHash, blockHash, options)` **Description**: Allow to fetch a specific block hash from its height diff --git a/docs/dapi-client-js/usage/core/getstatus.md b/docs/dapi-client-js/usage/core/getstatus.md index ffe3f9a24..f7bd66bee 100644 --- a/docs/dapi-client-js/usage/core/getstatus.md +++ b/docs/dapi-client-js/usage/core/getstatus.md @@ -1,3 +1,5 @@ +# getstatus + **Usage**: `await client.core.getStatus(options)` **Description**: Allow to fetch a specific block hash from its height diff --git a/docs/dapi-client-js/usage/core/gettransaction.md b/docs/dapi-client-js/usage/core/gettransaction.md index ad0ea7a0c..fea1ae92f 100644 --- a/docs/dapi-client-js/usage/core/gettransaction.md +++ b/docs/dapi-client-js/usage/core/gettransaction.md @@ -1,3 +1,5 @@ +# gettransaction + **Usage**: `await client.core.getTransaction(id, options)` **Description**: Allow to fetch a transaction by ID diff --git a/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.md b/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.md index c1b94b30f..09b300fb5 100644 --- a/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.md +++ b/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.md @@ -1,3 +1,5 @@ +# subscribetotransactionswithproofs + **Usage**: `await client.core.subscribeToTransactionsWithProofs(bloomFilter, options = { count: 0 })` **Description**: For any provided bloomfilter, it will return a ClientReadableStream streaming the transaction matching the filter. diff --git a/docs/dapi-client-js/usage/dapi-client.md b/docs/dapi-client-js/usage/dapi-client.md new file mode 100644 index 000000000..0e735f68f --- /dev/null +++ b/docs/dapi-client-js/usage/dapi-client.md @@ -0,0 +1,40 @@ +# Usage + +**Usage**: `new DAPIClient(options)` +**Description**: This method creates a new DAPIClient instance. + +Parameters: + +| parameters | type | required[def value] | Description | +| :------------------------------ | :------------------ | :-------------------------- | :--------------------------------------------------------------------------------------------- | +| **options** | Object | | | +| **options.dapiAddressProvider** | DAPIAddressProvider | no[ListDAPIAddressProvider] | Allow to override the default dapiAddressProvider (do not allow seeds or dapiAddresses params) | +| **options.seeds** | string\[] | no[seeds] | Allow to override default seeds (to connect to specific node) | +| **options.network** | string | no[=evonet] | Allow to setup the network to be used (livenet, testnet, evonet,..) | +| **options.timeout** | number | no[=2000] | Used to specify the timeout time in milliseconds. | +| **options.retries** | number | no[=3] | Used to specify the number of retries before aborting and erroring a request. | +| **options.baseBanTime** | number | no[=6000] | | + +Returns : DAPIClient instance. + +```js +const DAPIClient = require('@dashevo/dapi-client'); +const client = new DAPIClient({ + timeout: 5000, + retries: 3, + network: 'livenet' +}); +``` + +**Notes**: + +- Accessing the SimplifiedMasternodeListDAPIAddressProvider (or its overwrote instance), can be accessed via `client.dapiAddressProvider`. + +```{toctree} +:maxdepth: 2 +:titlesonly: +:caption: Core +:hidden: + +core/core +``` diff --git a/docs/index.md b/docs/index.md index c67ce0f47..d3780879a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -89,3 +89,14 @@ JavaScript SDK ``` + +```{toctree} +:maxdepth: 2 +:titlesonly: +:caption: DAPI Client +:hidden: + +dapi-client-js/overview +dapi-client-js/quick-start +dapi-client-js/usage/dapi-client +``` From a075633f913b8be9936c3929b4d285d4564b8a92 Mon Sep 17 00:00:00 2001 From: thephez Date: Wed, 30 Aug 2023 16:59:01 -0400 Subject: [PATCH 3/6] docs: update toc to include dapi-client platform info --- docs/dapi-client-js/usage/dapi-client.md | 1 + .../platform/broadcaststatetransition.md | 2 ++ .../usage/platform/getdatacontract.md | 2 ++ .../usage/platform/getdocuments.md | 2 ++ .../usage/platform/getidentity.md | 2 ++ .../platform/getidentitybyfirstpublickey.md | 2 ++ .../platform/getidentityidbyfirstpublickey.md | 2 ++ .../dapi-client-js/usage/platform/platform.md | 35 ++++++------------- 8 files changed, 23 insertions(+), 25 deletions(-) diff --git a/docs/dapi-client-js/usage/dapi-client.md b/docs/dapi-client-js/usage/dapi-client.md index 0e735f68f..53b88a73a 100644 --- a/docs/dapi-client-js/usage/dapi-client.md +++ b/docs/dapi-client-js/usage/dapi-client.md @@ -37,4 +37,5 @@ const client = new DAPIClient({ :hidden: core/core +platform/platform ``` diff --git a/docs/dapi-client-js/usage/platform/broadcaststatetransition.md b/docs/dapi-client-js/usage/platform/broadcaststatetransition.md index c3c3cdd9f..15667f37a 100644 --- a/docs/dapi-client-js/usage/platform/broadcaststatetransition.md +++ b/docs/dapi-client-js/usage/platform/broadcaststatetransition.md @@ -1,3 +1,5 @@ +# broadcaststatetransition + **Usage**: `async client.platform.broadcastStateTransition(stateTransition, options)` **Description**: Send State Transition to machine diff --git a/docs/dapi-client-js/usage/platform/getdatacontract.md b/docs/dapi-client-js/usage/platform/getdatacontract.md index 9f6a0e23d..c6c4ebd96 100644 --- a/docs/dapi-client-js/usage/platform/getdatacontract.md +++ b/docs/dapi-client-js/usage/platform/getdatacontract.md @@ -1,3 +1,5 @@ +# getdatacontract + **Usage**: `async client.platform.getDataContract(contractId)` **Description**: Fetch Data Contract by id diff --git a/docs/dapi-client-js/usage/platform/getdocuments.md b/docs/dapi-client-js/usage/platform/getdocuments.md index a7af6a671..ff290de62 100644 --- a/docs/dapi-client-js/usage/platform/getdocuments.md +++ b/docs/dapi-client-js/usage/platform/getdocuments.md @@ -1,3 +1,5 @@ +# getdocuments + **Usage**: `async client.platform.getDocuments(contractId, type, options)` **Description**: Fetch Documents from Drive diff --git a/docs/dapi-client-js/usage/platform/getidentity.md b/docs/dapi-client-js/usage/platform/getidentity.md index aea63ee2f..fa6de9f78 100644 --- a/docs/dapi-client-js/usage/platform/getidentity.md +++ b/docs/dapi-client-js/usage/platform/getidentity.md @@ -1,3 +1,5 @@ +# getidentity + **Usage**: `async client.platform.getIdentity(id)` **Description**: Fetch the identity by id diff --git a/docs/dapi-client-js/usage/platform/getidentitybyfirstpublickey.md b/docs/dapi-client-js/usage/platform/getidentitybyfirstpublickey.md index e714d879c..646b3bc27 100644 --- a/docs/dapi-client-js/usage/platform/getidentitybyfirstpublickey.md +++ b/docs/dapi-client-js/usage/platform/getidentitybyfirstpublickey.md @@ -1,3 +1,5 @@ +# getidentitybyfirstpublickey + **Usage**: `async client.platform.getIdentityByFirstPublicKey(publicKeyHash)` **Description**: Fetch the identity using the public key hash of the identity's first key diff --git a/docs/dapi-client-js/usage/platform/getidentityidbyfirstpublickey.md b/docs/dapi-client-js/usage/platform/getidentityidbyfirstpublickey.md index 428c2a895..814d11d37 100644 --- a/docs/dapi-client-js/usage/platform/getidentityidbyfirstpublickey.md +++ b/docs/dapi-client-js/usage/platform/getidentityidbyfirstpublickey.md @@ -1,3 +1,5 @@ +# getidentityidbyfirstpublickey + **Usage**: `async client.platform.getIdentityIdByFirstPublicKey(publicKeyHash)` **Description**: Fetch the identity ID using the public key hash of the identity's first key diff --git a/docs/dapi-client-js/usage/platform/platform.md b/docs/dapi-client-js/usage/platform/platform.md index ab4fe7011..f24015909 100644 --- a/docs/dapi-client-js/usage/platform/platform.md +++ b/docs/dapi-client-js/usage/platform/platform.md @@ -1,29 +1,14 @@ -**Usage**: `new DAPIClient(options)` -**Description**: This method creates a new DAPIClient instance. +# Platform -Parameters: +```{toctree} +:maxdepth: 2 +:titlesonly: -| parameters | type | required[def value] | Description | -| :------------------------------ | :------------------ | :-------------------------- | :--------------------------------------------------------------------------------------------- | -| **options** | Object | | | -| **options.dapiAddressProvider** | DAPIAddressProvider | no[ListDAPIAddressProvider] | Allow to override the default dapiAddressProvider (do not allow seeds or dapiAddresses params) | -| **options.seeds** | string\[] | no[seeds] | Allow to override default seeds (to connect to specific node) | -| **options.network** | string | no[=evonet] | Allow to setup the network to be used (livenet, testnet, evonet,..) | -| **options.timeout** | number | no[=2000] | Used to specify the timeout time in milliseconds. | -| **options.retries** | number | no[=3] | Used to specify the number of retries before aborting and erroring a request. | -| **options.baseBanTime** | number | no[=6000] | | -Returns : DAPIClient instance. - -```js -const DAPIClient = require('@dashevo/dapi-client'); -const client = new DAPIClient({ - timeout: 5000, - retries: 3, - network: 'livenet' -}); +broadcaststatetransition +getdatacontract +getdocuments +getidentity +getidentitybyfirstpublickey +getidentityidbyfirstpublickey ``` - -**Notes**: - -- Accessing the SimplifiedMasternodeListDAPIAddressProvider (or its overwrote instance), can be accessed via `client.dapiAddressProvider`. \ No newline at end of file From 2c9b7b3f8396c32db380170826b4eda7888402ad Mon Sep 17 00:00:00 2001 From: thephez Date: Wed, 30 Aug 2023 17:01:19 -0400 Subject: [PATCH 4/6] docs: add overview heading --- docs/dapi-client-js/overview.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/dapi-client-js/overview.md b/docs/dapi-client-js/overview.md index fdfc96efa..4d975cdf2 100644 --- a/docs/dapi-client-js/overview.md +++ b/docs/dapi-client-js/overview.md @@ -1,3 +1,5 @@ +# Overview + ## DAPI-Client [![NPM Version](https://img.shields.io/npm/v/@dashevo/dapi-client)](https://www.npmjs.com/package/@dashevo/dapi-client) From e8afb65d784bcc588731fd481563b015e049c20b Mon Sep 17 00:00:00 2001 From: thephez Date: Wed, 30 Aug 2023 17:01:34 -0400 Subject: [PATCH 5/6] chore: update script to rename files --- scripts/1-readme-rename.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/1-readme-rename.sh b/scripts/1-readme-rename.sh index b96500c48..2d0697590 100755 --- a/scripts/1-readme-rename.sh +++ b/scripts/1-readme-rename.sh @@ -2,6 +2,8 @@ RENAME_ARGS="-d" +find docs/dapi-client-js -iname "*.md" -type f -name 'dapi-client-*' -print0 | xargs -0 rename $RENAME_ARGS 's/dapi-client-//' +find docs/dapi-client-js/usage -iname "*.md" -type f -name 'usage-*' -print0 | xargs -0 rename $RENAME_ARGS 's/usage-//' find docs/explanations -iname "*.md" -type f -name 'explanation-*' -print0 | xargs -0 rename $RENAME_ARGS 's/explanation-//' find docs/intro -iname "*.md" -type f -name 'introduction-*' -print0 | xargs -0 rename $RENAME_ARGS 's/introduction-//' find docs/intro -iname "*.md" -type f -name 'intro-*' -print0 | xargs -0 rename $RENAME_ARGS 's/intro-//' From 9cbd9bbeb75c493e595da1b7422f3d89b5c4de8d Mon Sep 17 00:00:00 2001 From: thephez Date: Wed, 30 Aug 2023 17:14:18 -0400 Subject: [PATCH 6/6] docs: refactor slightly --- .../usage/{dapi-client.md => dapiclient.md} | 18 ++---------------- docs/dapi-client-js/usage/usage.md | 10 ++++++++++ docs/index.md | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) rename docs/dapi-client-js/usage/{dapi-client.md => dapiclient.md} (88%) create mode 100644 docs/dapi-client-js/usage/usage.md diff --git a/docs/dapi-client-js/usage/dapi-client.md b/docs/dapi-client-js/usage/dapiclient.md similarity index 88% rename from docs/dapi-client-js/usage/dapi-client.md rename to docs/dapi-client-js/usage/dapiclient.md index 53b88a73a..ee576394d 100644 --- a/docs/dapi-client-js/usage/dapi-client.md +++ b/docs/dapi-client-js/usage/dapiclient.md @@ -1,4 +1,4 @@ -# Usage +# DAPIClient **Usage**: `new DAPIClient(options)` **Description**: This method creates a new DAPIClient instance. @@ -24,18 +24,4 @@ const client = new DAPIClient({ retries: 3, network: 'livenet' }); -``` - -**Notes**: - -- Accessing the SimplifiedMasternodeListDAPIAddressProvider (or its overwrote instance), can be accessed via `client.dapiAddressProvider`. - -```{toctree} -:maxdepth: 2 -:titlesonly: -:caption: Core -:hidden: - -core/core -platform/platform -``` +``` \ No newline at end of file diff --git a/docs/dapi-client-js/usage/usage.md b/docs/dapi-client-js/usage/usage.md new file mode 100644 index 000000000..361a9a1e1 --- /dev/null +++ b/docs/dapi-client-js/usage/usage.md @@ -0,0 +1,10 @@ +# Usage + +```{toctree} +:maxdepth: 2 +:titlesonly: + +dapiclient +core/core +platform/platform +``` diff --git a/docs/index.md b/docs/index.md index d3780879a..4245443be 100644 --- a/docs/index.md +++ b/docs/index.md @@ -98,5 +98,5 @@ Previous Version of Docs dapi-client-js/overview dapi-client-js/quick-start -dapi-client-js/usage/dapi-client +dapi-client-js/usage/usage ```