@pioneer-platform/pioneer-sdk 4.21.3 → 4.21.6

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,337 +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
- var __importDefault = exports && exports.__importDefault || function(mod) {
144
- return mod && mod.__esModule ? mod : { default: mod };
145
- };
146
- Object.defineProperty(exports, "__esModule", { value: true });
147
- exports.Pioneer = undefined;
148
- var swagger_client_1 = __importDefault(__require("swagger-client"));
149
- var loggerdog_1 = __importDefault(__require("@pioneer-platform/loggerdog"));
150
- var log = typeof window === "undefined" ? (0, loggerdog_1.default)() : {
151
- debug: function() {
152
- var args = [];
153
- for (var _i = 0;_i < arguments.length; _i++) {
154
- args[_i] = arguments[_i];
155
- }
156
- return console.debug.apply(console, args);
157
- },
158
- info: function() {
159
- var args = [];
160
- for (var _i = 0;_i < arguments.length; _i++) {
161
- args[_i] = arguments[_i];
162
- }
163
- return console.info.apply(console, args);
164
- },
165
- warn: function() {
166
- var args = [];
167
- for (var _i = 0;_i < arguments.length; _i++) {
168
- args[_i] = arguments[_i];
169
- }
170
- return console.warn.apply(console, args);
171
- },
172
- error: function() {
173
- var args = [];
174
- for (var _i = 0;_i < arguments.length; _i++) {
175
- args[_i] = arguments[_i];
176
- }
177
- return console.error.apply(console, args);
178
- }
179
- };
180
- var Swagger = swagger_client_1.default;
181
- var TAG = " | Client | ";
182
- function customHttpClient(req) {
183
- var _this = this;
184
- return new Promise(function(resolve, reject) {
185
- var timer = setTimeout(function() {
186
- reject(new Error("Request timed out"));
187
- }, 60000);
188
- log.debug(TAG, "HTTP request URL:", req.url);
189
- log.debug(TAG, "HTTP request details:", req);
190
- if (Swagger.http) {
191
- Swagger.http(req).then(function(response) {
192
- clearTimeout(timer);
193
- resolve(response);
194
- }).catch(function(err) {
195
- clearTimeout(timer);
196
- reject(err);
197
- });
198
- } else {
199
- var fetchOptions = {
200
- method: req.method || "GET",
201
- headers: req.headers,
202
- body: req.body ? typeof req.body === "string" ? req.body : JSON.stringify(req.body) : undefined
203
- };
204
- fetch(req.url, fetchOptions).then(function(response) {
205
- return __awaiter(_this, undefined, undefined, function() {
206
- var text, body, headers;
207
- return __generator(this, function(_a) {
208
- switch (_a.label) {
209
- case 0:
210
- clearTimeout(timer);
211
- return [4, response.text()];
212
- case 1:
213
- text = _a.sent();
214
- try {
215
- body = JSON.parse(text);
216
- } catch (jsonError) {
217
- body = text;
218
- }
219
- headers = {};
220
- response.headers.forEach(function(value, key) {
221
- headers[key] = value;
222
- });
223
- resolve({
224
- status: response.status,
225
- body,
226
- headers
227
- });
228
- return [2];
229
- }
230
- });
231
- });
232
- }).catch(function(err) {
233
- clearTimeout(timer);
234
- reject(err);
235
- });
236
- }
237
- });
238
- }
239
- var Pioneer = function() {
240
- function Pioneer2(spec, config) {
241
- this.spec = spec;
242
- this.queryKey = config.queryKey;
243
- this.pioneer = {};
244
- this.timeout = config.timeout || 45000;
245
- }
246
- Pioneer2.prototype.init = function() {
247
- return __awaiter(this, undefined, undefined, function() {
248
- var tag, _a, e_1;
249
- var _this = this;
250
- return __generator(this, function(_b) {
251
- switch (_b.label) {
252
- case 0:
253
- tag = TAG + " | init | ";
254
- _b.label = 1;
255
- case 1:
256
- _b.trys.push([1, 3, , 4]);
257
- if (!this.queryKey)
258
- throw Error(" You must create an api key! ");
259
- _a = this;
260
- return [4, new Swagger({
261
- url: this.spec,
262
- requestInterceptor: function(req) {
263
- req.headers.Authorization = _this.queryKey;
264
- if ((req.method === "POST" || req.method === "post") && req.body) {
265
- log.debug(TAG, "Request interceptor - method:", req.method);
266
- log.debug(TAG, "Body type:", typeof req.body);
267
- log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
268
- if (!req.headers)
269
- req.headers = {};
270
- if (!req.headers["Content-Type"]) {
271
- req.headers["Content-Type"] = "application/json";
272
- }
273
- if (typeof req.body !== "string") {
274
- log.debug(TAG, "Converting body to JSON string");
275
- req.body = JSON.stringify(req.body);
276
- }
277
- }
278
- return req;
279
- },
280
- http: customHttpClient
281
- })];
282
- case 2:
283
- _a.client = _b.sent();
284
- Object.keys(this.client.spec.paths).forEach(function(path) {
285
- Object.keys(_this.client.spec.paths[path]).forEach(function(method) {
286
- var operationId = _this.client.spec.paths[path][method].operationId;
287
- _this.pioneer[operationId] = function(parameters) {
288
- return __awaiter(_this, undefined, undefined, function() {
289
- var invalidElements, request, result, e_2;
290
- return __generator(this, function(_a2) {
291
- switch (_a2.label) {
292
- case 0:
293
- _a2.trys.push([0, 2, , 3]);
294
- log.debug(TAG, "".concat(operationId, " called with:"), parameters);
295
- if (operationId === "GetMarketInfo") {
296
- if (!Array.isArray(parameters)) {
297
- throw new Error("GetMarketInfo requires an array of CAIP strings, got ".concat(typeof parameters));
298
- }
299
- invalidElements = parameters.map(function(item, index) {
300
- return { item, index, type: typeof item };
301
- }).filter(function(_a3) {
302
- var item = _a3.item;
303
- return !item || typeof item !== "string";
304
- });
305
- if (invalidElements.length > 0) {
306
- console.error("\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:", invalidElements);
307
- 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, ")"));
308
- }
309
- log.debug(TAG, "GetMarketInfo validation passed: ".concat(parameters.length, " valid CAIP strings"));
310
- }
311
- request = {
312
- operationId,
313
- parameters: {
314
- Authorization: this.queryKey
315
- },
316
- responseContentType: "application/json"
317
- };
318
- if (method === "post") {
319
- request.requestBody = parameters;
320
- } else {
321
- request.parameters = __assign(__assign({}, parameters), { Authorization: this.queryKey });
322
- }
323
- log.debug(TAG, "".concat(operationId, " request:"), request);
324
- return [4, this.client.execute(request)];
325
- case 1:
326
- result = _a2.sent();
327
- return [2, { data: result.body }];
328
- case 2:
329
- e_2 = _a2.sent();
330
- log.error(TAG, "Operation error:", e_2);
331
- throw e_2;
332
- case 3:
333
- return [2];
334
- }
335
- });
336
- });
337
- };
338
- });
339
- });
340
- return [2, this.pioneer];
341
- case 3:
342
- e_1 = _b.sent();
343
- log.error(TAG, "Initialization error:", e_1);
344
- throw e_1;
345
- case 4:
346
- return [2];
347
- }
348
- });
349
- });
350
- };
351
- return Pioneer2;
352
- }();
353
- exports.Pioneer = Pioneer;
354
- exports.default = Pioneer;
355
- });
356
-
357
26
  // ../../../node_modules/coinselect/utils.js
358
27
  var require_utils = __commonJS((exports, module) => {
359
28
  var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
@@ -551,9 +220,152 @@ var require_split = __commonJS((exports, module) => {
551
220
  });
552
221
 
553
222
  // src/index.ts
554
- var import_pioneer_client = __toESM(require_lib(), 1);
555
223
  import { KeepKeySdk } from "@keepkey/keepkey-sdk";
556
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
557
369
  import { addressNListToBIP32 as addressNListToBIP322, getPaths } from "@pioneer-platform/pioneer-coins";
558
370
  import { assetData as assetData2 } from "@pioneer-platform/pioneer-discovery";
559
371
  import { Events } from "@pioneer-platform/pioneer-events";
@@ -1913,7 +1725,7 @@ var SUPPORTED_CAIPS = {
1913
1725
  // src/txbuilder/createUnsignedEvmTx.ts
1914
1726
  import { caipToNetworkId } from "@pioneer-platform/pioneer-caip";
1915
1727
  import { bip32ToAddressNList } from "@pioneer-platform/pioneer-coins";
1916
- var TAG = " | createUnsignedEvmTx | ";
1728
+ var TAG2 = " | createUnsignedEvmTx | ";
1917
1729
  var toHex = (value) => {
1918
1730
  let hex = value.toString(16);
1919
1731
  if (hex.length % 2)
@@ -1992,7 +1804,7 @@ async function fetchTokenPriceInUsd(pioneer, caip) {
1992
1804
  }
1993
1805
  }
1994
1806
  async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax, feeLevel = 5) {
1995
- const tag6 = TAG + " | createUnsignedEvmTx | ";
1807
+ const tag6 = TAG2 + " | createUnsignedEvmTx | ";
1996
1808
  try {
1997
1809
  if (!pioneer)
1998
1810
  throw new Error("Failed to initialize Pioneer");
@@ -2313,9 +2125,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
2313
2125
 
2314
2126
  // src/txbuilder/createUnsignedRippleTx.ts
2315
2127
  import { caipToNetworkId as caipToNetworkId2 } from "@pioneer-platform/pioneer-caip";
2316
- var TAG2 = " | createUnsignedUxtoTx | ";
2128
+ var TAG3 = " | createUnsignedUxtoTx | ";
2317
2129
  async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax) {
2318
- let tag6 = TAG2 + " | createUnsignedRippleTx | ";
2130
+ let tag6 = TAG3 + " | createUnsignedRippleTx | ";
2319
2131
  try {
2320
2132
  if (!pioneer)
2321
2133
  throw new Error("Failed to init! pioneer");
@@ -2532,9 +2344,9 @@ var thorchainDepositTemplate = (params) => ({
2532
2344
  });
2533
2345
 
2534
2346
  // src/txbuilder/createUnsignedTendermintTx.ts
2535
- var TAG3 = " | createUnsignedTendermintTx | ";
2347
+ var TAG4 = " | createUnsignedTendermintTx | ";
2536
2348
  async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pioneer, pubkeyContext, isMax, to) {
2537
- const tag6 = TAG3 + " | createUnsignedTendermintTx | ";
2349
+ const tag6 = TAG4 + " | createUnsignedTendermintTx | ";
2538
2350
  try {
2539
2351
  if (!pioneer)
2540
2352
  throw new Error("Failed to init! pioneer");
@@ -3092,7 +2904,7 @@ function transformInput(input) {
3092
2904
  }
3093
2905
 
3094
2906
  // src/TransactionManager.ts
3095
- var TAG4 = " | Transaction | ";
2907
+ var TAG5 = " | Transaction | ";
3096
2908
 
3097
2909
  class TransactionManager {
3098
2910
  context;
@@ -3127,7 +2939,7 @@ class TransactionManager {
3127
2939
  throw new Error(`Unsupported CAIP: ${caip}`);
3128
2940
  }
3129
2941
  async transfer({ caip, to, amount, memo, isMax = false, feeLevel = 5, changeScriptType }) {
3130
- let tag6 = TAG4 + " | transfer | ";
2942
+ let tag6 = TAG5 + " | transfer | ";
3131
2943
  try {
3132
2944
  if (!this.pioneer)
3133
2945
  throw Error("Failed to init! pioneer");
@@ -3170,7 +2982,7 @@ class TransactionManager {
3170
2982
  }
3171
2983
  }
3172
2984
  async sign({ caip, unsignedTx }) {
3173
- let tag6 = TAG4 + " | sign | ";
2985
+ let tag6 = TAG5 + " | sign | ";
3174
2986
  try {
3175
2987
  if (!this.pioneer)
3176
2988
  throw Error("Failed to init! pioneer");
@@ -3328,7 +3140,7 @@ class TransactionManager {
3328
3140
  }
3329
3141
  }
3330
3142
  async broadcast({ networkId, serialized }) {
3331
- let tag6 = TAG4 + " | broadcast | ";
3143
+ let tag6 = TAG5 + " | broadcast | ";
3332
3144
  try {
3333
3145
  if (!this.pioneer)
3334
3146
  throw Error("Failed to init! pioneer");
@@ -3460,9 +3272,9 @@ var cosmosClaimAllRewardsTemplate = (params) => ({
3460
3272
  });
3461
3273
 
3462
3274
  // src/txbuilder/createUnsignedStakingTx.ts
3463
- var TAG5 = " | createUnsignedStakingTx | ";
3275
+ var TAG6 = " | createUnsignedStakingTx | ";
3464
3276
  async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, pubkeyContext) {
3465
- const tag6 = TAG5 + " | createUnsignedStakingTx | ";
3277
+ const tag6 = TAG6 + " | createUnsignedStakingTx | ";
3466
3278
  try {
3467
3279
  if (!pioneer)
3468
3280
  throw new Error("Failed to init! pioneer");
@@ -3596,7 +3408,7 @@ async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, pubkeyCon
3596
3408
  }
3597
3409
 
3598
3410
  // src/fees/index.ts
3599
- var TAG6 = " | Pioneer-sdk | fees | ";
3411
+ var TAG7 = " | Pioneer-sdk | fees | ";
3600
3412
  function getNetworkType(networkId) {
3601
3413
  if (networkId.startsWith("bip122:"))
3602
3414
  return "UTXO";
@@ -3636,7 +3448,7 @@ function withTimeout(promise, timeoutMs) {
3636
3448
  ]);
3637
3449
  }
3638
3450
  async function getFees(pioneer, networkId) {
3639
- const tag6 = TAG6 + " | getFees | ";
3451
+ const tag6 = TAG7 + " | getFees | ";
3640
3452
  try {
3641
3453
  console.log(tag6, `Fetching fees for network: ${networkId}`);
3642
3454
  const networkType = getNetworkType(networkId);
@@ -4103,9 +3915,9 @@ function formatTime(durationMs) {
4103
3915
 
4104
3916
  // src/utils/build-dashboard.ts
4105
3917
  import { caipToNetworkId as caipToNetworkId6, networkIdToCaip } from "@pioneer-platform/pioneer-caip";
4106
- var TAG7 = " | build-dashboard | ";
3918
+ var TAG8 = " | build-dashboard | ";
4107
3919
  function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4108
- console.log(TAG7, "[DASHBOARD] Building dashboard from cached balances...");
3920
+ console.log(TAG8, "[DASHBOARD] Building dashboard from cached balances...");
4109
3921
  const dashboardData = {
4110
3922
  networks: [],
4111
3923
  totalValueUsd: 0,
@@ -4113,7 +3925,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4113
3925
  };
4114
3926
  let totalPortfolioValue = 0;
4115
3927
  const networksTemp = [];
4116
- console.log(TAG7, "balances: ", balances);
3928
+ console.log(TAG8, "balances: ", balances);
4117
3929
  for (const blockchain of blockchains) {
4118
3930
  const filteredBalances = balances.filter((b3) => {
4119
3931
  const networkId = caipToNetworkId6(b3.caip);
@@ -4122,7 +3934,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4122
3934
  const balanceMap = new Map;
4123
3935
  const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
4124
3936
  if (isBitcoin) {
4125
- console.log(TAG7, "Bitcoin network detected - checking for duplicate balances");
3937
+ console.log(TAG8, "Bitcoin network detected - checking for duplicate balances");
4126
3938
  const bitcoinByValue = new Map;
4127
3939
  filteredBalances.forEach((balance) => {
4128
3940
  const valueKey = `${balance.balance}_${balance.valueUsd}`;
@@ -4133,7 +3945,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4133
3945
  });
4134
3946
  for (const [valueKey, balances2] of bitcoinByValue.entries()) {
4135
3947
  if (balances2.length === 3 && parseFloat(balances2[0].valueUsd || "0") > 0) {
4136
- 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");
4137
3949
  const xpubBalance = balances2.find((b3) => b3.pubkey?.startsWith("xpub")) || balances2[0];
4138
3950
  const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
4139
3951
  balanceMap.set(key, xpubBalance);
@@ -4156,7 +3968,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4156
3968
  const networkTotal = networkBalances.reduce((sum, balance, idx) => {
4157
3969
  const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
4158
3970
  if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
4159
- 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);
4160
3972
  }
4161
3973
  return sum + valueUsd;
4162
3974
  }, 0);
@@ -4167,11 +3979,11 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4167
3979
  return sum + balanceNum;
4168
3980
  }, 0).toString();
4169
3981
  const assetInfo = nativeAssetCaip ? assetsMap.get(nativeAssetCaip) : null;
4170
- console.log(TAG7, `[DEBUG] Network: ${blockchain}`);
4171
- console.log(TAG7, `[DEBUG] nativeAssetCaip: ${nativeAssetCaip}`);
4172
- console.log(TAG7, `[DEBUG] assetInfo:`, assetInfo);
4173
- console.log(TAG7, `[DEBUG] gasAsset:`, gasAsset);
4174
- 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"}`);
4175
3987
  networksTemp.push({
4176
3988
  networkId: blockchain,
4177
3989
  totalValueUsd: networkTotal,
@@ -4195,9 +4007,9 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4195
4007
  }
4196
4008
 
4197
4009
  // src/utils/sync-market.ts
4198
- var TAG8 = " | sync-market | ";
4010
+ var TAG9 = " | sync-market | ";
4199
4011
  async function syncMarket(balances, pioneer) {
4200
- const tag6 = `${TAG8} | syncMarket | `;
4012
+ const tag6 = `${TAG9} | syncMarket | `;
4201
4013
  try {
4202
4014
  const invalidBalances = balances.filter((b3) => !b3 || !b3.caip || typeof b3.caip !== "string" || !b3.caip.includes(":"));
4203
4015
  if (invalidBalances.length > 0) {
@@ -4249,7 +4061,7 @@ async function syncMarket(balances, pioneer) {
4249
4061
  }
4250
4062
 
4251
4063
  // src/index.ts
4252
- var TAG9 = " | Pioneer-sdk | ";
4064
+ var TAG10 = " | Pioneer-sdk | ";
4253
4065
 
4254
4066
  class SDK {
4255
4067
  status;
@@ -4407,7 +4219,7 @@ class SDK {
4407
4219
  return true;
4408
4220
  };
4409
4221
  this.setPubkeys = (newPubkeys) => {
4410
- const tag6 = `${TAG9} | setPubkeys | `;
4222
+ const tag6 = `${TAG10} | setPubkeys | `;
4411
4223
  this.pubkeys = [];
4412
4224
  this.pubkeySet.clear();
4413
4225
  let added = 0;
@@ -4424,7 +4236,7 @@ class SDK {
4424
4236
  this.pubkeySet.clear();
4425
4237
  }
4426
4238
  this.getUnifiedPortfolio = async function() {
4427
- const tag6 = `${TAG9} | getUnifiedPortfolio | `;
4239
+ const tag6 = `${TAG10} | getUnifiedPortfolio | `;
4428
4240
  try {
4429
4241
  const startTime = performance.now();
4430
4242
  try {
@@ -4532,7 +4344,7 @@ class SDK {
4532
4344
  }
4533
4345
  };
4534
4346
  this.init = async function(walletsVerbose, setup) {
4535
- const tag6 = `${TAG9} | init | `;
4347
+ const tag6 = `${TAG10} | init | `;
4536
4348
  try {
4537
4349
  if (!this.username)
4538
4350
  throw Error("username required!");
@@ -4549,7 +4361,7 @@ class SDK {
4549
4361
  const pioneerConfig = {
4550
4362
  ...config
4551
4363
  };
4552
- const PioneerClient = new import_pioneer_client.Pioneer(this.spec, pioneerConfig);
4364
+ const PioneerClient = new Pioneer(this.spec, pioneerConfig);
4553
4365
  this.pioneer = await PioneerClient.init();
4554
4366
  if (!this.pioneer)
4555
4367
  throw Error("Failed to init pioneer server!");
@@ -4626,7 +4438,7 @@ class SDK {
4626
4438
  return syncMarket(this.balances, this.pioneer);
4627
4439
  };
4628
4440
  this.sync = async function() {
4629
- const tag6 = `${TAG9} | sync | `;
4441
+ const tag6 = `${TAG10} | sync | `;
4630
4442
  try {
4631
4443
  const matchesNetwork = (item, networkId) => {
4632
4444
  if (!item.networks || !Array.isArray(item.networks))
@@ -4779,7 +4591,7 @@ class SDK {
4779
4591
  }
4780
4592
  };
4781
4593
  this.buildTx = async function(sendPayload) {
4782
- let tag6 = TAG9 + " | buildTx | ";
4594
+ let tag6 = TAG10 + " | buildTx | ";
4783
4595
  try {
4784
4596
  const transactionDependencies = {
4785
4597
  context: this.context,
@@ -4801,7 +4613,7 @@ class SDK {
4801
4613
  }
4802
4614
  };
4803
4615
  this.buildDelegateTx = async function(caip, params) {
4804
- let tag6 = TAG9 + " | buildDelegateTx | ";
4616
+ let tag6 = TAG10 + " | buildDelegateTx | ";
4805
4617
  try {
4806
4618
  const delegateParams = {
4807
4619
  ...params,
@@ -4816,7 +4628,7 @@ class SDK {
4816
4628
  }
4817
4629
  };
4818
4630
  this.buildUndelegateTx = async function(caip, params) {
4819
- let tag6 = TAG9 + " | buildUndelegateTx | ";
4631
+ let tag6 = TAG10 + " | buildUndelegateTx | ";
4820
4632
  try {
4821
4633
  const undelegateParams = {
4822
4634
  ...params,
@@ -4831,7 +4643,7 @@ class SDK {
4831
4643
  }
4832
4644
  };
4833
4645
  this.buildClaimRewardsTx = async function(caip, params) {
4834
- let tag6 = TAG9 + " | buildClaimRewardsTx | ";
4646
+ let tag6 = TAG10 + " | buildClaimRewardsTx | ";
4835
4647
  try {
4836
4648
  const claimParams = {
4837
4649
  ...params,
@@ -4846,7 +4658,7 @@ class SDK {
4846
4658
  }
4847
4659
  };
4848
4660
  this.buildClaimAllRewardsTx = async function(caip, params) {
4849
- let tag6 = TAG9 + " | buildClaimAllRewardsTx | ";
4661
+ let tag6 = TAG10 + " | buildClaimAllRewardsTx | ";
4850
4662
  try {
4851
4663
  const claimAllParams = {
4852
4664
  ...params,
@@ -4860,7 +4672,7 @@ class SDK {
4860
4672
  }
4861
4673
  };
4862
4674
  this.signTx = async function(caip, unsignedTx) {
4863
- let tag6 = TAG9 + " | signTx | ";
4675
+ let tag6 = TAG10 + " | signTx | ";
4864
4676
  try {
4865
4677
  const transactionDependencies = {
4866
4678
  context: this.context,
@@ -4881,7 +4693,7 @@ class SDK {
4881
4693
  }
4882
4694
  };
4883
4695
  this.broadcastTx = async function(caip, signedTx) {
4884
- let tag6 = TAG9 + " | broadcastTx | ";
4696
+ let tag6 = TAG10 + " | broadcastTx | ";
4885
4697
  try {
4886
4698
  const transactionDependencies = {
4887
4699
  context: this.context,
@@ -4905,7 +4717,7 @@ class SDK {
4905
4717
  }
4906
4718
  };
4907
4719
  this.swap = async function(swapPayload) {
4908
- let tag6 = `${TAG9} | swap | `;
4720
+ let tag6 = `${TAG10} | swap | `;
4909
4721
  try {
4910
4722
  if (!swapPayload)
4911
4723
  throw Error("swapPayload required!");
@@ -5044,7 +4856,7 @@ class SDK {
5044
4856
  }
5045
4857
  };
5046
4858
  this.transfer = async function(sendPayload) {
5047
- let tag6 = `${TAG9} | transfer | `;
4859
+ let tag6 = `${TAG10} | transfer | `;
5048
4860
  try {
5049
4861
  if (!sendPayload)
5050
4862
  throw Error("sendPayload required!");
@@ -5139,7 +4951,7 @@ class SDK {
5139
4951
  }
5140
4952
  };
5141
4953
  this.setBlockchains = async function(blockchains) {
5142
- const tag6 = `${TAG9} | setBlockchains | `;
4954
+ const tag6 = `${TAG10} | setBlockchains | `;
5143
4955
  try {
5144
4956
  if (!blockchains)
5145
4957
  throw Error("blockchains required!");
@@ -5155,7 +4967,7 @@ class SDK {
5155
4967
  }
5156
4968
  };
5157
4969
  this.addAsset = async function(caip, data) {
5158
- let tag6 = TAG9 + " | addAsset | ";
4970
+ let tag6 = TAG10 + " | addAsset | ";
5159
4971
  try {
5160
4972
  let success = false;
5161
4973
  if (!caip)
@@ -5193,7 +5005,7 @@ class SDK {
5193
5005
  }
5194
5006
  };
5195
5007
  this.clearWalletState = async function() {
5196
- const tag6 = `${TAG9} | clearWalletState | `;
5008
+ const tag6 = `${TAG10} | clearWalletState | `;
5197
5009
  try {
5198
5010
  this.context = null;
5199
5011
  this.paths = [];
@@ -5208,7 +5020,7 @@ class SDK {
5208
5020
  }
5209
5021
  };
5210
5022
  this.addPath = async function(path) {
5211
- const tag6 = `${TAG9} | addPath | `;
5023
+ const tag6 = `${TAG10} | addPath | `;
5212
5024
  try {
5213
5025
  this.paths.push(path);
5214
5026
  const pubkey = await getPubkey(path.networks[0], path, this.keepKeySdk, this.context);
@@ -5222,7 +5034,7 @@ class SDK {
5222
5034
  }
5223
5035
  };
5224
5036
  this.addPaths = async function(paths) {
5225
- const tag6 = `${TAG9} | addPaths | `;
5037
+ const tag6 = `${TAG10} | addPaths | `;
5226
5038
  try {
5227
5039
  console.log(tag6, `Adding ${paths.length} paths in batch mode...`);
5228
5040
  this.paths.push(...paths);
@@ -5258,7 +5070,7 @@ class SDK {
5258
5070
  return this.getGasAssets();
5259
5071
  };
5260
5072
  this.getGasAssets = async function() {
5261
- const tag6 = `${TAG9} | getGasAssets | `;
5073
+ const tag6 = `${TAG10} | getGasAssets | `;
5262
5074
  try {
5263
5075
  for (let i = 0;i < this.blockchains.length; i++) {
5264
5076
  let networkId = this.blockchains[i];
@@ -5301,7 +5113,7 @@ class SDK {
5301
5113
  }
5302
5114
  };
5303
5115
  this.getPubkeys = async function() {
5304
- const tag6 = `${TAG9} | getPubkeys | `;
5116
+ const tag6 = `${TAG10} | getPubkeys | `;
5305
5117
  try {
5306
5118
  if (this.paths.length === 0)
5307
5119
  throw new Error("No paths found!");
@@ -5322,7 +5134,7 @@ class SDK {
5322
5134
  }
5323
5135
  };
5324
5136
  this.getBalancesForNetworks = async function(networkIds) {
5325
- const tag6 = `${TAG9} | getBalancesForNetworks | `;
5137
+ const tag6 = `${TAG10} | getBalancesForNetworks | `;
5326
5138
  try {
5327
5139
  if (!this.pioneer) {
5328
5140
  console.error(tag6, "ERROR: Pioneer client not initialized! this.pioneer is:", this.pioneer);
@@ -5377,7 +5189,7 @@ class SDK {
5377
5189
  }
5378
5190
  };
5379
5191
  this.getBalances = async function() {
5380
- const tag6 = `${TAG9} | getBalances | `;
5192
+ const tag6 = `${TAG10} | getBalances | `;
5381
5193
  try {
5382
5194
  return await this.getBalancesForNetworks(this.blockchains);
5383
5195
  } catch (e) {
@@ -5386,7 +5198,7 @@ class SDK {
5386
5198
  }
5387
5199
  };
5388
5200
  this.getBalance = async function(networkId) {
5389
- const tag6 = `${TAG9} | getBalance | `;
5201
+ const tag6 = `${TAG10} | getBalance | `;
5390
5202
  try {
5391
5203
  const results = await this.getBalancesForNetworks([networkId]);
5392
5204
  const filtered = results.filter(async (b3) => b3.networkId === await networkIdToCaip2(networkId));
@@ -5397,7 +5209,7 @@ class SDK {
5397
5209
  }
5398
5210
  };
5399
5211
  this.getFees = async function(networkId) {
5400
- const tag6 = `${TAG9} | getFees | `;
5212
+ const tag6 = `${TAG10} | getFees | `;
5401
5213
  try {
5402
5214
  if (!this.pioneer) {
5403
5215
  throw new Error("Pioneer client not initialized. Call init() first.");
@@ -5412,7 +5224,7 @@ class SDK {
5412
5224
  return estimateTransactionFee(feeRate, unit, networkType, txSize);
5413
5225
  };
5414
5226
  this.getCharts = async function() {
5415
- const tag6 = `${TAG9} | getCharts | `;
5227
+ const tag6 = `${TAG10} | getCharts | `;
5416
5228
  try {
5417
5229
  console.log(tag6, "Fetching charts");
5418
5230
  const newBalances = await getCharts(this.blockchains, this.pioneer, this.pubkeys, this.context);
@@ -5434,7 +5246,7 @@ class SDK {
5434
5246
  }
5435
5247
  };
5436
5248
  this.setContext = async (context) => {
5437
- const tag6 = `${TAG9} | setContext | `;
5249
+ const tag6 = `${TAG10} | setContext | `;
5438
5250
  try {
5439
5251
  if (!context)
5440
5252
  throw Error("context required!");
@@ -5447,7 +5259,7 @@ class SDK {
5447
5259
  }
5448
5260
  };
5449
5261
  this.setContextType = async (contextType) => {
5450
- const tag6 = `${TAG9} | setContextType | `;
5262
+ const tag6 = `${TAG10} | setContextType | `;
5451
5263
  try {
5452
5264
  if (!contextType)
5453
5265
  throw Error("contextType required!");
@@ -5460,7 +5272,7 @@ class SDK {
5460
5272
  }
5461
5273
  };
5462
5274
  this.refresh = async () => {
5463
- const tag6 = `${TAG9} | refresh | `;
5275
+ const tag6 = `${TAG10} | refresh | `;
5464
5276
  try {
5465
5277
  await this.sync();
5466
5278
  return this.balances;
@@ -5470,7 +5282,7 @@ class SDK {
5470
5282
  }
5471
5283
  };
5472
5284
  this.setAssetContext = async function(asset) {
5473
- const tag6 = `${TAG9} | setAssetContext | `;
5285
+ const tag6 = `${TAG10} | setAssetContext | `;
5474
5286
  try {
5475
5287
  if (!asset) {
5476
5288
  this.assetContext = null;
@@ -5669,7 +5481,7 @@ class SDK {
5669
5481
  }
5670
5482
  };
5671
5483
  this.setPubkeyContext = async function(pubkey) {
5672
- let tag6 = `${TAG9} | setPubkeyContext | `;
5484
+ let tag6 = `${TAG10} | setPubkeyContext | `;
5673
5485
  try {
5674
5486
  if (!pubkey)
5675
5487
  throw Error("pubkey is required");
@@ -5688,7 +5500,7 @@ class SDK {
5688
5500
  }
5689
5501
  };
5690
5502
  this.setOutboundAssetContext = async function(asset) {
5691
- const tag6 = `${TAG9} | setOutputAssetContext | `;
5503
+ const tag6 = `${TAG10} | setOutputAssetContext | `;
5692
5504
  try {
5693
5505
  console.log(tag6, "0. asset: ", asset);
5694
5506
  if (!asset) {