@pioneer-platform/pioneer-sdk 4.20.1 → 4.20.3

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/dist/index.cjs CHANGED
@@ -40,398 +40,6 @@ var __export = (target, all) => {
40
40
  });
41
41
  };
42
42
 
43
- // ../pioneer-client/lib/index.js
44
- var require_lib = __commonJS((exports2) => {
45
- var __assign = exports2 && exports2.__assign || function() {
46
- __assign = Object.assign || function(t) {
47
- for (var s, i = 1, n = arguments.length;i < n; i++) {
48
- s = arguments[i];
49
- for (var p in s)
50
- if (Object.prototype.hasOwnProperty.call(s, p))
51
- t[p] = s[p];
52
- }
53
- return t;
54
- };
55
- return __assign.apply(this, arguments);
56
- };
57
- var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
58
- function adopt(value) {
59
- return value instanceof P ? value : new P(function(resolve) {
60
- resolve(value);
61
- });
62
- }
63
- return new (P || (P = Promise))(function(resolve, reject) {
64
- function fulfilled(value) {
65
- try {
66
- step(generator.next(value));
67
- } catch (e) {
68
- reject(e);
69
- }
70
- }
71
- function rejected(value) {
72
- try {
73
- step(generator["throw"](value));
74
- } catch (e) {
75
- reject(e);
76
- }
77
- }
78
- function step(result) {
79
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
80
- }
81
- step((generator = generator.apply(thisArg, _arguments || [])).next());
82
- });
83
- };
84
- var __generator = exports2 && exports2.__generator || function(thisArg, body) {
85
- var _ = { label: 0, sent: function() {
86
- if (t[0] & 1)
87
- throw t[1];
88
- return t[1];
89
- }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
90
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
91
- return this;
92
- }), g;
93
- function verb(n) {
94
- return function(v) {
95
- return step([n, v]);
96
- };
97
- }
98
- function step(op) {
99
- if (f)
100
- throw new TypeError("Generator is already executing.");
101
- while (g && (g = 0, op[0] && (_ = 0)), _)
102
- try {
103
- 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)
104
- return t;
105
- if (y = 0, t)
106
- op = [op[0] & 2, t.value];
107
- switch (op[0]) {
108
- case 0:
109
- case 1:
110
- t = op;
111
- break;
112
- case 4:
113
- _.label++;
114
- return { value: op[1], done: false };
115
- case 5:
116
- _.label++;
117
- y = op[1];
118
- op = [0];
119
- continue;
120
- case 7:
121
- op = _.ops.pop();
122
- _.trys.pop();
123
- continue;
124
- default:
125
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
126
- _ = 0;
127
- continue;
128
- }
129
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
130
- _.label = op[1];
131
- break;
132
- }
133
- if (op[0] === 6 && _.label < t[1]) {
134
- _.label = t[1];
135
- t = op;
136
- break;
137
- }
138
- if (t && _.label < t[2]) {
139
- _.label = t[2];
140
- _.ops.push(op);
141
- break;
142
- }
143
- if (t[2])
144
- _.ops.pop();
145
- _.trys.pop();
146
- continue;
147
- }
148
- op = body.call(thisArg, _);
149
- } catch (e) {
150
- op = [6, e];
151
- y = 0;
152
- } finally {
153
- f = t = 0;
154
- }
155
- if (op[0] & 5)
156
- throw op[1];
157
- return { value: op[0] ? op[1] : undefined, done: true };
158
- }
159
- };
160
- Object.defineProperty(exports2, "__esModule", { value: true });
161
- exports2.Pioneer = undefined;
162
- var Swagger;
163
- var log;
164
- if (typeof window === "undefined") {
165
- Swagger = require("swagger-client");
166
- log = require("@pioneer-platform/loggerdog")();
167
- } else {
168
- Swagger = null;
169
- log = {
170
- debug: function() {
171
- var args = [];
172
- for (var _i = 0;_i < arguments.length; _i++) {
173
- args[_i] = arguments[_i];
174
- }
175
- return console.debug.apply(console, args);
176
- },
177
- info: function() {
178
- var args = [];
179
- for (var _i = 0;_i < arguments.length; _i++) {
180
- args[_i] = arguments[_i];
181
- }
182
- return console.info.apply(console, args);
183
- },
184
- warn: function() {
185
- var args = [];
186
- for (var _i = 0;_i < arguments.length; _i++) {
187
- args[_i] = arguments[_i];
188
- }
189
- return console.warn.apply(console, args);
190
- },
191
- error: function() {
192
- var args = [];
193
- for (var _i = 0;_i < arguments.length; _i++) {
194
- args[_i] = arguments[_i];
195
- }
196
- return console.error.apply(console, args);
197
- }
198
- };
199
- }
200
- var TAG = " | Client | ";
201
- function customHttpClient(req) {
202
- var _this = this;
203
- return new Promise(function(resolve, reject) {
204
- var timer = setTimeout(function() {
205
- reject(new Error("Request timed out"));
206
- }, 60000);
207
- log.debug(TAG, "HTTP request URL:", req.url);
208
- log.debug(TAG, "HTTP request details:", req);
209
- if (Swagger && Swagger.http) {
210
- Swagger.http(req).then(function(response) {
211
- clearTimeout(timer);
212
- resolve(response);
213
- }).catch(function(err) {
214
- clearTimeout(timer);
215
- reject(err);
216
- });
217
- } else {
218
- var fetchOptions = {
219
- method: req.method || "GET",
220
- headers: req.headers,
221
- body: req.body ? typeof req.body === "string" ? req.body : JSON.stringify(req.body) : undefined
222
- };
223
- fetch(req.url, fetchOptions).then(function(response) {
224
- return __awaiter(_this, undefined, undefined, function() {
225
- var text, body, headers;
226
- return __generator(this, function(_a) {
227
- switch (_a.label) {
228
- case 0:
229
- clearTimeout(timer);
230
- return [4, response.text()];
231
- case 1:
232
- text = _a.sent();
233
- try {
234
- body = JSON.parse(text);
235
- } catch (jsonError) {
236
- body = text;
237
- }
238
- headers = {};
239
- response.headers.forEach(function(value, key) {
240
- headers[key] = value;
241
- });
242
- resolve({
243
- status: response.status,
244
- body,
245
- headers
246
- });
247
- return [2];
248
- }
249
- });
250
- });
251
- }).catch(function(err) {
252
- clearTimeout(timer);
253
- reject(err);
254
- });
255
- }
256
- });
257
- }
258
- var Pioneer = function() {
259
- function Pioneer2(spec, config) {
260
- this.spec = spec;
261
- this.queryKey = config.queryKey;
262
- this.pioneer = {};
263
- this.timeout = config.queryKey || 45000;
264
- }
265
- Pioneer2.prototype.init = function() {
266
- return __awaiter(this, undefined, undefined, function() {
267
- var tag, _a, specResponse, specData_1, e_1;
268
- var _this = this;
269
- return __generator(this, function(_b) {
270
- switch (_b.label) {
271
- case 0:
272
- tag = TAG + " | init | ";
273
- _b.label = 1;
274
- case 1:
275
- _b.trys.push([1, 7, , 8]);
276
- if (!this.queryKey)
277
- throw Error(" You must create an api key! ");
278
- if (!Swagger)
279
- return [3, 3];
280
- _a = this;
281
- return [4, new Swagger({
282
- url: this.spec,
283
- requestInterceptor: function(req) {
284
- req.headers.Authorization = _this.queryKey;
285
- if ((req.method === "POST" || req.method === "post") && req.body) {
286
- log.debug(TAG, "Request interceptor - method:", req.method);
287
- log.debug(TAG, "Body type:", typeof req.body);
288
- log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
289
- if (!req.headers)
290
- req.headers = {};
291
- if (!req.headers["Content-Type"]) {
292
- req.headers["Content-Type"] = "application/json";
293
- }
294
- if (typeof req.body !== "string") {
295
- log.debug(TAG, "Converting body to JSON string");
296
- req.body = JSON.stringify(req.body);
297
- }
298
- }
299
- return req;
300
- },
301
- http: customHttpClient
302
- })];
303
- case 2:
304
- _a.client = _b.sent();
305
- return [3, 6];
306
- case 3:
307
- return [4, fetch(this.spec)];
308
- case 4:
309
- specResponse = _b.sent();
310
- return [4, specResponse.json()];
311
- case 5:
312
- specData_1 = _b.sent();
313
- this.client = {
314
- spec: specData_1,
315
- execute: function(request) {
316
- return __awaiter(_this, undefined, undefined, function() {
317
- var operationId, parameters, requestBody, targetPath, targetMethod, path, method, baseUrl, url, httpReq;
318
- return __generator(this, function(_a2) {
319
- switch (_a2.label) {
320
- case 0:
321
- operationId = request.operationId, parameters = request.parameters, requestBody = request.requestBody;
322
- targetPath = "";
323
- targetMethod = "";
324
- for (path in specData_1.paths) {
325
- for (method in specData_1.paths[path]) {
326
- if (specData_1.paths[path][method].operationId === operationId) {
327
- targetPath = path;
328
- targetMethod = method;
329
- break;
330
- }
331
- }
332
- if (targetPath)
333
- break;
334
- }
335
- if (!targetPath) {
336
- throw new Error("Operation ".concat(operationId, " not found in spec"));
337
- }
338
- baseUrl = this.spec.replace("/spec/swagger.json", "");
339
- if (specData_1.servers && specData_1.servers.length > 0) {
340
- baseUrl = specData_1.servers[0].url;
341
- }
342
- url = "".concat(baseUrl).concat(targetPath);
343
- httpReq = {
344
- method: targetMethod.toUpperCase(),
345
- url,
346
- headers: {
347
- Authorization: this.queryKey,
348
- "Content-Type": "application/json"
349
- },
350
- body: requestBody
351
- };
352
- return [4, customHttpClient(httpReq)];
353
- case 1:
354
- return [2, _a2.sent()];
355
- }
356
- });
357
- });
358
- }
359
- };
360
- _b.label = 6;
361
- case 6:
362
- Object.keys(this.client.spec.paths).forEach(function(path) {
363
- Object.keys(_this.client.spec.paths[path]).forEach(function(method) {
364
- var operationId = _this.client.spec.paths[path][method].operationId;
365
- _this.pioneer[operationId] = function(parameters) {
366
- return __awaiter(_this, undefined, undefined, function() {
367
- var invalidElements, request, result, e_2;
368
- return __generator(this, function(_a2) {
369
- switch (_a2.label) {
370
- case 0:
371
- _a2.trys.push([0, 2, , 3]);
372
- log.debug(TAG, "".concat(operationId, " called with:"), parameters);
373
- if (operationId === "GetMarketInfo") {
374
- if (!Array.isArray(parameters)) {
375
- throw new Error("GetMarketInfo requires an array of CAIP strings, got ".concat(typeof parameters));
376
- }
377
- invalidElements = parameters.map(function(item, index) {
378
- return { item, index, type: typeof item };
379
- }).filter(function(_a3) {
380
- var item = _a3.item;
381
- return !item || typeof item !== "string";
382
- });
383
- if (invalidElements.length > 0) {
384
- console.error("\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:", invalidElements);
385
- throw new Error("GetMarketInfo array contains ".concat(invalidElements.length, " invalid element(s). ") + "All elements must be CAIP strings. First invalid at index ".concat(invalidElements[0].index, ": ") + "".concat(JSON.stringify(invalidElements[0].item), " (type: ").concat(invalidElements[0].type, ")"));
386
- }
387
- log.debug(TAG, "GetMarketInfo validation passed: ".concat(parameters.length, " valid CAIP strings"));
388
- }
389
- request = {
390
- operationId,
391
- parameters: {
392
- Authorization: this.queryKey
393
- },
394
- responseContentType: "application/json"
395
- };
396
- if (method === "post") {
397
- request.requestBody = parameters;
398
- } else {
399
- request.parameters = __assign(__assign({}, parameters), { Authorization: this.queryKey });
400
- }
401
- log.debug(TAG, "".concat(operationId, " request:"), request);
402
- return [4, this.client.execute(request)];
403
- case 1:
404
- result = _a2.sent();
405
- return [2, { data: result.body }];
406
- case 2:
407
- e_2 = _a2.sent();
408
- log.error(TAG, "Operation error:", e_2);
409
- throw e_2;
410
- case 3:
411
- return [2];
412
- }
413
- });
414
- });
415
- };
416
- });
417
- });
418
- return [2, this.pioneer];
419
- case 7:
420
- e_1 = _b.sent();
421
- log.error(TAG, "Initialization error:", e_1);
422
- throw e_1;
423
- case 8:
424
- return [2];
425
- }
426
- });
427
- });
428
- };
429
- return Pioneer2;
430
- }();
431
- exports2.Pioneer = Pioneer;
432
- exports2.default = Pioneer;
433
- });
434
-
435
43
  // ../../../node_modules/coinselect/utils.js
436
44
  var require_utils = __commonJS((exports2, module2) => {
437
45
  var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
@@ -637,7 +245,7 @@ __export(exports_src, {
637
245
  module.exports = __toCommonJS(exports_src);
638
246
  var import_keepkey_sdk = require("@keepkey/keepkey-sdk");
639
247
  var import_pioneer_caip6 = require("@pioneer-platform/pioneer-caip");
640
- var import_pioneer_client = __toESM(require_lib());
248
+ var import_pioneer_client = __toESM(require("@pioneer-platform/pioneer-client"));
641
249
  var import_pioneer_coins4 = require("@pioneer-platform/pioneer-coins");
642
250
  var import_pioneer_discovery2 = require("@pioneer-platform/pioneer-discovery");
643
251
  var import_pioneer_events = require("@pioneer-platform/pioneer-events");
package/dist/index.es.js CHANGED
@@ -23,398 +23,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
23
23
  throw Error('Dynamic require of "' + x + '" is not supported');
24
24
  });
25
25
 
26
- // ../pioneer-client/lib/index.js
27
- var require_lib = __commonJS((exports) => {
28
- var __assign = exports && exports.__assign || function() {
29
- __assign = Object.assign || function(t) {
30
- for (var s, i = 1, n = arguments.length;i < n; i++) {
31
- s = arguments[i];
32
- for (var p in s)
33
- if (Object.prototype.hasOwnProperty.call(s, p))
34
- t[p] = s[p];
35
- }
36
- return t;
37
- };
38
- return __assign.apply(this, arguments);
39
- };
40
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
41
- function adopt(value) {
42
- return value instanceof P ? value : new P(function(resolve) {
43
- resolve(value);
44
- });
45
- }
46
- return new (P || (P = Promise))(function(resolve, reject) {
47
- function fulfilled(value) {
48
- try {
49
- step(generator.next(value));
50
- } catch (e) {
51
- reject(e);
52
- }
53
- }
54
- function rejected(value) {
55
- try {
56
- step(generator["throw"](value));
57
- } catch (e) {
58
- reject(e);
59
- }
60
- }
61
- function step(result) {
62
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
63
- }
64
- step((generator = generator.apply(thisArg, _arguments || [])).next());
65
- });
66
- };
67
- var __generator = exports && exports.__generator || function(thisArg, body) {
68
- var _ = { label: 0, sent: function() {
69
- if (t[0] & 1)
70
- throw t[1];
71
- return t[1];
72
- }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
73
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
74
- return this;
75
- }), g;
76
- function verb(n) {
77
- return function(v) {
78
- return step([n, v]);
79
- };
80
- }
81
- function step(op) {
82
- if (f)
83
- throw new TypeError("Generator is already executing.");
84
- while (g && (g = 0, op[0] && (_ = 0)), _)
85
- try {
86
- 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)
87
- return t;
88
- if (y = 0, t)
89
- op = [op[0] & 2, t.value];
90
- switch (op[0]) {
91
- case 0:
92
- case 1:
93
- t = op;
94
- break;
95
- case 4:
96
- _.label++;
97
- return { value: op[1], done: false };
98
- case 5:
99
- _.label++;
100
- y = op[1];
101
- op = [0];
102
- continue;
103
- case 7:
104
- op = _.ops.pop();
105
- _.trys.pop();
106
- continue;
107
- default:
108
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
109
- _ = 0;
110
- continue;
111
- }
112
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
113
- _.label = op[1];
114
- break;
115
- }
116
- if (op[0] === 6 && _.label < t[1]) {
117
- _.label = t[1];
118
- t = op;
119
- break;
120
- }
121
- if (t && _.label < t[2]) {
122
- _.label = t[2];
123
- _.ops.push(op);
124
- break;
125
- }
126
- if (t[2])
127
- _.ops.pop();
128
- _.trys.pop();
129
- continue;
130
- }
131
- op = body.call(thisArg, _);
132
- } catch (e) {
133
- op = [6, e];
134
- y = 0;
135
- } finally {
136
- f = t = 0;
137
- }
138
- if (op[0] & 5)
139
- throw op[1];
140
- return { value: op[0] ? op[1] : undefined, done: true };
141
- }
142
- };
143
- Object.defineProperty(exports, "__esModule", { value: true });
144
- exports.Pioneer = undefined;
145
- var Swagger;
146
- var log;
147
- if (typeof window === "undefined") {
148
- Swagger = __require("swagger-client");
149
- log = __require("@pioneer-platform/loggerdog")();
150
- } else {
151
- Swagger = null;
152
- log = {
153
- debug: function() {
154
- var args = [];
155
- for (var _i = 0;_i < arguments.length; _i++) {
156
- args[_i] = arguments[_i];
157
- }
158
- return console.debug.apply(console, args);
159
- },
160
- info: function() {
161
- var args = [];
162
- for (var _i = 0;_i < arguments.length; _i++) {
163
- args[_i] = arguments[_i];
164
- }
165
- return console.info.apply(console, args);
166
- },
167
- warn: function() {
168
- var args = [];
169
- for (var _i = 0;_i < arguments.length; _i++) {
170
- args[_i] = arguments[_i];
171
- }
172
- return console.warn.apply(console, args);
173
- },
174
- error: function() {
175
- var args = [];
176
- for (var _i = 0;_i < arguments.length; _i++) {
177
- args[_i] = arguments[_i];
178
- }
179
- return console.error.apply(console, args);
180
- }
181
- };
182
- }
183
- var TAG = " | Client | ";
184
- function customHttpClient(req) {
185
- var _this = this;
186
- return new Promise(function(resolve, reject) {
187
- var timer = setTimeout(function() {
188
- reject(new Error("Request timed out"));
189
- }, 60000);
190
- log.debug(TAG, "HTTP request URL:", req.url);
191
- log.debug(TAG, "HTTP request details:", req);
192
- if (Swagger && Swagger.http) {
193
- Swagger.http(req).then(function(response) {
194
- clearTimeout(timer);
195
- resolve(response);
196
- }).catch(function(err) {
197
- clearTimeout(timer);
198
- reject(err);
199
- });
200
- } else {
201
- var fetchOptions = {
202
- method: req.method || "GET",
203
- headers: req.headers,
204
- body: req.body ? typeof req.body === "string" ? req.body : JSON.stringify(req.body) : undefined
205
- };
206
- fetch(req.url, fetchOptions).then(function(response) {
207
- return __awaiter(_this, undefined, undefined, function() {
208
- var text, body, headers;
209
- return __generator(this, function(_a) {
210
- switch (_a.label) {
211
- case 0:
212
- clearTimeout(timer);
213
- return [4, response.text()];
214
- case 1:
215
- text = _a.sent();
216
- try {
217
- body = JSON.parse(text);
218
- } catch (jsonError) {
219
- body = text;
220
- }
221
- headers = {};
222
- response.headers.forEach(function(value, key) {
223
- headers[key] = value;
224
- });
225
- resolve({
226
- status: response.status,
227
- body,
228
- headers
229
- });
230
- return [2];
231
- }
232
- });
233
- });
234
- }).catch(function(err) {
235
- clearTimeout(timer);
236
- reject(err);
237
- });
238
- }
239
- });
240
- }
241
- var Pioneer = function() {
242
- function Pioneer2(spec, config) {
243
- this.spec = spec;
244
- this.queryKey = config.queryKey;
245
- this.pioneer = {};
246
- this.timeout = config.queryKey || 45000;
247
- }
248
- Pioneer2.prototype.init = function() {
249
- return __awaiter(this, undefined, undefined, function() {
250
- var tag, _a, specResponse, specData_1, e_1;
251
- var _this = this;
252
- return __generator(this, function(_b) {
253
- switch (_b.label) {
254
- case 0:
255
- tag = TAG + " | init | ";
256
- _b.label = 1;
257
- case 1:
258
- _b.trys.push([1, 7, , 8]);
259
- if (!this.queryKey)
260
- throw Error(" You must create an api key! ");
261
- if (!Swagger)
262
- return [3, 3];
263
- _a = this;
264
- return [4, new Swagger({
265
- url: this.spec,
266
- requestInterceptor: function(req) {
267
- req.headers.Authorization = _this.queryKey;
268
- if ((req.method === "POST" || req.method === "post") && req.body) {
269
- log.debug(TAG, "Request interceptor - method:", req.method);
270
- log.debug(TAG, "Body type:", typeof req.body);
271
- log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
272
- if (!req.headers)
273
- req.headers = {};
274
- if (!req.headers["Content-Type"]) {
275
- req.headers["Content-Type"] = "application/json";
276
- }
277
- if (typeof req.body !== "string") {
278
- log.debug(TAG, "Converting body to JSON string");
279
- req.body = JSON.stringify(req.body);
280
- }
281
- }
282
- return req;
283
- },
284
- http: customHttpClient
285
- })];
286
- case 2:
287
- _a.client = _b.sent();
288
- return [3, 6];
289
- case 3:
290
- return [4, fetch(this.spec)];
291
- case 4:
292
- specResponse = _b.sent();
293
- return [4, specResponse.json()];
294
- case 5:
295
- specData_1 = _b.sent();
296
- this.client = {
297
- spec: specData_1,
298
- execute: function(request) {
299
- return __awaiter(_this, undefined, undefined, function() {
300
- var operationId, parameters, requestBody, targetPath, targetMethod, path, method, baseUrl, url, httpReq;
301
- return __generator(this, function(_a2) {
302
- switch (_a2.label) {
303
- case 0:
304
- operationId = request.operationId, parameters = request.parameters, requestBody = request.requestBody;
305
- targetPath = "";
306
- targetMethod = "";
307
- for (path in specData_1.paths) {
308
- for (method in specData_1.paths[path]) {
309
- if (specData_1.paths[path][method].operationId === operationId) {
310
- targetPath = path;
311
- targetMethod = method;
312
- break;
313
- }
314
- }
315
- if (targetPath)
316
- break;
317
- }
318
- if (!targetPath) {
319
- throw new Error("Operation ".concat(operationId, " not found in spec"));
320
- }
321
- baseUrl = this.spec.replace("/spec/swagger.json", "");
322
- if (specData_1.servers && specData_1.servers.length > 0) {
323
- baseUrl = specData_1.servers[0].url;
324
- }
325
- url = "".concat(baseUrl).concat(targetPath);
326
- httpReq = {
327
- method: targetMethod.toUpperCase(),
328
- url,
329
- headers: {
330
- Authorization: this.queryKey,
331
- "Content-Type": "application/json"
332
- },
333
- body: requestBody
334
- };
335
- return [4, customHttpClient(httpReq)];
336
- case 1:
337
- return [2, _a2.sent()];
338
- }
339
- });
340
- });
341
- }
342
- };
343
- _b.label = 6;
344
- case 6:
345
- Object.keys(this.client.spec.paths).forEach(function(path) {
346
- Object.keys(_this.client.spec.paths[path]).forEach(function(method) {
347
- var operationId = _this.client.spec.paths[path][method].operationId;
348
- _this.pioneer[operationId] = function(parameters) {
349
- return __awaiter(_this, undefined, undefined, function() {
350
- var invalidElements, request, result, e_2;
351
- return __generator(this, function(_a2) {
352
- switch (_a2.label) {
353
- case 0:
354
- _a2.trys.push([0, 2, , 3]);
355
- log.debug(TAG, "".concat(operationId, " called with:"), parameters);
356
- if (operationId === "GetMarketInfo") {
357
- if (!Array.isArray(parameters)) {
358
- throw new Error("GetMarketInfo requires an array of CAIP strings, got ".concat(typeof parameters));
359
- }
360
- invalidElements = parameters.map(function(item, index) {
361
- return { item, index, type: typeof item };
362
- }).filter(function(_a3) {
363
- var item = _a3.item;
364
- return !item || typeof item !== "string";
365
- });
366
- if (invalidElements.length > 0) {
367
- console.error("\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:", invalidElements);
368
- throw new Error("GetMarketInfo array contains ".concat(invalidElements.length, " invalid element(s). ") + "All elements must be CAIP strings. First invalid at index ".concat(invalidElements[0].index, ": ") + "".concat(JSON.stringify(invalidElements[0].item), " (type: ").concat(invalidElements[0].type, ")"));
369
- }
370
- log.debug(TAG, "GetMarketInfo validation passed: ".concat(parameters.length, " valid CAIP strings"));
371
- }
372
- request = {
373
- operationId,
374
- parameters: {
375
- Authorization: this.queryKey
376
- },
377
- responseContentType: "application/json"
378
- };
379
- if (method === "post") {
380
- request.requestBody = parameters;
381
- } else {
382
- request.parameters = __assign(__assign({}, parameters), { Authorization: this.queryKey });
383
- }
384
- log.debug(TAG, "".concat(operationId, " request:"), request);
385
- return [4, this.client.execute(request)];
386
- case 1:
387
- result = _a2.sent();
388
- return [2, { data: result.body }];
389
- case 2:
390
- e_2 = _a2.sent();
391
- log.error(TAG, "Operation error:", e_2);
392
- throw e_2;
393
- case 3:
394
- return [2];
395
- }
396
- });
397
- });
398
- };
399
- });
400
- });
401
- return [2, this.pioneer];
402
- case 7:
403
- e_1 = _b.sent();
404
- log.error(TAG, "Initialization error:", e_1);
405
- throw e_1;
406
- case 8:
407
- return [2];
408
- }
409
- });
410
- });
411
- };
412
- return Pioneer2;
413
- }();
414
- exports.Pioneer = Pioneer;
415
- exports.default = Pioneer;
416
- });
417
-
418
26
  // ../../../node_modules/coinselect/utils.js
419
27
  var require_utils = __commonJS((exports, module) => {
420
28
  var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
@@ -612,9 +220,9 @@ var require_split = __commonJS((exports, module) => {
612
220
  });
613
221
 
614
222
  // src/index.ts
615
- var import_pioneer_client = __toESM(require_lib(), 1);
616
223
  import { KeepKeySdk } from "@keepkey/keepkey-sdk";
617
224
  import { caipToNetworkId as caipToNetworkId6, networkIdToCaip } from "@pioneer-platform/pioneer-caip";
225
+ import Pioneer from "@pioneer-platform/pioneer-client";
618
226
  import { addressNListToBIP32 as addressNListToBIP322, getPaths } from "@pioneer-platform/pioneer-coins";
619
227
  import { assetData as assetData2 } from "@pioneer-platform/pioneer-discovery";
620
228
  import { Events } from "@pioneer-platform/pioneer-events";
@@ -4309,7 +3917,7 @@ class SDK {
4309
3917
  const pioneerConfig = {
4310
3918
  ...config
4311
3919
  };
4312
- const PioneerClient = new import_pioneer_client.default(this.spec, pioneerConfig);
3920
+ const PioneerClient = new Pioneer(this.spec, pioneerConfig);
4313
3921
  this.pioneer = await PioneerClient.init();
4314
3922
  if (!this.pioneer)
4315
3923
  throw Error("Failed to init pioneer server!");
package/dist/index.js CHANGED
@@ -23,398 +23,6 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
23
23
  throw Error('Dynamic require of "' + x + '" is not supported');
24
24
  });
25
25
 
26
- // ../pioneer-client/lib/index.js
27
- var require_lib = __commonJS((exports) => {
28
- var __assign = exports && exports.__assign || function() {
29
- __assign = Object.assign || function(t) {
30
- for (var s, i = 1, n = arguments.length;i < n; i++) {
31
- s = arguments[i];
32
- for (var p in s)
33
- if (Object.prototype.hasOwnProperty.call(s, p))
34
- t[p] = s[p];
35
- }
36
- return t;
37
- };
38
- return __assign.apply(this, arguments);
39
- };
40
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
41
- function adopt(value) {
42
- return value instanceof P ? value : new P(function(resolve) {
43
- resolve(value);
44
- });
45
- }
46
- return new (P || (P = Promise))(function(resolve, reject) {
47
- function fulfilled(value) {
48
- try {
49
- step(generator.next(value));
50
- } catch (e) {
51
- reject(e);
52
- }
53
- }
54
- function rejected(value) {
55
- try {
56
- step(generator["throw"](value));
57
- } catch (e) {
58
- reject(e);
59
- }
60
- }
61
- function step(result) {
62
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
63
- }
64
- step((generator = generator.apply(thisArg, _arguments || [])).next());
65
- });
66
- };
67
- var __generator = exports && exports.__generator || function(thisArg, body) {
68
- var _ = { label: 0, sent: function() {
69
- if (t[0] & 1)
70
- throw t[1];
71
- return t[1];
72
- }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
73
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
74
- return this;
75
- }), g;
76
- function verb(n) {
77
- return function(v) {
78
- return step([n, v]);
79
- };
80
- }
81
- function step(op) {
82
- if (f)
83
- throw new TypeError("Generator is already executing.");
84
- while (g && (g = 0, op[0] && (_ = 0)), _)
85
- try {
86
- 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)
87
- return t;
88
- if (y = 0, t)
89
- op = [op[0] & 2, t.value];
90
- switch (op[0]) {
91
- case 0:
92
- case 1:
93
- t = op;
94
- break;
95
- case 4:
96
- _.label++;
97
- return { value: op[1], done: false };
98
- case 5:
99
- _.label++;
100
- y = op[1];
101
- op = [0];
102
- continue;
103
- case 7:
104
- op = _.ops.pop();
105
- _.trys.pop();
106
- continue;
107
- default:
108
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
109
- _ = 0;
110
- continue;
111
- }
112
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
113
- _.label = op[1];
114
- break;
115
- }
116
- if (op[0] === 6 && _.label < t[1]) {
117
- _.label = t[1];
118
- t = op;
119
- break;
120
- }
121
- if (t && _.label < t[2]) {
122
- _.label = t[2];
123
- _.ops.push(op);
124
- break;
125
- }
126
- if (t[2])
127
- _.ops.pop();
128
- _.trys.pop();
129
- continue;
130
- }
131
- op = body.call(thisArg, _);
132
- } catch (e) {
133
- op = [6, e];
134
- y = 0;
135
- } finally {
136
- f = t = 0;
137
- }
138
- if (op[0] & 5)
139
- throw op[1];
140
- return { value: op[0] ? op[1] : undefined, done: true };
141
- }
142
- };
143
- Object.defineProperty(exports, "__esModule", { value: true });
144
- exports.Pioneer = undefined;
145
- var Swagger;
146
- var log;
147
- if (typeof window === "undefined") {
148
- Swagger = __require("swagger-client");
149
- log = __require("@pioneer-platform/loggerdog")();
150
- } else {
151
- Swagger = null;
152
- log = {
153
- debug: function() {
154
- var args = [];
155
- for (var _i = 0;_i < arguments.length; _i++) {
156
- args[_i] = arguments[_i];
157
- }
158
- return console.debug.apply(console, args);
159
- },
160
- info: function() {
161
- var args = [];
162
- for (var _i = 0;_i < arguments.length; _i++) {
163
- args[_i] = arguments[_i];
164
- }
165
- return console.info.apply(console, args);
166
- },
167
- warn: function() {
168
- var args = [];
169
- for (var _i = 0;_i < arguments.length; _i++) {
170
- args[_i] = arguments[_i];
171
- }
172
- return console.warn.apply(console, args);
173
- },
174
- error: function() {
175
- var args = [];
176
- for (var _i = 0;_i < arguments.length; _i++) {
177
- args[_i] = arguments[_i];
178
- }
179
- return console.error.apply(console, args);
180
- }
181
- };
182
- }
183
- var TAG = " | Client | ";
184
- function customHttpClient(req) {
185
- var _this = this;
186
- return new Promise(function(resolve, reject) {
187
- var timer = setTimeout(function() {
188
- reject(new Error("Request timed out"));
189
- }, 60000);
190
- log.debug(TAG, "HTTP request URL:", req.url);
191
- log.debug(TAG, "HTTP request details:", req);
192
- if (Swagger && Swagger.http) {
193
- Swagger.http(req).then(function(response) {
194
- clearTimeout(timer);
195
- resolve(response);
196
- }).catch(function(err) {
197
- clearTimeout(timer);
198
- reject(err);
199
- });
200
- } else {
201
- var fetchOptions = {
202
- method: req.method || "GET",
203
- headers: req.headers,
204
- body: req.body ? typeof req.body === "string" ? req.body : JSON.stringify(req.body) : undefined
205
- };
206
- fetch(req.url, fetchOptions).then(function(response) {
207
- return __awaiter(_this, undefined, undefined, function() {
208
- var text, body, headers;
209
- return __generator(this, function(_a) {
210
- switch (_a.label) {
211
- case 0:
212
- clearTimeout(timer);
213
- return [4, response.text()];
214
- case 1:
215
- text = _a.sent();
216
- try {
217
- body = JSON.parse(text);
218
- } catch (jsonError) {
219
- body = text;
220
- }
221
- headers = {};
222
- response.headers.forEach(function(value, key) {
223
- headers[key] = value;
224
- });
225
- resolve({
226
- status: response.status,
227
- body,
228
- headers
229
- });
230
- return [2];
231
- }
232
- });
233
- });
234
- }).catch(function(err) {
235
- clearTimeout(timer);
236
- reject(err);
237
- });
238
- }
239
- });
240
- }
241
- var Pioneer = function() {
242
- function Pioneer2(spec, config) {
243
- this.spec = spec;
244
- this.queryKey = config.queryKey;
245
- this.pioneer = {};
246
- this.timeout = config.queryKey || 45000;
247
- }
248
- Pioneer2.prototype.init = function() {
249
- return __awaiter(this, undefined, undefined, function() {
250
- var tag, _a, specResponse, specData_1, e_1;
251
- var _this = this;
252
- return __generator(this, function(_b) {
253
- switch (_b.label) {
254
- case 0:
255
- tag = TAG + " | init | ";
256
- _b.label = 1;
257
- case 1:
258
- _b.trys.push([1, 7, , 8]);
259
- if (!this.queryKey)
260
- throw Error(" You must create an api key! ");
261
- if (!Swagger)
262
- return [3, 3];
263
- _a = this;
264
- return [4, new Swagger({
265
- url: this.spec,
266
- requestInterceptor: function(req) {
267
- req.headers.Authorization = _this.queryKey;
268
- if ((req.method === "POST" || req.method === "post") && req.body) {
269
- log.debug(TAG, "Request interceptor - method:", req.method);
270
- log.debug(TAG, "Body type:", typeof req.body);
271
- log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
272
- if (!req.headers)
273
- req.headers = {};
274
- if (!req.headers["Content-Type"]) {
275
- req.headers["Content-Type"] = "application/json";
276
- }
277
- if (typeof req.body !== "string") {
278
- log.debug(TAG, "Converting body to JSON string");
279
- req.body = JSON.stringify(req.body);
280
- }
281
- }
282
- return req;
283
- },
284
- http: customHttpClient
285
- })];
286
- case 2:
287
- _a.client = _b.sent();
288
- return [3, 6];
289
- case 3:
290
- return [4, fetch(this.spec)];
291
- case 4:
292
- specResponse = _b.sent();
293
- return [4, specResponse.json()];
294
- case 5:
295
- specData_1 = _b.sent();
296
- this.client = {
297
- spec: specData_1,
298
- execute: function(request) {
299
- return __awaiter(_this, undefined, undefined, function() {
300
- var operationId, parameters, requestBody, targetPath, targetMethod, path, method, baseUrl, url, httpReq;
301
- return __generator(this, function(_a2) {
302
- switch (_a2.label) {
303
- case 0:
304
- operationId = request.operationId, parameters = request.parameters, requestBody = request.requestBody;
305
- targetPath = "";
306
- targetMethod = "";
307
- for (path in specData_1.paths) {
308
- for (method in specData_1.paths[path]) {
309
- if (specData_1.paths[path][method].operationId === operationId) {
310
- targetPath = path;
311
- targetMethod = method;
312
- break;
313
- }
314
- }
315
- if (targetPath)
316
- break;
317
- }
318
- if (!targetPath) {
319
- throw new Error("Operation ".concat(operationId, " not found in spec"));
320
- }
321
- baseUrl = this.spec.replace("/spec/swagger.json", "");
322
- if (specData_1.servers && specData_1.servers.length > 0) {
323
- baseUrl = specData_1.servers[0].url;
324
- }
325
- url = "".concat(baseUrl).concat(targetPath);
326
- httpReq = {
327
- method: targetMethod.toUpperCase(),
328
- url,
329
- headers: {
330
- Authorization: this.queryKey,
331
- "Content-Type": "application/json"
332
- },
333
- body: requestBody
334
- };
335
- return [4, customHttpClient(httpReq)];
336
- case 1:
337
- return [2, _a2.sent()];
338
- }
339
- });
340
- });
341
- }
342
- };
343
- _b.label = 6;
344
- case 6:
345
- Object.keys(this.client.spec.paths).forEach(function(path) {
346
- Object.keys(_this.client.spec.paths[path]).forEach(function(method) {
347
- var operationId = _this.client.spec.paths[path][method].operationId;
348
- _this.pioneer[operationId] = function(parameters) {
349
- return __awaiter(_this, undefined, undefined, function() {
350
- var invalidElements, request, result, e_2;
351
- return __generator(this, function(_a2) {
352
- switch (_a2.label) {
353
- case 0:
354
- _a2.trys.push([0, 2, , 3]);
355
- log.debug(TAG, "".concat(operationId, " called with:"), parameters);
356
- if (operationId === "GetMarketInfo") {
357
- if (!Array.isArray(parameters)) {
358
- throw new Error("GetMarketInfo requires an array of CAIP strings, got ".concat(typeof parameters));
359
- }
360
- invalidElements = parameters.map(function(item, index) {
361
- return { item, index, type: typeof item };
362
- }).filter(function(_a3) {
363
- var item = _a3.item;
364
- return !item || typeof item !== "string";
365
- });
366
- if (invalidElements.length > 0) {
367
- console.error("\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:", invalidElements);
368
- throw new Error("GetMarketInfo array contains ".concat(invalidElements.length, " invalid element(s). ") + "All elements must be CAIP strings. First invalid at index ".concat(invalidElements[0].index, ": ") + "".concat(JSON.stringify(invalidElements[0].item), " (type: ").concat(invalidElements[0].type, ")"));
369
- }
370
- log.debug(TAG, "GetMarketInfo validation passed: ".concat(parameters.length, " valid CAIP strings"));
371
- }
372
- request = {
373
- operationId,
374
- parameters: {
375
- Authorization: this.queryKey
376
- },
377
- responseContentType: "application/json"
378
- };
379
- if (method === "post") {
380
- request.requestBody = parameters;
381
- } else {
382
- request.parameters = __assign(__assign({}, parameters), { Authorization: this.queryKey });
383
- }
384
- log.debug(TAG, "".concat(operationId, " request:"), request);
385
- return [4, this.client.execute(request)];
386
- case 1:
387
- result = _a2.sent();
388
- return [2, { data: result.body }];
389
- case 2:
390
- e_2 = _a2.sent();
391
- log.error(TAG, "Operation error:", e_2);
392
- throw e_2;
393
- case 3:
394
- return [2];
395
- }
396
- });
397
- });
398
- };
399
- });
400
- });
401
- return [2, this.pioneer];
402
- case 7:
403
- e_1 = _b.sent();
404
- log.error(TAG, "Initialization error:", e_1);
405
- throw e_1;
406
- case 8:
407
- return [2];
408
- }
409
- });
410
- });
411
- };
412
- return Pioneer2;
413
- }();
414
- exports.Pioneer = Pioneer;
415
- exports.default = Pioneer;
416
- });
417
-
418
26
  // ../../../node_modules/coinselect/utils.js
419
27
  var require_utils = __commonJS((exports, module) => {
420
28
  var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
@@ -612,9 +220,9 @@ var require_split = __commonJS((exports, module) => {
612
220
  });
613
221
 
614
222
  // src/index.ts
615
- var import_pioneer_client = __toESM(require_lib(), 1);
616
223
  import { KeepKeySdk } from "@keepkey/keepkey-sdk";
617
224
  import { caipToNetworkId as caipToNetworkId6, networkIdToCaip } from "@pioneer-platform/pioneer-caip";
225
+ import Pioneer from "@pioneer-platform/pioneer-client";
618
226
  import { addressNListToBIP32 as addressNListToBIP322, getPaths } from "@pioneer-platform/pioneer-coins";
619
227
  import { assetData as assetData2 } from "@pioneer-platform/pioneer-discovery";
620
228
  import { Events } from "@pioneer-platform/pioneer-events";
@@ -4309,7 +3917,7 @@ class SDK {
4309
3917
  const pioneerConfig = {
4310
3918
  ...config
4311
3919
  };
4312
- const PioneerClient = new import_pioneer_client.default(this.spec, pioneerConfig);
3920
+ const PioneerClient = new Pioneer(this.spec, pioneerConfig);
4313
3921
  this.pioneer = await PioneerClient.init();
4314
3922
  if (!this.pioneer)
4315
3923
  throw Error("Failed to init pioneer server!");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "highlander",
3
3
  "name": "@pioneer-platform/pioneer-sdk",
4
- "version": "4.20.1",
4
+ "version": "4.20.3",
5
5
  "dependencies": {
6
6
  "@keepkey/keepkey-sdk": "^0.2.62",
7
7
  "@pioneer-platform/loggerdog": "^8.11.0",