@airgap/icp 0.13.11-beta.1 → 0.13.11-beta.11

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 (144) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +18 -0
  3. package/index.js.map +1 -0
  4. package/package.json +6 -9
  5. package/v1/block-explorer/ICPBlockExplorer.d.ts +9 -0
  6. package/v1/block-explorer/ICPBlockExplorer.js +74 -0
  7. package/v1/block-explorer/ICPBlockExplorer.js.map +1 -0
  8. package/v1/index.d.ts +14 -0
  9. package/v1/index.js +14 -0
  10. package/v1/index.js.map +1 -0
  11. package/v1/module/ICPModule.d.ts +14 -0
  12. package/v1/module/ICPModule.js +119 -0
  13. package/v1/module/ICPModule.js.map +1 -0
  14. package/v1/module.d.ts +3 -0
  15. package/v1/module.js +24 -0
  16. package/v1/module.js.map +1 -0
  17. package/v1/protocol/ICPImplementation.d.ts +34 -0
  18. package/v1/protocol/ICPImplementation.js +376 -0
  19. package/v1/protocol/ICPImplementation.js.map +1 -0
  20. package/v1/protocol/ICPProtocol.d.ts +45 -0
  21. package/v1/protocol/ICPProtocol.js +423 -0
  22. package/v1/protocol/ICPProtocol.js.map +1 -0
  23. package/v1/protocol/icrc/CkBTCProtocol.d.ts +13 -0
  24. package/v1/protocol/icrc/CkBTCProtocol.js +328 -0
  25. package/v1/protocol/icrc/CkBTCProtocol.js.map +1 -0
  26. package/v1/protocol/icrc/ICRC1Protocol.d.ts +91 -0
  27. package/v1/protocol/icrc/ICRC1Protocol.js +672 -0
  28. package/v1/protocol/icrc/ICRC1Protocol.js.map +1 -0
  29. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
  30. package/v1/serializer/v3/schemas/converter/transaction-converter.js +21 -0
  31. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  32. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.d.ts +4 -0
  33. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js +3 -0
  34. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.js.map +1 -0
  35. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.d.ts +3 -0
  36. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js +3 -0
  37. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-icp.js.map +1 -0
  38. package/v1/serializer/v3/schemas/generated/transaction-sign-request-icp.json +32 -0
  39. package/v1/serializer/v3/schemas/generated/transaction-sign-response-icp.json +19 -0
  40. package/v1/serializer/v3/serializer-companion.d.ts +14 -0
  41. package/v1/serializer/v3/serializer-companion.js +190 -0
  42. package/v1/serializer/v3/serializer-companion.js.map +1 -0
  43. package/v1/serializer/v3/validators/transaction-validator.d.ts +10 -0
  44. package/v1/serializer/v3/validators/transaction-validator.js +100 -0
  45. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
  46. package/v1/serializer/v3/validators/validators.d.ts +5 -0
  47. package/v1/serializer/v3/validators/validators.js +106 -0
  48. package/v1/serializer/v3/validators/validators.js.map +1 -0
  49. package/v1/types/ckbtc/metadata.d.ts +4 -0
  50. package/v1/types/ckbtc/metadata.js +3 -0
  51. package/v1/types/ckbtc/metadata.js.map +1 -0
  52. package/v1/types/crypto.d.ts +2 -0
  53. package/v1/types/crypto.js +3 -0
  54. package/v1/types/crypto.js.map +1 -0
  55. package/v1/types/governance.d.ts +580 -0
  56. package/v1/types/governance.js +796 -0
  57. package/v1/types/governance.js.map +1 -0
  58. package/v1/types/icrc/account.d.ts +4 -0
  59. package/v1/types/icrc/account.js +3 -0
  60. package/v1/types/icrc/account.js.map +1 -0
  61. package/v1/types/icrc/ledger.d.ts +15 -0
  62. package/v1/types/icrc/ledger.js +92 -0
  63. package/v1/types/icrc/ledger.js.map +1 -0
  64. package/v1/types/icrc/metadata.d.ts +6 -0
  65. package/v1/types/icrc/metadata.js +3 -0
  66. package/v1/types/icrc/metadata.js.map +1 -0
  67. package/v1/types/icrc/transfer.d.ts +9 -0
  68. package/v1/types/icrc/transfer.js +3 -0
  69. package/v1/types/icrc/transfer.js.map +1 -0
  70. package/v1/types/ledger.d.ts +142 -0
  71. package/v1/types/ledger.js +145 -0
  72. package/v1/types/ledger.js.map +1 -0
  73. package/v1/types/management_idl.d.ts +7 -0
  74. package/v1/types/management_idl.js +72 -0
  75. package/v1/types/management_idl.js.map +1 -0
  76. package/v1/types/protocol.d.ts +37 -0
  77. package/v1/types/protocol.js +3 -0
  78. package/v1/types/protocol.js.map +1 -0
  79. package/v1/types/transaction.d.ts +11 -0
  80. package/v1/types/transaction.js +3 -0
  81. package/v1/types/transaction.js.map +1 -0
  82. package/v1/utils/account.d.ts +24 -0
  83. package/v1/utils/account.js +112 -0
  84. package/v1/utils/account.js.map +1 -0
  85. package/v1/utils/actor.d.ts +246 -0
  86. package/v1/utils/actor.js +458 -0
  87. package/v1/utils/actor.js.map +1 -0
  88. package/v1/utils/agent.d.ts +156 -0
  89. package/v1/utils/agent.js +16 -0
  90. package/v1/utils/agent.js.map +1 -0
  91. package/v1/utils/auth.d.ts +110 -0
  92. package/v1/utils/auth.js +261 -0
  93. package/v1/utils/auth.js.map +1 -0
  94. package/v1/utils/bls.d.ts +38 -0
  95. package/v1/utils/bls.js +204 -0
  96. package/v1/utils/bls.js.map +1 -0
  97. package/v1/utils/buffer.d.ts +70 -0
  98. package/v1/utils/buffer.js +216 -0
  99. package/v1/utils/buffer.js.map +1 -0
  100. package/v1/utils/cbor.d.ts +9 -0
  101. package/v1/utils/cbor.js +178 -0
  102. package/v1/utils/cbor.js.map +1 -0
  103. package/v1/utils/certificate.d.ts +74 -0
  104. package/v1/utils/certificate.js +396 -0
  105. package/v1/utils/certificate.js.map +1 -0
  106. package/v1/utils/convert.d.ts +10 -0
  107. package/v1/utils/convert.js +88 -0
  108. package/v1/utils/convert.js.map +1 -0
  109. package/v1/utils/crypto.d.ts +0 -0
  110. package/v1/utils/crypto.js +104 -0
  111. package/v1/utils/crypto.js.map +1 -0
  112. package/v1/utils/der.d.ts +35 -0
  113. package/v1/utils/der.js +176 -0
  114. package/v1/utils/der.js.map +1 -0
  115. package/v1/utils/errors.d.ts +7 -0
  116. package/v1/utils/errors.js +38 -0
  117. package/v1/utils/errors.js.map +1 -0
  118. package/v1/utils/hdkey.d.ts +13 -0
  119. package/v1/utils/hdkey.js +265 -0
  120. package/v1/utils/hdkey.js.map +1 -0
  121. package/v1/utils/http.d.ts +284 -0
  122. package/v1/utils/http.js +614 -0
  123. package/v1/utils/http.js.map +1 -0
  124. package/v1/utils/icrc1.d.ts +20 -0
  125. package/v1/utils/icrc1.js +171 -0
  126. package/v1/utils/icrc1.js.map +1 -0
  127. package/v1/utils/idl.d.ts +515 -0
  128. package/v1/utils/idl.js +2103 -0
  129. package/v1/utils/idl.js.map +1 -0
  130. package/v1/utils/leb128.d.ts +63 -0
  131. package/v1/utils/leb128.js +224 -0
  132. package/v1/utils/leb128.js.map +1 -0
  133. package/v1/utils/polling.d.ts +59 -0
  134. package/v1/utils/polling.js +325 -0
  135. package/v1/utils/polling.js.map +1 -0
  136. package/v1/utils/principal.d.ts +58 -0
  137. package/v1/utils/principal.js +543 -0
  138. package/v1/utils/principal.js.map +1 -0
  139. package/v1/utils/secp256k1.d.ts +79 -0
  140. package/v1/utils/secp256k1.js +278 -0
  141. package/v1/utils/secp256k1.js.map +1 -0
  142. package/v1/utils/transaction.d.ts +3 -0
  143. package/v1/utils/transaction.js +56 -0
  144. package/v1/utils/transaction.js.map +1 -0
@@ -0,0 +1,325 @@
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;
13
+ return g = { next: verb(0), "throw": verb(1), "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 (_) 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
+ var __values = (this && this.__values) || function(o) {
39
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
+ if (m) return m.call(o);
41
+ if (o && typeof o.length === "number") return {
42
+ next: function () {
43
+ if (o && i >= o.length) o = void 0;
44
+ return { value: o && o[i++], done: !o };
45
+ }
46
+ };
47
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
+ };
49
+ var __read = (this && this.__read) || function (o, n) {
50
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
51
+ if (!m) return o;
52
+ var i = m.call(o), r, ar = [], e;
53
+ try {
54
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
+ }
56
+ catch (error) { e = { error: error }; }
57
+ finally {
58
+ try {
59
+ if (r && !r.done && (m = i["return"])) m.call(i);
60
+ }
61
+ finally { if (e) throw e.error; }
62
+ }
63
+ return ar;
64
+ };
65
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
+ if (ar || !(i in from)) {
68
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
+ ar[i] = from[i];
70
+ }
71
+ }
72
+ return to.concat(ar || Array.prototype.slice.call(from));
73
+ };
74
+ Object.defineProperty(exports, "__esModule", { value: true });
75
+ exports.pollForResponse = exports.chain = exports.backoff = exports.timeout = exports.throttle = exports.maxAttempts = exports.conditionalDelay = exports.once = exports.defaultStrategy = void 0;
76
+ var auth_1 = require("./auth");
77
+ var buffer_1 = require("./buffer");
78
+ var certificate_1 = require("./certificate");
79
+ var FIVE_MINUTES_IN_MSEC = 5 * 60 * 1000;
80
+ /**
81
+ * A best practices polling strategy: wait 2 seconds before the first poll, then 1 second
82
+ * with an exponential backoff factor of 1.2. Timeout after 5 minutes.
83
+ */
84
+ function defaultStrategy() {
85
+ return chain(conditionalDelay(once(), 1000), backoff(1000, 1.2), timeout(FIVE_MINUTES_IN_MSEC));
86
+ }
87
+ exports.defaultStrategy = defaultStrategy;
88
+ /**
89
+ * Predicate that returns true once.
90
+ */
91
+ function once() {
92
+ var _this = this;
93
+ var first = true;
94
+ return function () { return __awaiter(_this, void 0, void 0, function () {
95
+ return __generator(this, function (_a) {
96
+ if (first) {
97
+ first = false;
98
+ return [2 /*return*/, true];
99
+ }
100
+ return [2 /*return*/, false];
101
+ });
102
+ }); };
103
+ }
104
+ exports.once = once;
105
+ /**
106
+ * Delay the polling once.
107
+ * @param condition A predicate that indicates when to delay.
108
+ * @param timeInMsec The amount of time to delay.
109
+ */
110
+ function conditionalDelay(condition, timeInMsec) {
111
+ var _this = this;
112
+ return function (canisterId, requestId, status) { return __awaiter(_this, void 0, void 0, function () {
113
+ return __generator(this, function (_a) {
114
+ switch (_a.label) {
115
+ case 0: return [4 /*yield*/, condition(canisterId, requestId, status)];
116
+ case 1:
117
+ if (_a.sent()) {
118
+ return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, timeInMsec); })];
119
+ }
120
+ return [2 /*return*/];
121
+ }
122
+ });
123
+ }); };
124
+ }
125
+ exports.conditionalDelay = conditionalDelay;
126
+ /**
127
+ * Error out after a maximum number of polling has been done.
128
+ * @param count The maximum attempts to poll.
129
+ */
130
+ function maxAttempts(count) {
131
+ var _this = this;
132
+ var attempts = count;
133
+ return function (canisterId, requestId, status) { return __awaiter(_this, void 0, void 0, function () {
134
+ return __generator(this, function (_a) {
135
+ if (--attempts <= 0) {
136
+ throw new Error("Failed to retrieve a reply for request after ".concat(count, " attempts:\n") +
137
+ " Request ID: ".concat((0, buffer_1.toHex)(requestId), "\n") +
138
+ " Request status: ".concat(status, "\n"));
139
+ }
140
+ return [2 /*return*/];
141
+ });
142
+ }); };
143
+ }
144
+ exports.maxAttempts = maxAttempts;
145
+ /**
146
+ * Throttle polling.
147
+ * @param throttleInMsec Amount in millisecond to wait between each polling.
148
+ */
149
+ function throttle(throttleInMsec) {
150
+ return function () { return new Promise(function (resolve) { return setTimeout(resolve, throttleInMsec); }); };
151
+ }
152
+ exports.throttle = throttle;
153
+ /**
154
+ * Reject a call after a certain amount of time.
155
+ * @param timeInMsec Time in milliseconds before the polling should be rejected.
156
+ */
157
+ function timeout(timeInMsec) {
158
+ var _this = this;
159
+ var end = Date.now() + timeInMsec;
160
+ return function (canisterId, requestId, status) { return __awaiter(_this, void 0, void 0, function () {
161
+ return __generator(this, function (_a) {
162
+ if (Date.now() > end) {
163
+ throw new Error("Request timed out after ".concat(timeInMsec, " msec:\n") + " Request ID: ".concat((0, buffer_1.toHex)(requestId), "\n") + " Request status: ".concat(status, "\n"));
164
+ }
165
+ return [2 /*return*/];
166
+ });
167
+ }); };
168
+ }
169
+ exports.timeout = timeout;
170
+ /**
171
+ * A strategy that throttle, but using an exponential backoff strategy.
172
+ * @param startingThrottleInMsec The throttle in milliseconds to start with.
173
+ * @param backoffFactor The factor to multiple the throttle time between every poll. For
174
+ * example if using 2, the throttle will double between every run.
175
+ */
176
+ function backoff(startingThrottleInMsec, backoffFactor) {
177
+ var currentThrottling = startingThrottleInMsec;
178
+ return function () {
179
+ return new Promise(function (resolve) {
180
+ return setTimeout(function () {
181
+ currentThrottling *= backoffFactor;
182
+ resolve();
183
+ }, currentThrottling);
184
+ });
185
+ };
186
+ }
187
+ exports.backoff = backoff;
188
+ /**
189
+ * Chain multiple polling strategy. This _chains_ the strategies, so if you pass in,
190
+ * say, two throttling strategy of 1 second, it will result in a throttle of 2 seconds.
191
+ * @param strategies A strategy list to chain.
192
+ */
193
+ function chain() {
194
+ var _this = this;
195
+ var strategies = [];
196
+ for (var _i = 0; _i < arguments.length; _i++) {
197
+ strategies[_i] = arguments[_i];
198
+ }
199
+ return function (canisterId, requestId, status) { return __awaiter(_this, void 0, void 0, function () {
200
+ var strategies_1, strategies_1_1, a, e_1_1;
201
+ var e_1, _a;
202
+ return __generator(this, function (_b) {
203
+ switch (_b.label) {
204
+ case 0:
205
+ _b.trys.push([0, 5, 6, 7]);
206
+ strategies_1 = __values(strategies), strategies_1_1 = strategies_1.next();
207
+ _b.label = 1;
208
+ case 1:
209
+ if (!!strategies_1_1.done) return [3 /*break*/, 4];
210
+ a = strategies_1_1.value;
211
+ return [4 /*yield*/, a(canisterId, requestId, status)];
212
+ case 2:
213
+ _b.sent();
214
+ _b.label = 3;
215
+ case 3:
216
+ strategies_1_1 = strategies_1.next();
217
+ return [3 /*break*/, 1];
218
+ case 4: return [3 /*break*/, 7];
219
+ case 5:
220
+ e_1_1 = _b.sent();
221
+ e_1 = { error: e_1_1 };
222
+ return [3 /*break*/, 7];
223
+ case 6:
224
+ try {
225
+ if (strategies_1_1 && !strategies_1_1.done && (_a = strategies_1.return)) _a.call(strategies_1);
226
+ }
227
+ finally { if (e_1) throw e_1.error; }
228
+ return [7 /*endfinally*/];
229
+ case 7: return [2 /*return*/];
230
+ }
231
+ });
232
+ }); };
233
+ }
234
+ exports.chain = chain;
235
+ /**
236
+ * Polls the IC to check the status of the given request then
237
+ * returns the response bytes once the request has been processed.
238
+ * @param agent The agent to use to poll read_state.
239
+ * @param canisterId The effective canister ID.
240
+ * @param requestId The Request ID to poll status for.
241
+ * @param strategy A polling strategy.
242
+ * @param request Request for the readState call.
243
+ */
244
+ function pollForResponse(agent, canisterId, requestId, strategy,
245
+ // eslint-disable-next-line
246
+ request) {
247
+ var _a;
248
+ return __awaiter(this, void 0, void 0, function () {
249
+ var path, currentRequest, _b, state, cert, maybeBuf, status, _c, rejectCode, rejectMessage;
250
+ return __generator(this, function (_d) {
251
+ switch (_d.label) {
252
+ case 0:
253
+ path = [new TextEncoder().encode('request_status'), requestId];
254
+ if (!(request !== null && request !== void 0)) return [3 /*break*/, 1];
255
+ _b = request;
256
+ return [3 /*break*/, 3];
257
+ case 1: return [4 /*yield*/, ((_a = agent.createReadStateRequest) === null || _a === void 0 ? void 0 : _a.call(agent, { paths: [path] }))];
258
+ case 2:
259
+ _b = (_d.sent());
260
+ _d.label = 3;
261
+ case 3:
262
+ currentRequest = _b;
263
+ return [4 /*yield*/, agent.readState(canisterId, { paths: [path] }, undefined, currentRequest)];
264
+ case 4:
265
+ state = _d.sent();
266
+ if (agent.rootKey == null)
267
+ throw new Error('Agent root key not initialized before polling');
268
+ return [4 /*yield*/, certificate_1.Certificate.create({
269
+ certificate: state.certificate,
270
+ rootKey: agent.rootKey,
271
+ canisterId: canisterId
272
+ })];
273
+ case 5:
274
+ cert = _d.sent();
275
+ maybeBuf = cert.lookup(__spreadArray(__spreadArray([], __read(path), false), [new TextEncoder().encode('status')], false));
276
+ if (typeof maybeBuf === 'undefined') {
277
+ // Missing requestId means we need to wait
278
+ status = auth_1.RequestStatusResponseStatus.Unknown;
279
+ }
280
+ else {
281
+ status = new TextDecoder().decode(maybeBuf);
282
+ }
283
+ _c = status;
284
+ switch (_c) {
285
+ case auth_1.RequestStatusResponseStatus.Replied: return [3 /*break*/, 6];
286
+ case auth_1.RequestStatusResponseStatus.Received: return [3 /*break*/, 7];
287
+ case auth_1.RequestStatusResponseStatus.Unknown: return [3 /*break*/, 7];
288
+ case auth_1.RequestStatusResponseStatus.Processing: return [3 /*break*/, 7];
289
+ case auth_1.RequestStatusResponseStatus.Rejected: return [3 /*break*/, 9];
290
+ case auth_1.RequestStatusResponseStatus.Done: return [3 /*break*/, 10];
291
+ }
292
+ return [3 /*break*/, 11];
293
+ case 6:
294
+ {
295
+ return [2 /*return*/, cert.lookup(__spreadArray(__spreadArray([], __read(path), false), ['reply'], false))];
296
+ }
297
+ _d.label = 7;
298
+ case 7:
299
+ // Execute the polling strategy, then retry.
300
+ return [4 /*yield*/, strategy(canisterId, requestId, status)];
301
+ case 8:
302
+ // Execute the polling strategy, then retry.
303
+ _d.sent();
304
+ return [2 /*return*/, pollForResponse(agent, canisterId, requestId, strategy, currentRequest)];
305
+ case 9:
306
+ {
307
+ rejectCode = new Uint8Array(cert.lookup(__spreadArray(__spreadArray([], __read(path), false), ['reject_code'], false)))[0];
308
+ rejectMessage = new TextDecoder().decode(cert.lookup(__spreadArray(__spreadArray([], __read(path), false), ['reject_message'], false)));
309
+ throw new Error("Call was rejected:\n" +
310
+ " Request ID: ".concat((0, buffer_1.toHex)(requestId), "\n") +
311
+ " Reject code: ".concat(rejectCode, "\n") +
312
+ " Reject text: ".concat(rejectMessage, "\n"));
313
+ }
314
+ _d.label = 10;
315
+ case 10:
316
+ // This is _technically_ not an error, but we still didn't see the `Replied` status so
317
+ // we don't know the result and cannot decode it.
318
+ throw new Error("Call was marked as done but we never saw the reply:\n" + " Request ID: ".concat((0, buffer_1.toHex)(requestId), "\n"));
319
+ case 11: throw new Error('unreachable');
320
+ }
321
+ });
322
+ });
323
+ }
324
+ exports.pollForResponse = pollForResponse;
325
+ //# sourceMappingURL=polling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polling.js","sourceRoot":"","sources":["../../../src/v1/utils/polling.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA+D;AAC/D,mCAAgC;AAChC,6CAA2C;AAS3C,IAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA;AAE1C;;;GAGG;AACH,SAAgB,eAAe;IAC7B,OAAO,KAAK,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAA;AACjG,CAAC;AAFD,0CAEC;AAED;;GAEG;AACH,SAAgB,IAAI;IAApB,iBASC;IARC,IAAI,KAAK,GAAG,IAAI,CAAA;IAChB,OAAO;;YACL,IAAI,KAAK,EAAE;gBACT,KAAK,GAAG,KAAK,CAAA;gBACb,sBAAO,IAAI,EAAA;aACZ;YACD,sBAAO,KAAK,EAAA;;SACb,CAAA;AACH,CAAC;AATD,oBASC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,SAA6B,EAAE,UAAkB;IAAlF,iBAMC;IALC,OAAO,UAAO,UAAqB,EAAE,SAAoB,EAAE,MAAmC;;;wBACxF,qBAAM,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,M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AAO,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,CAAC,EAAA;;oBAErC;wBACnC,UAAU,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,wCAAK,IAAI,YAAE,aAAa,UAAG,CAAC,CAAC,CAAC,CAAC,CAAA;wBACtE,aAAa,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,wCAAK,IAAI,YAAE,gBAAgB,UAAG,CAAC,CAAA;wBACzF,MAAM,IAAI,KAAK,CACb,sBAAsB;4BACpB,wBAAiB,IAAA,cAAK,EAAC,SAAS,CAAC,OAAI;4BACrC,yBAAkB,UAAU,OAAI;4BAChC,yBAAkB,aAAa,OAAI,CACtC,CAAA;qBACF;;;gBAGC,sFAAsF;gBACtF,iDAAiD;gBACjD,MAAM,IAAI,KAAK,CAAC,uDAAuD,GAAG,wBAAiB,IAAA,cAAK,EAAC,SAAS,CAAC,OAAI,CAAC,CAAA;yBAEpH,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;;;;CAC/B;AAvDD,0CAuDC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @param input The input array to encode.
3
+ * @returns A Base32 string encoding the input.
4
+ */
5
+ export declare function encode(input: Uint8Array): string;
6
+ /**
7
+ * @param input The base32 encoded string to decode.
8
+ */
9
+ export declare function decode(input: string): Uint8Array;
10
+ /**
11
+ * Calculate the CRC32 of an ArrayBufferLike.
12
+ * @param buf The BufferLike to calculate the CRC32 of.
13
+ */
14
+ export declare function getCrc32(buf: ArrayBufferLike): number;
15
+ /**
16
+ * Returns the SHA224 hash of the buffer.
17
+ * @param data Arraybuffer to encode
18
+ */
19
+ export declare function sha224(data: ArrayBuffer): Uint8Array;
20
+ export declare class Principal {
21
+ private _arr;
22
+ static anonymous(): Principal;
23
+ /**
24
+ * Utility method, returning the principal representing the management canister, decoded from the hex string `'aaaaa-aa'`
25
+ * @returns {Principal} principal of the management canister
26
+ */
27
+ static managementCanister(): Principal;
28
+ static selfAuthenticating(publicKey: Uint8Array): Principal;
29
+ static from(other: unknown): Principal;
30
+ static fromHex(hex: string): Principal;
31
+ static fromText(text: string): Principal;
32
+ static fromUint8Array(arr: Uint8Array): Principal;
33
+ readonly _isPrincipal = true;
34
+ protected constructor(_arr: Uint8Array);
35
+ isAnonymous(): boolean;
36
+ toUint8Array(): Uint8Array;
37
+ toHex(): string;
38
+ toText(): string;
39
+ toString(): string;
40
+ /**
41
+ * Utility method taking a Principal to compare against. Used for determining canister ranges in certificate verification
42
+ * @param {Principal} other - a {@link Principal} to compare
43
+ * @returns {'lt' | 'eq' | 'gt'} `'lt' | 'eq' | 'gt'` a string, representing less than, equal to, or greater than
44
+ */
45
+ compareTo(other: Principal): 'lt' | 'eq' | 'gt';
46
+ /**
47
+ * Utility method checking whether a provided Principal is less than or equal to the current one using the {@link Principal.compareTo} method
48
+ * @param other a {@link Principal} to compare
49
+ * @returns {boolean} boolean
50
+ */
51
+ ltEq(other: Principal): boolean;
52
+ /**
53
+ * Utility method checking whether a provided Principal is greater than or equal to the current one using the {@link Principal.compareTo} method
54
+ * @param other a {@link Principal} to compare
55
+ * @returns {boolean} boolean
56
+ */
57
+ gtEq(other: Principal): boolean;
58
+ }