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.
Files changed (139) hide show
  1. package/bundle.min.js +21 -2
  2. package/package.json +30 -31
  3. package/proto/generated/google/protobuf/wrappers.d.ts +260 -29
  4. package/proto/generated/platform.client.d.ts +251 -0
  5. package/proto/generated/platform.d.ts +3682 -1939
  6. package/src/DashPlatformSDK.d.ts +5 -4
  7. package/src/contestedResources/createStateTransition.d.ts +1 -2
  8. package/src/grpcConnectionPool.d.ts +30 -8
  9. package/src/keyPair/deriveChild.d.ts +2 -2
  10. package/src/keyPair/derivePath.d.ts +2 -2
  11. package/src/keyPair/index.d.ts +39 -114
  12. package/src/keyPair/mnemonicToSeed.d.ts +1 -1
  13. package/src/names/searchByIdentity.d.ts +1 -1
  14. package/src/node/index.d.ts +3 -3
  15. package/src/node/totalCredits.d.ts +2 -1
  16. package/src/tokens/getTokenDirectPurchasePrices.d.ts +3 -0
  17. package/src/tokens/index.d.ts +9 -1
  18. package/src/types.d.ts +10 -12
  19. package/src/utils/bytesToTypedArray.d.ts +1 -0
  20. package/src/utils/calculateMsgHash.d.ts +1 -1
  21. package/src/utils/calculateSignHash.d.ts +1 -1
  22. package/src/utils/calculateStateIdHash.d.ts +1 -1
  23. package/src/utils/createVoterIdentityId.d.ts +1 -1
  24. package/src/utils/getEvonodeList.d.ts +2 -2
  25. package/src/utils/sha256.d.ts +1 -1
  26. package/src/utils/signHash.d.ts +1 -1
  27. package/src/utils/signRequestId.d.ts +1 -1
  28. package/src/utils/verifyTenderdashProof.d.ts +1 -1
  29. package/src/voting/createStateTransition.d.ts +1 -2
  30. package/src/voting/index.d.ts +3 -4
  31. package/bundle.min.js.LICENSE.txt +0 -1
  32. package/index.js +0 -5
  33. package/proto/generated/google/protobuf/wrappers.js +0 -398
  34. package/proto/generated/platform.js +0 -18524
  35. package/src/DashPlatformSDK.js +0 -91
  36. package/src/constants.js +0 -13
  37. package/src/contestedResources/createStateTransition.js +0 -9
  38. package/src/contestedResources/getContestedResourceVoteState.js +0 -123
  39. package/src/contestedResources/index.js +0 -76
  40. package/src/dataContracts/create.js +0 -14
  41. package/src/dataContracts/createStateTransition.js +0 -23
  42. package/src/dataContracts/getDataContractByIdentifier.js +0 -87
  43. package/src/dataContracts/index.js +0 -103
  44. package/src/documents/create.js +0 -7
  45. package/src/documents/createStateTransition.js +0 -64
  46. package/src/documents/index.js +0 -130
  47. package/src/documents/query.js +0 -94
  48. package/src/grpcConnectionPool.js +0 -137
  49. package/src/identities/createStateTransition.js +0 -46
  50. package/src/identities/getIdentityBalance.js +0 -83
  51. package/src/identities/getIdentityByIdentifier.js +0 -83
  52. package/src/identities/getIdentityByNonUniquePublicKeyHash.js +0 -85
  53. package/src/identities/getIdentityByPublicKeyHash.js +0 -83
  54. package/src/identities/getIdentityContractNonce.js +0 -86
  55. package/src/identities/getIdentityNonce.js +0 -84
  56. package/src/identities/getIdentityPublicKeys.js +0 -85
  57. package/src/identities/index.js +0 -237
  58. package/src/keyPair/deriveChild.js +0 -50
  59. package/src/keyPair/derivePath.js +0 -50
  60. package/src/keyPair/index.js +0 -323
  61. package/src/keyPair/keyToPublicKey.d.ts +0 -2
  62. package/src/keyPair/keyToPublicKey.js +0 -47
  63. package/src/keyPair/keyToWalletId.d.ts +0 -2
  64. package/src/keyPair/keyToWalletId.js +0 -50
  65. package/src/keyPair/keyToXPrivateKey.d.ts +0 -3
  66. package/src/keyPair/keyToXPrivateKey.js +0 -50
  67. package/src/keyPair/keyToXPublicKey.d.ts +0 -3
  68. package/src/keyPair/keyToXPublicKey.js +0 -50
  69. package/src/keyPair/mnemonicToIdentityKey.d.ts +0 -3
  70. package/src/keyPair/mnemonicToIdentityKey.js +0 -57
  71. package/src/keyPair/mnemonicToSeed.js +0 -47
  72. package/src/keyPair/mnemonicToWallet.d.ts +0 -2
  73. package/src/keyPair/mnemonicToWallet.js +0 -55
  74. package/src/keyPair/privateKeyToWif.d.ts +0 -2
  75. package/src/keyPair/privateKeyToWif.js +0 -50
  76. package/src/keyPair/publicKeyToAddress.d.ts +0 -2
  77. package/src/keyPair/publicKeyToAddress.js +0 -50
  78. package/src/keyPair/seedToWallet.d.ts +0 -2
  79. package/src/keyPair/seedToWallet.js +0 -50
  80. package/src/keyPair/walletToIdentityKey.d.ts +0 -3
  81. package/src/keyPair/walletToIdentityKey.js +0 -56
  82. package/src/keyPair/xkeyToHDXKey.d.ts +0 -2
  83. package/src/keyPair/xkeyToHDXKey.js +0 -50
  84. package/src/names/index.js +0 -170
  85. package/src/names/registerName.js +0 -131
  86. package/src/names/searchByIdentity.js +0 -51
  87. package/src/names/searchByName.js +0 -64
  88. package/src/names/testNameContested.js +0 -6
  89. package/src/names/validateName.js +0 -14
  90. package/src/node/epochs.js +0 -88
  91. package/src/node/index.js +0 -102
  92. package/src/node/status.js +0 -85
  93. package/src/node/totalCredits.js +0 -76
  94. package/src/signer/AbstractSigner.js +0 -2
  95. package/src/signer/PrivateKeySigner.d.ts +0 -0
  96. package/src/signer/PrivateKeySigner.js +0 -64
  97. package/src/signer/setSigner.js +0 -8
  98. package/src/stateTransitions/broadcast.js +0 -60
  99. package/src/stateTransitions/index.js +0 -87
  100. package/src/stateTransitions/waitForStateTransitionResult.js +0 -60
  101. package/src/tokens/createStateTransition.js +0 -79
  102. package/src/tokens/getIdentitiesTokenBalances.js +0 -86
  103. package/src/tokens/getIdentityTokensBalances.js +0 -86
  104. package/src/tokens/getTokenContractInfo.js +0 -86
  105. package/src/tokens/getTokenTotalSupply.js +0 -84
  106. package/src/tokens/index.js +0 -175
  107. package/src/types.js +0 -25
  108. package/src/utils/base58ToBytes.js +0 -7
  109. package/src/utils/bytesToHex.js +0 -6
  110. package/src/utils/calculateMsgHash.js +0 -34
  111. package/src/utils/calculateSignHash.js +0 -11
  112. package/src/utils/calculateStateIdHash.js +0 -12
  113. package/src/utils/convertToHomographSafeChars.js +0 -14
  114. package/src/utils/createVoterIdentityId.js +0 -12
  115. package/src/utils/getEvonodeList.js +0 -63
  116. package/src/utils/getQuorumPublicKey.js +0 -69
  117. package/src/utils/getRandomArrayItem.js +0 -6
  118. package/src/utils/getRandomBytes.js +0 -7
  119. package/src/utils/hexToBytes.js +0 -7
  120. package/src/utils/index.js +0 -68
  121. package/src/utils/indexBytesToString.js +0 -7
  122. package/src/utils/sha256.js +0 -13
  123. package/src/utils/signHash.js +0 -25
  124. package/src/utils/signRequestId.js +0 -22
  125. package/src/utils/sleep.js +0 -51
  126. package/src/utils/stringToIndexValueBytes.js +0 -13
  127. package/src/utils/verifyTenderdashProof.js +0 -30
  128. package/src/voting/createStateTransition.js +0 -9
  129. package/src/voting/createVote.js +0 -8
  130. package/src/voting/index.js +0 -62
  131. package/test/unit/ContestedResources.spec.js +0 -338
  132. package/test/unit/DataContract.spec.js +0 -142
  133. package/test/unit/Document.spec.js +0 -199
  134. package/test/unit/Identity.spec.js +0 -357
  135. package/test/unit/KeyPair.spec.js +0 -149
  136. package/test/unit/Names.spec.js +0 -96
  137. package/test/unit/Node.spec.js +0 -129
  138. package/test/unit/SDK.spec.js +0 -12
  139. package/test/unit/Tokens.spec.js +0 -271
@@ -1,149 +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 DashPlatformSDK_1 = require("../../src/DashPlatformSDK");
40
- var sdk;
41
- var mnemonic;
42
- describe('KeyPair', function () {
43
- beforeAll(function () {
44
- sdk = new DashPlatformSDK_1.DashPlatformSDK();
45
- mnemonic = 'deliver frame tomato ring tool second dream mutual fade sponsor visa teach';
46
- });
47
- describe('mnemonic', function () {
48
- test('should be able to get seed from mnemonic', function () { return __awaiter(void 0, void 0, void 0, function () {
49
- var seed;
50
- return __generator(this, function (_a) {
51
- switch (_a.label) {
52
- case 0: return [4 /*yield*/, sdk.keyPair.mnemonicToSeed(mnemonic, '', true)
53
- // TODO: Get mock data from sdk
54
- ];
55
- case 1:
56
- seed = _a.sent();
57
- // TODO: Get mock data from sdk
58
- expect(seed).toEqual(Uint8Array.from([170, 120, 192, 223, 47, 43, 142, 250, 243, 136, 44, 236, 84, 170, 156, 154, 126, 231, 185, 130, 242, 40, 134, 27, 36, 33, 187, 102, 29, 177, 119, 141, 61, 157, 81, 35, 85, 33, 43, 28, 108, 24, 108, 159, 119, 233, 104, 100, 2, 206, 18, 245, 142, 99, 19, 143, 141, 0, 207, 31, 143, 58, 245, 107]));
59
- return [2 /*return*/];
60
- }
61
- });
62
- }); });
63
- test('should be able to get wallet from seed', function () { return __awaiter(void 0, void 0, void 0, function () {
64
- var seed, wallet;
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0:
68
- seed = Uint8Array.from([170, 120, 192, 223, 47, 43, 142, 250, 243, 136, 44, 236, 84, 170, 156, 154, 126, 231, 185, 130, 242, 40, 134, 27, 36, 33, 187, 102, 29, 177, 119, 141, 61, 157, 81, 35, 85, 33, 43, 28, 108, 24, 108, 159, 119, 233, 104, 100, 2, 206, 18, 245, 142, 99, 19, 143, 141, 0, 207, 31, 143, 58, 245, 107]);
69
- return [4 /*yield*/, sdk.keyPair.seedToWallet(seed, { versions: 'testnet' })];
70
- case 1:
71
- wallet = _a.sent();
72
- expect(wallet.privateKey).toEqual(new Uint8Array([105, 213, 35, 36, 214, 9, 104, 32, 148, 57, 157, 10, 134, 251, 79, 152, 252, 58, 194, 48, 145, 102, 7, 252, 191, 69, 164, 97, 195, 136, 182, 93]));
73
- return [2 /*return*/];
74
- }
75
- });
76
- }); });
77
- test('should be able to get wallet from mnemonic', function () { return __awaiter(void 0, void 0, void 0, function () {
78
- var wallet;
79
- return __generator(this, function (_a) {
80
- switch (_a.label) {
81
- case 0: return [4 /*yield*/, sdk.keyPair.mnemonicToWallet(mnemonic, '', true, { versions: 'testnet' })];
82
- case 1:
83
- wallet = _a.sent();
84
- expect(wallet.privateKey).toEqual(new Uint8Array([105, 213, 35, 36, 214, 9, 104, 32, 148, 57, 157, 10, 134, 251, 79, 152, 252, 58, 194, 48, 145, 102, 7, 252, 191, 69, 164, 97, 195, 136, 182, 93]));
85
- return [2 /*return*/];
86
- }
87
- });
88
- }); });
89
- test('should be able to get wallet for testnet from mnemonic without options', function () { return __awaiter(void 0, void 0, void 0, function () {
90
- var wallet;
91
- return __generator(this, function (_a) {
92
- switch (_a.label) {
93
- case 0: return [4 /*yield*/, sdk.keyPair.mnemonicToWallet(mnemonic)];
94
- case 1:
95
- wallet = _a.sent();
96
- expect(wallet.privateKey).toEqual(new Uint8Array([105, 213, 35, 36, 214, 9, 104, 32, 148, 57, 157, 10, 134, 251, 79, 152, 252, 58, 194, 48, 145, 102, 7, 252, 191, 69, 164, 97, 195, 136, 182, 93]));
97
- return [2 /*return*/];
98
- }
99
- });
100
- }); });
101
- });
102
- describe('wallet', function () {
103
- test('should be able to derive address from wallet via derive path', function () { return __awaiter(void 0, void 0, void 0, function () {
104
- var wallet, key, address;
105
- return __generator(this, function (_a) {
106
- switch (_a.label) {
107
- case 0: return [4 /*yield*/, sdk.keyPair.mnemonicToWallet(mnemonic, '', true, { versions: 'testnet' })];
108
- case 1:
109
- wallet = _a.sent();
110
- return [4 /*yield*/, sdk.keyPair.derivePath(wallet, "m/44'/1'/0'/0/0")];
111
- case 2:
112
- key = _a.sent();
113
- return [4 /*yield*/, sdk.keyPair.publicKeyToAddress(key.publicKey, { version: 'testnet' })];
114
- case 3:
115
- address = _a.sent();
116
- expect(address).toEqual('yRGEqFgmuqJct4jzH48sFrvBCc3WuPKDTp');
117
- return [2 /*return*/];
118
- }
119
- });
120
- }); });
121
- test('should be able to derive identity from wallet', function () { return __awaiter(void 0, void 0, void 0, function () {
122
- var wallet, key;
123
- return __generator(this, function (_a) {
124
- switch (_a.label) {
125
- case 0: return [4 /*yield*/, sdk.keyPair.mnemonicToWallet(mnemonic, '', true, { versions: 'testnet' })];
126
- case 1:
127
- wallet = _a.sent();
128
- return [4 /*yield*/, sdk.keyPair.walletToIdentityKey(wallet, 0, 0)];
129
- case 2:
130
- key = _a.sent();
131
- expect(key.privateKey).toEqual(Uint8Array.from([89, 255, 64, 41, 202, 170, 83, 68, 135, 58, 161, 107, 130, 20, 3, 50, 69, 16, 108, 104, 32, 68, 13, 100, 225, 24, 79, 20, 193, 184, 238, 55]));
132
- return [2 /*return*/];
133
- }
134
- });
135
- }); });
136
- test('should be able to derive identity from mnemonic', function () { return __awaiter(void 0, void 0, void 0, function () {
137
- var key;
138
- return __generator(this, function (_a) {
139
- switch (_a.label) {
140
- case 0: return [4 /*yield*/, sdk.keyPair.mnemonicToIdentityKey(mnemonic, 0, 0)];
141
- case 1:
142
- key = _a.sent();
143
- expect(key.privateKey).toEqual(Uint8Array.from([89, 255, 64, 41, 202, 170, 83, 68, 135, 58, 161, 107, 130, 20, 3, 50, 69, 16, 108, 104, 32, 68, 13, 100, 225, 24, 79, 20, 193, 184, 238, 55]));
144
- return [2 /*return*/];
145
- }
146
- });
147
- }); });
148
- });
149
- });
@@ -1,96 +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 broadcast_1 = require("../../src/stateTransitions/broadcast");
40
- var pshenmic_dpp_1 = require("pshenmic-dpp");
41
- var DashPlatformSDK_1 = require("../../src/DashPlatformSDK");
42
- var sleep_1 = require("../../src/utils/sleep");
43
- jest.mock('../../src/stateTransitions/broadcast');
44
- jest.mock('../../src/utils/sleep');
45
- var sdk;
46
- describe('DPNS names', function () {
47
- beforeAll(function () {
48
- sdk = new DashPlatformSDK_1.DashPlatformSDK({ network: 'testnet' });
49
- // @ts-expect-error
50
- sleep_1.default.mockReturnValue(Promise.resolve());
51
- sdk.stateTransitions.broadcast = jest.fn();
52
- });
53
- test('should be able to search names by identity identifier', function () { return __awaiter(void 0, void 0, void 0, function () {
54
- var documents;
55
- return __generator(this, function (_a) {
56
- switch (_a.label) {
57
- case 0: return [4 /*yield*/, sdk.names.searchByName('xyz.dash')];
58
- case 1:
59
- documents = _a.sent();
60
- expect(documents === null || documents === void 0 ? void 0 : documents.length).toEqual(1);
61
- expect(documents[0]).toEqual(expect.any(pshenmic_dpp_1.DocumentWASM));
62
- return [2 /*return*/];
63
- }
64
- });
65
- }); });
66
- test('should be able to search names by DPNS name', function () { return __awaiter(void 0, void 0, void 0, function () {
67
- var documents, xyzDocument;
68
- return __generator(this, function (_a) {
69
- switch (_a.label) {
70
- case 0: return [4 /*yield*/, sdk.names.searchByIdentity('36LGwPSXef8q8wpdnx4EdDeVNuqCYNAE9boDu5bxytsm')];
71
- case 1:
72
- documents = _a.sent();
73
- expect(documents === null || documents === void 0 ? void 0 : documents.length).toEqual(3);
74
- xyzDocument = documents[0];
75
- expect(xyzDocument.ownerId.base58()).toEqual('36LGwPSXef8q8wpdnx4EdDeVNuqCYNAE9boDu5bxytsm');
76
- return [2 /*return*/];
77
- }
78
- });
79
- }); });
80
- test('should be able to register a name', function () { return __awaiter(void 0, void 0, void 0, function () {
81
- var fullName, identityId, privateKey;
82
- return __generator(this, function (_a) {
83
- switch (_a.label) {
84
- case 0:
85
- fullName = 'test-identity-050.dash';
86
- identityId = 'CKKYnVeKoxCbvuEhiT6MDoQaRyXgDECwtxoKL5cqucZE';
87
- privateKey = pshenmic_dpp_1.PrivateKeyWASM.fromWIF('XERm528aQWJ3hzEcb79KMQKewbSSJQtni3fWHbu75wDxg6xg6AA3');
88
- return [4 /*yield*/, sdk.names.registerName(fullName, identityId, privateKey)];
89
- case 1:
90
- _a.sent();
91
- expect(broadcast_1.default).toHaveBeenCalledTimes(2);
92
- return [2 /*return*/];
93
- }
94
- });
95
- }); });
96
- });
@@ -1,129 +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 DashPlatformSDK_1 = require("../../src/DashPlatformSDK");
40
- var sdk;
41
- describe('Node', function () {
42
- beforeAll(function () {
43
- sdk = new DashPlatformSDK_1.DashPlatformSDK();
44
- });
45
- test('should be able to call getStatus', function () { return __awaiter(void 0, void 0, void 0, function () {
46
- var status;
47
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
48
- return __generator(this, function (_19) {
49
- switch (_19.label) {
50
- case 0: return [4 /*yield*/, sdk.node.status()];
51
- case 1:
52
- status = _19.sent();
53
- expect((_b = (_a = status.version) === null || _a === void 0 ? void 0 : _a.software) === null || _b === void 0 ? void 0 : _b.dapi).toEqual(expect.any(String));
54
- expect((_d = (_c = status.version) === null || _c === void 0 ? void 0 : _c.software) === null || _d === void 0 ? void 0 : _d.drive).toEqual(expect.any(String));
55
- expect((_f = (_e = status.version) === null || _e === void 0 ? void 0 : _e.software) === null || _f === void 0 ? void 0 : _f.tenderdash).toEqual(expect.any(String));
56
- expect((_j = (_h = (_g = status.version) === null || _g === void 0 ? void 0 : _g.protocol) === null || _h === void 0 ? void 0 : _h.tenderdash) === null || _j === void 0 ? void 0 : _j.p2p).toEqual(expect.any(Number));
57
- expect((_m = (_l = (_k = status.version) === null || _k === void 0 ? void 0 : _k.protocol) === null || _l === void 0 ? void 0 : _l.tenderdash) === null || _m === void 0 ? void 0 : _m.block).toEqual(expect.any(Number));
58
- expect((_q = (_p = (_o = status.version) === null || _o === void 0 ? void 0 : _o.protocol) === null || _p === void 0 ? void 0 : _p.drive) === null || _q === void 0 ? void 0 : _q.latest).toEqual(expect.any(Number));
59
- expect((_t = (_s = (_r = status.version) === null || _r === void 0 ? void 0 : _r.protocol) === null || _s === void 0 ? void 0 : _s.drive) === null || _t === void 0 ? void 0 : _t.current).toEqual(expect.any(Number));
60
- expect((_u = status.node) === null || _u === void 0 ? void 0 : _u.id).toEqual(expect.any(String));
61
- expect((_v = status.chain) === null || _v === void 0 ? void 0 : _v.catchingUp).toEqual(expect.any(Boolean));
62
- expect((_w = status.chain) === null || _w === void 0 ? void 0 : _w.latestBlockHash).toEqual(expect.any(String));
63
- expect((_x = status.chain) === null || _x === void 0 ? void 0 : _x.latestAppHash).toEqual(expect.any(String));
64
- expect((_y = status.chain) === null || _y === void 0 ? void 0 : _y.latestBlockHeight).toEqual(expect.any(String));
65
- expect((_z = status.chain) === null || _z === void 0 ? void 0 : _z.earliestBlockHash).toEqual(expect.any(String));
66
- expect((_0 = status.chain) === null || _0 === void 0 ? void 0 : _0.earliestAppHash).toEqual(expect.any(String));
67
- expect((_1 = status.chain) === null || _1 === void 0 ? void 0 : _1.earliestBlockHeight).toEqual(expect.any(String));
68
- expect((_2 = status.chain) === null || _2 === void 0 ? void 0 : _2.maxPeerBlockHeight).toEqual(expect.any(String));
69
- expect((_3 = status.chain) === null || _3 === void 0 ? void 0 : _3.coreChainLockedHeight).toEqual(expect.any(Number));
70
- expect((_4 = status.network) === null || _4 === void 0 ? void 0 : _4.chainId).toEqual(expect.any(String));
71
- expect((_5 = status.network) === null || _5 === void 0 ? void 0 : _5.peersCount).toEqual(expect.any(Number));
72
- expect((_6 = status.network) === null || _6 === void 0 ? void 0 : _6.listening).toEqual(expect.any(Boolean));
73
- expect((_7 = status.stateSync) === null || _7 === void 0 ? void 0 : _7.totalSyncedTime).toEqual(expect.any(String));
74
- expect((_8 = status.stateSync) === null || _8 === void 0 ? void 0 : _8.remainingTime).toEqual(expect.any(String));
75
- expect((_9 = status.stateSync) === null || _9 === void 0 ? void 0 : _9.totalSnapshots).toEqual(expect.any(Number));
76
- expect((_10 = status.stateSync) === null || _10 === void 0 ? void 0 : _10.chunkProcessAvgTime).toEqual(expect.any(String));
77
- expect((_11 = status.stateSync) === null || _11 === void 0 ? void 0 : _11.snapshotHeight).toEqual(expect.any(String));
78
- expect((_12 = status.stateSync) === null || _12 === void 0 ? void 0 : _12.snapshotChunksCount).toEqual(expect.any(String));
79
- expect((_13 = status.stateSync) === null || _13 === void 0 ? void 0 : _13.backfilledBlocks).toEqual(expect.any(String));
80
- expect((_14 = status.stateSync) === null || _14 === void 0 ? void 0 : _14.backfillBlocksTotal).toEqual(expect.any(String));
81
- expect((_15 = status.time) === null || _15 === void 0 ? void 0 : _15.local).toEqual(expect.any(String));
82
- expect((_16 = status.time) === null || _16 === void 0 ? void 0 : _16.block).toEqual(expect.any(String));
83
- expect((_17 = status.time) === null || _17 === void 0 ? void 0 : _17.genesis).toEqual(expect.any(String));
84
- expect((_18 = status.time) === null || _18 === void 0 ? void 0 : _18.epoch).toEqual(expect.any(Number));
85
- return [2 /*return*/];
86
- }
87
- });
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
- }); });
129
- });
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var DashPlatformSDK_1 = require("../../src/DashPlatformSDK");
4
- var sdk;
5
- describe('DashPlatformSDK', function () {
6
- beforeAll(function () {
7
- sdk = new DashPlatformSDK_1.DashPlatformSDK();
8
- });
9
- test('should be constructable throw `new`', function () {
10
- expect(sdk).toEqual(expect.any(DashPlatformSDK_1.DashPlatformSDK));
11
- });
12
- });