dash 3.22.0-dev.1 → 3.22.0-dev.12
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/.mocharc.yml +1 -0
- package/README.md +5 -5
- package/build/src/SDK/Client/Client.js +8 -2
- package/build/src/SDK/Client/Client.js.map +1 -1
- package/build/src/SDK/Client/Client.spec.js +23 -15
- 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/broadcastStateTransition.js +1 -1
- package/build/src/SDK/Client/Platform/broadcastStateTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/createAssetLockTransaction.js +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 +86 -0
- package/build/src/SDK/Client/Platform/methods/contracts/update.js.map +1 -0
- package/build/src/SDK/Client/Platform/methods/documents/get.js +15 -5
- package/build/src/SDK/Client/Platform/methods/documents/get.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/documents/get.spec.js +49 -0
- package/build/src/SDK/Client/Platform/methods/documents/get.spec.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js +13 -3
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js +8 -2
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/names/register.js +1 -1
- package/build/src/SDK/Client/Platform/methods/names/register.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/names/search.js +3 -0
- package/build/src/SDK/Client/Platform/methods/names/search.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/names/search.spec.js +2 -0
- package/build/src/SDK/Client/Platform/methods/names/search.spec.js.map +1 -1
- package/build/src/SDK/Client/Platform/signStateTransition.js +3 -1
- package/build/src/SDK/Client/Platform/signStateTransition.js.map +1 -1
- package/build/src/test/bootstrap.js +11 -0
- package/build/src/test/bootstrap.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/src/test/mocks/createAndAttachTransportMocksToClient.js +5 -2
- package/build/src/test/mocks/createAndAttachTransportMocksToClient.js.map +1 -1
- package/build/src/utils/createFakeIntantLock.js +2 -0
- package/build/src/utils/createFakeIntantLock.js.map +1 -1
- package/build/tests/fixtures/contracts.json +3 -1
- package/dist/src/SDK/Client/Platform/IPlatformStateProof.d.ts +1 -2
- package/dist/src/SDK/Client/Platform/Platform.d.ts +9 -3
- package/dist/src/SDK/Client/Platform/broadcastStateTransition.d.ts +2 -2
- package/dist/src/SDK/Client/Platform/createAssetLockTransaction.d.ts +1 -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/Client/Platform/methods/documents/get.d.ts +7 -4
- package/dist/src/SDK/SDK.d.ts +167 -4
- package/docs/README.md +6 -6
- package/docs/_sidebar.md +19 -17
- package/docs/examples/pay-to-another-address.md +1 -1
- package/docs/examples/publishing-a-new-contract.md +7 -7
- package/docs/examples/receive-money-and-check-balance.md +2 -2
- package/docs/examples/sign-and-verify-messages.md +1 -1
- package/docs/examples/updating-a-contract.md +55 -0
- package/docs/getting-started/core-concepts.md +2 -2
- package/docs/getting-started/dash-platform-applications.md +1 -1
- package/docs/getting-started/quickstart.md +1 -1
- package/docs/platform/contracts/about-contracts.md +1 -1
- package/docs/platform/contracts/create.md +2 -2
- package/docs/platform/contracts/{broadcast.md → publish.md} +8 -8
- package/docs/platform/contracts/update.md +14 -0
- package/docs/platform/documents/broadcast.md +4 -4
- package/docs/platform/documents/create.md +2 -2
- package/docs/platform/identities/about-identity.md +1 -1
- package/docs/platform/identities/register.md +1 -1
- package/docs/platform/identities/topUp.md +3 -1
- package/docs/platform/names/register.md +1 -1
- package/docs/wallet/about-wallet-lib.md +1 -1
- package/examples/node/register-contract.js +1 -1
- package/examples/schema.json +2 -0
- package/karma.conf.js +17 -8
- package/package.json +35 -23
- package/src/SDK/Client/Client.spec.ts +5 -5
- package/src/SDK/Client/Client.ts +8 -2
- package/src/SDK/Client/Platform/IPlatformStateProof.ts +1 -2
- package/src/SDK/Client/Platform/Platform.ts +14 -5
- package/src/SDK/Client/Platform/broadcastStateTransition.ts +2 -3
- package/src/SDK/Client/Platform/createAssetLockTransaction.ts +1 -1
- package/src/SDK/Client/Platform/methods/contracts/{broadcast.ts → publish.ts} +4 -4
- package/src/SDK/Client/Platform/methods/contracts/update.ts +39 -0
- package/src/SDK/Client/Platform/methods/documents/get.spec.ts +37 -0
- package/src/SDK/Client/Platform/methods/documents/get.ts +18 -8
- package/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts +7 -2
- package/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.ts +2 -1
- package/src/SDK/Client/Platform/methods/names/register.ts +1 -1
- package/src/SDK/Client/Platform/methods/names/search.spec.ts +2 -0
- package/src/SDK/Client/Platform/methods/names/search.ts +3 -0
- package/src/SDK/Client/Platform/signStateTransition.ts +2 -2
- package/src/test/bootstrap.js +13 -0
- package/src/test/fixtures/createIdentityFixtureInAccount.ts +3 -1
- package/src/test/mocks/createAndAttachTransportMocksToClient.ts +25 -21
- package/src/utils/createFakeIntantLock.ts +2 -0
- 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/.editorconfig +0 -2
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -27
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -32
- package/.github/workflows/.env +0 -5
- package/.github/workflows/test_and_release.yml +0 -170
- 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
|
@@ -2,7 +2,6 @@ import crypto from "crypto";
|
|
|
2
2
|
import { Platform } from "./Platform";
|
|
3
3
|
import { StateTransitionBroadcastError } from "../../../errors/StateTransitionBroadcastError";
|
|
4
4
|
import { IStateTransitionResult } from "./IStateTransitionResult";
|
|
5
|
-
import { IPlatformStateProof } from "./IPlatformStateProof";
|
|
6
5
|
|
|
7
6
|
const ResponseError = require('@dashevo/dapi-client/lib/transport/errors/response/ResponseError');
|
|
8
7
|
const InvalidRequestDPPError = require('@dashevo/dapi-client/lib/transport/errors/response/InvalidRequestDPPError');
|
|
@@ -15,7 +14,7 @@ const GrpcError = require('@dashevo/grpc-common/lib/server/error/GrpcError');
|
|
|
15
14
|
* @param {Platform} platform
|
|
16
15
|
* @param stateTransition
|
|
17
16
|
*/
|
|
18
|
-
export default async function broadcastStateTransition(platform: Platform, stateTransition: any): Promise<
|
|
17
|
+
export default async function broadcastStateTransition(platform: Platform, stateTransition: any): Promise<IStateTransitionResult|void> {
|
|
19
18
|
const { client, dpp } = platform;
|
|
20
19
|
|
|
21
20
|
const result = await dpp.stateTransition.validateBasic(stateTransition);
|
|
@@ -83,5 +82,5 @@ export default async function broadcastStateTransition(platform: Platform, state
|
|
|
83
82
|
);
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
return stateTransitionResult
|
|
85
|
+
return stateTransitionResult;
|
|
87
86
|
}
|
|
@@ -9,7 +9,7 @@ const ASSET_LOCK_OUTPUT_INDEX = 0;
|
|
|
9
9
|
* Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
|
|
10
10
|
* @param {Platform} platform
|
|
11
11
|
* @param {number} fundingAmount - amount of dash to fund the identity's credits
|
|
12
|
-
* @return {{transaction: Transaction, privateKey: PrivateKey}} - transaction and one time private key
|
|
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
15
|
export default async function createAssetLockTransaction(platform : Platform, fundingAmount): Promise<{ transaction: Transaction, privateKey: PrivateKey, outputIndex: number }> {
|
|
@@ -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,39 @@
|
|
|
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} 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
|
+
// Clone contract
|
|
19
|
+
const updatedDataContract = await this.dpp.dataContract.createFromObject(
|
|
20
|
+
dataContract.toObject(),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
updatedDataContract.incrementVersion();
|
|
24
|
+
|
|
25
|
+
const dataContractUpdateTransition = dpp.dataContract.createDataContractUpdateTransition(updatedDataContract);
|
|
26
|
+
|
|
27
|
+
await signStateTransition(this, dataContractUpdateTransition, identity);
|
|
28
|
+
await broadcastStateTransition(this, dataContractUpdateTransition);
|
|
29
|
+
|
|
30
|
+
// Update app with updated data contract if available
|
|
31
|
+
for (const appName of this.client.getApps().getNames()) {
|
|
32
|
+
const appDefinition = this.client.getApps().get(appName);
|
|
33
|
+
if (appDefinition.contractId.equals(updatedDataContract.getId()) && appDefinition.contract) {
|
|
34
|
+
appDefinition.contract = updatedDataContract;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return dataContractUpdateTransition;
|
|
39
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import getDataContractFixture from '@dashevo/dpp/lib/test/fixtures/getDataContractFixture';
|
|
2
2
|
import generateRandomIdentifier from '@dashevo/dpp/lib/test/utils/generateRandomIdentifier';
|
|
3
3
|
import createDPPMock from '@dashevo/dpp/lib/test/mocks/createDPPMock';
|
|
4
|
+
import getDocumentsFixture from '@dashevo/dpp/lib/test/fixtures/getDocumentsFixture';
|
|
4
5
|
import getResponseMetadataFixture from '../../../../../test/fixtures/getResponseMetadataFixture';
|
|
5
6
|
const GetDocumentsResponse = require("@dashevo/dapi-client/lib/methods/platform/getDocuments/GetDocumentsResponse");
|
|
6
7
|
|
|
@@ -84,6 +85,42 @@ describe('Client - Platform - Documents - .get()', () => {
|
|
|
84
85
|
]);
|
|
85
86
|
});
|
|
86
87
|
|
|
88
|
+
it('should convert Document to identifiers inside where condition for "startAt" and "startAfter"', async () => {
|
|
89
|
+
const [docA, docB] = getDocumentsFixture();
|
|
90
|
+
|
|
91
|
+
await get.call(platform, 'app.withByteArrays', {
|
|
92
|
+
startAt: docA,
|
|
93
|
+
startAfter: docB,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
expect(getDocumentsMock.getCall(0).args).to.have.deep.members([
|
|
97
|
+
appDefinition.contractId,
|
|
98
|
+
'withByteArrays',
|
|
99
|
+
{
|
|
100
|
+
startAt: docA.getId(),
|
|
101
|
+
startAfter: docB.getId(),
|
|
102
|
+
},
|
|
103
|
+
]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should convert string to identifiers inside where condition for "startAt" and "startAfter"', async () => {
|
|
107
|
+
const [docA, docB] = getDocumentsFixture();
|
|
108
|
+
|
|
109
|
+
await get.call(platform, 'app.withByteArrays', {
|
|
110
|
+
startAt: docA.getId().toString('base58'),
|
|
111
|
+
startAfter: docB.getId().toString('base58'),
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expect(getDocumentsMock.getCall(0).args).to.have.deep.members([
|
|
115
|
+
appDefinition.contractId,
|
|
116
|
+
'withByteArrays',
|
|
117
|
+
{
|
|
118
|
+
startAt: docA.getId(),
|
|
119
|
+
startAfter: docB.getId(),
|
|
120
|
+
},
|
|
121
|
+
]);
|
|
122
|
+
});
|
|
123
|
+
|
|
87
124
|
it('should convert nested identifier properties inside where condition if `elementMatch` is used', async () => {
|
|
88
125
|
const id = generateRandomIdentifier();
|
|
89
126
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Identifier from '@dashevo/dpp/lib/Identifier';
|
|
2
2
|
import Metadata from "@dashevo/dpp/lib/Metadata";
|
|
3
|
+
import Document from '@dashevo/dpp/lib/document/Document';
|
|
3
4
|
|
|
4
5
|
import {Platform} from "../../Platform";
|
|
5
6
|
|
|
@@ -7,15 +8,15 @@ import {Platform} from "../../Platform";
|
|
|
7
8
|
* @param {WhereCondition[]} [where] - where
|
|
8
9
|
* @param {OrderByCondition[]} [orderBy] - order by
|
|
9
10
|
* @param {number} [limit] - limit
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {string|Buffer|Document|Identifier} [startAt] - start value (included)
|
|
12
|
+
* @param {string|Buffer|Document|Identifier} [startAfter] - start value (not included)
|
|
12
13
|
*/
|
|
13
14
|
declare interface fetchOpts {
|
|
14
15
|
where?: WhereCondition[];
|
|
15
16
|
orderBy?: OrderByCondition[];
|
|
16
17
|
limit?: number;
|
|
17
|
-
startAt?:
|
|
18
|
-
startAfter?:
|
|
18
|
+
startAt?: string|Buffer|Document|Identifier;
|
|
19
|
+
startAfter?: string|Buffer|Document|Identifier;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
type OrderByCondition = [
|
|
@@ -40,10 +41,7 @@ const ensureAppContractFetched = async function (this: Platform, appName) {
|
|
|
40
41
|
const appDefinition = this.client.getApps().get(appName);
|
|
41
42
|
|
|
42
43
|
if (!appDefinition.contract) {
|
|
43
|
-
|
|
44
|
-
if (!contract) {
|
|
45
|
-
throw new Error(`Applcation ${appName} contract with ID ${appDefinition.contractId} is not found`);
|
|
46
|
-
}
|
|
44
|
+
await this.contracts.get(appDefinition.contractId);
|
|
47
45
|
}
|
|
48
46
|
}
|
|
49
47
|
}
|
|
@@ -124,6 +122,18 @@ export async function get(this: Platform, typeLocator: string, opts: fetchOpts):
|
|
|
124
122
|
opts.where = opts.where.map((whereCondition) => convertIdentifierProperties(whereCondition, binaryProperties));
|
|
125
123
|
}
|
|
126
124
|
|
|
125
|
+
if (opts.startAt instanceof Document) {
|
|
126
|
+
opts.startAt = opts.startAt.getId();
|
|
127
|
+
} else if (typeof opts.startAt === 'string') {
|
|
128
|
+
opts.startAt = Identifier.from(opts.startAt);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (opts.startAfter instanceof Document) {
|
|
132
|
+
opts.startAfter = opts.startAfter.getId();
|
|
133
|
+
} else if (typeof opts.startAfter === 'string') {
|
|
134
|
+
opts.startAfter = Identifier.from(opts.startAfter);
|
|
135
|
+
}
|
|
136
|
+
|
|
127
137
|
// @ts-ignore
|
|
128
138
|
const documentsResponse = await this.client.getDAPIClient().platform.getDocuments(
|
|
129
139
|
appDefinition.contractId,
|
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,13 +25,17 @@ 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
|
|
31
36
|
const identityCreateTransition = dpp.identity.createIdentityCreateTransition(identity);
|
|
32
37
|
|
|
33
|
-
identityCreateTransition.signByPrivateKey(assetLockPrivateKey);
|
|
38
|
+
await identityCreateTransition.signByPrivateKey(assetLockPrivateKey, IdentityPublicKey.TYPES.ECDSA_SECP256K1);
|
|
34
39
|
|
|
35
40
|
const result = await dpp.stateTransition.validateBasic(identityCreateTransition);
|
|
36
41
|
|
package/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.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
|
|
@@ -20,7 +21,7 @@ export default async function createIdentityTopUpTransition(platform : Platform,
|
|
|
20
21
|
identityId, assetLockProof
|
|
21
22
|
);
|
|
22
23
|
|
|
23
|
-
identityTopUpTransition.signByPrivateKey(assetLockPrivateKey);
|
|
24
|
+
await identityTopUpTransition.signByPrivateKey(assetLockPrivateKey, IdentityPublicKey.TYPES.ECDSA_SECP256K1);
|
|
24
25
|
|
|
25
26
|
const result = await dpp.stateTransition.validateBasic(identityTopUpTransition);
|
|
26
27
|
|
|
@@ -36,6 +36,7 @@ describe('Platform', () => {
|
|
|
36
36
|
["normalizedParentDomainName", "==", "dash"],
|
|
37
37
|
["normalizedLabel", "startsWith", "prefix"]
|
|
38
38
|
],
|
|
39
|
+
orderBy: [['normalizedLabel', 'asc']],
|
|
39
40
|
},
|
|
40
41
|
]);
|
|
41
42
|
|
|
@@ -57,6 +58,7 @@ describe('Platform', () => {
|
|
|
57
58
|
["normalizedParentDomainName", "==", "dash"],
|
|
58
59
|
["normalizedLabel", "startsWith", "prefix"]
|
|
59
60
|
],
|
|
61
|
+
orderBy: [['normalizedLabel', 'asc']]
|
|
60
62
|
},
|
|
61
63
|
]);
|
|
62
64
|
|
|
@@ -17,6 +17,9 @@ export async function search(this: Platform, labelPrefix: string, parentDomainNa
|
|
|
17
17
|
['normalizedParentDomainName', '==', normalizedParentDomainName],
|
|
18
18
|
['normalizedLabel', 'startsWith', normalizedLabelPrefix],
|
|
19
19
|
],
|
|
20
|
+
orderBy: [
|
|
21
|
+
['normalizedLabel', 'asc']
|
|
22
|
+
]
|
|
20
23
|
});
|
|
21
24
|
|
|
22
25
|
return documents;
|
|
@@ -19,10 +19,10 @@ export async function signStateTransition(platform: Platform, stateTransition: a
|
|
|
19
19
|
keyIndex,
|
|
20
20
|
);
|
|
21
21
|
|
|
22
|
-
stateTransition.sign(
|
|
22
|
+
await stateTransition.sign(
|
|
23
23
|
identity.getPublicKeyById(keyIndex),
|
|
24
24
|
privateKey,
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
return stateTransition;
|
|
28
|
-
}
|
|
28
|
+
}
|
package/src/test/bootstrap.js
CHANGED
|
@@ -13,6 +13,19 @@ dotenvSafe.config({
|
|
|
13
13
|
use(dirtyChai);
|
|
14
14
|
use(sinonChai);
|
|
15
15
|
|
|
16
|
+
before(function before() {
|
|
17
|
+
if (!this.sinon) {
|
|
18
|
+
this.sinon = sinon.createSandbox();
|
|
19
|
+
} else {
|
|
20
|
+
this.sinon.restore();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
after(function after() {
|
|
26
|
+
this.sinon.restore();
|
|
27
|
+
});
|
|
28
|
+
|
|
16
29
|
beforeEach(function beforeEach() {
|
|
17
30
|
if (!this.sinon) {
|
|
18
31
|
this.sinon = sinon.createSandbox();
|
|
@@ -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
|
+
}
|
|
@@ -17,26 +17,30 @@ const TxStreamDataResponseMock = require('@dashevo/wallet-lib/src/test/mocks/TxS
|
|
|
17
17
|
const TransportMock = require('@dashevo/wallet-lib/src/test/mocks/TransportMock');
|
|
18
18
|
|
|
19
19
|
function makeTxStreamEmitISLocksForTransactions(transportMock, txStreamMock) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
39
|
-
|
|
20
|
+
transportMock.sendTransaction.callsFake((txString) => {
|
|
21
|
+
const transaction = new Transaction(txString);
|
|
22
|
+
const isLock = createFakeInstantLock(transaction.hash);
|
|
23
|
+
|
|
24
|
+
setImmediate(() => {
|
|
25
|
+
// Emit IS lock for the transaction
|
|
26
|
+
txStreamMock.emit(
|
|
27
|
+
TxStreamMock.EVENTS.data,
|
|
28
|
+
new TxStreamDataResponseMock(
|
|
29
|
+
{ instantSendLockMessages: [isLock.toBuffer()] }
|
|
30
|
+
)
|
|
31
|
+
);
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// Emit the same transaction back to the client so it will know about the change transaction
|
|
35
|
+
txStreamMock.emit(
|
|
36
|
+
TxStreamMock.EVENTS.data,
|
|
37
|
+
new TxStreamDataResponseMock(
|
|
38
|
+
{ rawTransactions: [transaction.toBuffer()] }
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return transaction.hash;
|
|
43
|
+
});
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
/**
|
|
@@ -88,4 +92,4 @@ export async function createAndAttachTransportMocksToClient(client, sinon) {
|
|
|
88
92
|
makeGetIdentityRespondWithIdentity(client, dapiClientMock);
|
|
89
93
|
|
|
90
94
|
return { txStreamMock, transportMock, dapiClientMock };
|
|
91
|
-
}
|
|
95
|
+
}
|
|
@@ -2,8 +2,10 @@ import { InstantLock } from "@dashevo/dashcore-lib";
|
|
|
2
2
|
|
|
3
3
|
export function createFakeInstantLock(transactionHash: string): InstantLock {
|
|
4
4
|
return new InstantLock({
|
|
5
|
+
version: 1,
|
|
5
6
|
txid: transactionHash,
|
|
6
7
|
signature: Buffer.alloc(96).toString('hex'),
|
|
8
|
+
cyclehash: '0dc8d0df62b076a7757ab5ca07dde0f1e2bfaf83f94299fd9a77577e6cc7022e',
|
|
7
9
|
inputs: [
|
|
8
10
|
{
|
|
9
11
|
outpointHash: '6e200d059fb567ba19e92f5c2dcd3dde522fd4e0a50af223752db16158dabb1d',
|
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',
|
package/.editorconfig
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Bug report
|
|
3
|
-
about: Create a report to help us improve
|
|
4
|
-
title: ''
|
|
5
|
-
labels: 'bug'
|
|
6
|
-
assignees: ''
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<!--- Provide a general summary of the issue in the Title above -->
|
|
11
|
-
|
|
12
|
-
## Expected Behavior
|
|
13
|
-
<!--- Tell us what should happen -->
|
|
14
|
-
|
|
15
|
-
## Current Behavior
|
|
16
|
-
<!--- Tell us what happens instead of the expected behavior -->
|
|
17
|
-
|
|
18
|
-
## Possible Solution
|
|
19
|
-
<!--- Not obligatory, but suggest a fix/reason for the bug -->
|
|
20
|
-
|
|
21
|
-
## Steps to Reproduce (for bugs)
|
|
22
|
-
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
|
|
23
|
-
<!--- reproduce this bug. Include code to reproduce, if relevant -->
|
|
24
|
-
1.
|
|
25
|
-
2.
|
|
26
|
-
3.
|
|
27
|
-
4.
|
|
28
|
-
|
|
29
|
-
## Context
|
|
30
|
-
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
|
31
|
-
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
|
32
|
-
|
|
33
|
-
## Your Environment
|
|
34
|
-
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
|
35
|
-
* Version used:
|
|
36
|
-
* Environment name and version (e.g. Chrome 39, node.js 5.4):
|
|
37
|
-
* Operating System and version (desktop, server, or mobile):
|
|
38
|
-
* Link to your project:
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Feature request
|
|
3
|
-
about: Suggest an idea for this project
|
|
4
|
-
title: ''
|
|
5
|
-
labels: 'enhancement'
|
|
6
|
-
assignees: ''
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
<!--- Provide a general summary of the feature request in the Title above -->
|
|
11
|
-
|
|
12
|
-
## Expected Behavior
|
|
13
|
-
<!--- A clear and concise description of what you want to happen -->
|
|
14
|
-
|
|
15
|
-
## Current Behavior
|
|
16
|
-
<!--- Explain the difference from current behavior -->
|
|
17
|
-
|
|
18
|
-
## Possible Solution
|
|
19
|
-
<!--- Suggest ideas of how to implement the addition or change -->
|
|
20
|
-
|
|
21
|
-
## Alternatives Considered
|
|
22
|
-
<!--- A clear and concise description of any alternative solutions or features you've considered -->
|
|
23
|
-
|
|
24
|
-
## Additional Context
|
|
25
|
-
<!--- Add any other context or screenshots about the feature request here. -->
|
|
26
|
-
|
|
27
|
-
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<!--- Provide a general summary of your changes in the Title above -->
|
|
2
|
-
<!--- Pull request titles must use the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) format -->
|
|
3
|
-
|
|
4
|
-
## Issue being fixed or feature implemented
|
|
5
|
-
<!--- Why is this change required? What problem does it solve? -->
|
|
6
|
-
<!--- If it fixes an open issue, please link to the issue here. -->
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## What was done?
|
|
10
|
-
<!--- Describe your changes in detail -->
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## How Has This Been Tested?
|
|
14
|
-
<!--- Please describe in detail how you tested your changes. -->
|
|
15
|
-
<!--- Include details of your testing environment, and the tests you ran to -->
|
|
16
|
-
<!--- see how your change affects other areas of the code, etc. -->
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Breaking Changes
|
|
20
|
-
<!--- Please describe any breaking changes your code introduces and verify that -->
|
|
21
|
-
<!--- the title includes "!" following the conventional commit type (e.g. "feat!: ..."-->
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## Checklist:
|
|
25
|
-
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
|
26
|
-
- [ ] I have performed a self-review of my own code
|
|
27
|
-
- [ ] I have commented my code, particularly in hard-to-understand areas
|
|
28
|
-
- [ ] I have added or updated relevant unit/integration/functional/e2e tests
|
|
29
|
-
- [ ] I have made corresponding changes to the documentation
|
|
30
|
-
|
|
31
|
-
**For repository code-owners and collaborators only**
|
|
32
|
-
- [ ] I have assigned this pull request to a milestone
|