dash-platform-sdk 1.1.1 → 1.1.2

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.
Files changed (68) hide show
  1. package/bundle.min.js +1 -1
  2. package/package.json +6 -5
  3. package/proto/generated/platform.d.ts +340 -115
  4. package/proto/generated/platform.js +3732 -2333
  5. package/src/DashPlatformSDK.d.ts +18 -5
  6. package/src/DashPlatformSDK.js +20 -7
  7. package/src/constants.d.ts +4 -0
  8. package/src/constants.js +5 -1
  9. package/src/contestedResources/getContestedResourceVoteState.d.ts +6 -0
  10. package/src/contestedResources/getContestedResourceVoteState.js +124 -0
  11. package/src/contestedResources/index.d.ts +29 -0
  12. package/src/contestedResources/index.js +75 -0
  13. package/src/dataContracts/create.js +1 -1
  14. package/src/dataContracts/createStateTransition.d.ts +1 -1
  15. package/src/dataContracts/createStateTransition.js +5 -6
  16. package/src/dataContracts/getDataContractByIdentifier.js +5 -5
  17. package/src/dataContracts/index.d.ts +2 -3
  18. package/src/dataContracts/index.js +1 -1
  19. package/src/documents/create.d.ts +1 -1
  20. package/src/documents/create.js +1 -41
  21. package/src/documents/createStateTransition.d.ts +2 -2
  22. package/src/documents/createStateTransition.js +9 -10
  23. package/src/documents/index.d.ts +3 -3
  24. package/src/documents/index.js +3 -7
  25. package/src/documents/query.js +3 -5
  26. package/src/grpcConnectionPool.d.ts +3 -2
  27. package/src/grpcConnectionPool.js +52 -48
  28. package/src/identities/getIdentityBalance.js +4 -4
  29. package/src/identities/getIdentityByIdentifier.js +4 -4
  30. package/src/identities/getIdentityByNonUniquePublicKeyHash.d.ts +3 -0
  31. package/src/identities/getIdentityByNonUniquePublicKeyHash.js +87 -0
  32. package/src/identities/getIdentityByPublicKeyHash.js +4 -4
  33. package/src/identities/getIdentityContractNonce.js +4 -4
  34. package/src/identities/getIdentityNonce.js +4 -4
  35. package/src/identities/getIdentityPublicKeys.js +4 -4
  36. package/src/identities/index.d.ts +9 -1
  37. package/src/identities/index.js +23 -1
  38. package/src/node/epochs.d.ts +10 -0
  39. package/src/node/epochs.js +82 -0
  40. package/src/node/index.d.ts +16 -1
  41. package/src/node/index.js +35 -1
  42. package/src/node/totalCredits.d.ts +2 -0
  43. package/src/node/totalCredits.js +77 -0
  44. package/src/stateTransitions/broadcast.js +3 -0
  45. package/src/tokens/getIdentitiesTokenBalances.d.ts +8 -0
  46. package/src/tokens/getIdentitiesTokenBalances.js +87 -0
  47. package/src/tokens/getIdentityTokensBalances.d.ts +8 -0
  48. package/src/tokens/getIdentityTokensBalances.js +87 -0
  49. package/src/tokens/getTokenContractInfo.d.ts +8 -0
  50. package/src/tokens/getTokenContractInfo.js +87 -0
  51. package/src/tokens/getTokenTotalSupply.d.ts +9 -0
  52. package/src/tokens/getTokenTotalSupply.js +85 -0
  53. package/src/tokens/index.d.ts +50 -0
  54. package/src/tokens/index.js +124 -0
  55. package/src/types.d.ts +30 -0
  56. package/src/types.js +14 -1
  57. package/src/utils/indexBytesToString.d.ts +1 -0
  58. package/src/utils/indexBytesToString.js +7 -0
  59. package/src/utils/stringToIndexValueBytes.d.ts +1 -0
  60. package/src/utils/stringToIndexValueBytes.js +13 -0
  61. package/test/unit/ContestedResources.spec.d.ts +1 -0
  62. package/test/unit/ContestedResources.spec.js +257 -0
  63. package/test/unit/DataContract.spec.js +16 -6
  64. package/test/unit/DocumentsBatch.spec.js +6 -6
  65. package/test/unit/Identity.spec.js +15 -3
  66. package/test/unit/Node.spec.js +40 -0
  67. package/test/unit/Tokens.spec.d.ts +1 -0
  68. package/test/unit/Tokens.spec.js +100 -0
@@ -86,4 +86,44 @@ describe('Node', function () {
86
86
  }
87
87
  });
88
88
  }); });
89
+ test('should be able to call getEpochsInfo in desc', function () { return __awaiter(void 0, void 0, void 0, function () {
90
+ var epochsInfo, expectedEpochsNumbers;
91
+ return __generator(this, function (_a) {
92
+ switch (_a.label) {
93
+ case 0: return [4 /*yield*/, sdk.node.getEpochsInfo(10, false, 8607)];
94
+ case 1:
95
+ epochsInfo = _a.sent();
96
+ expectedEpochsNumbers = Array.from({ length: 10 }, function (_val, index) { return 8598 + index; });
97
+ expect(epochsInfo.length).toEqual(10);
98
+ expect(epochsInfo.map(function (epochInfo) { return epochInfo.number; })).toEqual(expectedEpochsNumbers);
99
+ return [2 /*return*/];
100
+ }
101
+ });
102
+ }); });
103
+ test('should be able to call getEpochsInfo in asc', function () { return __awaiter(void 0, void 0, void 0, function () {
104
+ var epochsInfo, expectedEpochsNumbers;
105
+ return __generator(this, function (_a) {
106
+ switch (_a.label) {
107
+ case 0: return [4 /*yield*/, sdk.node.getEpochsInfo(10, true, 8596)];
108
+ case 1:
109
+ epochsInfo = _a.sent();
110
+ expectedEpochsNumbers = Array.from({ length: 10 }, function (_val, index) { return 8596 + index; });
111
+ expect(epochsInfo.length).toEqual(10);
112
+ expect(epochsInfo.map(function (epochInfo) { return epochInfo.number; })).toEqual(expectedEpochsNumbers);
113
+ return [2 /*return*/];
114
+ }
115
+ });
116
+ }); });
117
+ test('should be able to call getTotalCreditsInPlatform', function () { return __awaiter(void 0, void 0, void 0, function () {
118
+ var totalCredits;
119
+ return __generator(this, function (_a) {
120
+ switch (_a.label) {
121
+ case 0: return [4 /*yield*/, sdk.node.totalCredits()];
122
+ case 1:
123
+ totalCredits = _a.sent();
124
+ expect(Number(totalCredits)).toBeGreaterThan(0);
125
+ return [2 /*return*/];
126
+ }
127
+ });
128
+ }); });
89
129
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,100 @@
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 types_1 = require("../../src/types");
40
+ var sdk;
41
+ describe('Tokens', function () {
42
+ beforeAll(function () {
43
+ sdk = new types_1.DashPlatformSDK();
44
+ });
45
+ test('should be able to get token total supply', function () { return __awaiter(void 0, void 0, void 0, function () {
46
+ var tokenTotalSupply;
47
+ return __generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0: return [4 /*yield*/, sdk.tokens.getTokenTotalSupply('9YxdbQUjJmQsmVPen95HjAU3Esj7tVkWSY2EQWT84ZQP')];
50
+ case 1:
51
+ tokenTotalSupply = _a.sent();
52
+ expect(tokenTotalSupply.tokenId).toBeTruthy();
53
+ expect(tokenTotalSupply.totalSystemAmount).toBeTruthy();
54
+ expect(tokenTotalSupply.totalAggregatedAmountInUserAccounts).toBeTruthy();
55
+ return [2 /*return*/];
56
+ }
57
+ });
58
+ }); });
59
+ test('should be able to get token contract info', function () { return __awaiter(void 0, void 0, void 0, function () {
60
+ var tokenContractInfo;
61
+ return __generator(this, function (_a) {
62
+ switch (_a.label) {
63
+ case 0: return [4 /*yield*/, sdk.tokens.getTokenContractInfo('9YxdbQUjJmQsmVPen95HjAU3Esj7tVkWSY2EQWT84ZQP')];
64
+ case 1:
65
+ tokenContractInfo = _a.sent();
66
+ expect(tokenContractInfo.contractId.base58()).toEqual('Y189uedQG3CJCuu83P3DqnG7ngQaRKz69x3gY8uDzQe');
67
+ expect(tokenContractInfo.tokenContractPosition).toEqual(0);
68
+ return [2 /*return*/];
69
+ }
70
+ });
71
+ }); });
72
+ test('should be able to get identity tokens balances', function () { return __awaiter(void 0, void 0, void 0, function () {
73
+ var tokensIdentityBalance;
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
76
+ case 0: return [4 /*yield*/, sdk.tokens.getIdentityTokensBalances('8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc', ['9YxdbQUjJmQsmVPen95HjAU3Esj7tVkWSY2EQWT84ZQP'])];
77
+ case 1:
78
+ tokensIdentityBalance = _a.sent();
79
+ expect(tokensIdentityBalance.length).toEqual(1);
80
+ expect(tokensIdentityBalance[0].tokenId).toBeTruthy();
81
+ expect(tokensIdentityBalance[0].balance).toBeTruthy();
82
+ return [2 /*return*/];
83
+ }
84
+ });
85
+ }); });
86
+ test('should be able to get token identities token balances', function () { return __awaiter(void 0, void 0, void 0, function () {
87
+ var tokensIdentityBalance;
88
+ return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0: return [4 /*yield*/, sdk.tokens.getIdentitiesTokenBalances(['8eTDkBhpQjHeqgbVeriwLeZr1tCa6yBGw76SckvD1cwc'], '9YxdbQUjJmQsmVPen95HjAU3Esj7tVkWSY2EQWT84ZQP')];
91
+ case 1:
92
+ tokensIdentityBalance = _a.sent();
93
+ expect(tokensIdentityBalance.length).toEqual(1);
94
+ expect(tokensIdentityBalance[0].identityId).toBeTruthy();
95
+ expect(tokensIdentityBalance[0].balance).toBeTruthy();
96
+ return [2 /*return*/];
97
+ }
98
+ });
99
+ }); });
100
+ });