dash 3.21.5 → 3.22.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/SDK/Client/Client.spec.js +3 -3
- package/build/src/SDK/Client/Client.spec.js.map +1 -1
- package/build/src/SDK/Client/Platform/Platform.js +4 -2
- package/build/src/SDK/Client/Platform/Platform.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/{broadcast.js → publish.js} +6 -6
- package/build/src/SDK/Client/Platform/methods/contracts/publish.js.map +1 -0
- package/build/src/SDK/Client/Platform/methods/contracts/update.js +75 -0
- package/build/src/SDK/Client/Platform/methods/contracts/update.js.map +1 -0
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js +9 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js.map +1 -1
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js +2 -0
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js.map +1 -1
- package/build/tests/fixtures/contracts.json +3 -1
- package/dist/src/SDK/Client/Platform/Platform.d.ts +7 -1
- package/dist/src/SDK/Client/Platform/methods/contracts/publish.d.ts +10 -0
- package/dist/src/SDK/Client/Platform/methods/contracts/update.d.ts +10 -0
- package/dist/src/SDK/SDK.d.ts +12 -12
- package/docs/_sidebar.md +19 -17
- package/docs/examples/publishing-a-new-contract.md +6 -6
- package/docs/examples/updating-a-contract.md +55 -0
- package/docs/platform/contracts/{broadcast.md → publish.md} +6 -6
- package/docs/platform/contracts/update.md +14 -0
- package/examples/node/register-contract.js +1 -1
- package/examples/schema.json +2 -0
- package/karma.conf.js +14 -7
- package/package.json +17 -14
- package/src/SDK/Client/Client.spec.ts +3 -3
- package/src/SDK/Client/Platform/Platform.ts +12 -3
- package/src/SDK/Client/Platform/methods/contracts/{broadcast.ts → publish.ts} +4 -4
- package/src/SDK/Client/Platform/methods/contracts/update.ts +26 -0
- package/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts +6 -1
- package/src/test/fixtures/createIdentityFixtureInAccount.ts +3 -1
- package/tests/fixtures/contracts.json +3 -1
- package/tests/fixtures/dp1.schema.json +2 -0
- package/tests/fixtures/ratePlatform.schema.json +1 -0
- package/webpack.base.config.js +5 -2
- package/webpack.config.js +3 -24
- package/build/src/SDK/Client/Platform/methods/contracts/broadcast.js.map +0 -1
- package/dist/dash.min.js +0 -8
- package/dist/dash.min.js.LICENSE.txt +0 -47
- package/dist/src/SDK/Client/Platform/methods/contracts/broadcast.d.ts +0 -10
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',
|
|
@@ -43,12 +50,12 @@ module.exports = (config) => {
|
|
|
43
50
|
browserDisconnectTimeout: 3 * 2000, // 2000 default
|
|
44
51
|
pingTimeout: 3 * 5000, // 5000 default
|
|
45
52
|
plugins: [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
karmaMocha,
|
|
54
|
+
karmaMochaReporter,
|
|
55
|
+
karmaChai,
|
|
56
|
+
karmaChromeLauncher,
|
|
57
|
+
karmaFirefoxLauncher,
|
|
58
|
+
karmaWebpack,
|
|
52
59
|
],
|
|
53
60
|
customLaunchers: {
|
|
54
61
|
FirefoxHeadless: {
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dash",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.0-dev.3",
|
|
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 '
|
|
10
|
-
"build": "
|
|
11
|
-
"build:web": "
|
|
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
13
|
"lint": "",
|
|
14
|
-
"test": "
|
|
14
|
+
"test": "yarn run test:unit && yarn run test:functional && yarn run test:browsers",
|
|
15
15
|
"test:browsers": "karma start ./karma.conf.js --single-run",
|
|
16
|
-
"test:unit": "TS_NODE_COMPILER_OPTIONS={\"target\":\"es6\"}
|
|
17
|
-
"test:functional": "
|
|
18
|
-
"prepublishOnly": "
|
|
19
|
-
"prepare": "
|
|
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
20
|
},
|
|
21
21
|
"ultra": {
|
|
22
22
|
"concurrent": [
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/dashevo/DashJS#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@dashevo/dapi-client": "~0.
|
|
37
|
+
"@dashevo/dapi-client": "~0.22.0-dev.3",
|
|
38
38
|
"@dashevo/dashcore-lib": "~0.19.28",
|
|
39
|
-
"@dashevo/dpp": "~0.
|
|
40
|
-
"@dashevo/grpc-common": "~0.
|
|
41
|
-
"@dashevo/wallet-lib": "~7.
|
|
39
|
+
"@dashevo/dpp": "~0.22.0-dev.3",
|
|
40
|
+
"@dashevo/grpc-common": "~0.22.0-dev.3",
|
|
41
|
+
"@dashevo/wallet-lib": "~7.22.0-dev.3",
|
|
42
42
|
"bs58": "^4.0.1",
|
|
43
43
|
"node-inspect-extracted": "^1.0.8"
|
|
44
44
|
},
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"crypto-browserify": "^3.12.0",
|
|
59
59
|
"dirty-chai": "^2.0.1",
|
|
60
60
|
"dotenv-safe": "^8.2.0",
|
|
61
|
+
"events": "^3.3.0",
|
|
61
62
|
"https-browserify": "^1.0.0",
|
|
62
63
|
"karma": "^6.3.4",
|
|
63
64
|
"karma-chai": "^0.1.0",
|
|
@@ -76,7 +77,9 @@
|
|
|
76
77
|
"sinon-chai": "^3.7.0",
|
|
77
78
|
"stream-browserify": "^3.0.0",
|
|
78
79
|
"stream-http": "^3.2.0",
|
|
80
|
+
"string_decoder": "^1.3.0",
|
|
79
81
|
"ts-loader": "^8.0.2",
|
|
82
|
+
"ts-mocha": "^8.0.0",
|
|
80
83
|
"ts-mock-imports": "^1.3.0",
|
|
81
84
|
"ts-node": "^10.4.0",
|
|
82
85
|
"typescript": "^3.9.5",
|
|
@@ -85,4 +88,4 @@
|
|
|
85
88
|
"webpack": "^5.59.1",
|
|
86
89
|
"webpack-cli": "^4.9.1"
|
|
87
90
|
}
|
|
88
|
-
}
|
|
91
|
+
}
|
|
@@ -278,7 +278,7 @@ describe('Dash - Client', function suite() {
|
|
|
278
278
|
});
|
|
279
279
|
});
|
|
280
280
|
|
|
281
|
-
describe('#platform.contracts.
|
|
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.
|
|
295
|
+
await client.platform.contracts.publish(dataContractFixture, identityFixture);
|
|
296
296
|
} catch (e) {
|
|
297
297
|
error = e;
|
|
298
298
|
}
|
|
@@ -307,7 +307,7 @@ describe('Dash - Client', function suite() {
|
|
|
307
307
|
proof: { }
|
|
308
308
|
});
|
|
309
309
|
|
|
310
|
-
await client.platform.contracts.
|
|
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);
|
|
@@ -7,7 +7,8 @@ import broadcastDocument from "./methods/documents/broadcast";
|
|
|
7
7
|
import createDocument from "./methods/documents/create";
|
|
8
8
|
import getDocument from "./methods/documents/get";
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import publishContract from "./methods/contracts/publish";
|
|
11
|
+
import updateContract from "./methods/contracts/update";
|
|
11
12
|
import createContract from "./methods/contracts/create";
|
|
12
13
|
import getContract from "./methods/contracts/get";
|
|
13
14
|
|
|
@@ -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,7 +101,7 @@ 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:
|
|
104
|
+
public contracts: DataContracts;
|
|
97
105
|
|
|
98
106
|
/**
|
|
99
107
|
* Broadcasts state transition
|
|
@@ -121,7 +129,8 @@ export class Platform {
|
|
|
121
129
|
get: getDocument.bind(this),
|
|
122
130
|
};
|
|
123
131
|
this.contracts = {
|
|
124
|
-
|
|
132
|
+
publish: publishContract.bind(this),
|
|
133
|
+
update: updateContract.bind(this),
|
|
125
134
|
create: createContract.bind(this),
|
|
126
135
|
get: getContract.bind(this),
|
|
127
136
|
};
|
|
@@ -3,19 +3,19 @@ import broadcastStateTransition from "../../broadcastStateTransition";
|
|
|
3
3
|
import { signStateTransition } from "../../signStateTransition";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Publish contract onto the platform
|
|
7
7
|
*
|
|
8
8
|
* @param {Platform} this - bound instance class
|
|
9
9
|
* @param dataContract - contract
|
|
10
10
|
* @param identity - identity
|
|
11
|
-
* @return
|
|
11
|
+
* @return {DataContractCreateTransition}
|
|
12
12
|
*/
|
|
13
|
-
export default async function
|
|
13
|
+
export default async function publish(this: Platform, dataContract: any, identity: any): Promise<any> {
|
|
14
14
|
await this.initialize();
|
|
15
15
|
|
|
16
16
|
const { dpp } = this;
|
|
17
17
|
|
|
18
|
-
const dataContractCreateTransition = dpp.dataContract.
|
|
18
|
+
const dataContractCreateTransition = dpp.dataContract.createDataContractCreateTransition(dataContract);
|
|
19
19
|
|
|
20
20
|
await signStateTransition(this, dataContractCreateTransition, identity);
|
|
21
21
|
await broadcastStateTransition(this, dataContractCreateTransition);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Platform } from "../../Platform";
|
|
2
|
+
import broadcastStateTransition from "../../broadcastStateTransition";
|
|
3
|
+
import { signStateTransition } from "../../signStateTransition";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Publish contract onto the platform
|
|
7
|
+
*
|
|
8
|
+
* @param {Platform} this - bound instance class
|
|
9
|
+
* @param dataContract - contract
|
|
10
|
+
* @param identity - identity
|
|
11
|
+
* @return {DataContractUpdateTransition}
|
|
12
|
+
*/
|
|
13
|
+
export default async function update(this: Platform, dataContract: any, identity: any): Promise<any> {
|
|
14
|
+
await this.initialize();
|
|
15
|
+
|
|
16
|
+
const { dpp } = this;
|
|
17
|
+
|
|
18
|
+
dataContract.incrementVersion();
|
|
19
|
+
|
|
20
|
+
const dataContractUpdateTransition = dpp.dataContract.createDataContractUpdateTransition(dataContract);
|
|
21
|
+
|
|
22
|
+
await signStateTransition(this, dataContractUpdateTransition, identity);
|
|
23
|
+
await broadcastStateTransition(this, dataContractUpdateTransition);
|
|
24
|
+
|
|
25
|
+
return dataContractUpdateTransition;
|
|
26
|
+
}
|
package/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PrivateKey } from "@dashevo/dashcore-lib";
|
|
2
2
|
import { Platform } from "../../../Platform";
|
|
3
|
+
import IdentityPublicKey from "@dashevo/dpp/lib/identity/IdentityPublicKey"
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
|
|
@@ -24,7 +25,11 @@ export default async function createIdentityCreateTransition(platform : Platform
|
|
|
24
25
|
// Create Identity
|
|
25
26
|
// @ts-ignore
|
|
26
27
|
const identity = dpp.identity.create(
|
|
27
|
-
assetLockProof, [
|
|
28
|
+
assetLockProof, [{
|
|
29
|
+
key: identityPublicKey,
|
|
30
|
+
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
31
|
+
securityLevel: IdentityPublicKey.SECURITY_LEVELS.MASTER
|
|
32
|
+
}]
|
|
28
33
|
);
|
|
29
34
|
|
|
30
35
|
// Create ST
|
|
@@ -11,6 +11,8 @@ export function createIdentityFixtureInAccount(account) {
|
|
|
11
11
|
id: 0,
|
|
12
12
|
type: IdentityPublicKey.TYPES.ECDSA_SECP256K1,
|
|
13
13
|
data: identityPrivateKey.toPublicKey().toBuffer(),
|
|
14
|
+
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
15
|
+
securityLevel: IdentityPublicKey.SECURITY_LEVELS.MASTER
|
|
14
16
|
});
|
|
15
17
|
|
|
16
18
|
account.storage.insertIdentityIdAtIndex(
|
|
@@ -20,4 +22,4 @@ export function createIdentityFixtureInAccount(account) {
|
|
|
20
22
|
);
|
|
21
23
|
|
|
22
24
|
return identityFixture;
|
|
23
|
-
}
|
|
25
|
+
}
|
package/webpack.base.config.js
CHANGED
|
@@ -20,18 +20,21 @@ const baseConfig = {
|
|
|
20
20
|
crypto: require.resolve('crypto-browserify'),
|
|
21
21
|
http: require.resolve('stream-http'),
|
|
22
22
|
https: require.resolve('https-browserify'),
|
|
23
|
+
buffer: require.resolve('buffer/'),
|
|
23
24
|
url: require.resolve('url/'),
|
|
24
25
|
assert: require.resolve('assert/'),
|
|
25
26
|
stream: require.resolve('stream-browserify'),
|
|
26
27
|
path: require.resolve('path-browserify'),
|
|
27
28
|
os: require.resolve('os-browserify/browser'),
|
|
28
29
|
zlib: require.resolve('browserify-zlib'),
|
|
30
|
+
events: require.resolve('events/'),
|
|
31
|
+
string_decoder: require.resolve('string_decoder/'),
|
|
29
32
|
},
|
|
30
33
|
},
|
|
31
34
|
plugins: [
|
|
32
35
|
new webpack.ProvidePlugin({
|
|
33
|
-
Buffer: ['buffer', 'Buffer'],
|
|
34
|
-
process: 'process/browser',
|
|
36
|
+
Buffer: [require.resolve('buffer/'), 'Buffer'],
|
|
37
|
+
process: require.resolve('process/browser'),
|
|
35
38
|
}),
|
|
36
39
|
],
|
|
37
40
|
output: {
|
package/webpack.config.js
CHANGED
|
@@ -1,31 +1,10 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const
|
|
2
|
+
const webpackBaseConfig = require("./webpack.base.config");
|
|
3
3
|
|
|
4
4
|
const webConfig = {
|
|
5
|
+
...webpackBaseConfig,
|
|
5
6
|
entry: './build/src/index.js',
|
|
6
|
-
mode:
|
|
7
|
-
resolve: {
|
|
8
|
-
extensions: ['.js', '.json'],
|
|
9
|
-
fallback: {
|
|
10
|
-
fs: false,
|
|
11
|
-
util: require.resolve('util/'),
|
|
12
|
-
crypto: require.resolve('crypto-browserify'),
|
|
13
|
-
http: require.resolve('stream-http'),
|
|
14
|
-
https: require.resolve('https-browserify'),
|
|
15
|
-
url: require.resolve('url/'),
|
|
16
|
-
assert: require.resolve('assert/'),
|
|
17
|
-
stream: require.resolve('stream-browserify'),
|
|
18
|
-
path: require.resolve('path-browserify'),
|
|
19
|
-
os: require.resolve('os-browserify/browser'),
|
|
20
|
-
zlib: require.resolve('browserify-zlib'),
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
plugins: [
|
|
24
|
-
new webpack.ProvidePlugin({
|
|
25
|
-
Buffer: ['buffer', 'Buffer'],
|
|
26
|
-
process: 'process/browser',
|
|
27
|
-
}),
|
|
28
|
-
],
|
|
7
|
+
mode: 'production',
|
|
29
8
|
output: {
|
|
30
9
|
path: path.resolve(__dirname, 'dist'),
|
|
31
10
|
libraryTarget: 'umd',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../../../../../../src/SDK/Client/Platform/methods/contracts/broadcast.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4FAAsE;AACtE,iEAAgE;AAEhE;;;;;;;GAOG;AACH,SAA8B,SAAS,CAAiB,YAAiB,EAAE,QAAa;;;;;wBACpF,qBAAM,IAAI,CAAC,UAAU,EAAE,EAAA;;oBAAvB,SAAuB,CAAC;oBAEhB,GAAG,GAAK,IAAI,IAAT,CAAU;oBAEf,4BAA4B,GAAG,GAAG,CAAC,YAAY,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;oBAE1F,qBAAM,yCAAmB,CAAC,IAAI,EAAE,4BAA4B,EAAE,QAAQ,CAAC,EAAA;;oBAAvE,SAAuE,CAAC;oBACxE,qBAAM,kCAAwB,CAAC,IAAI,EAAE,4BAA4B,CAAC,EAAA;;oBAAlE,SAAkE,CAAC;oBAEnE,sBAAO,4BAA4B,EAAC;;;;CACvC;AAXD,4BAWC"}
|