dash-platform-sdk 1.1.3 → 1.1.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 +1 -1
- package/package.json +2 -2
- package/src/contestedResources/getContestedResourceVoteState.js +1 -1
- package/src/dataContracts/getDataContractByIdentifier.js +1 -1
- package/src/documents/query.js +1 -1
- package/src/grpcConnectionPool.d.ts +1 -0
- package/src/grpcConnectionPool.js +5 -4
- package/src/identities/getIdentityBalance.js +1 -1
- package/src/identities/getIdentityByIdentifier.js +1 -1
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +1 -1
- package/src/identities/getIdentityByPublicKeyHash.js +1 -1
- package/src/identities/getIdentityContractNonce.js +1 -1
- package/src/identities/getIdentityNonce.js +1 -1
- package/src/identities/getIdentityPublicKeys.js +1 -1
- package/src/node/epochs.js +1 -1
- package/src/node/totalCredits.js +1 -1
- package/src/tokens/createStateTransition.d.ts +3 -0
- package/src/tokens/createStateTransition.js +79 -0
- package/src/tokens/getIdentitiesTokenBalances.js +1 -1
- package/src/tokens/getIdentityTokensBalances.js +1 -1
- package/src/tokens/getTokenContractInfo.d.ts +1 -1
- package/src/tokens/getTokenContractInfo.js +2 -2
- package/src/tokens/getTokenTotalSupply.js +1 -1
- package/src/tokens/index.d.ts +25 -1
- package/src/tokens/index.js +50 -0
- package/src/types.d.ts +12 -1
- package/src/utils/getEvonodeList.d.ts +1 -1
- package/src/utils/getEvonodeList.js +13 -28
- package/src/utils/getQuorumPublicKey.d.ts +1 -1
- package/src/utils/getQuorumPublicKey.js +8 -21
- package/test/unit/Tokens.spec.js +172 -1
package/test/unit/Tokens.spec.js
CHANGED
|
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var types_1 = require("../../src/types");
|
|
40
|
+
var pshenmic_dpp_1 = require("pshenmic-dpp");
|
|
40
41
|
var sdk;
|
|
41
42
|
describe('Tokens', function () {
|
|
42
43
|
beforeAll(function () {
|
|
@@ -63,7 +64,7 @@ describe('Tokens', function () {
|
|
|
63
64
|
case 0: return [4 /*yield*/, sdk.tokens.getTokenContractInfo('9YxdbQUjJmQsmVPen95HjAU3Esj7tVkWSY2EQWT84ZQP')];
|
|
64
65
|
case 1:
|
|
65
66
|
tokenContractInfo = _a.sent();
|
|
66
|
-
expect(tokenContractInfo.
|
|
67
|
+
expect(tokenContractInfo.dataContractId.base58()).toEqual('Y189uedQG3CJCuu83P3DqnG7ngQaRKz69x3gY8uDzQe');
|
|
67
68
|
expect(tokenContractInfo.tokenContractPosition).toEqual(0);
|
|
68
69
|
return [2 /*return*/];
|
|
69
70
|
}
|
|
@@ -97,4 +98,174 @@ describe('Tokens', function () {
|
|
|
97
98
|
}
|
|
98
99
|
});
|
|
99
100
|
}); });
|
|
101
|
+
test('should be able to create base token transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
var tokenBaseTransition;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, sdk.tokens.createBaseTransition('A36eJF2kyYXwxCtJGsgbR3CTAscUFaNxZN19UqUfM1kw', '34vkjdeUTP2z798SiXqoB6EAuobh51kXYURqVa9xkujf')];
|
|
106
|
+
case 1:
|
|
107
|
+
tokenBaseTransition = _a.sent();
|
|
108
|
+
expect(tokenBaseTransition).toBeInstanceOf(pshenmic_dpp_1.TokenBaseTransitionWASM);
|
|
109
|
+
return [2 /*return*/];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}); });
|
|
113
|
+
describe('create state transitions', function () {
|
|
114
|
+
test('should be able to create burn transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
+
var tokenId, owner, amount, tokenBaseTransition, stateTransition;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
|
|
120
|
+
owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
121
|
+
amount = BigInt(10);
|
|
122
|
+
return [4 /*yield*/, sdk.tokens.createBaseTransition(tokenId, owner)];
|
|
123
|
+
case 1:
|
|
124
|
+
tokenBaseTransition = _a.sent();
|
|
125
|
+
stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'burn', { amount: amount });
|
|
126
|
+
expect(stateTransition).toBeInstanceOf(pshenmic_dpp_1.StateTransitionWASM);
|
|
127
|
+
return [2 /*return*/];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}); });
|
|
131
|
+
test('should be able to create mint transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
132
|
+
var tokenId, owner, recipientId, amount, tokenBaseTransition, stateTransition;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
switch (_a.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
|
|
137
|
+
owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
138
|
+
recipientId = '8GopLQQCViyroS2gHktesGaCMe2tueXWeQ6Y9vpMFTEC';
|
|
139
|
+
amount = BigInt(10);
|
|
140
|
+
return [4 /*yield*/, sdk.tokens.createBaseTransition(tokenId, owner)];
|
|
141
|
+
case 1:
|
|
142
|
+
tokenBaseTransition = _a.sent();
|
|
143
|
+
stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'mint', { identityId: recipientId, amount: amount });
|
|
144
|
+
expect(stateTransition).toBeInstanceOf(pshenmic_dpp_1.StateTransitionWASM);
|
|
145
|
+
return [2 /*return*/];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}); });
|
|
149
|
+
test('should be able to create transfer transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
150
|
+
var tokenId, owner, recipient, amount, tokenBaseTransition, stateTransition;
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
switch (_a.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
|
|
155
|
+
owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
156
|
+
recipient = '8GopLQQCViyroS2gHktesGaCMe2tueXWeQ6Y9vpMFTEC';
|
|
157
|
+
amount = BigInt(100);
|
|
158
|
+
return [4 /*yield*/, sdk.tokens.createBaseTransition(tokenId, owner)];
|
|
159
|
+
case 1:
|
|
160
|
+
tokenBaseTransition = _a.sent();
|
|
161
|
+
stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'transfer', { identityId: recipient, amount: amount });
|
|
162
|
+
expect(stateTransition).toBeInstanceOf(pshenmic_dpp_1.StateTransitionWASM);
|
|
163
|
+
return [2 /*return*/];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}); });
|
|
167
|
+
test('should be able to create freeze transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
+
var tokenId, owner, identityId, tokenBaseTransition, stateTransition;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0:
|
|
172
|
+
tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
|
|
173
|
+
owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
174
|
+
identityId = '8GopLQQCViyroS2gHktesGaCMe2tueXWeQ6Y9vpMFTEC';
|
|
175
|
+
return [4 /*yield*/, sdk.tokens.createBaseTransition(tokenId, owner)];
|
|
176
|
+
case 1:
|
|
177
|
+
tokenBaseTransition = _a.sent();
|
|
178
|
+
stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'freeze', { identityId: identityId });
|
|
179
|
+
expect(stateTransition).toBeInstanceOf(pshenmic_dpp_1.StateTransitionWASM);
|
|
180
|
+
return [2 /*return*/];
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}); });
|
|
184
|
+
test('should be able to create unfreeze transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
185
|
+
var tokenId, owner, identityId, tokenBaseTransition, stateTransition;
|
|
186
|
+
return __generator(this, function (_a) {
|
|
187
|
+
switch (_a.label) {
|
|
188
|
+
case 0:
|
|
189
|
+
tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
|
|
190
|
+
owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
191
|
+
identityId = '8GopLQQCViyroS2gHktesGaCMe2tueXWeQ6Y9vpMFTEC';
|
|
192
|
+
return [4 /*yield*/, sdk.tokens.createBaseTransition(tokenId, owner)];
|
|
193
|
+
case 1:
|
|
194
|
+
tokenBaseTransition = _a.sent();
|
|
195
|
+
stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'unfreeze', { identityId: identityId });
|
|
196
|
+
expect(stateTransition).toBeInstanceOf(pshenmic_dpp_1.StateTransitionWASM);
|
|
197
|
+
return [2 /*return*/];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}); });
|
|
201
|
+
test('should be able to create destroyFrozenFunds transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
202
|
+
var tokenId, owner, identityId, tokenBaseTransition, stateTransition;
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
switch (_a.label) {
|
|
205
|
+
case 0:
|
|
206
|
+
tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
|
|
207
|
+
owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
208
|
+
identityId = '8GopLQQCViyroS2gHktesGaCMe2tueXWeQ6Y9vpMFTEC';
|
|
209
|
+
return [4 /*yield*/, sdk.tokens.createBaseTransition(tokenId, owner)];
|
|
210
|
+
case 1:
|
|
211
|
+
tokenBaseTransition = _a.sent();
|
|
212
|
+
stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'destroyFrozenFunds', { identityId: identityId });
|
|
213
|
+
expect(stateTransition).toBeInstanceOf(pshenmic_dpp_1.StateTransitionWASM);
|
|
214
|
+
return [2 /*return*/];
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}); });
|
|
218
|
+
test('should be able to create emergency action transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
219
|
+
var tokenId, owner, emergencyAction, tokenBaseTransition, stateTransition;
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
switch (_a.label) {
|
|
222
|
+
case 0:
|
|
223
|
+
tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
|
|
224
|
+
owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
225
|
+
emergencyAction = pshenmic_dpp_1.TokenEmergencyActionWASM.Pause;
|
|
226
|
+
return [4 /*yield*/, sdk.tokens.createBaseTransition(tokenId, owner)];
|
|
227
|
+
case 1:
|
|
228
|
+
tokenBaseTransition = _a.sent();
|
|
229
|
+
stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'emergencyAction', { emergencyAction: emergencyAction });
|
|
230
|
+
expect(stateTransition).toBeInstanceOf(pshenmic_dpp_1.StateTransitionWASM);
|
|
231
|
+
return [2 /*return*/];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}); });
|
|
235
|
+
test('should be able to create setPriceForDirectPurchase transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
236
|
+
var tokenId, owner, price, tokenBaseTransition, stateTransition;
|
|
237
|
+
return __generator(this, function (_a) {
|
|
238
|
+
switch (_a.label) {
|
|
239
|
+
case 0:
|
|
240
|
+
tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
|
|
241
|
+
owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
242
|
+
price = BigInt(10);
|
|
243
|
+
return [4 /*yield*/, sdk.tokens.createBaseTransition(tokenId, owner)];
|
|
244
|
+
case 1:
|
|
245
|
+
tokenBaseTransition = _a.sent();
|
|
246
|
+
stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'setPriceForDirectPurchase', { price: price });
|
|
247
|
+
expect(stateTransition).toBeInstanceOf(pshenmic_dpp_1.StateTransitionWASM);
|
|
248
|
+
return [2 /*return*/];
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}); });
|
|
252
|
+
test('should be able to create directPurchase transition', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
253
|
+
var tokenId, owner, amount, totalAgreedPrice, tokenBaseTransition, stateTransition;
|
|
254
|
+
return __generator(this, function (_a) {
|
|
255
|
+
switch (_a.label) {
|
|
256
|
+
case 0:
|
|
257
|
+
tokenId = '6niNoQpsT9zyVDJtXcbpV3tR3qEGi6BC6xoDdJyx1u7C';
|
|
258
|
+
owner = 'HT3pUBM1Uv2mKgdPEN1gxa7A4PdsvNY89aJbdSKQb5wR';
|
|
259
|
+
amount = BigInt(10);
|
|
260
|
+
totalAgreedPrice = BigInt(100);
|
|
261
|
+
return [4 /*yield*/, sdk.tokens.createBaseTransition(tokenId, owner)];
|
|
262
|
+
case 1:
|
|
263
|
+
tokenBaseTransition = _a.sent();
|
|
264
|
+
stateTransition = sdk.tokens.createStateTransition(tokenBaseTransition, owner, 'directPurchase', { amount: amount, totalAgreedPrice: totalAgreedPrice });
|
|
265
|
+
expect(stateTransition).toBeInstanceOf(pshenmic_dpp_1.StateTransitionWASM);
|
|
266
|
+
return [2 /*return*/];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}); });
|
|
270
|
+
});
|
|
100
271
|
});
|