Skip to content

Commit 5dc2f45

Browse files
authored
docs(tutorials): migrate to evo sdk (#133)
* ocs(tutorials): migrate connecting-to-testnet and introduction to Evo SDK - Replaced old dash SDK references with @dashevo/evo-sdk patterns including EvoSDK.testnetTrusted(), try/catch error handling, and .toJSON() output. - Simplified devnet section to local-only since WASM SDK doesn't support remote devnets. - Remove outdated proof security warning from introduction. * docs(tutorials): migrate create-and-fund-a-wallet to Evo SDK Replace old Dash.Client wallet generation with Evo SDK wallet utilities, BIP44 derivation paths, and bech32m platform addresses. Update faucet link to Core -> Platform bridge. * docs(tutorials): update create and fund wallet * docs(tutorials): migrate client sdk setup to evo sdk, pt 1 * docs(tutorials): sync sdkClient.mjs with reference repo Add clientConfig, dotenv support, setupDashClient() convenience wrapper, and full JSDoc to match the platform-tutorial-testing reference. Users now configure network and mnemonic in one place. * docs(tutorials): more setup updates * docs(tutorials): migrate identity create to evo sdk * chore: update exclude pattern in conf * docs(tutorials): migrate retreive identity to evo sdk * docs(tutorials): migrate document submit to evo sdk * docs(tutorials): migrate document retrieve and delete to evo sdk * docs(tutorials): migrate doc update to evo sdk * docs(tutorials): add bug workaround to identity create * docs(tutorials): migrate contract tutorials to evo sdk * docs(tutorials): migrate name register and retrieve to evo sdk * chore: update .gitignore * docs(tutorials): minor example update * docs(tutorials): add attention header on tutorials not yet migrated to evo sdk
1 parent f74cb33 commit 5dc2f45

24 files changed

Lines changed: 1597 additions & 999 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
*.exe
33
_build
44
**/.DS_Store
5+
.local/
56
.vscode

conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@
3939
'.DS_Store',
4040
'README.md',
4141
'.devcontainer',
42+
'local',
4243
'scripts',
4344
'img/dev/gifs/README.md',
4445
'docs/other',
45-
'docs/ai-prompt.md'
46+
'docs/ai-prompt.md',
47+
'platform-src'
4648
]
4749

4850
# The master toctree document.

docs/tutorials/connecting-to-testnet.md

Lines changed: 31 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The purpose of this tutorial is to walk through the steps necessary to access th
88

99
## Overview
1010

11-
Platform services are provided via a combination of HTTP and gRPC connections to DAPI, and some connections to an Insight API. Although one could interact with DAPI by connecting to these directly, or by using [DAPI-client](https://github.com/dashpay/platform/tree/master/packages/js-dapi-client), the easiest approach is to use the [JavaScript Dash SDK](https://github.com/dashpay/platform/tree/master/packages/js-dash-sdk).
11+
Platform services are provided via a combination of HTTP and gRPC connections to DAPI. The easiest approach is to use the [Dash Evo SDK](https://www.npmjs.com/package/@dashevo/evo-sdk), which handles connection management automatically.
1212

1313
## Prerequisites
1414

@@ -18,94 +18,60 @@ Platform services are provided via a combination of HTTP and gRPC connections to
1818

1919
### 1. Install the Dash SDK
2020

21-
The JavaScript SDK package is available from npmjs.com and can be installed by running `npm install dash` from the command line:
21+
The JavaScript SDK package is available from npmjs.com and can be installed by running `npm install @dashevo/evo-sdk` from the command line:
2222

2323
```shell
24-
npm install dash
24+
npm install @dashevo/evo-sdk
2525
```
2626

2727
### 2. Connect to Dash Platform
2828

29-
:::{tip}
30-
The JavaScript Dash SDK connects to mainnet by default. To connect to other networks,
31-
set the `network` option when instantiating the client as shown in the following example.
32-
:::
33-
34-
Create a file named `dashConnect.js` with the following contents. Then run it by typing `node dashConnect.js` from the command line:
29+
Create a file named `dashConnect.mjs` with the following contents. Then run it by typing `node dashConnect.mjs` from the command line:
3530

36-
```javascript dashConnect.js
37-
const Dash = require('dash');
31+
```{code-block} javascript
32+
:caption: dashConnect.mjs
3833
39-
const client = new Dash.Client({ network: 'testnet' });
34+
import { EvoSDK } from '@dashevo/evo-sdk';
4035
41-
async function connect() {
42-
return await client.getDAPIClient().core.getBestBlockHash();
36+
try {
37+
const sdk = EvoSDK.testnetTrusted();
38+
await sdk.connect();
39+
const status = await sdk.system.status();
40+
console.log('Connected. System status:\n', status.toJSON());
41+
} catch (e) {
42+
console.error('Failed to fetch system status:', e.message);
4343
}
44-
45-
connect()
46-
.then((d) => console.log('Connected. Best block hash:\n', d))
47-
.catch((e) => console.error('Something went wrong:\n', e))
48-
.finally(() => client.disconnect());
4944
```
5045

51-
Once this returns successfully, you're ready to begin developing! See the [Quickstart](../tutorials/introduction.md#quickstart) for recommended next steps. For details on all SDK options and methods, please refer to the [SDK documentation](../sdk-js/overview.md).
52-
53-
## Connect to a Devnet
46+
Once this returns successfully, you're ready to begin developing! See the [Quickstart](../tutorials/introduction.md#quickstart) for recommended next steps. For details on SDK methods, please refer to the [SDK documentation](https://dashpay.github.io/evo-sdk-website/docs.html).
5447

55-
The SDK also supports connecting to development networks (devnets). Since devnets can be created by anyone, the client library will be unaware of them unless connection information is provided using one of the options described below.
48+
## Connect to a Local Devnet
5649

57-
### Connect via Seed
50+
The SDK supports connecting to a local development network managed by [dashmate](https://github.com/dashpay/platform/tree/master/packages/dashmate). The `local` factory methods expect a dashmate-managed environment with a quorum sidecar running at `127.0.0.1:2444`.
5851

59-
Using a seed node is the preferred method in most cases. The client uses the provided seed node to a retrieve a list of available masternodes on the network so requests can be spread across the entire network.
52+
```{code-block} javascript
53+
:caption: localConnect.mjs
6054
61-
```javascript
62-
const Dash = require('dash');
55+
import { EvoSDK } from '@dashevo/evo-sdk';
6356
64-
const client = new Dash.Client({
65-
network: 'testnet',
66-
seeds: [{
67-
host: 'seed-1.testnet.networks.dash.org:1443',
68-
}],
69-
});
70-
71-
async function connect() {
72-
return await client.getDAPIClient().core.getBestBlockHash();
57+
try {
58+
const sdk = EvoSDK.localTrusted();
59+
await sdk.connect();
60+
const status = await sdk.system.status();
61+
console.log('Connected. System status:\n', status.toJSON());
62+
} catch (e) {
63+
console.error('Failed to fetch system status:', e.message);
7364
}
74-
75-
connect()
76-
.then((d) => console.log('Connected. Best block hash:\n', d))
77-
.catch((e) => console.error('Something went wrong:\n', e))
78-
.finally(() => client.disconnect());
7965
```
8066

81-
### Connect via Address
82-
83-
Custom addresses may be directly specified via `dapiAddresses` in cases where it is beneficial to know exactly what node(s) are being accessed (e.g. debugging, local development, etc.).
84-
85-
```javascript
86-
const Dash = require('dash');
87-
88-
const client = new Dash.Client({
89-
dapiAddresses: [
90-
'127.0.0.1:3000:3010',
91-
'127.0.0.2:3000:3010',
92-
],
93-
});
94-
95-
async function connect() {
96-
return await client.getDAPIClient().core.getBestBlockHash();
97-
}
98-
99-
connect()
100-
.then((d) => console.log('Connected. Best block hash:\n', d))
101-
.catch((e) => console.error('Something went wrong:\n', e))
102-
.finally(() => client.disconnect());
103-
```
67+
:::{note}
68+
The WASM-based SDK currently only supports connecting to known networks (testnet, mainnet, local) via the built-in factory methods. Connecting to remote devnets with custom addresses is not yet supported.
69+
:::
10470

10571
## Connect Directly to DAPI (Optional)
10672

10773
:::{attention}
108-
Normally, the Dash SDK, dapi-client, or another library should be used to interact with DAPI. Connecting directly may be helpful for debugging in some cases, but generally is not required.
74+
Normally, the Dash SDK or another library should be used to interact with DAPI. Connecting directly may be helpful for debugging in some cases, but generally is not required.
10975
:::
11076

11177
The example below demonstrates retrieving the hash of the best block hash directly from a DAPI node via command line and several languages:

docs/tutorials/contracts-and-documents/delete-documents.md

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,60 @@
44

55
# Delete documents
66

7-
In this tutorial we will update delete data from Dash Platform. Data is stored in the form of [documents](../../explanations/platform-protocol-document.md) which are encapsulated in a [state transition](../../explanations/platform-protocol-state-transition.md) before being submitted to DAPI.
7+
In this tutorial we will delete data from Dash Platform. Data is stored in the form of [documents](../../explanations/platform-protocol-document.md) which are encapsulated in a [state transition](../../explanations/platform-protocol-state-transition.md) before being submitted to DAPI.
88

99
## Prerequisites
1010

1111
- [General prerequisites](../../tutorials/introduction.md#prerequisites) (Node.js / Dash SDK installed)
12-
- A wallet mnemonic with some funds in it: [Tutorial: Create and Fund a Wallet](../../tutorials/create-and-fund-a-wallet.md)
12+
- A platform address with a balance: [Tutorial: Create and Fund a Wallet](../../tutorials/create-and-fund-a-wallet.md)
1313
- A configured client: [Setup SDK Client](../setup-sdk-client.md)
14-
- Access to a previously created document (e.g., one created using the [Submit Documents tutorial](../../tutorials/contracts-and-documents/submit-documents.md))
14+
- A Dash Platform Identity: [Tutorial: Register an Identity](../../tutorials/identities-and-names/register-an-identity.md)
15+
- (Optional) A Dash Platform Contract ID: [Tutorial: Register a Data Contract](../../tutorials/contracts-and-documents/register-a-data-contract.md) — a default testnet tutorial contract is provided
16+
- An existing document (e.g., one created using the [Submit Documents tutorial](../../tutorials/contracts-and-documents/submit-documents.md))
1517

1618
## Code
1719

18-
```javascript
19-
const setupDashClient = require('../setupDashClient');
20-
21-
const client = setupDashClient();
22-
23-
const deleteNoteDocument = async () => {
24-
const { platform } = client;
25-
const identity = await platform.identities.get('an identity ID goes here');
26-
const documentId = 'an existing document ID goes here';
27-
28-
// Retrieve the existing document
29-
const [document] = await client.platform.documents.get(
30-
'tutorialContract.note',
31-
{ where: [['$id', '==', documentId]] },
32-
);
33-
34-
// Sign and submit the document delete transition
35-
await platform.documents.broadcast({ delete: [document] }, identity);
36-
return document;
37-
};
38-
39-
deleteNoteDocument()
40-
.then((d) => console.log('Document deleted:\n', d.toJSON()))
41-
.catch((e) => console.error('Something went wrong:\n', e))
42-
.finally(() => client.disconnect());
20+
```{code-block} javascript
21+
:caption: deleteDocument.mjs
22+
23+
import { setupDashClient } from '../setupDashClient.mjs';
24+
25+
const { sdk, keyManager } = await setupDashClient();
26+
const { identity, identityKey, signer } = await keyManager.getAuth();
27+
28+
// Default tutorial contract (testnet). Replace or override via DATA_CONTRACT_ID.
29+
const DATA_CONTRACT_ID =
30+
process.env.DATA_CONTRACT_ID ??
31+
'FW3DHrQiG24VqzPY4ARenMgjEPpBNuEQTZckV8hbVCG4';
32+
33+
// Replace with your existing document ID
34+
const DOCUMENT_ID = 'YOUR_DOCUMENT_ID';
35+
36+
try {
37+
// Delete the document from the platform
38+
await sdk.documents.delete({
39+
document: {
40+
id: DOCUMENT_ID,
41+
ownerId: identity.id,
42+
dataContractId: DATA_CONTRACT_ID,
43+
documentTypeName: 'note',
44+
},
45+
identityKey,
46+
signer,
47+
});
48+
49+
console.log('Document deleted successfully');
50+
} catch (e) {
51+
console.error('Something went wrong:\n', e.message);
52+
}
4353
```
4454

45-
:::{tip}
46-
The example above shows how access to contract documents via `<contract name>.<contract document>` syntax (e.g. `tutorialContract.note`) can be enabled by passing a contract identity to the constructor. Please refer to the [Dash SDK documentation](https://github.com/dashpay/platform/blob/master/packages/js-dash-sdk/docs/getting-started/multiple-apps.md) for details.
47-
:::
48-
4955
## What's happening
5056

51-
After we initialize the Client, we retrieve the document to be deleted via `platform.documents.get` using its `id`.
52-
53-
Once the document has been retrieved, we must submit it to [DAPI](../../explanations/dapi.md). Documents are submitted in batches that may contain multiple documents to be created, replaced, or deleted. In this example, a single document is being deleted.
57+
After we initialize the client, we get the auth key signer from the key manager. We then call `sdk.documents.delete()` with an object identifying the document to delete — its `id`, `ownerId`, `dataContractId`, and `documentTypeName` — along with the signing credentials.
5458

55-
The `platform.documents.broadcast` method takes the document batch (e.g. `{delete: [documents[0]]}`) and an identity parameter. Internally, it creates a [State Transition](../../explanations/platform-protocol-state-transition.md) containing the previously created document, signs the state transition, and submits the signed state transition to DAPI.
59+
Internally, the method creates a [State Transition](../../explanations/platform-protocol-state-transition.md) containing the document deletion instruction, signs the state transition, and submits it to DAPI. Only the document's owner can delete it.
5660

5761
:::{note}
58-
:class: note
59-
Since the SDK does not cache wallet information, lengthy re-syncs (5+ minutes) may be required for some Core chain wallet operations. See [Wallet Operations](../setup-sdk-client.md#wallet-operations) for options.
62+
You do not need to retrieve the full document before deleting it. The `sdk.documents.delete()` method only requires the document's identifying fields (`id`, `ownerId`, `dataContractId`, `documentTypeName`).
6063
:::

0 commit comments

Comments
 (0)