dash 3.22.11 → 3.22.14

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 (92) hide show
  1. package/README.md +57 -14
  2. package/build/src/SDK/Client/Platform/Platform.js +12 -0
  3. package/build/src/SDK/Client/Platform/Platform.js.map +1 -1
  4. package/build/src/SDK/Client/Platform/createAssetLockTransaction.js +8 -4
  5. package/build/src/SDK/Client/Platform/createAssetLockTransaction.js.map +1 -1
  6. package/build/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.js +8 -4
  7. package/build/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.js.map +1 -1
  8. package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js +8 -4
  9. package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js.map +1 -1
  10. package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js +8 -4
  11. package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js.map +1 -1
  12. package/build/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.js +7 -3
  13. package/build/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.js.map +1 -1
  14. package/build/src/SDK/Client/Platform/methods/identities/register.js +5 -6
  15. package/build/src/SDK/Client/Platform/methods/identities/register.js.map +1 -1
  16. package/build/src/SDK/Client/Platform/methods/identities/topUp.js +5 -7
  17. package/build/src/SDK/Client/Platform/methods/identities/topUp.js.map +1 -1
  18. package/build/src/SDK/SDK.js +10 -0
  19. package/build/src/SDK/SDK.js.map +1 -1
  20. package/build-utils/ws.js +15 -0
  21. package/dist/dash.min.js +9 -0
  22. package/dist/dash.min.js.LICENSE.txt +80 -0
  23. package/dist/dash.min.js.map +1 -0
  24. package/dist/src/SDK/Client/Platform/Platform.d.ts +7 -0
  25. package/dist/src/SDK/Client/Platform/createAssetLockTransaction.d.ts +3 -2
  26. package/dist/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.d.ts +3 -2
  27. package/dist/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.d.ts +3 -2
  28. package/dist/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.d.ts +3 -2
  29. package/dist/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.d.ts +2 -1
  30. package/dist/src/SDK/SDK.d.ts +9 -0
  31. package/docs/README.md +11 -52
  32. package/docs/_sidebar.md +0 -17
  33. package/docs/examples/fetch-an-identity-from-its-name.md +5 -9
  34. package/docs/examples/generate-a-new-mnemonic.md +1 -1
  35. package/docs/examples/pay-to-another-address.md +16 -13
  36. package/docs/examples/receive-money-and-check-balance.md +55 -39
  37. package/docs/examples/sign-and-verify-messages.md +19 -9
  38. package/docs/examples/use-different-account.md +5 -17
  39. package/docs/getting-started/core-concepts.md +6 -5
  40. package/docs/getting-started/dash-platform-applications.md +1 -1
  41. package/docs/getting-started/quickstart.md +7 -24
  42. package/docs/getting-started/with-typescript.md +5 -2
  43. package/docs/index.html +2 -2
  44. package/docs/platform/about-platform.md +5 -5
  45. package/docs/platform/contracts/about-contracts.md +2 -2
  46. package/docs/platform/contracts/create.md +5 -5
  47. package/docs/platform/contracts/get.md +1 -1
  48. package/docs/platform/contracts/publish.md +3 -3
  49. package/docs/platform/contracts/update.md +1 -4
  50. package/docs/platform/documents/broadcast.md +15 -15
  51. package/docs/platform/documents/create.md +5 -5
  52. package/docs/platform/documents/get.md +6 -5
  53. package/docs/platform/identities/about-identity.md +1 -1
  54. package/docs/platform/identities/get.md +1 -1
  55. package/docs/platform/identities/register.md +1 -1
  56. package/docs/platform/identities/topUp.md +2 -2
  57. package/docs/platform/names/about-dpns.md +1 -1
  58. package/docs/platform/names/register.md +9 -9
  59. package/docs/platform/names/resolve.md +1 -1
  60. package/docs/platform/names/resolveByRecord.md +9 -8
  61. package/docs/platform/names/search.md +1 -1
  62. package/docs/usage/dashcorelib-primitives.md +48 -37
  63. package/docs/wallet/about-wallet-lib.md +3 -3
  64. package/docs/wallet/accounts.md +11 -7
  65. package/docs/wallet/signing-encrypt.md +12 -6
  66. package/package.json +16 -12
  67. package/src/SDK/Client/Platform/Platform.ts +21 -0
  68. package/src/SDK/Client/Platform/createAssetLockTransaction.ts +5 -2
  69. package/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.ts +5 -2
  70. package/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts +5 -2
  71. package/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.ts +5 -2
  72. package/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.ts +4 -3
  73. package/src/SDK/Client/Platform/methods/identities/register.ts +7 -8
  74. package/src/SDK/Client/Platform/methods/identities/topUp.ts +5 -8
  75. package/src/SDK/SDK.ts +34 -21
  76. package/webpack.base.config.js +14 -0
  77. package/webpack.config.js +6 -2
  78. package/docs/examples/publishing-a-new-contract.md +0 -68
  79. package/docs/examples/updating-a-contract.md +0 -55
  80. package/docs/examples/use-local-evonet.md +0 -19
  81. package/examples/node/create-and-fund-wallet.js +0 -28
  82. package/examples/node/register-contract.js +0 -34
  83. package/examples/node/register-identity.js +0 -23
  84. package/examples/node/register-name.js +0 -19
  85. package/examples/node/retrieve-contract.js +0 -20
  86. package/examples/node/retrieve-documents.js +0 -22
  87. package/examples/node/retrieve-identity.js +0 -20
  88. package/examples/node/retrieve-name.js +0 -14
  89. package/examples/node/sign-and-verify-messages.js +0 -29
  90. package/examples/schema.json +0 -58
  91. package/examples/web/usage.web.html +0 -12
  92. package/examples/web/usage.web.js +0 -28
package/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "dash",
3
- "version": "3.22.11",
3
+ "version": "3.22.14",
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
+ "browser": "dist/dash.min.js",
7
8
  "types": "dist/src/index.d.ts",
8
9
  "scripts": {
9
10
  "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",
11
+ "start:ts": "tsc --watch",
12
+ "build": "yarn run build:ts && webpack --stats-error-details",
12
13
  "build:ts": "tsc",
13
14
  "lint": "",
14
15
  "test": "yarn run test:unit && yarn run test:functional && yarn run test:browsers",
15
16
  "test:browsers": "karma start ./karma.conf.js --single-run",
16
17
  "test:unit": "TS_NODE_COMPILER_OPTIONS={\"target\":\"es6\"} ts-mocha \"src/**/*.spec.ts\"",
17
18
  "test:functional": "yarn run build && mocha --recursive tests/functional/**/*.js",
18
- "prepublishOnly": "yarn run build:web",
19
+ "prepublishOnly": "yarn run build",
19
20
  "prepare": "yarn run build"
20
21
  },
21
22
  "ultra": {
@@ -34,14 +35,14 @@
34
35
  },
35
36
  "homepage": "https://github.com/dashevo/DashJS#readme",
36
37
  "dependencies": {
37
- "@dashevo/dapi-client": "~0.22.11",
38
- "@dashevo/dashcore-lib": "~0.19.38",
39
- "@dashevo/dashpay-contract": "~0.22.11",
40
- "@dashevo/dpns-contract": "~0.22.11",
41
- "@dashevo/dpp": "~0.22.11",
42
- "@dashevo/grpc-common": "~0.22.11",
43
- "@dashevo/masternode-reward-shares-contract": "~0.22.11",
44
- "@dashevo/wallet-lib": "~7.22.11",
38
+ "@dashevo/dapi-client": "~0.22.14",
39
+ "@dashevo/dashcore-lib": "~0.19.39",
40
+ "@dashevo/dashpay-contract": "~0.22.14",
41
+ "@dashevo/dpns-contract": "~0.22.14",
42
+ "@dashevo/dpp": "~0.22.14",
43
+ "@dashevo/grpc-common": "~0.22.14",
44
+ "@dashevo/masternode-reward-shares-contract": "~0.22.14",
45
+ "@dashevo/wallet-lib": "~7.22.14",
45
46
  "bs58": "^4.0.1",
46
47
  "node-inspect-extracted": "^1.0.8"
47
48
  },
@@ -71,6 +72,7 @@
71
72
  "karma-mocha-reporter": "^2.2.5",
72
73
  "karma-webpack": "^5.0.0",
73
74
  "mocha": "^9.1.2",
75
+ "net": "^1.0.2",
74
76
  "nodemon": "^2.0.4",
75
77
  "os-browserify": "^0.3.0",
76
78
  "path-browserify": "^1.0.1",
@@ -81,6 +83,8 @@
81
83
  "stream-browserify": "^3.0.0",
82
84
  "stream-http": "^3.2.0",
83
85
  "string_decoder": "^1.3.0",
86
+ "terser-webpack-plugin": "^5.3.1",
87
+ "tls": "^0.0.1",
84
88
  "ts-loader": "^8.0.2",
85
89
  "ts-mocha": "^8.0.0",
86
90
  "ts-mock-imports": "^1.3.0",
@@ -4,6 +4,8 @@ import DashPlatformProtocol from "@dashevo/dpp";
4
4
  import Client from "../Client";
5
5
  import { IStateTransitionResult } from './IStateTransitionResult';
6
6
 
7
+ import createAssetLockTransaction from "./createAssetLockTransaction";
8
+
7
9
  import broadcastDocument from "./methods/documents/broadcast";
8
10
  import createDocument from "./methods/documents/create";
9
11
  import getDocument from "./methods/documents/get";
@@ -16,6 +18,10 @@ import getContract from "./methods/contracts/get";
16
18
  import getIdentity from "./methods/identities/get";
17
19
  import registerIdentity from "./methods/identities/register";
18
20
  import topUpIdentity from "./methods/identities/topUp";
21
+ import createIdentityCreateTransition from "./methods/identities/internal/createIdentityCreateTransition";
22
+ import createIdentityTopUpTransition from "./methods/identities/internal/createIdnetityTopUpTransition";
23
+ import createAssetLockProof from "./methods/identities/internal/createAssetLockProof";
24
+ import waitForCoreChainLockedHeight from "./methods/identities/internal/waitForCoreChainLockedHeight";
19
25
 
20
26
  import registerName from "./methods/names/register";
21
27
  import resolveName from "./methods/names/resolve";
@@ -65,6 +71,13 @@ interface Identities {
65
71
  get: Function,
66
72
  register: Function,
67
73
  topUp: Function,
74
+ utils: {
75
+ createAssetLockTransaction: Function
76
+ createAssetLockProof: Function
77
+ createIdentityCreateTransition: Function
78
+ createIdentityTopUpTransition: Function
79
+ waitForCoreChainLockedHeight: Function
80
+ }
68
81
  }
69
82
 
70
83
  interface DataContracts {
@@ -144,6 +157,13 @@ export class Platform {
144
157
  register: registerIdentity.bind(this),
145
158
  get: getIdentity.bind(this),
146
159
  topUp: topUpIdentity.bind(this),
160
+ utils: {
161
+ createAssetLockProof: createAssetLockProof.bind(this),
162
+ createAssetLockTransaction: createAssetLockTransaction.bind(this),
163
+ createIdentityCreateTransition: createIdentityCreateTransition.bind(this),
164
+ createIdentityTopUpTransition: createIdentityTopUpTransition.bind(this),
165
+ waitForCoreChainLockedHeight: waitForCoreChainLockedHeight.bind(this),
166
+ }
147
167
  };
148
168
 
149
169
  this.client = options.client;
@@ -172,3 +192,4 @@ export class Platform {
172
192
  await this.dpp.initialize();
173
193
  }
174
194
  }
195
+
@@ -7,12 +7,13 @@ const ASSET_LOCK_OUTPUT_INDEX = 0;
7
7
 
8
8
  /**
9
9
  * Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
10
- * @param {Platform} platform
10
+ * @param {Platform} this
11
11
  * @param {number} fundingAmount - amount of dash to fund the identity's credits
12
12
  * @return {Promise<{transaction: Transaction, privateKey: PrivateKey}>} - transaction and one time private key
13
13
  * that can be used to sign registration/top-up state transition
14
14
  */
15
- export default async function createAssetLockTransaction(platform : Platform, fundingAmount): Promise<{ transaction: Transaction, privateKey: PrivateKey, outputIndex: number }> {
15
+ export async function createAssetLockTransaction(this : Platform, fundingAmount): Promise<{ transaction: Transaction, privateKey: PrivateKey, outputIndex: number }> {
16
+ const platform = this;
16
17
  const account = await platform.client.getWalletAccount();
17
18
 
18
19
  // @ts-ignore
@@ -61,3 +62,5 @@ export default async function createAssetLockTransaction(platform : Platform, fu
61
62
  outputIndex: ASSET_LOCK_OUTPUT_INDEX,
62
63
  };
63
64
  }
65
+
66
+ export default createAssetLockTransaction;
@@ -7,13 +7,14 @@ const { InstantLockTimeoutError, TxMetadataTimeoutError } = require('@dashevo/wa
7
7
 
8
8
  /**
9
9
  * Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
10
- * @param {Platform} platform
10
+ * @param {Platform} this
11
11
  * @param {Transaction} assetLockTransaction
12
12
  * @param {number} outputIndex - index of the funding output in the asset lock transaction
13
13
  * @return {AssetLockProof} - asset lock proof to be used in the state transition
14
14
  * that can be used to sign registration/top-up state transition
15
15
  */
16
- export default async function createAssetLockProof(platform : Platform, assetLockTransaction: Transaction, outputIndex: number): Promise<any> {
16
+ export async function createAssetLockProof(this : Platform, assetLockTransaction: Transaction, outputIndex: number): Promise<any> {
17
+ const platform = this;
17
18
  await platform.initialize();
18
19
 
19
20
  const account = await platform.client.getWalletAccount();
@@ -119,3 +120,5 @@ export default async function createAssetLockProof(platform : Platform, assetLoc
119
120
  })
120
121
  ]);
121
122
  }
123
+
124
+ export default createAssetLockProof;
@@ -4,13 +4,14 @@ import IdentityPublicKey from "@dashevo/dpp/lib/identity/IdentityPublicKey"
4
4
 
5
5
  /**
6
6
  * Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
7
- * @param {Platform} platform
7
+ * @param {Platform} this
8
8
  * @param {AssetLockProof} assetLockProof - asset lock transaction proof for the identity create transition
9
9
  * @param {PrivateKey} assetLockPrivateKey - private key used in asset lock
10
10
  * @return {{identity: Identity, identityCreateTransition: IdentityCreateTransition}} - identity, state transition and index of the key used to create it
11
11
  * that can be used to sign registration/top-up state transition
12
12
  */
13
- export default async function createIdentityCreateTransition(platform : Platform, assetLockProof: any, assetLockPrivateKey: PrivateKey): Promise<{ identity: any, identityCreateTransition: any, identityIndex: number }> {
13
+ export async function createIdentityCreateTransition(this : Platform, assetLockProof: any, assetLockPrivateKey: PrivateKey): Promise<{ identity: any, identityCreateTransition: any, identityIndex: number }> {
14
+ const platform = this;
14
15
  await platform.initialize();
15
16
 
16
17
  const account = await platform.client.getWalletAccount();
@@ -45,3 +46,5 @@ export default async function createIdentityCreateTransition(platform : Platform
45
46
 
46
47
  return { identity, identityCreateTransition, identityIndex };
47
48
  }
49
+
50
+ export default createIdentityCreateTransition;
@@ -4,14 +4,15 @@ import IdentityPublicKey from "@dashevo/dpp/lib/identity/IdentityPublicKey"
4
4
 
5
5
  /**
6
6
  * Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
7
- * @param {Platform} platform
7
+ * @param {Platform} this
8
8
  * @param {AssetLockProof} assetLockProof - asset lock transaction proof for the identity create transition
9
9
  * @param {PrivateKey} assetLockPrivateKey - private key used in asset lock
10
10
  * @param {string|Buffer|Identifier} identityId
11
11
  * @return {{identity: Identity, identityCreateTransition: IdentityCreateTransition}} - identity, state transition and index of the key used to create it
12
12
  * that can be used to sign registration/top-up state transition
13
13
  */
14
- export default async function createIdentityTopUpTransition(platform : Platform, assetLockProof: any, assetLockPrivateKey: PrivateKey, identityId: any): Promise<any> {
14
+ export async function createIdentityTopUpTransition(this : Platform, assetLockProof: any, assetLockPrivateKey: PrivateKey, identityId: any): Promise<any> {
15
+ const platform = this;
15
16
  await platform.initialize();
16
17
 
17
18
  const { dpp } = platform;
@@ -31,3 +32,5 @@ export default async function createIdentityTopUpTransition(platform : Platform,
31
32
 
32
33
  return identityTopUpTransition;
33
34
  }
35
+
36
+ export default createIdentityTopUpTransition;
@@ -2,10 +2,11 @@ import { Platform } from "../../../Platform";
2
2
 
3
3
  import { ownerId as dpnsOwnerId } from "@dashevo/dpns-contract/lib/systemIds";
4
4
 
5
- export default async function waitForCoreChainLockedHeight(
6
- platform : Platform,
5
+ export async function waitForCoreChainLockedHeight(
6
+ this : Platform,
7
7
  expectedCoreHeight : number,
8
8
  ): Promise<{ promise: Promise<any>, cancel: Function }> {
9
+ const platform = this;
9
10
  await platform.initialize();
10
11
 
11
12
  const interval = 5000;
@@ -64,6 +65,6 @@ export default async function waitForCoreChainLockedHeight(
64
65
  }
65
66
  }
66
67
 
67
-
68
+ export default waitForCoreChainLockedHeight;
68
69
 
69
70
 
@@ -1,7 +1,4 @@
1
1
  import { Platform } from "../../Platform";
2
- import createAssetLockTransaction from "../../createAssetLockTransaction";
3
- import createIdentityCreateTransition from "./internal/createIdentityCreateTransition";
4
- import createAssetLockProof from "./internal/createAssetLockProof";
5
2
  import broadcastStateTransition from "../../broadcastStateTransition";
6
3
 
7
4
  /**
@@ -24,15 +21,17 @@ export default async function register(
24
21
  transaction: assetLockTransaction,
25
22
  privateKey: assetLockPrivateKey,
26
23
  outputIndex: assetLockOutputIndex
27
- } = await createAssetLockTransaction(this, fundingAmount);
24
+ } = await this.identities.utils.createAssetLockTransaction(fundingAmount);
28
25
 
29
26
  // Broadcast Asset Lock transaction
30
27
  await account.broadcastTransaction(assetLockTransaction);
31
- const assetLockProof = await createAssetLockProof(this, assetLockTransaction, assetLockOutputIndex);
32
28
 
33
- const { identity, identityCreateTransition, identityIndex } = await createIdentityCreateTransition(
34
- this, assetLockProof, assetLockPrivateKey
35
- );
29
+ const assetLockProof = await this.identities.utils
30
+ .createAssetLockProof(assetLockTransaction, assetLockOutputIndex);
31
+
32
+ const { identity, identityCreateTransition, identityIndex } = await this.identities.utils
33
+ .createIdentityCreateTransition(assetLockProof, assetLockPrivateKey);
34
+
36
35
  await broadcastStateTransition(this, identityCreateTransition);
37
36
 
38
37
  // If state transition was broadcast without any errors, import identity to the account
@@ -1,10 +1,6 @@
1
- // @ts-ignore
2
1
  import Identifier from "@dashevo/dpp/lib/Identifier";
3
2
  import {Platform} from "../../Platform";
4
3
 
5
- import createAssetLockTransaction from "../../createAssetLockTransaction";
6
- import createAssetLockProof from "./internal/createAssetLockProof";
7
- import createIdentityTopUpTransition from "./internal/createIdnetityTopUpTransition";
8
4
  import broadcastStateTransition from "../../broadcastStateTransition";
9
5
 
10
6
  /**
@@ -28,15 +24,16 @@ export async function topUp(this: Platform, identityId: Identifier | string, amo
28
24
  transaction: assetLockTransaction,
29
25
  privateKey: assetLockPrivateKey,
30
26
  outputIndex: assetLockOutputIndex
31
- } = await createAssetLockTransaction(this, amount);
27
+ } = await this.identities.utils.createAssetLockTransaction(amount);
32
28
 
33
29
  // Broadcast Asset Lock transaction
34
30
  await account.broadcastTransaction(assetLockTransaction);
35
31
  // Create a proof for the asset lock transaction
36
- const assetLockProof = await createAssetLockProof(this, assetLockTransaction, assetLockOutputIndex);
32
+ const assetLockProof = await this.identities.utils
33
+ .createAssetLockProof(assetLockTransaction, assetLockOutputIndex);
37
34
 
38
- // @ts-ignore
39
- const identityTopUpTransition = await createIdentityTopUpTransition(this, assetLockProof, assetLockPrivateKey, identityId);
35
+ const identityTopUpTransition = await this.identities.utils
36
+ .createIdentityTopUpTransition(assetLockProof, assetLockPrivateKey, identityId);
40
37
 
41
38
  // Broadcast ST
42
39
  await broadcastStateTransition(this, identityTopUpTransition);
package/src/SDK/SDK.ts CHANGED
@@ -3,34 +3,47 @@ import { Core as _Core } from './Core';
3
3
  import { Platform as _Platform } from './Platform';
4
4
  import { default as _DAPIClient } from '@dashevo/dapi-client';
5
5
 
6
+ import { StateTransitionBroadcastError } from '../errors/StateTransitionBroadcastError'
7
+
6
8
  import {
7
- Wallet as _Wallet,
8
- Account as _Account,
9
- DerivableKeyChain as _KeyChain,
10
- CONSTANTS as _WalletLibCONSTANTS,
11
- EVENTS as _WalletLibEVENTS,
12
- utils as _WalletLibUtils,
13
- plugins as _WalletLibPlugins
9
+ Wallet as _Wallet,
10
+ Account as _Account,
11
+ DerivableKeyChain as _KeyChain,
12
+ CONSTANTS as _WalletLibCONSTANTS,
13
+ EVENTS as _WalletLibEVENTS,
14
+ utils as _WalletLibUtils,
15
+ plugins as _WalletLibPlugins
14
16
  } from '@dashevo/wallet-lib';
15
17
 
16
18
  export namespace SDK {
17
- export let DAPIClient = _DAPIClient;
18
- export let Client = _Client;
19
+ export let DAPIClient = _DAPIClient;
20
+ export let Client = _Client;
21
+
22
+ export let Core = _Core;
23
+ // TODO: consider marking as DEPRECATED and use PlatformProtocol below instead
24
+ export let Platform = _Platform;
25
+
26
+ // Wallet-lib primitives
27
+ export let Wallet = _Wallet;
28
+ export let Account = _Account;
29
+ export let KeyChain = _KeyChain;
19
30
 
20
- export let Core = _Core;
21
- export let Platform = _Platform;
31
+ // TODO: consider merging into Wallet above and mark as DEPRECATED
32
+ export let WalletLib = {
33
+ CONSTANTS: _WalletLibCONSTANTS,
34
+ EVENTS: _WalletLibEVENTS,
35
+ plugins: _WalletLibPlugins,
36
+ utils: _WalletLibUtils,
37
+ }
22
38
 
23
- // Wallet-lib primitives
24
- export let Wallet = _Wallet;
25
- export let Account = _Account;
26
- export let KeyChain = _KeyChain;
39
+ export let PlatformProtocol = Platform.DashPlatformProtocol;
27
40
 
28
- export let WalletLib = {
29
- CONSTANTS: _WalletLibCONSTANTS,
30
- EVENTS: _WalletLibEVENTS,
31
- plugins: _WalletLibPlugins,
32
- utils: _WalletLibUtils,
33
- }
41
+ export let Essentials = {
42
+ Buffer,
43
+ }
34
44
 
45
+ export let Errors = {
46
+ StateTransitionBroadcastError
47
+ }
35
48
  }
36
49
  export { SDK as default };
@@ -1,8 +1,10 @@
1
1
  const path = require('path');
2
2
  const webpack = require('webpack');
3
+ const TerserPlugin = require("terser-webpack-plugin");
3
4
 
4
5
  const baseConfig = {
5
6
  entry: './src/index.ts',
7
+ devtool: 'eval',
6
8
  module: {
7
9
  rules: [
8
10
  {
@@ -12,6 +14,14 @@ const baseConfig = {
12
14
  },
13
15
  ],
14
16
  },
17
+ optimization: {
18
+ minimize: true,
19
+ minimizer: [new TerserPlugin({
20
+ terserOptions: {
21
+ keep_classnames: true // fixes empty string in `object.constructor.name`
22
+ }
23
+ })],
24
+ },
15
25
  resolve: {
16
26
  extensions: ['.ts', '.js', '.json'],
17
27
  fallback: {
@@ -29,6 +39,10 @@ const baseConfig = {
29
39
  zlib: require.resolve('browserify-zlib'),
30
40
  events: require.resolve('events/'),
31
41
  string_decoder: require.resolve('string_decoder/'),
42
+ tls: require.resolve('tls/'),
43
+ net: require.resolve('net/'),
44
+ // Browser build have to use native WebSocket
45
+ ws: require.resolve('./build-utils/ws'),
32
46
  },
33
47
  },
34
48
  plugins: [
package/webpack.config.js CHANGED
@@ -4,11 +4,15 @@ const webpackBaseConfig = require("./webpack.base.config");
4
4
  const webConfig = {
5
5
  ...webpackBaseConfig,
6
6
  entry: './build/src/index.js',
7
+ devtool: 'source-map',
7
8
  mode: 'production',
9
+ target: 'web',
8
10
  output: {
9
11
  path: path.resolve(__dirname, 'dist'),
10
- libraryTarget: 'umd',
11
- library: 'Dash',
12
+ library: {
13
+ name: 'Dash',
14
+ type: 'umd'
15
+ },
12
16
  filename: 'dash.min.js',
13
17
  // fixes ReferenceError: window is not defined
14
18
  globalObject: "(typeof self !== 'undefined' ? self : this)"
@@ -1,68 +0,0 @@
1
- ## Publishing a new contract
2
-
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
-
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
-
7
- ## Create your contract
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 :
11
-
12
- ```js
13
- const schema = {};// You JSON schema defining the app.
14
- const client = new Dash.Client({
15
- wallet: {
16
- mnemonic: '', // Your app mnemonic, which holds the identity
17
- },
18
- });
19
-
20
- // This is the name previously registered in DPNS.
21
- const appName = 'MyApp';
22
- client.isReady().then(registerContract);
23
-
24
- async function getIdentity(idName) {
25
- const {identities, names} = client.platform;
26
- const identityId = (await names.get(idName)).data.records.dashIdentity;
27
- const identity = await identities.get(identityId);
28
- return identity
29
- }
30
- async function registerContract() {
31
- const {platform} = client;
32
- const identity = await getIdentity(appName);
33
- const contract = platform.contracts.create(schema, identity)
34
- const contractId = await platform.contracts.publish(contract, identity);
35
- }
36
- ```
37
-
38
- ## Fetch or publish documents on your app
39
-
40
- ```js
41
- const schema = {};// You JSON schema defining the app.
42
-
43
- // This is the name previously registered in DPNS.
44
- const client = new Dash.Client({
45
- wallet: {
46
- mnemonic: "", // Your app mnemonic, which holds the identity
47
- },
48
- apps:{
49
- myapp:{
50
- contractId:""// The registered contract id
51
- }
52
- }
53
- });
54
-
55
- client.isReady().then(getDocuments);
56
-
57
- async function getDocuments() {
58
- const {documents} = client.platform;
59
- const docs = await documents.fetch('myapp.myfield',{});
60
- }
61
-
62
- async function publishDocument(){
63
- const identity = await getIdentity(appName);
64
- const {documents} = client.platform;
65
- const doc = await documents.create('myapp.myfield',identity, {myproperties:'my value'});
66
- await documents.broadcast(doc, identity)
67
- }
68
- ```
@@ -1,55 +0,0 @@
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`**
@@ -1,19 +0,0 @@
1
- ## Use a local evonet
2
-
3
- You can refer to https://github.com/dashevo/dash-network-deploy to deploy a devnet locally.
4
-
5
- You will then need to pass the seed ip, and [register the DPNS contract](https://github.com/dashevo/dpns-contract), and reference its `contractId` below.
6
-
7
- ```js
8
- const seeds = [{service: '54.245.133.124'}];
9
- const client = new Dash.Client({
10
- seeds,
11
- apps: {
12
- dpns: {
13
- contractId: '77w8Xqn25HwJhjodrHW133aXhjuTsTv9ozQaYpSHACE3'
14
- }
15
- }
16
- });
17
- ```
18
-
19
- After that, usage is the same.
@@ -1,28 +0,0 @@
1
- const Dash = require('dash');
2
- const clientOpts = {
3
- network: 'testnet',
4
- wallet: {
5
- mnemonic: null, // Will generate a new address, you should keep it.
6
- },
7
- };
8
- const client = new Dash.Client(clientOpts);
9
-
10
- const displayFundingAddress = async function () {
11
- const {account, wallet} = client;
12
-
13
- const mnemonic = wallet.exportWallet();
14
- const address = account.getUnusedAddress().address;
15
- console.log('Mnemonic:', mnemonic);
16
- console.log('Total balance', account.getTotalBalance());
17
- console.log('Unused address:', address);
18
- // Fund this address using the faucet : http://devnet-evonet-1117662964.us-west-2.elb.amazonaws.com/
19
- };
20
- const onReceivedTransaction = function(data){
21
- const {account} = client;
22
- console.log('Received tx',data.txid);
23
- console.log('Total pending confirmation', account.getUnconfirmedBalance());
24
- console.log('Total balance', account.getTotalBalance());
25
- }
26
- client.account.on('FETCHED/UNCONFIRMED_TRANSACTION',onReceivedTransaction)
27
- client.isReady().then(displayFundingAddress);
28
-
@@ -1,34 +0,0 @@
1
- const DashJS = require('dash');
2
-
3
- const sdkOpts = {
4
- network: 'testnet',
5
- wallet: {
6
- mnemonic: 'your mnemonic here',
7
- },
8
- };
9
- const sdk = new DashJS.Client(sdkOpts);
10
-
11
- const registerContract = async function () {
12
- await sdk.isReady();
13
- let platform = sdk.platform;
14
- const identity = await platform.identities.get('your identity id here');
15
-
16
- const contractDocuments = {
17
- note: {
18
- properties: {
19
- message: {
20
- type: "string"
21
- }
22
- },
23
- indices: [
24
- { "message": "asc"}
25
- ],
26
- additionalProperties: false
27
- }};
28
-
29
- const contract = await platform.contracts.create(contractDocuments, identity);
30
- await platform.dpp.dataContract.validate(contract)
31
- await platform.contracts.publish(contract, identity);
32
- };
33
-
34
- registerContract();
@@ -1,23 +0,0 @@
1
- const Dash = require('dash');
2
- const clientOpts = {
3
- network: 'testnet',
4
- wallet: {
5
- mnemonic: 'your mnemonic here',
6
- },
7
- };
8
- const client = new Dash.Client(clientOpts);
9
-
10
- const createIdentity = async function () {
11
- await client.isReady();
12
-
13
- let platform = client.platform;
14
-
15
- platform
16
- .identities
17
- .register()
18
- .then((identityId) => {
19
- console.log({identityId});
20
- });
21
-
22
- };
23
- createIdentity();