dash-platform-sdk 1.3.0-dev.1 → 1.3.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle.min.js +21 -2
- package/index.d.ts +1 -1
- package/index.js +2 -5
- package/package.json +32 -31
- package/proto/generated/google/protobuf/wrappers.d.ts +260 -29
- package/proto/generated/google/protobuf/wrappers.js +562 -345
- package/proto/generated/platform.client.d.ts +251 -0
- package/proto/generated/platform.client.js +175 -0
- package/proto/generated/platform.d.ts +3682 -1939
- package/proto/generated/platform.js +8119 -18366
- package/src/DashPlatformSDK.d.ts +18 -19
- package/src/DashPlatformSDK.js +52 -45
- package/src/constants.d.ts +2 -0
- package/src/constants.js +7 -8
- package/src/contestedResources/createStateTransition.d.ts +2 -0
- package/src/contestedResources/createStateTransition.js +6 -0
- package/src/contestedResources/getContestedResourceVoteState.d.ts +3 -3
- package/src/contestedResources/getContestedResourceVoteState.js +67 -118
- package/src/contestedResources/index.d.ts +3 -3
- package/src/contestedResources/index.js +9 -55
- package/src/dataContracts/create.d.ts +1 -1
- package/src/dataContracts/create.js +5 -8
- package/src/dataContracts/createStateTransition.js +10 -14
- package/src/dataContracts/getDataContractByIdentifier.d.ts +2 -2
- package/src/dataContracts/getDataContractByIdentifier.js +40 -79
- package/src/dataContracts/index.d.ts +2 -2
- package/src/dataContracts/index.js +17 -63
- package/src/documents/create.d.ts +1 -1
- package/src/documents/create.js +3 -6
- package/src/documents/createStateTransition.d.ts +1 -1
- package/src/documents/createStateTransition.js +19 -31
- package/src/documents/index.d.ts +2 -2
- package/src/documents/index.js +25 -72
- package/src/documents/query.d.ts +2 -2
- package/src/documents/query.js +58 -90
- package/src/grpcConnectionPool.d.ts +30 -8
- package/src/grpcConnectionPool.js +63 -121
- package/src/identities/createStateTransition.d.ts +2 -2
- package/src/identities/createStateTransition.js +24 -26
- package/src/identities/getIdentityBalance.d.ts +2 -2
- package/src/identities/getIdentityBalance.js +37 -80
- package/src/identities/getIdentityByIdentifier.d.ts +2 -2
- package/src/identities/getIdentityByIdentifier.js +37 -80
- package/src/identities/getIdentityByNonUniquePublicKeyHash.d.ts +1 -1
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +41 -82
- package/src/identities/getIdentityByPublicKeyHash.d.ts +1 -1
- package/src/identities/getIdentityByPublicKeyHash.js +37 -80
- package/src/identities/getIdentityContractNonce.d.ts +2 -2
- package/src/identities/getIdentityContractNonce.js +40 -83
- package/src/identities/getIdentityNonce.d.ts +2 -2
- package/src/identities/getIdentityNonce.js +38 -81
- package/src/identities/getIdentityPublicKeys.d.ts +2 -2
- package/src/identities/getIdentityPublicKeys.js +43 -81
- package/src/identities/index.d.ts +6 -4
- package/src/identities/index.js +70 -154
- package/src/keyPair/deriveChild.d.ts +2 -2
- package/src/keyPair/deriveChild.js +2 -49
- package/src/keyPair/derivePath.d.ts +2 -2
- package/src/keyPair/derivePath.js +2 -49
- package/src/keyPair/index.d.ts +39 -114
- package/src/keyPair/index.js +62 -296
- package/src/keyPair/mnemonicToSeed.d.ts +1 -1
- package/src/keyPair/mnemonicToSeed.js +3 -46
- package/src/names/index.d.ts +44 -3
- package/src/names/index.js +81 -69
- package/src/names/registerName.d.ts +3 -0
- package/src/names/registerName.js +64 -0
- package/src/names/searchByIdentity.d.ts +3 -0
- package/src/names/searchByIdentity.js +5 -0
- package/src/names/searchByName.d.ts +3 -0
- package/src/names/searchByName.js +16 -0
- package/src/names/testNameContested.d.ts +1 -0
- package/src/names/testNameContested.js +3 -0
- package/src/names/validateName.d.ts +1 -0
- package/src/names/validateName.js +11 -0
- package/src/node/epochs.d.ts +1 -1
- package/src/node/epochs.js +43 -85
- package/src/node/index.d.ts +5 -5
- package/src/node/index.js +18 -77
- package/src/node/status.d.ts +2 -2
- package/src/node/status.js +37 -81
- package/src/node/totalCredits.d.ts +3 -2
- package/src/node/totalCredits.js +32 -73
- package/src/stateTransitions/broadcast.d.ts +1 -1
- package/src/stateTransitions/broadcast.js +7 -57
- package/src/stateTransitions/index.d.ts +1 -1
- package/src/stateTransitions/index.js +13 -66
- package/src/stateTransitions/waitForStateTransitionResult.d.ts +1 -1
- package/src/stateTransitions/waitForStateTransitionResult.js +6 -62
- package/src/tokens/createStateTransition.d.ts +1 -1
- package/src/tokens/createStateTransition.js +23 -35
- package/src/tokens/getIdentitiesTokenBalances.d.ts +2 -2
- package/src/tokens/getIdentitiesTokenBalances.js +40 -83
- package/src/tokens/getIdentityTokensBalances.d.ts +2 -2
- package/src/tokens/getIdentityTokensBalances.js +40 -83
- package/src/tokens/getTokenContractInfo.d.ts +2 -2
- package/src/tokens/getTokenContractInfo.js +40 -83
- package/src/tokens/getTokenDirectPurchasePrices.d.ts +3 -0
- package/src/tokens/getTokenDirectPurchasePrices.js +40 -0
- package/src/tokens/getTokenTotalSupply.d.ts +2 -2
- package/src/tokens/getTokenTotalSupply.js +38 -81
- package/src/tokens/index.d.ts +13 -5
- package/src/tokens/index.js +46 -113
- package/src/types.d.ts +20 -16
- package/src/types.js +6 -16
- package/src/utils/base58ToBytes.js +3 -6
- package/src/utils/bytesToHex.js +2 -5
- package/src/utils/bytesToTypedArray.d.ts +1 -0
- package/src/utils/bytesToTypedArray.js +3 -0
- package/src/utils/calculateMsgHash.d.ts +1 -1
- package/src/utils/calculateMsgHash.js +10 -13
- package/src/utils/calculateSignHash.d.ts +2 -2
- package/src/utils/calculateSignHash.js +7 -10
- package/src/utils/calculateStateIdHash.d.ts +2 -2
- package/src/utils/calculateStateIdHash.js +8 -10
- package/src/utils/convertToHomographSafeChars.d.ts +0 -4
- package/src/utils/convertToHomographSafeChars.js +2 -9
- package/src/utils/createMasternodeIdentityId.d.ts +2 -0
- package/src/utils/createMasternodeIdentityId.js +4 -0
- package/src/utils/createVoterIdentityId.d.ts +2 -0
- package/src/utils/createVoterIdentityId.js +13 -0
- package/src/utils/getEvonodeList.d.ts +2 -2
- package/src/utils/getEvonodeList.js +10 -61
- package/src/utils/getQuorumPublicKey.js +15 -66
- package/src/utils/getRandomArrayItem.js +1 -4
- package/src/utils/getRandomBytes.d.ts +1 -0
- package/src/utils/getRandomBytes.js +4 -0
- package/src/utils/hexToBytes.js +2 -6
- package/src/utils/index.d.ts +19 -3
- package/src/utils/index.js +45 -31
- package/src/utils/indexBytesToString.js +2 -5
- package/src/utils/sha256.d.ts +1 -1
- package/src/utils/sha256.js +10 -8
- package/src/utils/signHash.d.ts +1 -1
- package/src/utils/signHash.js +9 -12
- package/src/utils/signRequestId.d.ts +1 -1
- package/src/utils/signRequestId.js +9 -12
- package/src/utils/sleep.d.ts +1 -0
- package/src/utils/sleep.js +3 -0
- package/src/utils/stringToIndexValueBytes.js +4 -7
- package/src/utils/verifyTenderdashProof.d.ts +2 -2
- package/src/utils/verifyTenderdashProof.js +13 -17
- package/src/voting/createStateTransition.d.ts +2 -0
- package/src/voting/createStateTransition.js +6 -0
- package/src/voting/createVote.d.ts +2 -0
- package/src/voting/createVote.js +5 -0
- package/src/voting/index.d.ts +37 -0
- package/src/voting/index.js +55 -0
- package/test/unit/ContestedResources.spec.js +91 -90
- package/test/unit/DataContract.spec.js +44 -111
- package/test/unit/Document.spec.js +93 -183
- package/test/unit/Identity.spec.js +254 -357
- package/test/unit/KeyPair.spec.js +30 -145
- package/test/unit/Names.spec.d.ts +1 -0
- package/test/unit/Names.spec.js +33 -0
- package/test/unit/Node.spec.js +55 -126
- package/test/unit/SDK.spec.js +7 -9
- package/test/unit/Tokens.spec.js +112 -262
- package/bundle.min.js.LICENSE.txt +0 -1
- 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/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/search.d.ts +0 -3
- package/src/names/search.js +0 -63
- package/src/signer/AbstractSigner.d.ts +0 -12
- 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.d.ts +0 -2
- package/src/signer/setSigner.js +0 -8
|
@@ -1,50 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 types_1 = require("../../src/types");
|
|
40
|
-
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
41
|
-
var stringToIndexValueBytes_1 = require("../../src/utils/stringToIndexValueBytes");
|
|
42
|
-
var sdk;
|
|
43
|
-
var contract;
|
|
44
|
-
describe('Contested State', function () {
|
|
45
|
-
beforeAll(function () {
|
|
46
|
-
sdk = new types_1.DashPlatformSDK();
|
|
47
|
-
contract = new pshenmic_dpp_1.DataContractWASM('11111111111111111111111111111111', BigInt(1), {
|
|
1
|
+
import { DataContractWASM, PlatformVersionWASM, PrivateKeyWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { DashPlatformSDK, ContestedStateResultType } from '../../src/types.js';
|
|
3
|
+
import stringToIndexValueBytes from '../../src/utils/stringToIndexValueBytes.js';
|
|
4
|
+
let sdk;
|
|
5
|
+
let contract;
|
|
6
|
+
describe('Contested Resources', () => {
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
9
|
+
contract = new DataContractWASM('11111111111111111111111111111111', BigInt(1), {
|
|
48
10
|
domain: {
|
|
49
11
|
type: 'object',
|
|
50
12
|
indices: [
|
|
@@ -209,49 +171,88 @@ describe('Contested State', function () {
|
|
|
209
171
|
documentsMutable: false,
|
|
210
172
|
additionalProperties: false
|
|
211
173
|
}
|
|
212
|
-
}, undefined, undefined, true,
|
|
174
|
+
}, undefined, undefined, true, PlatformVersionWASM.PLATFORM_V9);
|
|
213
175
|
contract.id = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
214
176
|
});
|
|
215
|
-
test('should be able to get contested resource vote state with finishedVoteInfo',
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
177
|
+
test('should be able to get contested resource vote state with finishedVoteInfo', async () => {
|
|
178
|
+
const voteState = await sdk.contestedResources.getContestedResourceVoteState(contract, 'domain', 'parentNameAndLabel', [
|
|
179
|
+
'dash',
|
|
180
|
+
'asdmaye1ght'
|
|
181
|
+
].map(stringToIndexValueBytes), ContestedStateResultType.DOCUMENTS_AND_VOTE_TALLY, true);
|
|
182
|
+
expect(voteState.finishedVoteInfo).toBeTruthy();
|
|
183
|
+
expect(voteState.contenders).toBeTruthy();
|
|
184
|
+
expect(voteState.contenders.length).toBeGreaterThan(0);
|
|
185
|
+
expect(voteState.abstainVoteTally).toBeDefined();
|
|
186
|
+
expect(voteState.lockVoteTally).toBeDefined();
|
|
187
|
+
});
|
|
188
|
+
test('should be able to get contested resource vote state for incorrect values', async () => {
|
|
189
|
+
try {
|
|
190
|
+
await sdk.contestedResources.getContestedResourceVoteState(contract, 'domain', 'parentNameAndLabel', [
|
|
191
|
+
'dash',
|
|
192
|
+
'agreatma1n'
|
|
193
|
+
].map(stringToIndexValueBytes), ContestedStateResultType.DOCUMENTS_AND_VOTE_TALLY, false);
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
expect(true).toBeTruthy();
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
expect(false).toBeTruthy();
|
|
200
|
+
});
|
|
201
|
+
test('should be able to create TowardsIdentity vote', async () => {
|
|
202
|
+
const dataContactId = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
203
|
+
const documentTypeName = 'domain';
|
|
204
|
+
const indexName = 'parentNameAndLabel';
|
|
205
|
+
const indexValues = ['dash', sdk.names.normalizeLabel('testidentity')];
|
|
206
|
+
const proTxHash = 'd9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89';
|
|
207
|
+
const choice = 'CKKYnVeKoxCbvuEhiT6MDoQaRyXgDECwtxoKL5cqucZE';
|
|
208
|
+
const privateKey = PrivateKeyWASM.fromWIF('cPGCETHtoevguQoyTSdsowCEF91yqhrcikcvBNK2CuTwpSLV7m9Z');
|
|
209
|
+
const voterIdentifier = await sdk.voting.createVoterIdentityId(proTxHash, privateKey.getPublicKeyHash());
|
|
210
|
+
expect(voterIdentifier.base58()).toEqual('HqfLeB9PLg3t9CL25tRNkEDPjAnDaHAMmthRNe8ucn8q');
|
|
211
|
+
const voterIdentity = await sdk.identities.getIdentityByIdentifier(voterIdentifier);
|
|
212
|
+
const [identityPublicKey] = voterIdentity.getPublicKeys().filter(identityPublicKey => privateKey.getPublicKeyHash() === identityPublicKey.getPublicKeyHash());
|
|
213
|
+
const identityNonce = await sdk.identities.getIdentityNonce(voterIdentity.id);
|
|
214
|
+
const vote = sdk.voting.createVote(dataContactId, documentTypeName, indexName, indexValues, choice);
|
|
215
|
+
const stateTransition = sdk.voting.createStateTransition(vote, proTxHash, voterIdentity.id, identityNonce + BigInt(1));
|
|
216
|
+
// test key disabled
|
|
217
|
+
identityPublicKey.removeDisabledAt();
|
|
218
|
+
stateTransition.sign(privateKey, identityPublicKey);
|
|
219
|
+
});
|
|
220
|
+
test('should be able to create Abstain vote', async () => {
|
|
221
|
+
const dataContactId = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
222
|
+
const documentTypeName = 'domain';
|
|
223
|
+
const indexName = 'parentNameAndLabel';
|
|
224
|
+
const indexValues = ['dash', sdk.names.normalizeLabel('testidentity')];
|
|
225
|
+
const proTxHash = 'd9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89';
|
|
226
|
+
const choice = 'abstain';
|
|
227
|
+
const privateKey = PrivateKeyWASM.fromWIF('cPGCETHtoevguQoyTSdsowCEF91yqhrcikcvBNK2CuTwpSLV7m9Z');
|
|
228
|
+
const voterIdentifier = await sdk.voting.createVoterIdentityId(proTxHash, privateKey.getPublicKeyHash());
|
|
229
|
+
expect(voterIdentifier.base58()).toEqual('HqfLeB9PLg3t9CL25tRNkEDPjAnDaHAMmthRNe8ucn8q');
|
|
230
|
+
const voterIdentity = await sdk.identities.getIdentityByIdentifier(voterIdentifier);
|
|
231
|
+
const [identityPublicKey] = voterIdentity.getPublicKeys().filter(identityPublicKey => privateKey.getPublicKeyHash() === identityPublicKey.getPublicKeyHash());
|
|
232
|
+
const identityNonce = await sdk.identities.getIdentityNonce(voterIdentity.id);
|
|
233
|
+
const vote = sdk.voting.createVote(dataContactId, documentTypeName, indexName, indexValues, choice);
|
|
234
|
+
const stateTransition = sdk.voting.createStateTransition(vote, proTxHash, voterIdentity.id, identityNonce + BigInt(1));
|
|
235
|
+
// test key disabled
|
|
236
|
+
identityPublicKey.removeDisabledAt();
|
|
237
|
+
stateTransition.sign(privateKey, identityPublicKey);
|
|
238
|
+
});
|
|
239
|
+
test('should be able to create Lock vote', async () => {
|
|
240
|
+
const dataContactId = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
241
|
+
const documentTypeName = 'domain';
|
|
242
|
+
const indexName = 'parentNameAndLabel';
|
|
243
|
+
const indexValues = ['dash', sdk.names.normalizeLabel('testidentity')];
|
|
244
|
+
const proTxHash = 'd9b090cfc19caf2e27d512e69c43812a274bdf29c081d0ade4fd272ad56a5f89';
|
|
245
|
+
const choice = 'lock';
|
|
246
|
+
const privateKey = PrivateKeyWASM.fromWIF('cPGCETHtoevguQoyTSdsowCEF91yqhrcikcvBNK2CuTwpSLV7m9Z');
|
|
247
|
+
const voterIdentifier = await sdk.voting.createVoterIdentityId(proTxHash, privateKey.getPublicKeyHash());
|
|
248
|
+
expect(voterIdentifier.base58()).toEqual('HqfLeB9PLg3t9CL25tRNkEDPjAnDaHAMmthRNe8ucn8q');
|
|
249
|
+
const voterIdentity = await sdk.identities.getIdentityByIdentifier(voterIdentifier);
|
|
250
|
+
const [identityPublicKey] = voterIdentity.getPublicKeys().filter(identityPublicKey => privateKey.getPublicKeyHash() === identityPublicKey.getPublicKeyHash());
|
|
251
|
+
const identityNonce = await sdk.identities.getIdentityNonce(voterIdentity.id);
|
|
252
|
+
const vote = sdk.voting.createVote(dataContactId, documentTypeName, indexName, indexValues, choice);
|
|
253
|
+
const stateTransition = sdk.voting.createStateTransition(vote, proTxHash, voterIdentity.id, identityNonce + BigInt(1));
|
|
254
|
+
// test key disabled
|
|
255
|
+
identityPublicKey.removeDisabledAt();
|
|
256
|
+
stateTransition.sign(privateKey, identityPublicKey);
|
|
257
|
+
});
|
|
257
258
|
});
|
|
@@ -1,51 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 types_1 = require("../../src/types");
|
|
41
|
-
var sdk;
|
|
42
|
-
var ownerIdentifier;
|
|
43
|
-
var identityNonce;
|
|
44
|
-
var config;
|
|
45
|
-
var schema;
|
|
46
|
-
describe('DataContract', function () {
|
|
47
|
-
beforeAll(function () {
|
|
48
|
-
sdk = new types_1.DashPlatformSDK();
|
|
1
|
+
import { DataContractWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { DashPlatformSDK } from '../../src/types.js';
|
|
3
|
+
let sdk;
|
|
4
|
+
let ownerIdentifier;
|
|
5
|
+
let identityNonce;
|
|
6
|
+
let config;
|
|
7
|
+
let schema;
|
|
8
|
+
describe('DataContract', () => {
|
|
9
|
+
beforeAll(() => {
|
|
10
|
+
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
49
11
|
ownerIdentifier = 'GARSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
50
12
|
identityNonce = BigInt(11);
|
|
51
13
|
config = {
|
|
@@ -76,67 +38,38 @@ describe('DataContract', function () {
|
|
|
76
38
|
}
|
|
77
39
|
};
|
|
78
40
|
});
|
|
79
|
-
test('should be able to get data contract',
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
});
|
|
114
|
-
}); });
|
|
115
|
-
test('should be able to create data contract with optional params', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
|
-
var dataContract;
|
|
117
|
-
return __generator(this, function (_a) {
|
|
118
|
-
dataContract = sdk.dataContracts.create(ownerIdentifier, identityNonce, schema, true, undefined, config);
|
|
119
|
-
expect(dataContract).toEqual(expect.any(pshenmic_dpp_1.DataContractWASM));
|
|
120
|
-
expect(dataContract.getConfig()).toEqual(config);
|
|
121
|
-
return [2 /*return*/];
|
|
122
|
-
});
|
|
123
|
-
}); });
|
|
124
|
-
test('should be able to create data contract create transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
-
var dataContract, transition;
|
|
126
|
-
return __generator(this, function (_a) {
|
|
127
|
-
dataContract = sdk.dataContracts.create(ownerIdentifier, identityNonce, schema);
|
|
128
|
-
transition = sdk.dataContracts.createStateTransition(dataContract, 'create', identityNonce);
|
|
129
|
-
expect(transition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
130
|
-
return [2 /*return*/];
|
|
131
|
-
});
|
|
132
|
-
}); });
|
|
133
|
-
test('should be able to create data contract update transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
134
|
-
var dataContract, transition;
|
|
135
|
-
return __generator(this, function (_a) {
|
|
136
|
-
dataContract = sdk.dataContracts.create(ownerIdentifier, identityNonce, schema);
|
|
137
|
-
transition = sdk.dataContracts.createStateTransition(dataContract, 'update', identityNonce);
|
|
138
|
-
expect(transition).toEqual(expect.any(pshenmic_dpp_1.StateTransitionWASM));
|
|
139
|
-
return [2 /*return*/];
|
|
140
|
-
});
|
|
141
|
-
}); });
|
|
41
|
+
test('should be able to get data contract', async () => {
|
|
42
|
+
let dataContract;
|
|
43
|
+
// System Data Contract
|
|
44
|
+
dataContract = await sdk.dataContracts.getDataContractByIdentifier('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec');
|
|
45
|
+
expect(dataContract).toEqual(expect.any(DataContractWASM));
|
|
46
|
+
// User Data Contract
|
|
47
|
+
dataContract = await sdk.dataContracts.getDataContractByIdentifier('Aukz296s36am6wKStoMbxm4YhC6kTpu3mERVrC7vHokP');
|
|
48
|
+
expect(dataContract).toEqual(expect.any(DataContractWASM));
|
|
49
|
+
// User Data Contract with keep history
|
|
50
|
+
dataContract = await sdk.dataContracts.getDataContractByIdentifier('DrEhmVJz56ukHbaFt8xLVRasnNWsrx3x8dGtcu9xg6rV');
|
|
51
|
+
expect(dataContract).toEqual(expect.any(DataContractWASM));
|
|
52
|
+
// Token Data Contract
|
|
53
|
+
dataContract = await sdk.dataContracts.getDataContractByIdentifier('3XtMFe9UPf75DAcLmLsX9CLTrLPNysNPMcnWCE1C39vm');
|
|
54
|
+
expect(dataContract).toEqual(expect.any(DataContractWASM));
|
|
55
|
+
});
|
|
56
|
+
test('should be able to create data contract', async () => {
|
|
57
|
+
const dataContract = sdk.dataContracts.create(ownerIdentifier, identityNonce, schema);
|
|
58
|
+
expect(dataContract).toEqual(expect.any(DataContractWASM));
|
|
59
|
+
});
|
|
60
|
+
test('should be able to create data contract with optional params', async () => {
|
|
61
|
+
const dataContract = sdk.dataContracts.create(ownerIdentifier, identityNonce, schema, true, undefined, config);
|
|
62
|
+
expect(dataContract).toEqual(expect.any(DataContractWASM));
|
|
63
|
+
expect(dataContract.getConfig()).toEqual(config);
|
|
64
|
+
});
|
|
65
|
+
test('should be able to create data contract create transition', async () => {
|
|
66
|
+
const dataContract = sdk.dataContracts.create(ownerIdentifier, identityNonce, schema);
|
|
67
|
+
const transition = sdk.dataContracts.createStateTransition(dataContract, 'create', identityNonce);
|
|
68
|
+
expect(transition).toEqual(expect.any(StateTransitionWASM));
|
|
69
|
+
});
|
|
70
|
+
test('should be able to create data contract update transition', async () => {
|
|
71
|
+
const dataContract = sdk.dataContracts.create(ownerIdentifier, identityNonce, schema);
|
|
72
|
+
const transition = sdk.dataContracts.createStateTransition(dataContract, 'update', identityNonce);
|
|
73
|
+
expect(transition).toEqual(expect.any(StateTransitionWASM));
|
|
74
|
+
});
|
|
142
75
|
});
|