dash-platform-sdk 1.3.0-dev.4 → 1.3.0-dev.6
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.js +2 -5
- package/package.json +30 -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 +5 -4
- package/src/DashPlatformSDK.js +56 -46
- package/src/constants.js +7 -10
- package/src/contestedResources/createStateTransition.d.ts +1 -2
- package/src/contestedResources/createStateTransition.js +4 -7
- package/src/contestedResources/getContestedResourceVoteState.js +67 -118
- package/src/contestedResources/index.js +9 -55
- package/src/dataContracts/create.js +5 -8
- package/src/dataContracts/createStateTransition.js +10 -14
- package/src/dataContracts/getDataContractByIdentifier.js +40 -83
- package/src/dataContracts/index.js +17 -63
- package/src/documents/create.js +3 -6
- package/src/documents/createStateTransition.js +19 -31
- package/src/documents/index.js +25 -72
- package/src/documents/query.js +58 -90
- package/src/grpcConnectionPool.d.ts +30 -8
- package/src/grpcConnectionPool.js +63 -121
- package/src/identities/createStateTransition.js +14 -26
- package/src/identities/getIdentityBalance.js +37 -80
- package/src/identities/getIdentityByIdentifier.js +37 -80
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +41 -82
- package/src/identities/getIdentityByPublicKeyHash.js +37 -80
- package/src/identities/getIdentityContractNonce.js +40 -83
- package/src/identities/getIdentityNonce.js +38 -81
- package/src/identities/getIdentityPublicKeys.js +43 -81
- package/src/identities/index.js +57 -153
- 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.js +43 -111
- package/src/names/registerName.js +60 -127
- package/src/names/searchByIdentity.d.ts +1 -1
- package/src/names/searchByIdentity.js +4 -50
- package/src/names/searchByName.js +15 -63
- package/src/names/testNameContested.js +1 -4
- package/src/names/validateName.js +3 -6
- package/src/node/epochs.js +43 -85
- package/src/node/index.d.ts +3 -3
- package/src/node/index.js +18 -77
- package/src/node/status.js +37 -81
- package/src/node/totalCredits.d.ts +2 -1
- package/src/node/totalCredits.js +32 -73
- package/src/signer/AbstractSigner.js +1 -2
- package/src/signer/setSigner.js +1 -4
- package/src/stateTransitions/broadcast.js +7 -57
- package/src/stateTransitions/index.js +13 -66
- package/src/stateTransitions/waitForStateTransitionResult.js +6 -58
- package/src/tokens/createStateTransition.js +23 -35
- package/src/tokens/getIdentitiesTokenBalances.js +40 -83
- package/src/tokens/getIdentityTokensBalances.js +40 -83
- package/src/tokens/getTokenContractInfo.js +40 -83
- package/src/tokens/getTokenDirectPurchasePrices.js +37 -80
- package/src/tokens/getTokenTotalSupply.js +38 -81
- package/src/tokens/index.js +39 -124
- package/src/types.d.ts +6 -12
- 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 +1 -1
- package/src/utils/calculateSignHash.js +7 -10
- package/src/utils/calculateStateIdHash.d.ts +1 -1
- package/src/utils/calculateStateIdHash.js +8 -10
- package/src/utils/convertToHomographSafeChars.js +2 -5
- package/src/utils/createVoterIdentityId.d.ts +1 -1
- package/src/utils/createVoterIdentityId.js +12 -11
- 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.js +2 -5
- package/src/utils/hexToBytes.js +2 -6
- package/src/utils/index.js +21 -28
- 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.js +2 -50
- package/src/utils/stringToIndexValueBytes.js +4 -7
- package/src/utils/verifyTenderdashProof.d.ts +1 -1
- package/src/utils/verifyTenderdashProof.js +13 -17
- package/src/voting/createStateTransition.d.ts +1 -2
- package/src/voting/createStateTransition.js +4 -7
- package/src/voting/createVote.js +4 -7
- package/src/voting/index.d.ts +3 -4
- package/src/voting/index.js +19 -26
- package/test/unit/ContestedResources.spec.js +92 -177
- package/test/unit/DataContract.spec.js +44 -111
- package/test/unit/Document.spec.js +93 -183
- package/test/unit/Identity.spec.js +221 -346
- package/test/unit/KeyPair.spec.js +30 -145
- package/test/unit/Names.spec.js +27 -90
- package/test/unit/Node.spec.js +55 -126
- package/test/unit/SDK.spec.js +7 -9
- package/test/unit/Tokens.spec.js +111 -278
- 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
|
@@ -1,52 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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();
|
|
1
|
+
import { DocumentWASM, GasFeesPaidByWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { DashPlatformSDK } from '../../src/DashPlatformSDK';
|
|
3
|
+
let sdk;
|
|
4
|
+
let dataContract;
|
|
5
|
+
let identity;
|
|
6
|
+
let documentType;
|
|
7
|
+
let revision;
|
|
8
|
+
let data;
|
|
9
|
+
describe('Document', () => {
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
50
12
|
dataContract = '6QMfQTdKpC3Y9uWBcTwXeY3KdzRLDqASUsDnQ4MEc9XC';
|
|
51
13
|
identity = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
|
52
14
|
revision = BigInt(1);
|
|
@@ -58,142 +20,90 @@ describe('Document', function () {
|
|
|
58
20
|
description: 'test pool'
|
|
59
21
|
};
|
|
60
22
|
});
|
|
61
|
-
test('should be able to create document',
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
23
|
+
test('should be able to create document', async () => {
|
|
24
|
+
const document = sdk.documents.create(dataContract, documentType, data, identity, revision);
|
|
25
|
+
expect(document).toEqual(expect.any(DocumentWASM));
|
|
26
|
+
});
|
|
27
|
+
test('should be able to get documents', async () => {
|
|
28
|
+
const dataContract = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
29
|
+
const documentType = 'domain';
|
|
30
|
+
const [document] = await sdk.documents.query(dataContract, documentType);
|
|
31
|
+
expect(document.createdAtBlockHeight).toEqual(undefined);
|
|
32
|
+
expect(document.dataContractId.base58()).toEqual(dataContract);
|
|
33
|
+
expect(document).toEqual(expect.any(DocumentWASM));
|
|
34
|
+
});
|
|
35
|
+
test('should be able to get document', async () => {
|
|
36
|
+
const dataContract = '6hVQW16jyvZyGSQk2YVty4ND6bgFXozizYWnPt753uW5';
|
|
37
|
+
const documentType = 'torrent';
|
|
38
|
+
const limit = 100;
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
const [document] = await sdk.documents.query(dataContract, documentType, null, null, limit);
|
|
41
|
+
expect(document.createdAtBlockHeight).toEqual(undefined);
|
|
42
|
+
expect(document.dataContractId.base58()).toEqual(dataContract);
|
|
43
|
+
expect(document).toEqual(expect.any(DocumentWASM));
|
|
44
|
+
});
|
|
45
|
+
describe('should be able to create state transition', () => {
|
|
46
|
+
test('should be able to create a create transition', async () => {
|
|
47
|
+
const document = sdk.documents.create(dataContract, documentType, data, identity);
|
|
48
|
+
const identityContractNonce = BigInt(1);
|
|
49
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'create', { identityContractNonce });
|
|
50
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
51
|
+
});
|
|
52
|
+
test('should be able to create a contested document transition', async () => {
|
|
53
|
+
const document = sdk.documents.create(dataContract, documentType, data, identity);
|
|
54
|
+
const identityContractNonce = BigInt(1);
|
|
55
|
+
// 0.2 Dash typically
|
|
56
|
+
const contestedFee = BigInt(20000000000);
|
|
57
|
+
const indexName = 'parentNameAndLabel';
|
|
58
|
+
const prefundedVotingBalance = { indexName, amount: contestedFee };
|
|
59
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'create', { identityContractNonce, prefundedVotingBalance });
|
|
60
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
61
|
+
});
|
|
62
|
+
test('should be able to create a document with token payment info', async () => {
|
|
63
|
+
const document = sdk.documents.create(dataContract, documentType, data, identity);
|
|
64
|
+
const identityContractNonce = BigInt(1);
|
|
65
|
+
const tokenPaymentInfo = {
|
|
66
|
+
tokenContractId: '6hVQW16jyvZyGSQk2YVty4ND6bgFXozizYWnPt753uW5',
|
|
67
|
+
tokenContractPosition: 0,
|
|
68
|
+
minimumTokenCost: BigInt(1000),
|
|
69
|
+
maximumTokenCost: BigInt(100000),
|
|
70
|
+
gasFeesPaidBy: GasFeesPaidByWASM.ContractOwner
|
|
71
|
+
};
|
|
72
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'create', { identityContractNonce, tokenPaymentInfo });
|
|
73
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
74
|
+
});
|
|
75
|
+
test('should be able to create a replace transition', async () => {
|
|
76
|
+
const document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
77
|
+
const identityContractNonce = BigInt(1);
|
|
78
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'replace', { identityContractNonce });
|
|
79
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
80
|
+
});
|
|
81
|
+
test('should be able to create a delete transition', async () => {
|
|
82
|
+
const document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
83
|
+
const identityContractNonce = BigInt(1);
|
|
84
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'delete', { identityContractNonce });
|
|
85
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
86
|
+
});
|
|
87
|
+
test('should be able to create a transfer transition', async () => {
|
|
88
|
+
const document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
89
|
+
const identityContractNonce = BigInt(1);
|
|
90
|
+
const recipientId = '6hVQW16jyvZyGSQk2YVty4ND6bgFXozizYWnPt753uW5';
|
|
91
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'transfer', { identityContractNonce, recipientId });
|
|
92
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
67
93
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
}
|
|
94
|
+
test('should be able to create an updatePrice transition', async () => {
|
|
95
|
+
const document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
96
|
+
const identityContractNonce = BigInt(1);
|
|
97
|
+
const price = BigInt(10000000);
|
|
98
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'updatePrice', { identityContractNonce, price });
|
|
99
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
84
100
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
}
|
|
101
|
+
test('should be able to create a purchase transition', async () => {
|
|
102
|
+
const document = sdk.documents.create(dataContract, documentType, data, identity, revision + BigInt(1));
|
|
103
|
+
const identityContractNonce = BigInt(1);
|
|
104
|
+
const amount = BigInt(10000000);
|
|
105
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'purchase', { identityContractNonce, amount });
|
|
106
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
102
107
|
});
|
|
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
108
|
});
|
|
199
109
|
});
|