dash 3.22.0-dev.1 → 3.22.0-dev.10

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.
Files changed (108) hide show
  1. package/.mocharc.yml +1 -0
  2. package/README.md +5 -5
  3. package/build/src/SDK/Client/Client.js +8 -2
  4. package/build/src/SDK/Client/Client.js.map +1 -1
  5. package/build/src/SDK/Client/Client.spec.js +23 -15
  6. package/build/src/SDK/Client/Client.spec.js.map +1 -1
  7. package/build/src/SDK/Client/Platform/Platform.js +4 -2
  8. package/build/src/SDK/Client/Platform/Platform.js.map +1 -1
  9. package/build/src/SDK/Client/Platform/broadcastStateTransition.js +1 -1
  10. package/build/src/SDK/Client/Platform/broadcastStateTransition.js.map +1 -1
  11. package/build/src/SDK/Client/Platform/createAssetLockTransaction.js +1 -1
  12. package/build/src/SDK/Client/Platform/methods/contracts/{broadcast.js → publish.js} +6 -6
  13. package/build/src/SDK/Client/Platform/methods/contracts/publish.js.map +1 -0
  14. package/build/src/SDK/Client/Platform/methods/contracts/update.js +86 -0
  15. package/build/src/SDK/Client/Platform/methods/contracts/update.js.map +1 -0
  16. package/build/src/SDK/Client/Platform/methods/documents/get.js +15 -5
  17. package/build/src/SDK/Client/Platform/methods/documents/get.js.map +1 -1
  18. package/build/src/SDK/Client/Platform/methods/documents/get.spec.js +49 -0
  19. package/build/src/SDK/Client/Platform/methods/documents/get.spec.js.map +1 -1
  20. package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js +13 -3
  21. package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js.map +1 -1
  22. package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js +8 -2
  23. package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js.map +1 -1
  24. package/build/src/SDK/Client/Platform/methods/names/register.js +1 -1
  25. package/build/src/SDK/Client/Platform/methods/names/register.js.map +1 -1
  26. package/build/src/SDK/Client/Platform/methods/names/search.js +3 -0
  27. package/build/src/SDK/Client/Platform/methods/names/search.js.map +1 -1
  28. package/build/src/SDK/Client/Platform/methods/names/search.spec.js +2 -0
  29. package/build/src/SDK/Client/Platform/methods/names/search.spec.js.map +1 -1
  30. package/build/src/SDK/Client/Platform/signStateTransition.js +3 -1
  31. package/build/src/SDK/Client/Platform/signStateTransition.js.map +1 -1
  32. package/build/src/test/bootstrap.js +11 -0
  33. package/build/src/test/bootstrap.js.map +1 -1
  34. package/build/src/test/fixtures/createIdentityFixtureInAccount.js +2 -0
  35. package/build/src/test/fixtures/createIdentityFixtureInAccount.js.map +1 -1
  36. package/build/src/test/mocks/createAndAttachTransportMocksToClient.js +5 -2
  37. package/build/src/test/mocks/createAndAttachTransportMocksToClient.js.map +1 -1
  38. package/build/src/utils/createFakeIntantLock.js +2 -0
  39. package/build/src/utils/createFakeIntantLock.js.map +1 -1
  40. package/build/tests/fixtures/contracts.json +3 -1
  41. package/dist/src/SDK/Client/Platform/IPlatformStateProof.d.ts +1 -2
  42. package/dist/src/SDK/Client/Platform/Platform.d.ts +9 -3
  43. package/dist/src/SDK/Client/Platform/broadcastStateTransition.d.ts +2 -2
  44. package/dist/src/SDK/Client/Platform/createAssetLockTransaction.d.ts +1 -1
  45. package/dist/src/SDK/Client/Platform/methods/contracts/publish.d.ts +10 -0
  46. package/dist/src/SDK/Client/Platform/methods/contracts/update.d.ts +10 -0
  47. package/dist/src/SDK/Client/Platform/methods/documents/get.d.ts +7 -4
  48. package/dist/src/SDK/SDK.d.ts +167 -4
  49. package/docs/README.md +6 -6
  50. package/docs/_sidebar.md +19 -17
  51. package/docs/examples/pay-to-another-address.md +1 -1
  52. package/docs/examples/publishing-a-new-contract.md +7 -7
  53. package/docs/examples/receive-money-and-check-balance.md +2 -2
  54. package/docs/examples/sign-and-verify-messages.md +1 -1
  55. package/docs/examples/updating-a-contract.md +55 -0
  56. package/docs/getting-started/core-concepts.md +2 -2
  57. package/docs/getting-started/dash-platform-applications.md +1 -1
  58. package/docs/getting-started/quickstart.md +1 -1
  59. package/docs/platform/contracts/about-contracts.md +1 -1
  60. package/docs/platform/contracts/create.md +2 -2
  61. package/docs/platform/contracts/{broadcast.md → publish.md} +8 -8
  62. package/docs/platform/contracts/update.md +14 -0
  63. package/docs/platform/documents/broadcast.md +4 -4
  64. package/docs/platform/documents/create.md +2 -2
  65. package/docs/platform/identities/about-identity.md +1 -1
  66. package/docs/platform/identities/register.md +1 -1
  67. package/docs/platform/identities/topUp.md +3 -1
  68. package/docs/platform/names/register.md +1 -1
  69. package/docs/wallet/about-wallet-lib.md +1 -1
  70. package/examples/node/register-contract.js +1 -1
  71. package/examples/schema.json +2 -0
  72. package/karma.conf.js +17 -8
  73. package/package.json +35 -23
  74. package/src/SDK/Client/Client.spec.ts +5 -5
  75. package/src/SDK/Client/Client.ts +8 -2
  76. package/src/SDK/Client/Platform/IPlatformStateProof.ts +1 -2
  77. package/src/SDK/Client/Platform/Platform.ts +14 -5
  78. package/src/SDK/Client/Platform/broadcastStateTransition.ts +2 -3
  79. package/src/SDK/Client/Platform/createAssetLockTransaction.ts +1 -1
  80. package/src/SDK/Client/Platform/methods/contracts/{broadcast.ts → publish.ts} +4 -4
  81. package/src/SDK/Client/Platform/methods/contracts/update.ts +39 -0
  82. package/src/SDK/Client/Platform/methods/documents/get.spec.ts +37 -0
  83. package/src/SDK/Client/Platform/methods/documents/get.ts +18 -8
  84. package/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts +7 -2
  85. package/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.ts +2 -1
  86. package/src/SDK/Client/Platform/methods/names/register.ts +1 -1
  87. package/src/SDK/Client/Platform/methods/names/search.spec.ts +2 -0
  88. package/src/SDK/Client/Platform/methods/names/search.ts +3 -0
  89. package/src/SDK/Client/Platform/signStateTransition.ts +2 -2
  90. package/src/test/bootstrap.js +13 -0
  91. package/src/test/fixtures/createIdentityFixtureInAccount.ts +3 -1
  92. package/src/test/mocks/createAndAttachTransportMocksToClient.ts +25 -21
  93. package/src/utils/createFakeIntantLock.ts +2 -0
  94. package/tests/fixtures/contracts.json +3 -1
  95. package/tests/fixtures/dp1.schema.json +2 -0
  96. package/tests/fixtures/ratePlatform.schema.json +1 -0
  97. package/webpack.base.config.js +5 -2
  98. package/webpack.config.js +3 -24
  99. package/.editorconfig +0 -2
  100. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  101. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -27
  102. package/.github/PULL_REQUEST_TEMPLATE.md +0 -32
  103. package/.github/workflows/.env +0 -5
  104. package/.github/workflows/test_and_release.yml +0 -170
  105. package/build/src/SDK/Client/Platform/methods/contracts/broadcast.js.map +0 -1
  106. package/dist/dash.min.js +0 -8
  107. package/dist/dash.min.js.LICENSE.txt +0 -47
  108. package/dist/src/SDK/Client/Platform/methods/contracts/broadcast.d.ts +0 -10
@@ -2,12 +2,12 @@
2
2
 
3
3
  Right now, Evonet does not support publishing a public contract. You will have to run a local instance or wait for updates to the [Dash Platform documentation](https://dashplatform.readme.io/docs) regarding how to run a devnet locally and publish a contract.
4
4
 
5
- For now you can try your luck using the [Dash Network Deploy tool](https://github.com/dashevo/dash-network-deploy) and refer to [how to use a local evonet](/examples/use-local-evonet.md).
5
+ For now you can try your luck using the [Dash Network Deploy tool](https://github.com/dashevo/dash-network-deploy) and refer to [how to use a local evonet](../examples/use-local-evonet.md).
6
6
 
7
- ## Create your contract
7
+ ## Create your contract
8
8
 
9
- After having [registered an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity)
10
- and [attached to a name](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity) crafted your schema (you can see how on [about schemas](getting-started/about-schemas.md) and read the [DPNS schema](https://github.com/dashevo/dpns-contract/blob/v0.2-dev/src/schema/dpns-documents.json) as an example), you then can perform the below actions :
9
+ After having [registered an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity)
10
+ and [attached to a name](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity) crafted your schema (you can see how on [about schemas](getting-started/about-schemas.md) and read the [DPNS schema](https://github.com/dashevo/dpns-contract/blob/v0.2-dev/src/schema/dpns-documents.json) as an example), you then can perform the below actions :
11
11
 
12
12
  ```js
13
13
  const schema = {};// You JSON schema defining the app.
@@ -31,11 +31,11 @@ async function registerContract() {
31
31
  const {platform} = client;
32
32
  const identity = await getIdentity(appName);
33
33
  const contract = platform.contracts.create(schema, identity)
34
- const contractId = await platform.contracts.broadcast(contract, identity);
34
+ const contractId = await platform.contracts.publish(contract, identity);
35
35
  }
36
36
  ```
37
37
 
38
- ## Fetch or publish documents on your app
38
+ ## Fetch or publish documents on your app
39
39
 
40
40
  ```js
41
41
  const schema = {};// You JSON schema defining the app.
@@ -47,7 +47,7 @@ const client = new Dash.Client({
47
47
  },
48
48
  apps:{
49
49
  myapp:{
50
- contractId:""// The registered contract id
50
+ contractId:""// The registered contract id
51
51
  }
52
52
  }
53
53
  });
@@ -1,6 +1,6 @@
1
1
  ## Receive money and display balance
2
2
 
3
- Initialize the SDK Client with your [generated mnemonic](/examples/generate-a-new-mnemonic) passed as an option.
3
+ Initialize the SDK Client with your [generated mnemonic](../examples/generate-a-new-mnemonic.md) passed as an option.
4
4
  By default, the SDK Client will work on Evonet, the only network having DAPI at the time of writing.
5
5
 
6
6
  ```js
@@ -13,7 +13,7 @@ const client = new Dash.Client({
13
13
 
14
14
  Having set up your `client` instance, you be able to access the `account` and `wallet` instance generated from your mnemonic.
15
15
 
16
- You can read more on [how to use a different account](/examples/use-different-account) as by default, you are on the first BIP44 account.
16
+ You can read more on [how to use a different account](../examples/use-different-account.md) as by default, you are on the first BIP44 account.
17
17
 
18
18
 
19
19
  ## Generate a receiving address
@@ -11,4 +11,4 @@ const signed = account.sign(message, pk);
11
11
  const verify = message.verify(pk.toAddress().toString(), signed.toString());
12
12
  ```
13
13
 
14
- See [code snippet](https://github.com/dashevo/DashJS/blob/master/examples/node/sign-and-verify-messages.js).
14
+ See [code snippet](https://github.com/dashevo/platform/blob/master/packages/js-dash-sdk/examples/node/sign-and-verify-messages.js).
@@ -0,0 +1,55 @@
1
+ ## Updating an existing contract
2
+
3
+ To update your existing data contract you have to follow these steps:
4
+
5
+ ### Fetch your exising contract
6
+
7
+ ```js
8
+ const schema = {};// You JSON schema defining the app.
9
+ const client = new Dash.Client({
10
+ wallet: {
11
+ mnemonic: '', // Your app mnemonic, which holds the identity
12
+ },
13
+ });
14
+
15
+ const exisingContractId = ''; // Your existing data contract id
16
+
17
+ const existingDataContract = await client.platform.contracts.get(exisingContractId);
18
+ ```
19
+
20
+ ### Update document definitions
21
+
22
+ ```js
23
+ // Update an existing document
24
+ const documentDefinition = existingDataContract.getDocumentDefinition('myDocumentType');
25
+
26
+ // adding optional field
27
+ documentDefinition.properties.newField = {
28
+ type: 'integer',
29
+ minimum: 1,
30
+ };
31
+
32
+ existingDataContract.setDocumentDefinition('myDocumentType', documentDefinition);
33
+
34
+ // ... or, add a new one
35
+ const newDocumentDefinition = {
36
+ type: 'object',
37
+ properties: {
38
+ someField: {
39
+ type: 'integer',
40
+ minimum: 42,
41
+ },
42
+ },
43
+ required: ['someField'],
44
+ };
45
+
46
+ existingDataContract.setDocumentDefinition('myNewDocument', newDocumentDefinition);
47
+ ```
48
+
49
+ ### Broadcast your changes
50
+
51
+ ```js
52
+ await client.platform.contracts.update(existingDataContract, yourExistingIdentity);
53
+ ```
54
+
55
+ **Note, that update will be only allowed if schema is backward compatible. Also, version incremented by 1 and only one of following fields updated: `$defs`, `documents` or `version`**
@@ -16,7 +16,7 @@ Since the introduction of deterministic wallets ([BIP44](https://github.com/bitc
16
16
 
17
17
  It is the instance you will use most of the time for receiving or broadcasting payments.
18
18
 
19
- You can access your account with `client.getWalletAccount()` and see [how to use a different account](/examples/use-different-account) if you need to get a specific account index.
19
+ You can access your account with `client.getWalletAccount()` and see [how to use a different account](../examples/use-different-account.md) if you need to get a specific account index.
20
20
 
21
21
  ## App Schema and Contracts
22
22
 
@@ -25,4 +25,4 @@ The Dash Platform Chain, provides to developers the ability to create applicatio
25
25
  When registered, those applications schemas are called contracts and contains a contractId (namespace : `client.platform.contracts`).
26
26
  By default, this library supports Dash Platform Name Service (DPNS) (to attach a name to an identity), under the namespace `client.platform.names` for testnet.
27
27
 
28
- You can read more on [how to use DPNS on a local Evonet devnet](/examples/use-local-evonet.md) or [how to use multiple apps](/getting-started/multiple-apps.md).
28
+ You can read more on [how to use DPNS on a local Evonet devnet](../examples/use-local-evonet.md) or [how to use multiple apps](../getting-started/multiple-apps.md).
@@ -1,6 +1,6 @@
1
1
  ## DPNS
2
2
 
3
- DPNS is handled in the Dash SDK Client under the namespace `client.platform.names.*'`. [Read more here](/platform/names)
3
+ DPNS is handled in the Dash SDK Client under the namespace `client.platform.names.*'`. [Read more here](../platform/names/about-dpns.md)
4
4
 
5
5
  ## DashPay
6
6
 
@@ -50,7 +50,7 @@ client.getWalletAccount().then(async (account) => {
50
50
 
51
51
  ## Read a document
52
52
 
53
- At the time of writing, you will need to have registered a data contract yourself. See [publishing a new contract](/examples/publishing-a-new-contract.md).
53
+ At the time of writing, you will need to have registered a data contract yourself. See [publishing a new contract](../examples/publishing-a-new-contract.md).
54
54
 
55
55
  ```js
56
56
 
@@ -1,6 +1,6 @@
1
1
  ## What is a contract
2
2
 
3
- Contracts are a [registered](/examples/publishing-a-new-contract.md) set of rules defined in a [JSON Application Schema](/getting-started/core-concepts#schemas).
3
+ Contracts are a [registered](../../examples/publishing-a-new-contract.md) set of rules defined in a [JSON Application Schema](../../getting-started/core-concepts#schemas).
4
4
 
5
5
  See more on the Dash Platform documentation about [Data Contract](https://dashplatform.readme.io/docs/explanation-platform-protocol-data-contract).
6
6
 
@@ -6,7 +6,7 @@ Parameters:
6
6
  | parameters | type | required | Description |
7
7
  |--------------------------|-------------------|------------------ | ----------------------------------------------------------------- |
8
8
  | **contractDefinitions** | JSONDataContract | yes | The defined [JSON Application Schema](https://dashplatform.readme.io/docs/explanation-platform-protocol-data-contract) |
9
- | **identity** | Identity | yes | A valid [registered `application` identity](/platform/identities/register.md) |
9
+ | **identity** | Identity | yes | A valid [registered `application` identity](../identities/register.md) |
10
10
 
11
11
  **Example**:
12
12
 
@@ -31,6 +31,6 @@ Parameters:
31
31
  const validationResult = client.platform.dpp.dataContract.validate(contract);
32
32
  ```
33
33
 
34
- **Note**: When your contract is created, it will only exist locally, use the [broadcast](/platform/contracts/broadcast.md) method to register it.
34
+ **Note**: When your contract is created, it will only exist locally, use the [broadcast](../contracts/broadcast.md) method to register it.
35
35
 
36
36
  Returns : Contract.
@@ -1,12 +1,12 @@
1
- **Usage**: `client.platform.contracts.broadcast(contract, identity)`
2
- **Description**: This method will sign and broadcast any valid contract.
1
+ **Usage**: `client.platform.contracts.publish(contract, identity)`
2
+ **Description**: This method will sign and broadcast any valid contract.
3
3
 
4
- Parameters:
4
+ Parameters:
5
5
 
6
- | parameters | type | required | Description |
6
+ | parameters | type | required | Description |
7
7
  |---------------------------|-----------|----------------| ------------------------------------------------------------------------------|
8
- | **contract** | Contract | yes | A valid [created contract](/platform/contracts/create.md) |
9
- | **identity** | Identity | yes | A valid [registered `application` identity](/platform/identities/register.md) |
8
+ | **contract** | Contract | yes | A valid [created contract](../contracts/create.md) |
9
+ | **identity** | Identity | yes | A valid [registered `application` identity](../identities/register.md) |
10
10
 
11
11
  **Example**:
12
12
  ```js
@@ -14,7 +14,7 @@ const identityId = '';// Your identity identifier.
14
14
  const identity = await client.platform.identities.get(identityId);
15
15
  // See the contract.create documentation for more on how to create a dataContract
16
16
  const contract = await client.platform.contracts.create(contractDefinitions, identity);
17
- await platform.contracts.broadcast(contract, identity);
17
+ await platform.contracts.publish(contract, identity);
18
18
  ```
19
19
 
20
- Returns : dataContract.
20
+ Returns : DataContractCreateTransition.
@@ -0,0 +1,14 @@
1
+ **Usage**: `client.platform.contracts.update(contract, identity)`
2
+ **Description**: This method will sign and broadcast an updated valid contract.
3
+
4
+ Parameters:
5
+
6
+ | parameters | type | required | Description |
7
+ |---------------------------|-----------|----------------| ------------------------------------------------------------------------------|
8
+ | **contract** | Contract | yes | A valid [created contract](/platform/contracts/create.md) |
9
+ | **identity** | Identity | yes | A valid [registered `application` identity](/platform/identities/register.md) |
10
+
11
+ **Example**:
12
+ You may check [following document](/examples/updating-a-contract.md) for an example on how to update a contract.
13
+
14
+ Returns : DataContractUpdateTransition.
@@ -6,10 +6,10 @@ Parameters:
6
6
  | parameters | type | required | Description |
7
7
  |----------------------------|------------|----------| ----------------------------------------------------------------------------|
8
8
  | **documents** | Object | yes | |
9
- | **documents.create** | Document[] | no | array of valid [created document](/platform/documents/create.md) to create |
10
- | **documents.replace** | Document[] | no | array of valid [created document](/platform/documents/create.md) to replace |
11
- | **documents.delete** | Document[] | no | array of valid [created document](/platform/documents/create.md) to delete |
12
- | **identity** | Identity | yes | A valid [registered identity](/platform/identities/register.md) |
9
+ | **documents.create** | Document[] | no | array of valid [created document](../documents/create.md) to create |
10
+ | **documents.replace** | Document[] | no | array of valid [created document](../documents/create.md) to replace |
11
+ | **documents.delete** | Document[] | no | array of valid [created document](../documents/create.md) to delete |
12
+ | **identity** | Identity | yes | A valid [registered identity](../identities/register.md) |
13
13
 
14
14
 
15
15
  **Example**:
@@ -6,7 +6,7 @@ Parameters:
6
6
  | parameters | type | required | Description |
7
7
  |-------------------|---------|------------------ | ----------------------------------------------------------------- |
8
8
  | **dotLocator** | string | yes | Field of a specific application, under the form `appName.fieldName` |
9
- | **identity** | Identity| yes | A valid [registered identity](/platform/identities/register.md) |
9
+ | **identity** | Identity| yes | A valid [registered identity](../identities/register.md) |
10
10
  | **docOpts** | Object | yes | A valid data that match the data contract structure |
11
11
 
12
12
  **Example**:
@@ -21,6 +21,6 @@ const helloWorldDocument = await platform.documents.create(
21
21
  { message: 'Hello World'},
22
22
  );
23
23
  ```
24
- **Note**: When your document is created, it will only exist locally, use the [broadcast](/platform/documents/broadcast.md) method to register it.
24
+ **Note**: When your document is created, it will only exist locally, use the [broadcast](../documents/broadcast.md) method to register it.
25
25
 
26
26
  Returns: Document
@@ -4,7 +4,7 @@ An Identity is a blockchain-based identifier for individuals (users) and applica
4
4
  Identity is the atomic element that linked with additional applications can be extended to provide new functionality.
5
5
 
6
6
  Read more on the Dash Platform documentation about [Identity](https://dashplatform.readme.io/docs/explanation-identity).
7
- You might also want to consult the usage for the [DPNS Name Service](/platform/names) in order to attach a name to your created identity.
7
+ You might also want to consult the usage for the [DPNS Name Service](../names/about-dpns.md) in order to attach a name to your created identity.
8
8
 
9
9
  ## Credits
10
10
 
@@ -9,6 +9,6 @@ Parameters:
9
9
 
10
10
  **Example**: `await client.platform.identities.register()`
11
11
 
12
- **Note**: The created identity will be associated to the active account. You might want to know more about how to [change your active account](/examples/use-different-account).
12
+ **Note**: The created identity will be associated to the active account. You might want to know more about how to [change your active account](../../examples/use-different-account.md).
13
13
 
14
14
  Returns : Identity.
@@ -1,11 +1,13 @@
1
1
  **Usage**: `client.platform.identities.topUp(identity, amount)`
2
2
  **Description**: This method will topup the provided identity's balance.
3
3
 
4
+ _The identity balance might slightly vary from the topped up amount because of the transaction fee estimation._
5
+
4
6
  Parameters:
5
7
 
6
8
  | parameters | type | required | Description |
7
9
  |-------------------|---------|------------------| ----------------------------------------------------------------------------------------|
8
- | **identity** | Identity| yes | A valid [registered identity](/platform/identities/register.md) |
10
+ | **identity** | Identity| yes | A valid [registered identity](../identities/register.md) |
9
11
  | **amount** | number | yes | A duffs (satoshis) value corresponding to the amount you want to top up to the identity.|
10
12
 
11
13
  **Example**:
@@ -9,7 +9,7 @@ Parameters:
9
9
  | **records** | Object | yes | records object having only one of the following items |
10
10
  | **records.dashUniqueIdentityId** | String | no | Unique Identity ID for this name record |
11
11
  | **records.dashAliasIdentityId** | String | no | Used to signify that this name is the alias for another id |
12
- | **identity** | Identity | yes | A valid [registered identity](/platform/identities/register.md) |
12
+ | **identity** | Identity | yes | A valid [registered identity](../identities/register.md) |
13
13
 
14
14
 
15
15
  **Example**: `await client.platform.identities.register('alice', { dashUniqueIdentityId: identity.getId() }, identity)`
@@ -4,4 +4,4 @@ When Dash.Client is initiated with a `mnemonic` property, a wallet instance is a
4
4
 
5
5
  In order to ensure the sync-up with the network has happened, you will need to wait for the method `client.isReady()` to resolve.
6
6
 
7
- You will find else where the [complete documentation of Wallet-lib](https://github.com/dashevo/wallet-lib), as we only cover the most basic pieces in this documentation.
7
+ You will find else where the [complete documentation of Wallet-lib](https://github.com/dashevo/platform/tree/master/packages/wallet-lib), as we only cover the most basic pieces in this documentation.
@@ -28,7 +28,7 @@ const registerContract = async function () {
28
28
 
29
29
  const contract = await platform.contracts.create(contractDocuments, identity);
30
30
  await platform.dpp.dataContract.validate(contract)
31
- await platform.contracts.broadcast(contract, identity);
31
+ await platform.contracts.publish(contract, identity);
32
32
  };
33
33
 
34
34
  registerContract();
@@ -2,6 +2,7 @@
2
2
  "contact": {
3
3
  "indices": [
4
4
  {
5
+ "name": "userIdToUserId",
5
6
  "unique": true,
6
7
  "properties": [
7
8
  {
@@ -30,6 +31,7 @@
30
31
  "profile": {
31
32
  "indices": [
32
33
  {
34
+ "name": "userId",
33
35
  "unique": true,
34
36
  "properties": [
35
37
  {
package/karma.conf.js CHANGED
@@ -4,13 +4,20 @@ const dotenvResult = require('dotenv-safe').config();
4
4
 
5
5
  const webpackBaseConfig = require("./webpack.base.config");
6
6
 
7
+ const karmaMocha = require('karma-mocha');
8
+ const karmaMochaReporter = require('karma-mocha-reporter');
9
+ const karmaChai = require('karma-chai');
10
+ const karmaChromeLauncher = require('karma-chrome-launcher');
11
+ const karmaFirefoxLauncher = require('karma-firefox-launcher');
12
+ const karmaWebpack = require('karma-webpack');
13
+
7
14
  if (dotenvResult.error) {
8
15
  throw dotenvResult.error;
9
16
  }
10
17
 
11
18
  module.exports = (config) => {
12
19
  config.set({
13
- frameworks: ['mocha', 'chai'],
20
+ frameworks: ['mocha', 'chai', 'webpack'],
14
21
  files: [
15
22
  'src/**/*.spec.ts',
16
23
  'src/test/karma/bootstrap.ts',
@@ -39,14 +46,16 @@ module.exports = (config) => {
39
46
  browsers: ['ChromeHeadless', 'FirefoxHeadless'],
40
47
  singleRun: false,
41
48
  concurrency: Infinity,
42
- browserNoActivityTimeout: 7 * 60 * 1000,
49
+ browserNoActivityTimeout: 7 * 60 * 1000, // 30000 default
50
+ browserDisconnectTimeout: 3 * 2000, // 2000 default
51
+ pingTimeout: 3 * 5000, // 5000 default
43
52
  plugins: [
44
- 'karma-mocha',
45
- 'karma-mocha-reporter',
46
- 'karma-chai',
47
- 'karma-chrome-launcher',
48
- 'karma-firefox-launcher',
49
- 'karma-webpack',
53
+ karmaMocha,
54
+ karmaMochaReporter,
55
+ karmaChai,
56
+ karmaChromeLauncher,
57
+ karmaFirefoxLauncher,
58
+ karmaWebpack,
50
59
  ],
51
60
  customLaunchers: {
52
61
  FirefoxHeadless: {
package/package.json CHANGED
@@ -1,21 +1,27 @@
1
1
  {
2
2
  "name": "dash",
3
- "version": "3.22.0-dev.1",
3
+ "version": "3.22.0-dev.10",
4
4
  "description": "Dash library for JavaScript/TypeScript ecosystem (Wallet, DAPI, Primitives, BLS, ...)",
5
5
  "main": "build/src/index.js",
6
6
  "unpkg": "dist/dash.min.js",
7
7
  "types": "dist/src/index.d.ts",
8
8
  "scripts": {
9
- "start:dev": "nodemon --exec 'npm run build && npm run test:unit'",
10
- "build": "npm run build:web",
11
- "build:web": "npm run build:ts && webpack --stats-error-details",
9
+ "start:dev": "nodemon --exec 'yarn run build && yarn run test:unit'",
10
+ "build": "yarn run build:ts",
11
+ "build:web": "yarn run build:ts && webpack --stats-error-details",
12
12
  "build:ts": "tsc",
13
- "test": "npm run test:unit && npm run test:functional && npm run test:browsers",
13
+ "lint": "",
14
+ "test": "yarn run test:unit && yarn run test:functional && yarn run test:browsers",
14
15
  "test:browsers": "karma start ./karma.conf.js --single-run",
15
- "test:unit": "mocha -r ts-node/register \"src/**/*.spec.ts\"",
16
- "test:functional": "npm run build && mocha --recursive tests/functional/**/*.js",
17
- "prepublishOnly": "npm run build",
18
- "prepare": "npm run build"
16
+ "test:unit": "TS_NODE_COMPILER_OPTIONS={\"target\":\"es6\"} ts-mocha \"src/**/*.spec.ts\"",
17
+ "test:functional": "yarn run build && mocha --recursive tests/functional/**/*.js",
18
+ "prepublishOnly": "yarn run build:web",
19
+ "prepare": "yarn run build"
20
+ },
21
+ "ultra": {
22
+ "concurrent": [
23
+ "test"
24
+ ]
19
25
  },
20
26
  "repository": {
21
27
  "type": "git",
@@ -28,13 +34,16 @@
28
34
  },
29
35
  "homepage": "https://github.com/dashevo/DashJS#readme",
30
36
  "dependencies": {
31
- "@dashevo/dapi-client": "0.21.2",
32
- "@dashevo/dashcore-lib": "~0.19.26",
33
- "@dashevo/dpp": "~0.21.0",
34
- "@dashevo/grpc-common": "~0.5.4",
35
- "@dashevo/wallet-lib": "~7.22.0-dev.1",
37
+ "@dashevo/dapi-client": "~0.22.0-dev.10",
38
+ "@dashevo/dashcore-lib": "~0.19.30",
39
+ "@dashevo/dashpay-contract": "~0.22.0-dev.10",
40
+ "@dashevo/dpns-contract": "~0.22.0-dev.10",
41
+ "@dashevo/dpp": "~0.22.0-dev.10",
42
+ "@dashevo/grpc-common": "~0.22.0-dev.10",
43
+ "@dashevo/masternode-reward-shares-contract": "~0.22.0-dev.10",
44
+ "@dashevo/wallet-lib": "~7.22.0-dev.10",
36
45
  "bs58": "^4.0.1",
37
- "node-inspect-extracted": "1.0.7"
46
+ "node-inspect-extracted": "^1.0.8"
38
47
  },
39
48
  "devDependencies": {
40
49
  "@types/chai": "^4.2.12",
@@ -47,36 +56,39 @@
47
56
  "assert": "^2.0.0",
48
57
  "browserify-zlib": "^0.2.0",
49
58
  "buffer": "^6.0.3",
50
- "chai": "^4.2.0",
59
+ "chai": "^4.3.4",
51
60
  "chance": "^1.1.6",
52
61
  "crypto-browserify": "^3.12.0",
53
62
  "dirty-chai": "^2.0.1",
54
63
  "dotenv-safe": "^8.2.0",
64
+ "events": "^3.3.0",
55
65
  "https-browserify": "^1.0.0",
56
- "karma": "^5.1.1",
66
+ "karma": "^6.3.4",
57
67
  "karma-chai": "^0.1.0",
58
68
  "karma-chrome-launcher": "^3.1.0",
59
- "karma-firefox-launcher": "^1.3.0",
69
+ "karma-firefox-launcher": "^2.1.1",
60
70
  "karma-mocha": "^2.0.1",
61
71
  "karma-mocha-reporter": "^2.2.5",
62
72
  "karma-webpack": "^5.0.0",
63
- "mocha": "^8.1.1",
73
+ "mocha": "^9.1.2",
64
74
  "nodemon": "^2.0.4",
65
75
  "os-browserify": "^0.3.0",
66
76
  "path-browserify": "^1.0.1",
67
77
  "process": "^0.11.10",
68
78
  "rimraf": "^3.0.2",
69
- "sinon": "^9.0.3",
70
- "sinon-chai": "^3.5.0",
79
+ "sinon": "^11.1.2",
80
+ "sinon-chai": "^3.7.0",
71
81
  "stream-browserify": "^3.0.0",
72
82
  "stream-http": "^3.2.0",
83
+ "string_decoder": "^1.3.0",
73
84
  "ts-loader": "^8.0.2",
85
+ "ts-mocha": "^8.0.0",
74
86
  "ts-mock-imports": "^1.3.0",
75
- "ts-node": "^8.10.2",
87
+ "ts-node": "^10.4.0",
76
88
  "typescript": "^3.9.5",
77
89
  "url": "^0.11.0",
78
90
  "util": "^0.12.4",
79
91
  "webpack": "^5.59.1",
80
92
  "webpack-cli": "^4.9.1"
81
93
  }
82
- }
94
+ }
@@ -269,7 +269,7 @@ describe('Dash - Client', function suite() {
269
269
  const interceptedSt = await client.platform.dpp.stateTransition.createFromBuffer(serializedSt);
270
270
 
271
271
  // .to.be.true() doesn't work after TS compilation in Chrome
272
- expect(interceptedSt.verifySignature(identityFixture.getPublicKeyById(0))).to.be.equal(true);
272
+ expect(await interceptedSt.verifySignature(identityFixture.getPublicKeyById(0))).to.be.equal(true);
273
273
 
274
274
  const documentTransitions = interceptedSt.getTransitions();
275
275
 
@@ -278,7 +278,7 @@ describe('Dash - Client', function suite() {
278
278
  });
279
279
  });
280
280
 
281
- describe('#platform.contracts.broadcast', () => {
281
+ describe('#platform.contracts.publish', () => {
282
282
  it('should throw TransitionBroadcastError when transport resolves error', async () => {
283
283
  const errorResponse = {
284
284
  error: {
@@ -292,7 +292,7 @@ describe('Dash - Client', function suite() {
292
292
 
293
293
  let error;
294
294
  try {
295
- await client.platform.contracts.broadcast(dataContractFixture, identityFixture);
295
+ await client.platform.contracts.publish(dataContractFixture, identityFixture);
296
296
  } catch (e) {
297
297
  error = e;
298
298
  }
@@ -307,13 +307,13 @@ describe('Dash - Client', function suite() {
307
307
  proof: { }
308
308
  });
309
309
 
310
- await client.platform.contracts.broadcast(dataContractFixture, identityFixture);
310
+ await client.platform.contracts.publish(dataContractFixture, identityFixture);
311
311
 
312
312
  const serializedSt = dapiClientMock.platform.broadcastStateTransition.getCall(0).args[0];
313
313
  const interceptedSt = await client.platform.dpp.stateTransition.createFromBuffer(serializedSt);
314
314
 
315
315
  // .to.be.true() doesn't work after TS compilation in Chrome
316
- expect(interceptedSt.verifySignature(identityFixture.getPublicKeyById(0))).to.be.equal(true);
316
+ expect(await interceptedSt.verifySignature(identityFixture.getPublicKeyById(0))).to.be.equal(true);
317
317
  expect(interceptedSt.getEntropy()).to.be.deep.equal(dataContractFixture.entropy);
318
318
  expect(interceptedSt.getDataContract().toObject()).to.be.deep.equal(dataContractFixture.toObject());
319
319
  });
@@ -4,6 +4,9 @@ import DAPIClientTransport from "@dashevo/wallet-lib/src/transport/DAPIClientTra
4
4
  import { Platform } from './Platform';
5
5
  import { Network } from "@dashevo/dashcore-lib";
6
6
  import DAPIClient from "@dashevo/dapi-client";
7
+ import { contractId as dpnsContractId } from "@dashevo/dpns-contract/lib/systemIds";
8
+ import { contractId as dashpayContractId } from "@dashevo/dashpay-contract/lib/systemIds";
9
+ import { contractId as masternodeRewardSharesContractId } from "@dashevo/masternode-reward-shares-contract/lib/systemIds";
7
10
  import { ClientApps, ClientAppsOptions } from "./ClientApps";
8
11
 
9
12
  export interface WalletOptions extends Wallet.IWalletOptions {
@@ -107,11 +110,14 @@ export class Client extends EventEmitter {
107
110
 
108
111
  this.apps = new ClientApps(Object.assign({
109
112
  dpns: {
110
- contractId: 'Bw9PUC3aSEGQ4j5qrvpNLrRNFPVMiUHZLr1atgfYJcmf'
113
+ contractId: dpnsContractId,
111
114
  },
112
115
  dashpay: {
113
- contractId: '2Vuou3EfbrtunwCZvQp1XS5PXZ5CgC1pGBz4VPT4ojmy',
116
+ contractId: dashpayContractId,
114
117
  },
118
+ masternodeRewardShares: {
119
+ contractId: masternodeRewardSharesContractId,
120
+ }
115
121
  }, this.options.apps));
116
122
 
117
123
  this.platform = new Platform({
@@ -1,4 +1,3 @@
1
1
  export interface IPlatformStateProof {
2
- rootTreeProof: Buffer,
3
- storeTreeProof: Buffer,
2
+ merkleProof: Buffer,
4
3
  }
@@ -2,12 +2,14 @@
2
2
  import DashPlatformProtocol from "@dashevo/dpp";
3
3
 
4
4
  import Client from "../Client";
5
+ import { IStateTransitionResult } from './IStateTransitionResult';
5
6
 
6
7
  import broadcastDocument from "./methods/documents/broadcast";
7
8
  import createDocument from "./methods/documents/create";
8
9
  import getDocument from "./methods/documents/get";
9
10
 
10
- import broadcastContract from "./methods/contracts/broadcast";
11
+ import publishContract from "./methods/contracts/publish";
12
+ import updateContract from "./methods/contracts/update";
11
13
  import createContract from "./methods/contracts/create";
12
14
  import getContract from "./methods/contracts/get";
13
15
 
@@ -20,7 +22,6 @@ import resolveName from "./methods/names/resolve";
20
22
  import resolveNameByRecord from "./methods/names/resolveByRecord";
21
23
  import searchName from "./methods/names/search";
22
24
  import broadcastStateTransition from "./broadcastStateTransition";
23
- import { IPlatformStateProof } from "./IPlatformStateProof";
24
25
  import StateRepository from './StateRepository';
25
26
  import { latestVersion as latestProtocolVersion } from "@dashevo/dpp/lib/version/protocolVersion";
26
27
 
@@ -66,6 +67,13 @@ interface Identities {
66
67
  topUp: Function,
67
68
  }
68
69
 
70
+ interface DataContracts {
71
+ update: Function,
72
+ publish: Function,
73
+ create: Function,
74
+ get: Function,
75
+ }
76
+
69
77
  /**
70
78
  * Class for Dash Platform
71
79
  *
@@ -93,13 +101,13 @@ export class Platform {
93
101
  * @param {Function} create - create contracts which can be broadcasted
94
102
  * @param {Function} register - register contracts on the platform
95
103
  */
96
- public contracts: Records;
104
+ public contracts: DataContracts;
97
105
 
98
106
  /**
99
107
  * Broadcasts state transition
100
108
  * @param {Object} stateTransition
101
109
  */
102
- public broadcastStateTransition(stateTransition: any): Promise<IPlatformStateProof|void> {
110
+ public broadcastStateTransition(stateTransition: any): Promise<IStateTransitionResult|void> {
103
111
  return broadcastStateTransition(this, stateTransition);
104
112
  };
105
113
 
@@ -121,7 +129,8 @@ export class Platform {
121
129
  get: getDocument.bind(this),
122
130
  };
123
131
  this.contracts = {
124
- broadcast: broadcastContract.bind(this),
132
+ publish: publishContract.bind(this),
133
+ update: updateContract.bind(this),
125
134
  create: createContract.bind(this),
126
135
  get: getContract.bind(this),
127
136
  };