@pioneer-platform/pioneer-sdk 4.21.2 → 4.21.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -23,408 +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.timeout || 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, finalPath, _i, _a2, _b2, key, value, placeholder, url, httpReq;
301
- return __generator(this, function(_c) {
302
- switch (_c.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
- finalPath = targetPath;
326
- if (parameters) {
327
- for (_i = 0, _a2 = Object.entries(parameters);_i < _a2.length; _i++) {
328
- _b2 = _a2[_i], key = _b2[0], value = _b2[1];
329
- placeholder = "{".concat(key, "}");
330
- if (finalPath.includes(placeholder)) {
331
- finalPath = finalPath.replace(placeholder, encodeURIComponent(String(value)));
332
- }
333
- }
334
- }
335
- url = "".concat(baseUrl).concat(finalPath);
336
- httpReq = {
337
- method: targetMethod.toUpperCase(),
338
- url,
339
- headers: {
340
- Authorization: this.queryKey,
341
- "Content-Type": "application/json"
342
- },
343
- body: requestBody
344
- };
345
- return [4, customHttpClient(httpReq)];
346
- case 1:
347
- return [2, _c.sent()];
348
- }
349
- });
350
- });
351
- }
352
- };
353
- _b.label = 6;
354
- case 6:
355
- Object.keys(this.client.spec.paths).forEach(function(path) {
356
- Object.keys(_this.client.spec.paths[path]).forEach(function(method) {
357
- var operationId = _this.client.spec.paths[path][method].operationId;
358
- _this.pioneer[operationId] = function(parameters) {
359
- return __awaiter(_this, undefined, undefined, function() {
360
- var invalidElements, request, result, e_2;
361
- return __generator(this, function(_a2) {
362
- switch (_a2.label) {
363
- case 0:
364
- _a2.trys.push([0, 2, , 3]);
365
- log.debug(TAG, "".concat(operationId, " called with:"), parameters);
366
- if (operationId === "GetMarketInfo") {
367
- if (!Array.isArray(parameters)) {
368
- throw new Error("GetMarketInfo requires an array of CAIP strings, got ".concat(typeof parameters));
369
- }
370
- invalidElements = parameters.map(function(item, index) {
371
- return { item, index, type: typeof item };
372
- }).filter(function(_a3) {
373
- var item = _a3.item;
374
- return !item || typeof item !== "string";
375
- });
376
- if (invalidElements.length > 0) {
377
- console.error("\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:", invalidElements);
378
- 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, ")"));
379
- }
380
- log.debug(TAG, "GetMarketInfo validation passed: ".concat(parameters.length, " valid CAIP strings"));
381
- }
382
- request = {
383
- operationId,
384
- parameters: {
385
- Authorization: this.queryKey
386
- },
387
- responseContentType: "application/json"
388
- };
389
- if (method === "post") {
390
- request.requestBody = parameters;
391
- } else {
392
- request.parameters = __assign(__assign({}, parameters), { Authorization: this.queryKey });
393
- }
394
- log.debug(TAG, "".concat(operationId, " request:"), request);
395
- return [4, this.client.execute(request)];
396
- case 1:
397
- result = _a2.sent();
398
- return [2, { data: result.body }];
399
- case 2:
400
- e_2 = _a2.sent();
401
- log.error(TAG, "Operation error:", e_2);
402
- throw e_2;
403
- case 3:
404
- return [2];
405
- }
406
- });
407
- });
408
- };
409
- });
410
- });
411
- return [2, this.pioneer];
412
- case 7:
413
- e_1 = _b.sent();
414
- log.error(TAG, "Initialization error:", e_1);
415
- throw e_1;
416
- case 8:
417
- return [2];
418
- }
419
- });
420
- });
421
- };
422
- return Pioneer2;
423
- }();
424
- exports.Pioneer = Pioneer;
425
- exports.default = Pioneer;
426
- });
427
-
428
26
  // ../../../node_modules/coinselect/utils.js
429
27
  var require_utils = __commonJS((exports, module) => {
430
28
  var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
@@ -622,9 +220,152 @@ var require_split = __commonJS((exports, module) => {
622
220
  });
623
221
 
624
222
  // src/index.ts
625
- var import_pioneer_client = __toESM(require_lib(), 1);
626
223
  import { KeepKeySdk } from "@keepkey/keepkey-sdk";
627
224
  import { caipToNetworkId as caipToNetworkId7, networkIdToCaip as networkIdToCaip2 } from "@pioneer-platform/pioneer-caip";
225
+
226
+ // ../pioneer-client/lib/index.js
227
+ import SwaggerClient from "swagger-client";
228
+ import loggerdog from "@pioneer-platform/loggerdog";
229
+ var log = typeof window === "undefined" ? loggerdog() : {
230
+ debug: (...args) => console.debug(...args),
231
+ info: (...args) => console.info(...args),
232
+ warn: (...args) => console.warn(...args),
233
+ error: (...args) => console.error(...args)
234
+ };
235
+ var Swagger = SwaggerClient;
236
+ var TAG = " | Client | ";
237
+ function customHttpClient(req) {
238
+ return new Promise((resolve, reject) => {
239
+ const timer = setTimeout(() => {
240
+ reject(new Error("Request timed out"));
241
+ }, 60000);
242
+ log.debug(TAG, "HTTP request URL:", req.url);
243
+ log.debug(TAG, "HTTP request details:", req);
244
+ if (Swagger.http) {
245
+ Swagger.http(req).then((response) => {
246
+ clearTimeout(timer);
247
+ resolve(response);
248
+ }).catch((err) => {
249
+ clearTimeout(timer);
250
+ reject(err);
251
+ });
252
+ } else {
253
+ const fetchOptions = {
254
+ method: req.method || "GET",
255
+ headers: req.headers,
256
+ body: req.body ? typeof req.body === "string" ? req.body : JSON.stringify(req.body) : undefined
257
+ };
258
+ fetch(req.url, fetchOptions).then(async (response) => {
259
+ clearTimeout(timer);
260
+ const text = await response.text();
261
+ let body;
262
+ try {
263
+ body = JSON.parse(text);
264
+ } catch (jsonError) {
265
+ body = text;
266
+ }
267
+ const headers = {};
268
+ response.headers.forEach((value, key) => {
269
+ headers[key] = value;
270
+ });
271
+ resolve({
272
+ status: response.status,
273
+ body,
274
+ headers
275
+ });
276
+ }).catch((err) => {
277
+ clearTimeout(timer);
278
+ reject(err);
279
+ });
280
+ }
281
+ });
282
+ }
283
+
284
+ class Pioneer {
285
+ constructor(spec, config) {
286
+ this.spec = spec;
287
+ this.queryKey = config.queryKey;
288
+ this.pioneer = {};
289
+ this.timeout = config.timeout || 45000;
290
+ }
291
+ async init() {
292
+ let tag = TAG + " | init | ";
293
+ try {
294
+ if (!this.queryKey)
295
+ throw Error(" You must create an api key! ");
296
+ this.client = await new Swagger({
297
+ url: this.spec,
298
+ requestInterceptor: (req) => {
299
+ req.headers.Authorization = this.queryKey;
300
+ if ((req.method === "POST" || req.method === "post") && req.body) {
301
+ log.debug(TAG, "Request interceptor - method:", req.method);
302
+ log.debug(TAG, "Body type:", typeof req.body);
303
+ log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
304
+ if (!req.headers)
305
+ req.headers = {};
306
+ if (!req.headers["Content-Type"]) {
307
+ req.headers["Content-Type"] = "application/json";
308
+ }
309
+ if (typeof req.body !== "string") {
310
+ log.debug(TAG, "Converting body to JSON string");
311
+ req.body = JSON.stringify(req.body);
312
+ }
313
+ }
314
+ return req;
315
+ },
316
+ http: customHttpClient
317
+ });
318
+ Object.keys(this.client.spec.paths).forEach((path) => {
319
+ Object.keys(this.client.spec.paths[path]).forEach((method) => {
320
+ const operationId = this.client.spec.paths[path][method].operationId;
321
+ this.pioneer[operationId] = async (parameters) => {
322
+ try {
323
+ log.debug(TAG, `${operationId} called with:`, parameters);
324
+ if (operationId === "GetMarketInfo") {
325
+ if (!Array.isArray(parameters)) {
326
+ throw new Error(`GetMarketInfo requires an array of CAIP strings, got ${typeof parameters}`);
327
+ }
328
+ const invalidElements = parameters.map((item, index) => ({ item, index, type: typeof item })).filter(({ item }) => !item || typeof item !== "string");
329
+ if (invalidElements.length > 0) {
330
+ console.error(`\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:`, invalidElements);
331
+ throw new Error(`GetMarketInfo array contains ${invalidElements.length} invalid element(s). ` + `All elements must be CAIP strings. First invalid at index ${invalidElements[0].index}: ` + `${JSON.stringify(invalidElements[0].item)} (type: ${invalidElements[0].type})`);
332
+ }
333
+ log.debug(TAG, `GetMarketInfo validation passed: ${parameters.length} valid CAIP strings`);
334
+ }
335
+ let request = {
336
+ operationId,
337
+ parameters: {
338
+ Authorization: this.queryKey
339
+ },
340
+ responseContentType: "application/json"
341
+ };
342
+ if (method === "post") {
343
+ request.requestBody = parameters;
344
+ } else {
345
+ request.parameters = {
346
+ ...parameters,
347
+ Authorization: this.queryKey
348
+ };
349
+ }
350
+ log.debug(TAG, `${operationId} request:`, request);
351
+ const result = await this.client.execute(request);
352
+ return { data: result.body };
353
+ } catch (e) {
354
+ log.error(TAG, "Operation error:", e);
355
+ throw e;
356
+ }
357
+ };
358
+ });
359
+ });
360
+ return this.pioneer;
361
+ } catch (e) {
362
+ log.error(TAG, "Initialization error:", e);
363
+ throw e;
364
+ }
365
+ }
366
+ }
367
+
368
+ // src/index.ts
628
369
  import { addressNListToBIP32 as addressNListToBIP322, getPaths } from "@pioneer-platform/pioneer-coins";
629
370
  import { assetData as assetData2 } from "@pioneer-platform/pioneer-discovery";
630
371
  import { Events } from "@pioneer-platform/pioneer-events";
@@ -1984,7 +1725,7 @@ var SUPPORTED_CAIPS = {
1984
1725
  // src/txbuilder/createUnsignedEvmTx.ts
1985
1726
  import { caipToNetworkId } from "@pioneer-platform/pioneer-caip";
1986
1727
  import { bip32ToAddressNList } from "@pioneer-platform/pioneer-coins";
1987
- var TAG = " | createUnsignedEvmTx | ";
1728
+ var TAG2 = " | createUnsignedEvmTx | ";
1988
1729
  var toHex = (value) => {
1989
1730
  let hex = value.toString(16);
1990
1731
  if (hex.length % 2)
@@ -2063,7 +1804,7 @@ async function fetchTokenPriceInUsd(pioneer, caip) {
2063
1804
  }
2064
1805
  }
2065
1806
  async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax, feeLevel = 5) {
2066
- const tag6 = TAG + " | createUnsignedEvmTx | ";
1807
+ const tag6 = TAG2 + " | createUnsignedEvmTx | ";
2067
1808
  try {
2068
1809
  if (!pioneer)
2069
1810
  throw new Error("Failed to initialize Pioneer");
@@ -2384,9 +2125,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
2384
2125
 
2385
2126
  // src/txbuilder/createUnsignedRippleTx.ts
2386
2127
  import { caipToNetworkId as caipToNetworkId2 } from "@pioneer-platform/pioneer-caip";
2387
- var TAG2 = " | createUnsignedUxtoTx | ";
2128
+ var TAG3 = " | createUnsignedUxtoTx | ";
2388
2129
  async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax) {
2389
- let tag6 = TAG2 + " | createUnsignedRippleTx | ";
2130
+ let tag6 = TAG3 + " | createUnsignedRippleTx | ";
2390
2131
  try {
2391
2132
  if (!pioneer)
2392
2133
  throw new Error("Failed to init! pioneer");
@@ -2603,9 +2344,9 @@ var thorchainDepositTemplate = (params) => ({
2603
2344
  });
2604
2345
 
2605
2346
  // src/txbuilder/createUnsignedTendermintTx.ts
2606
- var TAG3 = " | createUnsignedTendermintTx | ";
2347
+ var TAG4 = " | createUnsignedTendermintTx | ";
2607
2348
  async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pioneer, pubkeyContext, isMax, to) {
2608
- const tag6 = TAG3 + " | createUnsignedTendermintTx | ";
2349
+ const tag6 = TAG4 + " | createUnsignedTendermintTx | ";
2609
2350
  try {
2610
2351
  if (!pioneer)
2611
2352
  throw new Error("Failed to init! pioneer");
@@ -3163,7 +2904,7 @@ function transformInput(input) {
3163
2904
  }
3164
2905
 
3165
2906
  // src/TransactionManager.ts
3166
- var TAG4 = " | Transaction | ";
2907
+ var TAG5 = " | Transaction | ";
3167
2908
 
3168
2909
  class TransactionManager {
3169
2910
  context;
@@ -3198,7 +2939,7 @@ class TransactionManager {
3198
2939
  throw new Error(`Unsupported CAIP: ${caip}`);
3199
2940
  }
3200
2941
  async transfer({ caip, to, amount, memo, isMax = false, feeLevel = 5, changeScriptType }) {
3201
- let tag6 = TAG4 + " | transfer | ";
2942
+ let tag6 = TAG5 + " | transfer | ";
3202
2943
  try {
3203
2944
  if (!this.pioneer)
3204
2945
  throw Error("Failed to init! pioneer");
@@ -3241,7 +2982,7 @@ class TransactionManager {
3241
2982
  }
3242
2983
  }
3243
2984
  async sign({ caip, unsignedTx }) {
3244
- let tag6 = TAG4 + " | sign | ";
2985
+ let tag6 = TAG5 + " | sign | ";
3245
2986
  try {
3246
2987
  if (!this.pioneer)
3247
2988
  throw Error("Failed to init! pioneer");
@@ -3399,7 +3140,7 @@ class TransactionManager {
3399
3140
  }
3400
3141
  }
3401
3142
  async broadcast({ networkId, serialized }) {
3402
- let tag6 = TAG4 + " | broadcast | ";
3143
+ let tag6 = TAG5 + " | broadcast | ";
3403
3144
  try {
3404
3145
  if (!this.pioneer)
3405
3146
  throw Error("Failed to init! pioneer");
@@ -3531,9 +3272,9 @@ var cosmosClaimAllRewardsTemplate = (params) => ({
3531
3272
  });
3532
3273
 
3533
3274
  // src/txbuilder/createUnsignedStakingTx.ts
3534
- var TAG5 = " | createUnsignedStakingTx | ";
3275
+ var TAG6 = " | createUnsignedStakingTx | ";
3535
3276
  async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, pubkeyContext) {
3536
- const tag6 = TAG5 + " | createUnsignedStakingTx | ";
3277
+ const tag6 = TAG6 + " | createUnsignedStakingTx | ";
3537
3278
  try {
3538
3279
  if (!pioneer)
3539
3280
  throw new Error("Failed to init! pioneer");
@@ -3667,7 +3408,7 @@ async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, pubkeyCon
3667
3408
  }
3668
3409
 
3669
3410
  // src/fees/index.ts
3670
- var TAG6 = " | Pioneer-sdk | fees | ";
3411
+ var TAG7 = " | Pioneer-sdk | fees | ";
3671
3412
  function getNetworkType(networkId) {
3672
3413
  if (networkId.startsWith("bip122:"))
3673
3414
  return "UTXO";
@@ -3707,7 +3448,7 @@ function withTimeout(promise, timeoutMs) {
3707
3448
  ]);
3708
3449
  }
3709
3450
  async function getFees(pioneer, networkId) {
3710
- const tag6 = TAG6 + " | getFees | ";
3451
+ const tag6 = TAG7 + " | getFees | ";
3711
3452
  try {
3712
3453
  console.log(tag6, `Fetching fees for network: ${networkId}`);
3713
3454
  const networkType = getNetworkType(networkId);
@@ -4174,9 +3915,9 @@ function formatTime(durationMs) {
4174
3915
 
4175
3916
  // src/utils/build-dashboard.ts
4176
3917
  import { caipToNetworkId as caipToNetworkId6, networkIdToCaip } from "@pioneer-platform/pioneer-caip";
4177
- var TAG7 = " | build-dashboard | ";
3918
+ var TAG8 = " | build-dashboard | ";
4178
3919
  function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4179
- console.log(TAG7, "[DASHBOARD] Building dashboard from cached balances...");
3920
+ console.log(TAG8, "[DASHBOARD] Building dashboard from cached balances...");
4180
3921
  const dashboardData = {
4181
3922
  networks: [],
4182
3923
  totalValueUsd: 0,
@@ -4184,7 +3925,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4184
3925
  };
4185
3926
  let totalPortfolioValue = 0;
4186
3927
  const networksTemp = [];
4187
- console.log(TAG7, "balances: ", balances);
3928
+ console.log(TAG8, "balances: ", balances);
4188
3929
  for (const blockchain of blockchains) {
4189
3930
  const filteredBalances = balances.filter((b3) => {
4190
3931
  const networkId = caipToNetworkId6(b3.caip);
@@ -4193,7 +3934,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4193
3934
  const balanceMap = new Map;
4194
3935
  const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
4195
3936
  if (isBitcoin) {
4196
- console.log(TAG7, "Bitcoin network detected - checking for duplicate balances");
3937
+ console.log(TAG8, "Bitcoin network detected - checking for duplicate balances");
4197
3938
  const bitcoinByValue = new Map;
4198
3939
  filteredBalances.forEach((balance) => {
4199
3940
  const valueKey = `${balance.balance}_${balance.valueUsd}`;
@@ -4204,7 +3945,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4204
3945
  });
4205
3946
  for (const [valueKey, balances2] of bitcoinByValue.entries()) {
4206
3947
  if (balances2.length === 3 && parseFloat(balances2[0].valueUsd || "0") > 0) {
4207
- console.log(TAG7, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
3948
+ console.log(TAG8, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
4208
3949
  const xpubBalance = balances2.find((b3) => b3.pubkey?.startsWith("xpub")) || balances2[0];
4209
3950
  const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
4210
3951
  balanceMap.set(key, xpubBalance);
@@ -4227,7 +3968,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4227
3968
  const networkTotal = networkBalances.reduce((sum, balance, idx) => {
4228
3969
  const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
4229
3970
  if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
4230
- console.log(TAG7, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
3971
+ console.log(TAG8, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
4231
3972
  }
4232
3973
  return sum + valueUsd;
4233
3974
  }, 0);
@@ -4238,11 +3979,11 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4238
3979
  return sum + balanceNum;
4239
3980
  }, 0).toString();
4240
3981
  const assetInfo = nativeAssetCaip ? assetsMap.get(nativeAssetCaip) : null;
4241
- console.log(TAG7, `[DEBUG] Network: ${blockchain}`);
4242
- console.log(TAG7, `[DEBUG] nativeAssetCaip: ${nativeAssetCaip}`);
4243
- console.log(TAG7, `[DEBUG] assetInfo:`, assetInfo);
4244
- console.log(TAG7, `[DEBUG] gasAsset:`, gasAsset);
4245
- console.log(TAG7, `[DEBUG] Resolved name: ${gasAsset?.name || assetInfo?.name || "NO NAME"}`);
3982
+ console.log(TAG8, `[DEBUG] Network: ${blockchain}`);
3983
+ console.log(TAG8, `[DEBUG] nativeAssetCaip: ${nativeAssetCaip}`);
3984
+ console.log(TAG8, `[DEBUG] assetInfo:`, assetInfo);
3985
+ console.log(TAG8, `[DEBUG] gasAsset:`, gasAsset);
3986
+ console.log(TAG8, `[DEBUG] Resolved name: ${gasAsset?.name || assetInfo?.name || "NO NAME"}`);
4246
3987
  networksTemp.push({
4247
3988
  networkId: blockchain,
4248
3989
  totalValueUsd: networkTotal,
@@ -4266,9 +4007,9 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4266
4007
  }
4267
4008
 
4268
4009
  // src/utils/sync-market.ts
4269
- var TAG8 = " | sync-market | ";
4010
+ var TAG9 = " | sync-market | ";
4270
4011
  async function syncMarket(balances, pioneer) {
4271
- const tag6 = `${TAG8} | syncMarket | `;
4012
+ const tag6 = `${TAG9} | syncMarket | `;
4272
4013
  try {
4273
4014
  const invalidBalances = balances.filter((b3) => !b3 || !b3.caip || typeof b3.caip !== "string" || !b3.caip.includes(":"));
4274
4015
  if (invalidBalances.length > 0) {
@@ -4320,7 +4061,7 @@ async function syncMarket(balances, pioneer) {
4320
4061
  }
4321
4062
 
4322
4063
  // src/index.ts
4323
- var TAG9 = " | Pioneer-sdk | ";
4064
+ var TAG10 = " | Pioneer-sdk | ";
4324
4065
 
4325
4066
  class SDK {
4326
4067
  status;
@@ -4421,12 +4162,6 @@ class SDK {
4421
4162
  this.blockchains = config.blockchains ? [...new Set(config.blockchains)] : [];
4422
4163
  if (config.blockchains && config.blockchains.length !== this.blockchains.length) {
4423
4164
  }
4424
- if (config.pubkeys && config.pubkeys.length > 0) {
4425
- this.setPubkeys(config.pubkeys);
4426
- } else {
4427
- this.pubkeys = [];
4428
- this.pubkeySet.clear();
4429
- }
4430
4165
  this.balances = config.balances || [];
4431
4166
  this.nodes = config.nodes || [];
4432
4167
  this.charts = ["covalent", "zapper"];
@@ -4484,7 +4219,7 @@ class SDK {
4484
4219
  return true;
4485
4220
  };
4486
4221
  this.setPubkeys = (newPubkeys) => {
4487
- const tag6 = `${TAG9} | setPubkeys | `;
4222
+ const tag6 = `${TAG10} | setPubkeys | `;
4488
4223
  this.pubkeys = [];
4489
4224
  this.pubkeySet.clear();
4490
4225
  let added = 0;
@@ -4494,8 +4229,14 @@ class SDK {
4494
4229
  }
4495
4230
  }
4496
4231
  };
4232
+ if (config.pubkeys && config.pubkeys.length > 0) {
4233
+ this.setPubkeys(config.pubkeys);
4234
+ } else {
4235
+ this.pubkeys = [];
4236
+ this.pubkeySet.clear();
4237
+ }
4497
4238
  this.getUnifiedPortfolio = async function() {
4498
- const tag6 = `${TAG9} | getUnifiedPortfolio | `;
4239
+ const tag6 = `${TAG10} | getUnifiedPortfolio | `;
4499
4240
  try {
4500
4241
  const startTime = performance.now();
4501
4242
  try {
@@ -4603,7 +4344,7 @@ class SDK {
4603
4344
  }
4604
4345
  };
4605
4346
  this.init = async function(walletsVerbose, setup) {
4606
- const tag6 = `${TAG9} | init | `;
4347
+ const tag6 = `${TAG10} | init | `;
4607
4348
  try {
4608
4349
  if (!this.username)
4609
4350
  throw Error("username required!");
@@ -4620,7 +4361,7 @@ class SDK {
4620
4361
  const pioneerConfig = {
4621
4362
  ...config
4622
4363
  };
4623
- const PioneerClient = new import_pioneer_client.Pioneer(this.spec, pioneerConfig);
4364
+ const PioneerClient = new Pioneer(this.spec, pioneerConfig);
4624
4365
  this.pioneer = await PioneerClient.init();
4625
4366
  if (!this.pioneer)
4626
4367
  throw Error("Failed to init pioneer server!");
@@ -4697,7 +4438,7 @@ class SDK {
4697
4438
  return syncMarket(this.balances, this.pioneer);
4698
4439
  };
4699
4440
  this.sync = async function() {
4700
- const tag6 = `${TAG9} | sync | `;
4441
+ const tag6 = `${TAG10} | sync | `;
4701
4442
  try {
4702
4443
  const matchesNetwork = (item, networkId) => {
4703
4444
  if (!item.networks || !Array.isArray(item.networks))
@@ -4850,7 +4591,7 @@ class SDK {
4850
4591
  }
4851
4592
  };
4852
4593
  this.buildTx = async function(sendPayload) {
4853
- let tag6 = TAG9 + " | buildTx | ";
4594
+ let tag6 = TAG10 + " | buildTx | ";
4854
4595
  try {
4855
4596
  const transactionDependencies = {
4856
4597
  context: this.context,
@@ -4872,7 +4613,7 @@ class SDK {
4872
4613
  }
4873
4614
  };
4874
4615
  this.buildDelegateTx = async function(caip, params) {
4875
- let tag6 = TAG9 + " | buildDelegateTx | ";
4616
+ let tag6 = TAG10 + " | buildDelegateTx | ";
4876
4617
  try {
4877
4618
  const delegateParams = {
4878
4619
  ...params,
@@ -4887,7 +4628,7 @@ class SDK {
4887
4628
  }
4888
4629
  };
4889
4630
  this.buildUndelegateTx = async function(caip, params) {
4890
- let tag6 = TAG9 + " | buildUndelegateTx | ";
4631
+ let tag6 = TAG10 + " | buildUndelegateTx | ";
4891
4632
  try {
4892
4633
  const undelegateParams = {
4893
4634
  ...params,
@@ -4902,7 +4643,7 @@ class SDK {
4902
4643
  }
4903
4644
  };
4904
4645
  this.buildClaimRewardsTx = async function(caip, params) {
4905
- let tag6 = TAG9 + " | buildClaimRewardsTx | ";
4646
+ let tag6 = TAG10 + " | buildClaimRewardsTx | ";
4906
4647
  try {
4907
4648
  const claimParams = {
4908
4649
  ...params,
@@ -4917,7 +4658,7 @@ class SDK {
4917
4658
  }
4918
4659
  };
4919
4660
  this.buildClaimAllRewardsTx = async function(caip, params) {
4920
- let tag6 = TAG9 + " | buildClaimAllRewardsTx | ";
4661
+ let tag6 = TAG10 + " | buildClaimAllRewardsTx | ";
4921
4662
  try {
4922
4663
  const claimAllParams = {
4923
4664
  ...params,
@@ -4931,7 +4672,7 @@ class SDK {
4931
4672
  }
4932
4673
  };
4933
4674
  this.signTx = async function(caip, unsignedTx) {
4934
- let tag6 = TAG9 + " | signTx | ";
4675
+ let tag6 = TAG10 + " | signTx | ";
4935
4676
  try {
4936
4677
  const transactionDependencies = {
4937
4678
  context: this.context,
@@ -4952,7 +4693,7 @@ class SDK {
4952
4693
  }
4953
4694
  };
4954
4695
  this.broadcastTx = async function(caip, signedTx) {
4955
- let tag6 = TAG9 + " | broadcastTx | ";
4696
+ let tag6 = TAG10 + " | broadcastTx | ";
4956
4697
  try {
4957
4698
  const transactionDependencies = {
4958
4699
  context: this.context,
@@ -4976,7 +4717,7 @@ class SDK {
4976
4717
  }
4977
4718
  };
4978
4719
  this.swap = async function(swapPayload) {
4979
- let tag6 = `${TAG9} | swap | `;
4720
+ let tag6 = `${TAG10} | swap | `;
4980
4721
  try {
4981
4722
  if (!swapPayload)
4982
4723
  throw Error("swapPayload required!");
@@ -5115,7 +4856,7 @@ class SDK {
5115
4856
  }
5116
4857
  };
5117
4858
  this.transfer = async function(sendPayload) {
5118
- let tag6 = `${TAG9} | transfer | `;
4859
+ let tag6 = `${TAG10} | transfer | `;
5119
4860
  try {
5120
4861
  if (!sendPayload)
5121
4862
  throw Error("sendPayload required!");
@@ -5210,7 +4951,7 @@ class SDK {
5210
4951
  }
5211
4952
  };
5212
4953
  this.setBlockchains = async function(blockchains) {
5213
- const tag6 = `${TAG9} | setBlockchains | `;
4954
+ const tag6 = `${TAG10} | setBlockchains | `;
5214
4955
  try {
5215
4956
  if (!blockchains)
5216
4957
  throw Error("blockchains required!");
@@ -5226,7 +4967,7 @@ class SDK {
5226
4967
  }
5227
4968
  };
5228
4969
  this.addAsset = async function(caip, data) {
5229
- let tag6 = TAG9 + " | addAsset | ";
4970
+ let tag6 = TAG10 + " | addAsset | ";
5230
4971
  try {
5231
4972
  let success = false;
5232
4973
  if (!caip)
@@ -5264,7 +5005,7 @@ class SDK {
5264
5005
  }
5265
5006
  };
5266
5007
  this.clearWalletState = async function() {
5267
- const tag6 = `${TAG9} | clearWalletState | `;
5008
+ const tag6 = `${TAG10} | clearWalletState | `;
5268
5009
  try {
5269
5010
  this.context = null;
5270
5011
  this.paths = [];
@@ -5279,7 +5020,7 @@ class SDK {
5279
5020
  }
5280
5021
  };
5281
5022
  this.addPath = async function(path) {
5282
- const tag6 = `${TAG9} | addPath | `;
5023
+ const tag6 = `${TAG10} | addPath | `;
5283
5024
  try {
5284
5025
  this.paths.push(path);
5285
5026
  const pubkey = await getPubkey(path.networks[0], path, this.keepKeySdk, this.context);
@@ -5293,7 +5034,7 @@ class SDK {
5293
5034
  }
5294
5035
  };
5295
5036
  this.addPaths = async function(paths) {
5296
- const tag6 = `${TAG9} | addPaths | `;
5037
+ const tag6 = `${TAG10} | addPaths | `;
5297
5038
  try {
5298
5039
  console.log(tag6, `Adding ${paths.length} paths in batch mode...`);
5299
5040
  this.paths.push(...paths);
@@ -5329,7 +5070,7 @@ class SDK {
5329
5070
  return this.getGasAssets();
5330
5071
  };
5331
5072
  this.getGasAssets = async function() {
5332
- const tag6 = `${TAG9} | getGasAssets | `;
5073
+ const tag6 = `${TAG10} | getGasAssets | `;
5333
5074
  try {
5334
5075
  for (let i = 0;i < this.blockchains.length; i++) {
5335
5076
  let networkId = this.blockchains[i];
@@ -5372,7 +5113,7 @@ class SDK {
5372
5113
  }
5373
5114
  };
5374
5115
  this.getPubkeys = async function() {
5375
- const tag6 = `${TAG9} | getPubkeys | `;
5116
+ const tag6 = `${TAG10} | getPubkeys | `;
5376
5117
  try {
5377
5118
  if (this.paths.length === 0)
5378
5119
  throw new Error("No paths found!");
@@ -5393,7 +5134,7 @@ class SDK {
5393
5134
  }
5394
5135
  };
5395
5136
  this.getBalancesForNetworks = async function(networkIds) {
5396
- const tag6 = `${TAG9} | getBalancesForNetworks | `;
5137
+ const tag6 = `${TAG10} | getBalancesForNetworks | `;
5397
5138
  try {
5398
5139
  if (!this.pioneer) {
5399
5140
  console.error(tag6, "ERROR: Pioneer client not initialized! this.pioneer is:", this.pioneer);
@@ -5448,7 +5189,7 @@ class SDK {
5448
5189
  }
5449
5190
  };
5450
5191
  this.getBalances = async function() {
5451
- const tag6 = `${TAG9} | getBalances | `;
5192
+ const tag6 = `${TAG10} | getBalances | `;
5452
5193
  try {
5453
5194
  return await this.getBalancesForNetworks(this.blockchains);
5454
5195
  } catch (e) {
@@ -5457,7 +5198,7 @@ class SDK {
5457
5198
  }
5458
5199
  };
5459
5200
  this.getBalance = async function(networkId) {
5460
- const tag6 = `${TAG9} | getBalance | `;
5201
+ const tag6 = `${TAG10} | getBalance | `;
5461
5202
  try {
5462
5203
  const results = await this.getBalancesForNetworks([networkId]);
5463
5204
  const filtered = results.filter(async (b3) => b3.networkId === await networkIdToCaip2(networkId));
@@ -5468,7 +5209,7 @@ class SDK {
5468
5209
  }
5469
5210
  };
5470
5211
  this.getFees = async function(networkId) {
5471
- const tag6 = `${TAG9} | getFees | `;
5212
+ const tag6 = `${TAG10} | getFees | `;
5472
5213
  try {
5473
5214
  if (!this.pioneer) {
5474
5215
  throw new Error("Pioneer client not initialized. Call init() first.");
@@ -5483,7 +5224,7 @@ class SDK {
5483
5224
  return estimateTransactionFee(feeRate, unit, networkType, txSize);
5484
5225
  };
5485
5226
  this.getCharts = async function() {
5486
- const tag6 = `${TAG9} | getCharts | `;
5227
+ const tag6 = `${TAG10} | getCharts | `;
5487
5228
  try {
5488
5229
  console.log(tag6, "Fetching charts");
5489
5230
  const newBalances = await getCharts(this.blockchains, this.pioneer, this.pubkeys, this.context);
@@ -5505,7 +5246,7 @@ class SDK {
5505
5246
  }
5506
5247
  };
5507
5248
  this.setContext = async (context) => {
5508
- const tag6 = `${TAG9} | setContext | `;
5249
+ const tag6 = `${TAG10} | setContext | `;
5509
5250
  try {
5510
5251
  if (!context)
5511
5252
  throw Error("context required!");
@@ -5518,7 +5259,7 @@ class SDK {
5518
5259
  }
5519
5260
  };
5520
5261
  this.setContextType = async (contextType) => {
5521
- const tag6 = `${TAG9} | setContextType | `;
5262
+ const tag6 = `${TAG10} | setContextType | `;
5522
5263
  try {
5523
5264
  if (!contextType)
5524
5265
  throw Error("contextType required!");
@@ -5531,7 +5272,7 @@ class SDK {
5531
5272
  }
5532
5273
  };
5533
5274
  this.refresh = async () => {
5534
- const tag6 = `${TAG9} | refresh | `;
5275
+ const tag6 = `${TAG10} | refresh | `;
5535
5276
  try {
5536
5277
  await this.sync();
5537
5278
  return this.balances;
@@ -5541,7 +5282,7 @@ class SDK {
5541
5282
  }
5542
5283
  };
5543
5284
  this.setAssetContext = async function(asset) {
5544
- const tag6 = `${TAG9} | setAssetContext | `;
5285
+ const tag6 = `${TAG10} | setAssetContext | `;
5545
5286
  try {
5546
5287
  if (!asset) {
5547
5288
  this.assetContext = null;
@@ -5740,7 +5481,7 @@ class SDK {
5740
5481
  }
5741
5482
  };
5742
5483
  this.setPubkeyContext = async function(pubkey) {
5743
- let tag6 = `${TAG9} | setPubkeyContext | `;
5484
+ let tag6 = `${TAG10} | setPubkeyContext | `;
5744
5485
  try {
5745
5486
  if (!pubkey)
5746
5487
  throw Error("pubkey is required");
@@ -5759,7 +5500,7 @@ class SDK {
5759
5500
  }
5760
5501
  };
5761
5502
  this.setOutboundAssetContext = async function(asset) {
5762
- const tag6 = `${TAG9} | setOutputAssetContext | `;
5503
+ const tag6 = `${TAG10} | setOutputAssetContext | `;
5763
5504
  try {
5764
5505
  console.log(tag6, "0. asset: ", asset);
5765
5506
  if (!asset) {