dash-platform-sdk 1.3.0-dev.3 → 1.3.0-dev.5
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/bundle.min.js +21 -2
- package/package.json +30 -31
- package/proto/generated/google/protobuf/wrappers.d.ts +260 -29
- package/proto/generated/platform.client.d.ts +251 -0
- package/proto/generated/platform.d.ts +3682 -1939
- package/src/DashPlatformSDK.d.ts +5 -4
- package/src/contestedResources/createStateTransition.d.ts +1 -2
- package/src/grpcConnectionPool.d.ts +30 -8
- package/src/keyPair/deriveChild.d.ts +2 -2
- package/src/keyPair/derivePath.d.ts +2 -2
- package/src/keyPair/index.d.ts +39 -114
- package/src/keyPair/mnemonicToSeed.d.ts +1 -1
- package/src/names/searchByIdentity.d.ts +1 -1
- package/src/node/index.d.ts +3 -3
- package/src/node/totalCredits.d.ts +2 -1
- package/src/tokens/getTokenDirectPurchasePrices.d.ts +3 -0
- package/src/tokens/index.d.ts +9 -1
- package/src/types.d.ts +10 -12
- package/src/utils/bytesToTypedArray.d.ts +1 -0
- package/src/utils/calculateMsgHash.d.ts +1 -1
- package/src/utils/calculateSignHash.d.ts +1 -1
- package/src/utils/calculateStateIdHash.d.ts +1 -1
- package/src/utils/createVoterIdentityId.d.ts +1 -1
- package/src/utils/getEvonodeList.d.ts +2 -2
- package/src/utils/sha256.d.ts +1 -1
- package/src/utils/signHash.d.ts +1 -1
- package/src/utils/signRequestId.d.ts +1 -1
- package/src/utils/verifyTenderdashProof.d.ts +1 -1
- package/src/voting/createStateTransition.d.ts +1 -2
- package/src/voting/index.d.ts +3 -4
- package/bundle.min.js.LICENSE.txt +0 -1
- package/index.js +0 -5
- package/proto/generated/google/protobuf/wrappers.js +0 -398
- package/proto/generated/platform.js +0 -18524
- package/src/DashPlatformSDK.js +0 -91
- package/src/constants.js +0 -13
- package/src/contestedResources/createStateTransition.js +0 -9
- package/src/contestedResources/getContestedResourceVoteState.js +0 -123
- package/src/contestedResources/index.js +0 -76
- package/src/dataContracts/create.js +0 -14
- package/src/dataContracts/createStateTransition.js +0 -23
- package/src/dataContracts/getDataContractByIdentifier.js +0 -87
- package/src/dataContracts/index.js +0 -103
- package/src/documents/create.js +0 -7
- package/src/documents/createStateTransition.js +0 -64
- package/src/documents/index.js +0 -130
- package/src/documents/query.js +0 -94
- package/src/grpcConnectionPool.js +0 -137
- package/src/identities/createStateTransition.js +0 -46
- package/src/identities/getIdentityBalance.js +0 -83
- package/src/identities/getIdentityByIdentifier.js +0 -83
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +0 -85
- package/src/identities/getIdentityByPublicKeyHash.js +0 -83
- package/src/identities/getIdentityContractNonce.js +0 -86
- package/src/identities/getIdentityNonce.js +0 -84
- package/src/identities/getIdentityPublicKeys.js +0 -85
- package/src/identities/index.js +0 -237
- package/src/keyPair/deriveChild.js +0 -50
- package/src/keyPair/derivePath.js +0 -50
- package/src/keyPair/index.js +0 -323
- package/src/keyPair/keyToPublicKey.d.ts +0 -2
- package/src/keyPair/keyToPublicKey.js +0 -47
- package/src/keyPair/keyToWalletId.d.ts +0 -2
- package/src/keyPair/keyToWalletId.js +0 -50
- package/src/keyPair/keyToXPrivateKey.d.ts +0 -3
- package/src/keyPair/keyToXPrivateKey.js +0 -50
- package/src/keyPair/keyToXPublicKey.d.ts +0 -3
- package/src/keyPair/keyToXPublicKey.js +0 -50
- package/src/keyPair/mnemonicToIdentityKey.d.ts +0 -3
- package/src/keyPair/mnemonicToIdentityKey.js +0 -57
- package/src/keyPair/mnemonicToSeed.js +0 -47
- package/src/keyPair/mnemonicToWallet.d.ts +0 -2
- package/src/keyPair/mnemonicToWallet.js +0 -55
- package/src/keyPair/privateKeyToWif.d.ts +0 -2
- package/src/keyPair/privateKeyToWif.js +0 -50
- package/src/keyPair/publicKeyToAddress.d.ts +0 -2
- package/src/keyPair/publicKeyToAddress.js +0 -50
- package/src/keyPair/seedToWallet.d.ts +0 -2
- package/src/keyPair/seedToWallet.js +0 -50
- package/src/keyPair/walletToIdentityKey.d.ts +0 -3
- package/src/keyPair/walletToIdentityKey.js +0 -56
- package/src/keyPair/xkeyToHDXKey.d.ts +0 -2
- package/src/keyPair/xkeyToHDXKey.js +0 -50
- package/src/names/index.js +0 -170
- package/src/names/registerName.js +0 -131
- package/src/names/searchByIdentity.js +0 -51
- package/src/names/searchByName.js +0 -64
- package/src/names/testNameContested.js +0 -6
- package/src/names/validateName.js +0 -14
- package/src/node/epochs.js +0 -88
- package/src/node/index.js +0 -102
- package/src/node/status.js +0 -85
- package/src/node/totalCredits.js +0 -76
- package/src/signer/AbstractSigner.js +0 -2
- package/src/signer/PrivateKeySigner.d.ts +0 -0
- package/src/signer/PrivateKeySigner.js +0 -64
- package/src/signer/setSigner.js +0 -8
- package/src/stateTransitions/broadcast.js +0 -60
- package/src/stateTransitions/index.js +0 -87
- package/src/stateTransitions/waitForStateTransitionResult.js +0 -60
- package/src/tokens/createStateTransition.js +0 -79
- package/src/tokens/getIdentitiesTokenBalances.js +0 -86
- package/src/tokens/getIdentityTokensBalances.js +0 -86
- package/src/tokens/getTokenContractInfo.js +0 -86
- package/src/tokens/getTokenTotalSupply.js +0 -84
- package/src/tokens/index.js +0 -175
- package/src/types.js +0 -25
- package/src/utils/base58ToBytes.js +0 -7
- package/src/utils/bytesToHex.js +0 -6
- package/src/utils/calculateMsgHash.js +0 -34
- package/src/utils/calculateSignHash.js +0 -11
- package/src/utils/calculateStateIdHash.js +0 -12
- package/src/utils/convertToHomographSafeChars.js +0 -14
- package/src/utils/createVoterIdentityId.js +0 -12
- package/src/utils/getEvonodeList.js +0 -63
- package/src/utils/getQuorumPublicKey.js +0 -69
- package/src/utils/getRandomArrayItem.js +0 -6
- package/src/utils/getRandomBytes.js +0 -7
- package/src/utils/hexToBytes.js +0 -7
- package/src/utils/index.js +0 -68
- package/src/utils/indexBytesToString.js +0 -7
- package/src/utils/sha256.js +0 -13
- package/src/utils/signHash.js +0 -25
- package/src/utils/signRequestId.js +0 -22
- package/src/utils/sleep.js +0 -51
- package/src/utils/stringToIndexValueBytes.js +0 -13
- package/src/utils/verifyTenderdashProof.js +0 -30
- package/src/voting/createStateTransition.js +0 -9
- package/src/voting/createVote.js +0 -8
- package/src/voting/index.js +0 -62
- package/test/unit/ContestedResources.spec.js +0 -338
- package/test/unit/DataContract.spec.js +0 -142
- package/test/unit/Document.spec.js +0 -199
- package/test/unit/Identity.spec.js +0 -357
- package/test/unit/KeyPair.spec.js +0 -149
- package/test/unit/Names.spec.js +0 -96
- package/test/unit/Node.spec.js +0 -129
- package/test/unit/SDK.spec.js +0 -12
- package/test/unit/Tokens.spec.js +0 -271
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
40
|
-
var DashPlatformSDK_1 = require("../../src/DashPlatformSDK");
|
|
41
|
-
var sdk;
|
|
42
|
-
var dataContract;
|
|
43
|
-
var identity;
|
|
44
|
-
var documentType;
|
|
45
|
-
var revision;
|
|
46
|
-
var data;
|
|
47
|
-
describe('Document', function () {
|
|
48
|
-
beforeAll(function () {
|
|
49
|
-
sdk = new DashPlatformSDK_1.DashPlatformSDK();
|
|
50
|
-
dataContract = '6QMfQTdKpC3Y9uWBcTwXeY3KdzRLDqASUsDnQ4MEc9XC';
|
|
51
|
-
identity = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
|
52
|
-
revision = BigInt(1);
|
|
53
|
-
documentType = 'pool';
|
|
54
|
-
data = {
|
|
55
|
-
name: 'MyPool',
|
|
56
|
-
type: 'EVONODE',
|
|
57
|
-
status: 'INACTIVE',
|
|
58
|
-
description: 'test pool'
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
test('should be able to create document', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
-
var document;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
document = sdk.documents.create(dataContract, documentType, data, identity, revision);
|
|
65
|
-
expect(document).toEqual(expect.any(pshenmic_dpp_1.DocumentWASM));
|
|
66
|
-
return [2 /*return*/];
|
|
67
|
-
});
|
|
68
|
-
}); });
|
|
69
|
-
test('should be able to get documents', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
-
var dataContract, documentType, document;
|
|
71
|
-
return __generator(this, function (_a) {
|
|
72
|
-
switch (_a.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
dataContract = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
75
|
-
documentType = 'domain';
|
|
76
|
-
return [4 /*yield*/, sdk.documents.query(dataContract, documentType)];
|
|
77
|
-
case 1:
|
|
78
|
-
document = (_a.sent())[0];
|
|
79
|
-
expect(document.createdAtBlockHeight).toEqual(undefined);
|
|
80
|
-
expect(document.dataContractId.base58()).toEqual(dataContract);
|
|
81
|
-
expect(document).toEqual(expect.any(pshenmic_dpp_1.DocumentWASM));
|
|
82
|
-
return [2 /*return*/];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}); });
|
|
86
|
-
test('should be able to get document', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
-
var dataContract, documentType, limit, document;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0:
|
|
91
|
-
dataContract = '6hVQW16jyvZyGSQk2YVty4ND6bgFXozizYWnPt753uW5';
|
|
92
|
-
documentType = 'torrent';
|
|
93
|
-
limit = 100;
|
|
94
|
-
return [4 /*yield*/, sdk.documents.query(dataContract, documentType, null, null, limit)];
|
|
95
|
-
case 1:
|
|
96
|
-
document = (_a.sent())[0];
|
|
97
|
-
expect(document.createdAtBlockHeight).toEqual(undefined);
|
|
98
|
-
expect(document.dataContractId.base58()).toEqual(dataContract);
|
|
99
|
-
expect(document).toEqual(expect.any(pshenmic_dpp_1.DocumentWASM));
|
|
100
|
-
return [2 /*return*/];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}); });
|
|
104
|
-
describe('should be able to create state transition', function () {
|
|
105
|
-
test('should be able to create a create transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
-
var document, identityContractNonce, stateTransition;
|
|
107
|
-
return __generator(this, function (_a) {
|
|
108
|
-
document = sdk.documents.create(dataContract, documentType, data, identity);
|
|
109
|
-
identityContractNonce = BigInt(1);
|
|
110
|
-
stateTransition = sdk.documents.createStateTransition(document, 'create', { identityContractNonce: identityContractNonce });
|
|
111
|
-
expect(stateTransition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
112
|
-
return [2 /*return*/];
|
|
113
|
-
});
|
|
114
|
-
}); });
|
|
115
|
-
test('should be able to create a contested document transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
|
-
var document, identityContractNonce, contestedFee, indexName, prefundedVotingBalance, stateTransition;
|
|
117
|
-
return __generator(this, function (_a) {
|
|
118
|
-
document = sdk.documents.create(dataContract, documentType, data, identity);
|
|
119
|
-
identityContractNonce = BigInt(1);
|
|
120
|
-
contestedFee = BigInt(20000000000);
|
|
121
|
-
indexName = 'parentNameAndLabel';
|
|
122
|
-
prefundedVotingBalance = { indexName: indexName, amount: contestedFee };
|
|
123
|
-
stateTransition = sdk.documents.createStateTransition(document, 'create', { identityContractNonce: identityContractNonce, prefundedVotingBalance: prefundedVotingBalance });
|
|
124
|
-
expect(stateTransition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
125
|
-
return [2 /*return*/];
|
|
126
|
-
});
|
|
127
|
-
}); });
|
|
128
|
-
test('should be able to create a document with token payment info', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
129
|
-
var document, identityContractNonce, tokenPaymentInfo, stateTransition;
|
|
130
|
-
return __generator(this, function (_a) {
|
|
131
|
-
document = sdk.documents.create(dataContract, documentType, data, identity);
|
|
132
|
-
identityContractNonce = BigInt(1);
|
|
133
|
-
tokenPaymentInfo = {
|
|
134
|
-
tokenContractId: '6hVQW16jyvZyGSQk2YVty4ND6bgFXozizYWnPt753uW5',
|
|
135
|
-
tokenContractPosition: 0,
|
|
136
|
-
minimumTokenCost: BigInt(1000),
|
|
137
|
-
maximumTokenCost: BigInt(100000),
|
|
138
|
-
gasFeesPaidBy: pshenmic_dpp_1.GasFeesPaidByWASM.ContractOwner
|
|
139
|
-
};
|
|
140
|
-
stateTransition = sdk.documents.createStateTransition(document, 'create', { identityContractNonce: identityContractNonce, tokenPaymentInfo: tokenPaymentInfo });
|
|
141
|
-
expect(stateTransition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
142
|
-
return [2 /*return*/];
|
|
143
|
-
});
|
|
144
|
-
}); });
|
|
145
|
-
test('should be able to create a replace transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
-
var document, identityContractNonce, stateTransition;
|
|
147
|
-
return __generator(this, function (_a) {
|
|
148
|
-
document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
149
|
-
identityContractNonce = BigInt(1);
|
|
150
|
-
stateTransition = sdk.documents.createStateTransition(document, 'replace', { identityContractNonce: identityContractNonce });
|
|
151
|
-
expect(stateTransition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
152
|
-
return [2 /*return*/];
|
|
153
|
-
});
|
|
154
|
-
}); });
|
|
155
|
-
test('should be able to create a delete transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
156
|
-
var document, identityContractNonce, stateTransition;
|
|
157
|
-
return __generator(this, function (_a) {
|
|
158
|
-
document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
159
|
-
identityContractNonce = BigInt(1);
|
|
160
|
-
stateTransition = sdk.documents.createStateTransition(document, 'delete', { identityContractNonce: identityContractNonce });
|
|
161
|
-
expect(stateTransition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
162
|
-
return [2 /*return*/];
|
|
163
|
-
});
|
|
164
|
-
}); });
|
|
165
|
-
test('should be able to create a transfer transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
166
|
-
var document, identityContractNonce, recipientId, stateTransition;
|
|
167
|
-
return __generator(this, function (_a) {
|
|
168
|
-
document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
169
|
-
identityContractNonce = BigInt(1);
|
|
170
|
-
recipientId = '6hVQW16jyvZyGSQk2YVty4ND6bgFXozizYWnPt753uW5';
|
|
171
|
-
stateTransition = sdk.documents.createStateTransition(document, 'transfer', { identityContractNonce: identityContractNonce, recipientId: recipientId });
|
|
172
|
-
expect(stateTransition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
173
|
-
return [2 /*return*/];
|
|
174
|
-
});
|
|
175
|
-
}); });
|
|
176
|
-
test('should be able to create an updatePrice transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
177
|
-
var document, identityContractNonce, price, stateTransition;
|
|
178
|
-
return __generator(this, function (_a) {
|
|
179
|
-
document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
180
|
-
identityContractNonce = BigInt(1);
|
|
181
|
-
price = BigInt(10000000);
|
|
182
|
-
stateTransition = sdk.documents.createStateTransition(document, 'updatePrice', { identityContractNonce: identityContractNonce, price: price });
|
|
183
|
-
expect(stateTransition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
184
|
-
return [2 /*return*/];
|
|
185
|
-
});
|
|
186
|
-
}); });
|
|
187
|
-
test('should be able to create a purchase transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
188
|
-
var document, identityContractNonce, amount, stateTransition;
|
|
189
|
-
return __generator(this, function (_a) {
|
|
190
|
-
document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
191
|
-
identityContractNonce = BigInt(1);
|
|
192
|
-
amount = BigInt(10000000);
|
|
193
|
-
stateTransition = sdk.documents.createStateTransition(document, 'purchase', { identityContractNonce: identityContractNonce, amount: amount });
|
|
194
|
-
expect(stateTransition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
195
|
-
return [2 /*return*/];
|
|
196
|
-
});
|
|
197
|
-
}); });
|
|
198
|
-
});
|
|
199
|
-
});
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
40
|
-
var DashPlatformSDK_1 = require("../../src/DashPlatformSDK");
|
|
41
|
-
var sdk;
|
|
42
|
-
describe('Identity', function () {
|
|
43
|
-
beforeAll(function () {
|
|
44
|
-
sdk = new DashPlatformSDK_1.DashPlatformSDK();
|
|
45
|
-
});
|
|
46
|
-
test('should be able to get identity by identifier', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var identifier, identity;
|
|
48
|
-
return __generator(this, function (_a) {
|
|
49
|
-
switch (_a.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
identifier = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
|
52
|
-
return [4 /*yield*/, sdk.identities.getIdentityByIdentifier(identifier)];
|
|
53
|
-
case 1:
|
|
54
|
-
identity = _a.sent();
|
|
55
|
-
expect(identity).toEqual(expect.any(pshenmic_dpp_1.IdentityWASM));
|
|
56
|
-
return [2 /*return*/];
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}); });
|
|
60
|
-
test('should be able to get identity by public key hash', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
|
-
var publicKeyHash, identity;
|
|
62
|
-
return __generator(this, function (_a) {
|
|
63
|
-
switch (_a.label) {
|
|
64
|
-
case 0:
|
|
65
|
-
publicKeyHash = 'c1b95d254c405a3d9d82ef88a47f9f792ac8efd7';
|
|
66
|
-
return [4 /*yield*/, sdk.identities.getIdentityByPublicKeyHash(publicKeyHash)];
|
|
67
|
-
case 1:
|
|
68
|
-
identity = _a.sent();
|
|
69
|
-
expect(identity).toEqual(expect.any(pshenmic_dpp_1.IdentityWASM));
|
|
70
|
-
return [2 /*return*/];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}); });
|
|
74
|
-
test('should be able to get identity by non unique public key hash', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
-
var identity;
|
|
76
|
-
return __generator(this, function (_a) {
|
|
77
|
-
switch (_a.label) {
|
|
78
|
-
case 0: return [4 /*yield*/, sdk.identities.getIdentityByNonUniquePublicKeyHash('8b30a2cda275d1110874c0380b8447db3a9b04ee')];
|
|
79
|
-
case 1:
|
|
80
|
-
identity = _a.sent();
|
|
81
|
-
expect(identity).toEqual(expect.any(pshenmic_dpp_1.IdentityWASM));
|
|
82
|
-
return [2 /*return*/];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}); });
|
|
86
|
-
test('should be able to get identity contract nonce', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
-
var identifier, dataContract, identityContractNonce;
|
|
88
|
-
return __generator(this, function (_a) {
|
|
89
|
-
switch (_a.label) {
|
|
90
|
-
case 0:
|
|
91
|
-
identifier = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
|
92
|
-
dataContract = 'DrEhmVJz56ukHbaFt8xLVRasnNWsrx3x8dGtcu9xg6rV';
|
|
93
|
-
return [4 /*yield*/, sdk.identities.getIdentityContractNonce(identifier, dataContract)];
|
|
94
|
-
case 1:
|
|
95
|
-
identityContractNonce = _a.sent();
|
|
96
|
-
expect(identityContractNonce).toEqual(expect.any(BigInt));
|
|
97
|
-
return [2 /*return*/];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}); });
|
|
101
|
-
test('should be able to get identity nonce', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
-
var identifier, identityNonce;
|
|
103
|
-
return __generator(this, function (_a) {
|
|
104
|
-
switch (_a.label) {
|
|
105
|
-
case 0:
|
|
106
|
-
identifier = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
|
107
|
-
return [4 /*yield*/, sdk.identities.getIdentityNonce(identifier)];
|
|
108
|
-
case 1:
|
|
109
|
-
identityNonce = _a.sent();
|
|
110
|
-
expect(identityNonce).toEqual(expect.any(BigInt));
|
|
111
|
-
return [2 /*return*/];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}); });
|
|
115
|
-
test('should be able to get identity public keys', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
|
-
var identifier, identityPublicKeys;
|
|
117
|
-
return __generator(this, function (_a) {
|
|
118
|
-
switch (_a.label) {
|
|
119
|
-
case 0:
|
|
120
|
-
identifier = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
|
121
|
-
return [4 /*yield*/, sdk.identities.getIdentityPublicKeys(identifier)];
|
|
122
|
-
case 1:
|
|
123
|
-
identityPublicKeys = _a.sent();
|
|
124
|
-
expect(identityPublicKeys.every(function (identityPublicKey) { return identityPublicKey instanceof pshenmic_dpp_1.IdentityPublicKeyWASM; })).toBeTruthy();
|
|
125
|
-
return [2 /*return*/];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}); });
|
|
129
|
-
test('should be able to get balance', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
130
|
-
var identifier, balance;
|
|
131
|
-
return __generator(this, function (_a) {
|
|
132
|
-
switch (_a.label) {
|
|
133
|
-
case 0:
|
|
134
|
-
identifier = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
|
135
|
-
return [4 /*yield*/, sdk.identities.getIdentityBalance(identifier)];
|
|
136
|
-
case 1:
|
|
137
|
-
balance = _a.sent();
|
|
138
|
-
expect(balance).toEqual(expect.any(BigInt));
|
|
139
|
-
return [2 /*return*/];
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}); });
|
|
143
|
-
describe('createStateTransition', function () {
|
|
144
|
-
test('should be able to create IdentityCreateTransition via ChainLock', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
145
|
-
var assetLockPrivateKey, txid, outputIndex, coreChainLockedHeight, privateKey1, identityPublicKeyInCreation1, privateKey2, identityPublicKeyInCreation2, identityCreateStateTransition;
|
|
146
|
-
return __generator(this, function (_a) {
|
|
147
|
-
assetLockPrivateKey = pshenmic_dpp_1.PrivateKeyWASM.fromHex('edd04a71bddb31e530f6c2314fd42ada333f6656bb853ece13f0577a8fd30612', 'testnet');
|
|
148
|
-
txid = '61aede830477254876d435a317241ad46753c4b1350dc991a45ebcf19ab80a11';
|
|
149
|
-
outputIndex = 0;
|
|
150
|
-
coreChainLockedHeight = 1337;
|
|
151
|
-
privateKey1 = pshenmic_dpp_1.PrivateKeyWASM.fromHex('a1286dd195e2b8e1f6bdc946c56a53e0c544750d6452ddc0f4c593ef311f21af', 'testnet');
|
|
152
|
-
identityPublicKeyInCreation1 = {
|
|
153
|
-
id: 0,
|
|
154
|
-
purpose: pshenmic_dpp_1.Purpose.AUTHENTICATION,
|
|
155
|
-
securityLevel: pshenmic_dpp_1.SecurityLevel.MASTER,
|
|
156
|
-
keyType: pshenmic_dpp_1.KeyType.ECDSA_SECP256K1,
|
|
157
|
-
readOnly: false,
|
|
158
|
-
data: privateKey1.getPublicKey().bytes()
|
|
159
|
-
};
|
|
160
|
-
privateKey2 = pshenmic_dpp_1.PrivateKeyWASM.fromHex('44a8195e242364b935e9d7ff2106ed109e9baf3800907f5e58a259fdfd1ca5e5', 'testnet');
|
|
161
|
-
identityPublicKeyInCreation2 = {
|
|
162
|
-
id: 1,
|
|
163
|
-
purpose: pshenmic_dpp_1.Purpose.AUTHENTICATION,
|
|
164
|
-
securityLevel: pshenmic_dpp_1.SecurityLevel.HIGH,
|
|
165
|
-
keyType: pshenmic_dpp_1.KeyType.ECDSA_SECP256K1,
|
|
166
|
-
readOnly: false,
|
|
167
|
-
data: privateKey2.getPublicKey().bytes()
|
|
168
|
-
};
|
|
169
|
-
// Set identity public key signature for public key 0
|
|
170
|
-
identityCreateStateTransition = sdk.identities.createStateTransition('create', {
|
|
171
|
-
publicKeys: [identityPublicKeyInCreation1, identityPublicKeyInCreation2],
|
|
172
|
-
assetLockProof: {
|
|
173
|
-
txid: txid,
|
|
174
|
-
outputIndex: outputIndex,
|
|
175
|
-
coreChainLockedHeight: coreChainLockedHeight,
|
|
176
|
-
type: 'chainLock'
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
identityCreateStateTransition.signByPrivateKey(privateKey1, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
180
|
-
identityPublicKeyInCreation1.signature = identityCreateStateTransition.signature;
|
|
181
|
-
// Set identity public key signature for public key 1
|
|
182
|
-
identityCreateStateTransition = sdk.identities.createStateTransition('create', {
|
|
183
|
-
publicKeys: [identityPublicKeyInCreation1, identityPublicKeyInCreation2],
|
|
184
|
-
assetLockProof: {
|
|
185
|
-
txid: txid,
|
|
186
|
-
outputIndex: outputIndex,
|
|
187
|
-
coreChainLockedHeight: coreChainLockedHeight,
|
|
188
|
-
type: 'chainLock'
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
identityCreateStateTransition.signByPrivateKey(privateKey2, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
192
|
-
identityPublicKeyInCreation2.signature = identityCreateStateTransition.signature;
|
|
193
|
-
// Finalize
|
|
194
|
-
identityCreateStateTransition = sdk.identities.createStateTransition('create', {
|
|
195
|
-
publicKeys: [identityPublicKeyInCreation1, identityPublicKeyInCreation2],
|
|
196
|
-
assetLockProof: {
|
|
197
|
-
txid: txid,
|
|
198
|
-
outputIndex: outputIndex,
|
|
199
|
-
coreChainLockedHeight: coreChainLockedHeight,
|
|
200
|
-
type: 'chainLock'
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
identityCreateStateTransition.signByPrivateKey(assetLockPrivateKey, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
204
|
-
return [2 /*return*/];
|
|
205
|
-
});
|
|
206
|
-
}); });
|
|
207
|
-
test('should be able to create IdentityCreateTransition via InstantSend', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
208
|
-
var assetLockPrivateKey, transaction, instantLock, outputIndex, privateKey1, identityPublicKeyInCreation1, privateKey2, identityPublicKeyInCreation2, identityCreateStateTransition;
|
|
209
|
-
return __generator(this, function (_a) {
|
|
210
|
-
assetLockPrivateKey = pshenmic_dpp_1.PrivateKeyWASM.fromHex('edd04a71bddb31e530f6c2314fd42ada333f6656bb853ece13f0577a8fd30612', 'testnet');
|
|
211
|
-
transaction = '03000800017dada5379e34ae1b59df35ba7acb879f3afaa12fa522f4b289a34d9fa2a68825010000006b48304502210093d609f65219e0d7ee694d271c4b7460ce89d298ef3e3670d5aef957e5551ead0220085d252e16cb3aae0d4e5d371e359e844fe82db93d8e4e26b5c61dc94676b7df0121037b86a1f7a11b4cc69fc7052e5cabdc625f3db47ee283ed4b87108f2cd879521effffffff0200e1f50500000000026a004054fa02000000001976a91416bbe230f46eea86fc4bf4dd550be45dc9adfcb488ac0000000024010100e1f505000000001976a914883bccdb8bfa44e55a19a1120ff2427537f7e92488ac';
|
|
212
|
-
instantLock = '01017dada5379e34ae1b59df35ba7acb879f3afaa12fa522f4b289a34d9fa2a688250100000060afc1323120f0a3b835dd113b3221e92dea56814369925f10dd3e8f6bcfaa6aa89ed4282521863d8eb72e7e0e7d80c86ca64cce9986ae8bb63657f43f0000009179b5d130fe69bd0f2ea7bc90e9ea904a7eeea515a2612045a70925a7c678b0b09499ea307575751e22f804c443d2e1105e1fd4e30aa894324a41cd983ffe58d5312ff8db11676bd530c6ab8af1f7d2980d356dd3c86d0386da7df70aa3a66b';
|
|
213
|
-
outputIndex = 0;
|
|
214
|
-
privateKey1 = pshenmic_dpp_1.PrivateKeyWASM.fromHex('a1286dd195e2b8e1f6bdc946c56a53e0c544750d6452ddc0f4c593ef311f21af', 'testnet');
|
|
215
|
-
identityPublicKeyInCreation1 = {
|
|
216
|
-
id: 0,
|
|
217
|
-
purpose: pshenmic_dpp_1.Purpose.AUTHENTICATION,
|
|
218
|
-
securityLevel: pshenmic_dpp_1.SecurityLevel.MASTER,
|
|
219
|
-
keyType: pshenmic_dpp_1.KeyType.ECDSA_SECP256K1,
|
|
220
|
-
readOnly: false,
|
|
221
|
-
data: privateKey1.getPublicKey().bytes()
|
|
222
|
-
};
|
|
223
|
-
privateKey2 = pshenmic_dpp_1.PrivateKeyWASM.fromHex('44a8195e242364b935e9d7ff2106ed109e9baf3800907f5e58a259fdfd1ca5e5', 'testnet');
|
|
224
|
-
identityPublicKeyInCreation2 = {
|
|
225
|
-
id: 1,
|
|
226
|
-
purpose: pshenmic_dpp_1.Purpose.AUTHENTICATION,
|
|
227
|
-
securityLevel: pshenmic_dpp_1.SecurityLevel.HIGH,
|
|
228
|
-
keyType: pshenmic_dpp_1.KeyType.ECDSA_SECP256K1,
|
|
229
|
-
readOnly: false,
|
|
230
|
-
data: privateKey2.getPublicKey().bytes()
|
|
231
|
-
};
|
|
232
|
-
// Set identity public key signature for public key 0
|
|
233
|
-
identityCreateStateTransition = sdk.identities.createStateTransition('create', {
|
|
234
|
-
publicKeys: [identityPublicKeyInCreation1, identityPublicKeyInCreation2],
|
|
235
|
-
assetLockProof: {
|
|
236
|
-
transaction: transaction,
|
|
237
|
-
instantLock: instantLock,
|
|
238
|
-
outputIndex: outputIndex,
|
|
239
|
-
type: 'instantLock'
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
identityCreateStateTransition.signByPrivateKey(privateKey1, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
243
|
-
identityPublicKeyInCreation1.signature = identityCreateStateTransition.signature;
|
|
244
|
-
// Set identity public key signature for public key 1
|
|
245
|
-
identityCreateStateTransition = sdk.identities.createStateTransition('create', {
|
|
246
|
-
publicKeys: [identityPublicKeyInCreation1, identityPublicKeyInCreation2],
|
|
247
|
-
assetLockProof: {
|
|
248
|
-
transaction: transaction,
|
|
249
|
-
instantLock: instantLock,
|
|
250
|
-
outputIndex: outputIndex,
|
|
251
|
-
type: 'instantLock'
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
identityCreateStateTransition.signByPrivateKey(privateKey2, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
255
|
-
identityPublicKeyInCreation2.signature = identityCreateStateTransition.signature;
|
|
256
|
-
// Finalize
|
|
257
|
-
identityCreateStateTransition = sdk.identities.createStateTransition('create', {
|
|
258
|
-
publicKeys: [identityPublicKeyInCreation1, identityPublicKeyInCreation2],
|
|
259
|
-
assetLockProof: {
|
|
260
|
-
transaction: transaction,
|
|
261
|
-
instantLock: instantLock,
|
|
262
|
-
outputIndex: outputIndex,
|
|
263
|
-
type: 'instantLock'
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
identityCreateStateTransition.signByPrivateKey(assetLockPrivateKey, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
267
|
-
return [2 /*return*/];
|
|
268
|
-
});
|
|
269
|
-
}); });
|
|
270
|
-
test('should be able to create IdentityTopUpTransition via InstantSend', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
271
|
-
var transaction, instantLock, outputIndex, assetLockPrivateKey, identityId, identityTopUpTransaction;
|
|
272
|
-
return __generator(this, function (_a) {
|
|
273
|
-
transaction = '03000800011a468e6a7cf1c5111b09b7bca6743f2571a9bf13d2ff6d21d3d230fd1dea1e97000000006b483045022100fceb25c45e77e1a273660e4f4c9a09042fb858a57704806e14bf80a734af232a02201929893dd720cf5855e31dda577cda16df29520a9774b4f3e813a4cc468fe086012103e16ede6dc5c99f28e3a5733f47a7494992bc6ce4f98551c092645910b9888b8fffffffff0200e1f50500000000026a004054fa02000000001976a91416bbe230f46eea86fc4bf4dd550be45dc9adfcb488ac0000000024010100e1f505000000001976a9147f78813975a3282e09e284d97d93c083b202e34188ac';
|
|
274
|
-
instantLock = '01011a468e6a7cf1c5111b09b7bca6743f2571a9bf13d2ff6d21d3d230fd1dea1e9700000000892304531821bcddfe960388f93e6e91bbae170987a5c6db33f0a4cf2d88ef148968a159512600791f94053e30f688aac43bf6e698fd78339a9ab5fd3b00000091ee77cadbf9683ca3d1fb1abcb2f561f0c745b26099fe5294885852a03a4f26770a3d437265f5f00ae21d0f681d0e1610a7ac47b6d463c3efdc5f7f922e310e6f3cd66c319e63e4f1c2cc70e97886e15485dba4f29b836bf55f0619837437e8';
|
|
275
|
-
outputIndex = 0;
|
|
276
|
-
assetLockPrivateKey = pshenmic_dpp_1.PrivateKeyWASM.fromHex('3ca33236ab14f6df6cf87fcbb0551544fee7dcf4f251557af02c175725764a5a', 'testnet');
|
|
277
|
-
identityId = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
278
|
-
identityTopUpTransaction = sdk.identities.createStateTransition('topUp', {
|
|
279
|
-
identityId: identityId,
|
|
280
|
-
assetLockProof: {
|
|
281
|
-
transaction: transaction,
|
|
282
|
-
instantLock: instantLock,
|
|
283
|
-
outputIndex: outputIndex,
|
|
284
|
-
type: 'instantLock'
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
identityTopUpTransaction.signByPrivateKey(assetLockPrivateKey, undefined, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
288
|
-
return [2 /*return*/];
|
|
289
|
-
});
|
|
290
|
-
}); });
|
|
291
|
-
test('should be able to create IdentityTopUpTransition via ChainLock', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
292
|
-
var txid, outputIndex, coreChainLockedHeight, assetLockPrivateKey, identityId, identityTopUpTransaction;
|
|
293
|
-
return __generator(this, function (_a) {
|
|
294
|
-
txid = '61aede830477254876d435a317241ad46753c4b1350dc991a45ebcf19ab80a11';
|
|
295
|
-
outputIndex = 0;
|
|
296
|
-
coreChainLockedHeight = 1337;
|
|
297
|
-
assetLockPrivateKey = pshenmic_dpp_1.PrivateKeyWASM.fromHex('3ca33236ab14f6df6cf87fcbb0551544fee7dcf4f251557af02c175725764a5a', 'testnet');
|
|
298
|
-
identityId = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
299
|
-
identityTopUpTransaction = sdk.identities.createStateTransition('topUp', {
|
|
300
|
-
identityId: identityId,
|
|
301
|
-
assetLockProof: {
|
|
302
|
-
txid: txid,
|
|
303
|
-
outputIndex: outputIndex,
|
|
304
|
-
coreChainLockedHeight: coreChainLockedHeight,
|
|
305
|
-
type: 'chainLock'
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
identityTopUpTransaction.signByPrivateKey(assetLockPrivateKey, undefined, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
309
|
-
return [2 /*return*/];
|
|
310
|
-
});
|
|
311
|
-
}); });
|
|
312
|
-
test('should be able to create IdentityUpdateTransition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
313
|
-
var identityId, masterPrivateKey, masterKeyId, identity, revision, identityNonce, keyId, identityPrivateKey, identityPublicKeyInCreation, identityUpdateTransition;
|
|
314
|
-
return __generator(this, function (_a) {
|
|
315
|
-
switch (_a.label) {
|
|
316
|
-
case 0:
|
|
317
|
-
identityId = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
318
|
-
masterPrivateKey = pshenmic_dpp_1.PrivateKeyWASM.fromHex('16f614c6242580628d849e3616491dda1eccce99642a85667eb9a364dc85324a', 'testnet');
|
|
319
|
-
masterKeyId = 0;
|
|
320
|
-
return [4 /*yield*/, sdk.identities.getIdentityByIdentifier(identityId)];
|
|
321
|
-
case 1:
|
|
322
|
-
identity = _a.sent();
|
|
323
|
-
revision = identity.revision + BigInt(1);
|
|
324
|
-
return [4 /*yield*/, sdk.identities.getIdentityNonce(identityId)];
|
|
325
|
-
case 2:
|
|
326
|
-
identityNonce = (_a.sent()) + BigInt(1);
|
|
327
|
-
keyId = identity.getPublicKeys()[identity.getPublicKeys().length - 1].keyId + 1;
|
|
328
|
-
identityPrivateKey = pshenmic_dpp_1.PrivateKeyWASM.fromHex('16f614c6242580628d849e3616491dda1eccce99642a85667eb9a364dc85324a', 'testnet');
|
|
329
|
-
identityPublicKeyInCreation = {
|
|
330
|
-
id: keyId,
|
|
331
|
-
purpose: pshenmic_dpp_1.Purpose.AUTHENTICATION,
|
|
332
|
-
securityLevel: pshenmic_dpp_1.SecurityLevel.HIGH,
|
|
333
|
-
keyType: pshenmic_dpp_1.KeyType.ECDSA_SECP256K1,
|
|
334
|
-
readOnly: false,
|
|
335
|
-
data: identityPrivateKey.getPublicKey().bytes()
|
|
336
|
-
};
|
|
337
|
-
identityUpdateTransition = sdk.identities.createStateTransition('update', {
|
|
338
|
-
identityId: identityId,
|
|
339
|
-
revision: revision,
|
|
340
|
-
identityNonce: identityNonce,
|
|
341
|
-
addPublicKeys: [identityPublicKeyInCreation]
|
|
342
|
-
});
|
|
343
|
-
identityUpdateTransition.signByPrivateKey(masterPrivateKey, masterKeyId, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
344
|
-
identityPublicKeyInCreation.signature = identityUpdateTransition.signature;
|
|
345
|
-
identityUpdateTransition = sdk.identities.createStateTransition('update', {
|
|
346
|
-
identityId: identityId,
|
|
347
|
-
revision: revision,
|
|
348
|
-
identityNonce: identityNonce,
|
|
349
|
-
addPublicKeys: [identityPublicKeyInCreation]
|
|
350
|
-
});
|
|
351
|
-
identityUpdateTransition.signByPrivateKey(masterPrivateKey, masterKeyId, pshenmic_dpp_1.KeyType.ECDSA_SECP256K1);
|
|
352
|
-
return [2 /*return*/];
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}); });
|
|
356
|
-
});
|
|
357
|
-
});
|