@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.cjs CHANGED
@@ -40,337 +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
- var __importDefault = exports2 && exports2.__importDefault || function(mod) {
161
- return mod && mod.__esModule ? mod : { default: mod };
162
- };
163
- Object.defineProperty(exports2, "__esModule", { value: true });
164
- exports2.Pioneer = undefined;
165
- var swagger_client_1 = __importDefault(require("swagger-client"));
166
- var loggerdog_1 = __importDefault(require("@pioneer-platform/loggerdog"));
167
- var log = typeof window === "undefined" ? (0, loggerdog_1.default)() : {
168
- debug: function() {
169
- var args = [];
170
- for (var _i = 0;_i < arguments.length; _i++) {
171
- args[_i] = arguments[_i];
172
- }
173
- return console.debug.apply(console, args);
174
- },
175
- info: function() {
176
- var args = [];
177
- for (var _i = 0;_i < arguments.length; _i++) {
178
- args[_i] = arguments[_i];
179
- }
180
- return console.info.apply(console, args);
181
- },
182
- warn: function() {
183
- var args = [];
184
- for (var _i = 0;_i < arguments.length; _i++) {
185
- args[_i] = arguments[_i];
186
- }
187
- return console.warn.apply(console, args);
188
- },
189
- error: function() {
190
- var args = [];
191
- for (var _i = 0;_i < arguments.length; _i++) {
192
- args[_i] = arguments[_i];
193
- }
194
- return console.error.apply(console, args);
195
- }
196
- };
197
- var Swagger = swagger_client_1.default;
198
- var TAG = " | Client | ";
199
- function customHttpClient(req) {
200
- var _this = this;
201
- return new Promise(function(resolve, reject) {
202
- var timer = setTimeout(function() {
203
- reject(new Error("Request timed out"));
204
- }, 60000);
205
- log.debug(TAG, "HTTP request URL:", req.url);
206
- log.debug(TAG, "HTTP request details:", req);
207
- if (Swagger.http) {
208
- Swagger.http(req).then(function(response) {
209
- clearTimeout(timer);
210
- resolve(response);
211
- }).catch(function(err) {
212
- clearTimeout(timer);
213
- reject(err);
214
- });
215
- } else {
216
- var fetchOptions = {
217
- method: req.method || "GET",
218
- headers: req.headers,
219
- body: req.body ? typeof req.body === "string" ? req.body : JSON.stringify(req.body) : undefined
220
- };
221
- fetch(req.url, fetchOptions).then(function(response) {
222
- return __awaiter(_this, undefined, undefined, function() {
223
- var text, body, headers;
224
- return __generator(this, function(_a) {
225
- switch (_a.label) {
226
- case 0:
227
- clearTimeout(timer);
228
- return [4, response.text()];
229
- case 1:
230
- text = _a.sent();
231
- try {
232
- body = JSON.parse(text);
233
- } catch (jsonError) {
234
- body = text;
235
- }
236
- headers = {};
237
- response.headers.forEach(function(value, key) {
238
- headers[key] = value;
239
- });
240
- resolve({
241
- status: response.status,
242
- body,
243
- headers
244
- });
245
- return [2];
246
- }
247
- });
248
- });
249
- }).catch(function(err) {
250
- clearTimeout(timer);
251
- reject(err);
252
- });
253
- }
254
- });
255
- }
256
- var Pioneer = function() {
257
- function Pioneer2(spec, config) {
258
- this.spec = spec;
259
- this.queryKey = config.queryKey;
260
- this.pioneer = {};
261
- this.timeout = config.timeout || 45000;
262
- }
263
- Pioneer2.prototype.init = function() {
264
- return __awaiter(this, undefined, undefined, function() {
265
- var tag, _a, e_1;
266
- var _this = this;
267
- return __generator(this, function(_b) {
268
- switch (_b.label) {
269
- case 0:
270
- tag = TAG + " | init | ";
271
- _b.label = 1;
272
- case 1:
273
- _b.trys.push([1, 3, , 4]);
274
- if (!this.queryKey)
275
- throw Error(" You must create an api key! ");
276
- _a = this;
277
- return [4, new Swagger({
278
- url: this.spec,
279
- requestInterceptor: function(req) {
280
- req.headers.Authorization = _this.queryKey;
281
- if ((req.method === "POST" || req.method === "post") && req.body) {
282
- log.debug(TAG, "Request interceptor - method:", req.method);
283
- log.debug(TAG, "Body type:", typeof req.body);
284
- log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
285
- if (!req.headers)
286
- req.headers = {};
287
- if (!req.headers["Content-Type"]) {
288
- req.headers["Content-Type"] = "application/json";
289
- }
290
- if (typeof req.body !== "string") {
291
- log.debug(TAG, "Converting body to JSON string");
292
- req.body = JSON.stringify(req.body);
293
- }
294
- }
295
- return req;
296
- },
297
- http: customHttpClient
298
- })];
299
- case 2:
300
- _a.client = _b.sent();
301
- Object.keys(this.client.spec.paths).forEach(function(path) {
302
- Object.keys(_this.client.spec.paths[path]).forEach(function(method) {
303
- var operationId = _this.client.spec.paths[path][method].operationId;
304
- _this.pioneer[operationId] = function(parameters) {
305
- return __awaiter(_this, undefined, undefined, function() {
306
- var invalidElements, request, result, e_2;
307
- return __generator(this, function(_a2) {
308
- switch (_a2.label) {
309
- case 0:
310
- _a2.trys.push([0, 2, , 3]);
311
- log.debug(TAG, "".concat(operationId, " called with:"), parameters);
312
- if (operationId === "GetMarketInfo") {
313
- if (!Array.isArray(parameters)) {
314
- throw new Error("GetMarketInfo requires an array of CAIP strings, got ".concat(typeof parameters));
315
- }
316
- invalidElements = parameters.map(function(item, index) {
317
- return { item, index, type: typeof item };
318
- }).filter(function(_a3) {
319
- var item = _a3.item;
320
- return !item || typeof item !== "string";
321
- });
322
- if (invalidElements.length > 0) {
323
- console.error("\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:", invalidElements);
324
- 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, ")"));
325
- }
326
- log.debug(TAG, "GetMarketInfo validation passed: ".concat(parameters.length, " valid CAIP strings"));
327
- }
328
- request = {
329
- operationId,
330
- parameters: {
331
- Authorization: this.queryKey
332
- },
333
- responseContentType: "application/json"
334
- };
335
- if (method === "post") {
336
- request.requestBody = parameters;
337
- } else {
338
- request.parameters = __assign(__assign({}, parameters), { Authorization: this.queryKey });
339
- }
340
- log.debug(TAG, "".concat(operationId, " request:"), request);
341
- return [4, this.client.execute(request)];
342
- case 1:
343
- result = _a2.sent();
344
- return [2, { data: result.body }];
345
- case 2:
346
- e_2 = _a2.sent();
347
- log.error(TAG, "Operation error:", e_2);
348
- throw e_2;
349
- case 3:
350
- return [2];
351
- }
352
- });
353
- });
354
- };
355
- });
356
- });
357
- return [2, this.pioneer];
358
- case 3:
359
- e_1 = _b.sent();
360
- log.error(TAG, "Initialization error:", e_1);
361
- throw e_1;
362
- case 4:
363
- return [2];
364
- }
365
- });
366
- });
367
- };
368
- return Pioneer2;
369
- }();
370
- exports2.Pioneer = Pioneer;
371
- exports2.default = Pioneer;
372
- });
373
-
374
43
  // ../../../node_modules/coinselect/utils.js
375
44
  var require_utils = __commonJS((exports2, module2) => {
376
45
  var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
@@ -576,7 +245,150 @@ __export(exports_src, {
576
245
  module.exports = __toCommonJS(exports_src);
577
246
  var import_keepkey_sdk = require("@keepkey/keepkey-sdk");
578
247
  var import_pioneer_caip7 = require("@pioneer-platform/pioneer-caip");
579
- var import_pioneer_client = __toESM(require_lib());
248
+
249
+ // ../pioneer-client/lib/index.js
250
+ var import_swagger_client = __toESM(require("swagger-client"));
251
+ var import_loggerdog = __toESM(require("@pioneer-platform/loggerdog"));
252
+ var log = typeof window === "undefined" ? import_loggerdog.default() : {
253
+ debug: (...args) => console.debug(...args),
254
+ info: (...args) => console.info(...args),
255
+ warn: (...args) => console.warn(...args),
256
+ error: (...args) => console.error(...args)
257
+ };
258
+ var Swagger = import_swagger_client.default;
259
+ var TAG = " | Client | ";
260
+ function customHttpClient(req) {
261
+ return new Promise((resolve, reject) => {
262
+ const timer = setTimeout(() => {
263
+ reject(new Error("Request timed out"));
264
+ }, 60000);
265
+ log.debug(TAG, "HTTP request URL:", req.url);
266
+ log.debug(TAG, "HTTP request details:", req);
267
+ if (Swagger.http) {
268
+ Swagger.http(req).then((response) => {
269
+ clearTimeout(timer);
270
+ resolve(response);
271
+ }).catch((err) => {
272
+ clearTimeout(timer);
273
+ reject(err);
274
+ });
275
+ } else {
276
+ const fetchOptions = {
277
+ method: req.method || "GET",
278
+ headers: req.headers,
279
+ body: req.body ? typeof req.body === "string" ? req.body : JSON.stringify(req.body) : undefined
280
+ };
281
+ fetch(req.url, fetchOptions).then(async (response) => {
282
+ clearTimeout(timer);
283
+ const text = await response.text();
284
+ let body;
285
+ try {
286
+ body = JSON.parse(text);
287
+ } catch (jsonError) {
288
+ body = text;
289
+ }
290
+ const headers = {};
291
+ response.headers.forEach((value, key) => {
292
+ headers[key] = value;
293
+ });
294
+ resolve({
295
+ status: response.status,
296
+ body,
297
+ headers
298
+ });
299
+ }).catch((err) => {
300
+ clearTimeout(timer);
301
+ reject(err);
302
+ });
303
+ }
304
+ });
305
+ }
306
+
307
+ class Pioneer {
308
+ constructor(spec, config) {
309
+ this.spec = spec;
310
+ this.queryKey = config.queryKey;
311
+ this.pioneer = {};
312
+ this.timeout = config.timeout || 45000;
313
+ }
314
+ async init() {
315
+ let tag = TAG + " | init | ";
316
+ try {
317
+ if (!this.queryKey)
318
+ throw Error(" You must create an api key! ");
319
+ this.client = await new Swagger({
320
+ url: this.spec,
321
+ requestInterceptor: (req) => {
322
+ req.headers.Authorization = this.queryKey;
323
+ if ((req.method === "POST" || req.method === "post") && req.body) {
324
+ log.debug(TAG, "Request interceptor - method:", req.method);
325
+ log.debug(TAG, "Body type:", typeof req.body);
326
+ log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
327
+ if (!req.headers)
328
+ req.headers = {};
329
+ if (!req.headers["Content-Type"]) {
330
+ req.headers["Content-Type"] = "application/json";
331
+ }
332
+ if (typeof req.body !== "string") {
333
+ log.debug(TAG, "Converting body to JSON string");
334
+ req.body = JSON.stringify(req.body);
335
+ }
336
+ }
337
+ return req;
338
+ },
339
+ http: customHttpClient
340
+ });
341
+ Object.keys(this.client.spec.paths).forEach((path) => {
342
+ Object.keys(this.client.spec.paths[path]).forEach((method) => {
343
+ const operationId = this.client.spec.paths[path][method].operationId;
344
+ this.pioneer[operationId] = async (parameters) => {
345
+ try {
346
+ log.debug(TAG, `${operationId} called with:`, parameters);
347
+ if (operationId === "GetMarketInfo") {
348
+ if (!Array.isArray(parameters)) {
349
+ throw new Error(`GetMarketInfo requires an array of CAIP strings, got ${typeof parameters}`);
350
+ }
351
+ const invalidElements = parameters.map((item, index) => ({ item, index, type: typeof item })).filter(({ item }) => !item || typeof item !== "string");
352
+ if (invalidElements.length > 0) {
353
+ console.error(`\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:`, invalidElements);
354
+ 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})`);
355
+ }
356
+ log.debug(TAG, `GetMarketInfo validation passed: ${parameters.length} valid CAIP strings`);
357
+ }
358
+ let request = {
359
+ operationId,
360
+ parameters: {
361
+ Authorization: this.queryKey
362
+ },
363
+ responseContentType: "application/json"
364
+ };
365
+ if (method === "post") {
366
+ request.requestBody = parameters;
367
+ } else {
368
+ request.parameters = {
369
+ ...parameters,
370
+ Authorization: this.queryKey
371
+ };
372
+ }
373
+ log.debug(TAG, `${operationId} request:`, request);
374
+ const result = await this.client.execute(request);
375
+ return { data: result.body };
376
+ } catch (e) {
377
+ log.error(TAG, "Operation error:", e);
378
+ throw e;
379
+ }
380
+ };
381
+ });
382
+ });
383
+ return this.pioneer;
384
+ } catch (e) {
385
+ log.error(TAG, "Initialization error:", e);
386
+ throw e;
387
+ }
388
+ }
389
+ }
390
+
391
+ // src/index.ts
580
392
  var import_pioneer_coins4 = require("@pioneer-platform/pioneer-coins");
581
393
  var import_pioneer_discovery2 = require("@pioneer-platform/pioneer-discovery");
582
394
  var import_pioneer_events = require("@pioneer-platform/pioneer-events");
@@ -1737,7 +1549,7 @@ var SUPPORTED_CAIPS = {
1737
1549
  // src/txbuilder/createUnsignedEvmTx.ts
1738
1550
  var import_pioneer_caip = require("@pioneer-platform/pioneer-caip");
1739
1551
  var import_pioneer_coins2 = require("@pioneer-platform/pioneer-coins");
1740
- var TAG = " | createUnsignedEvmTx | ";
1552
+ var TAG2 = " | createUnsignedEvmTx | ";
1741
1553
  var toHex = (value) => {
1742
1554
  let hex = value.toString(16);
1743
1555
  if (hex.length % 2)
@@ -1816,7 +1628,7 @@ async function fetchTokenPriceInUsd(pioneer, caip) {
1816
1628
  }
1817
1629
  }
1818
1630
  async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax, feeLevel = 5) {
1819
- const tag6 = TAG + " | createUnsignedEvmTx | ";
1631
+ const tag6 = TAG2 + " | createUnsignedEvmTx | ";
1820
1632
  try {
1821
1633
  if (!pioneer)
1822
1634
  throw new Error("Failed to initialize Pioneer");
@@ -2137,9 +1949,9 @@ async function createUnsignedEvmTx(caip, to, amount, memo, pubkeys, pioneer, pub
2137
1949
 
2138
1950
  // src/txbuilder/createUnsignedRippleTx.ts
2139
1951
  var import_pioneer_caip2 = require("@pioneer-platform/pioneer-caip");
2140
- var TAG2 = " | createUnsignedUxtoTx | ";
1952
+ var TAG3 = " | createUnsignedUxtoTx | ";
2141
1953
  async function createUnsignedRippleTx(caip, to, amount, memo, pubkeys, pioneer, pubkeyContext, isMax) {
2142
- let tag6 = TAG2 + " | createUnsignedRippleTx | ";
1954
+ let tag6 = TAG3 + " | createUnsignedRippleTx | ";
2143
1955
  try {
2144
1956
  if (!pioneer)
2145
1957
  throw new Error("Failed to init! pioneer");
@@ -2356,9 +2168,9 @@ var thorchainDepositTemplate = (params) => ({
2356
2168
  });
2357
2169
 
2358
2170
  // src/txbuilder/createUnsignedTendermintTx.ts
2359
- var TAG3 = " | createUnsignedTendermintTx | ";
2171
+ var TAG4 = " | createUnsignedTendermintTx | ";
2360
2172
  async function createUnsignedTendermintTx(caip, type, amount, memo, pubkeys, pioneer, pubkeyContext, isMax, to) {
2361
- const tag6 = TAG3 + " | createUnsignedTendermintTx | ";
2173
+ const tag6 = TAG4 + " | createUnsignedTendermintTx | ";
2362
2174
  try {
2363
2175
  if (!pioneer)
2364
2176
  throw new Error("Failed to init! pioneer");
@@ -2916,7 +2728,7 @@ function transformInput(input) {
2916
2728
  }
2917
2729
 
2918
2730
  // src/TransactionManager.ts
2919
- var TAG4 = " | Transaction | ";
2731
+ var TAG5 = " | Transaction | ";
2920
2732
 
2921
2733
  class TransactionManager {
2922
2734
  context;
@@ -2951,7 +2763,7 @@ class TransactionManager {
2951
2763
  throw new Error(`Unsupported CAIP: ${caip}`);
2952
2764
  }
2953
2765
  async transfer({ caip, to, amount, memo, isMax = false, feeLevel = 5, changeScriptType }) {
2954
- let tag6 = TAG4 + " | transfer | ";
2766
+ let tag6 = TAG5 + " | transfer | ";
2955
2767
  try {
2956
2768
  if (!this.pioneer)
2957
2769
  throw Error("Failed to init! pioneer");
@@ -2994,7 +2806,7 @@ class TransactionManager {
2994
2806
  }
2995
2807
  }
2996
2808
  async sign({ caip, unsignedTx }) {
2997
- let tag6 = TAG4 + " | sign | ";
2809
+ let tag6 = TAG5 + " | sign | ";
2998
2810
  try {
2999
2811
  if (!this.pioneer)
3000
2812
  throw Error("Failed to init! pioneer");
@@ -3152,7 +2964,7 @@ class TransactionManager {
3152
2964
  }
3153
2965
  }
3154
2966
  async broadcast({ networkId, serialized }) {
3155
- let tag6 = TAG4 + " | broadcast | ";
2967
+ let tag6 = TAG5 + " | broadcast | ";
3156
2968
  try {
3157
2969
  if (!this.pioneer)
3158
2970
  throw Error("Failed to init! pioneer");
@@ -3284,9 +3096,9 @@ var cosmosClaimAllRewardsTemplate = (params) => ({
3284
3096
  });
3285
3097
 
3286
3098
  // src/txbuilder/createUnsignedStakingTx.ts
3287
- var TAG5 = " | createUnsignedStakingTx | ";
3099
+ var TAG6 = " | createUnsignedStakingTx | ";
3288
3100
  async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, pubkeyContext) {
3289
- const tag6 = TAG5 + " | createUnsignedStakingTx | ";
3101
+ const tag6 = TAG6 + " | createUnsignedStakingTx | ";
3290
3102
  try {
3291
3103
  if (!pioneer)
3292
3104
  throw new Error("Failed to init! pioneer");
@@ -3420,7 +3232,7 @@ async function createUnsignedStakingTx(caip, params, pubkeys, pioneer, pubkeyCon
3420
3232
  }
3421
3233
 
3422
3234
  // src/fees/index.ts
3423
- var TAG6 = " | Pioneer-sdk | fees | ";
3235
+ var TAG7 = " | Pioneer-sdk | fees | ";
3424
3236
  function getNetworkType(networkId) {
3425
3237
  if (networkId.startsWith("bip122:"))
3426
3238
  return "UTXO";
@@ -3460,7 +3272,7 @@ function withTimeout(promise, timeoutMs) {
3460
3272
  ]);
3461
3273
  }
3462
3274
  async function getFees(pioneer, networkId) {
3463
- const tag6 = TAG6 + " | getFees | ";
3275
+ const tag6 = TAG7 + " | getFees | ";
3464
3276
  try {
3465
3277
  console.log(tag6, `Fetching fees for network: ${networkId}`);
3466
3278
  const networkType = getNetworkType(networkId);
@@ -3927,9 +3739,9 @@ function formatTime(durationMs) {
3927
3739
 
3928
3740
  // src/utils/build-dashboard.ts
3929
3741
  var import_pioneer_caip6 = require("@pioneer-platform/pioneer-caip");
3930
- var TAG7 = " | build-dashboard | ";
3742
+ var TAG8 = " | build-dashboard | ";
3931
3743
  function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3932
- console.log(TAG7, "[DASHBOARD] Building dashboard from cached balances...");
3744
+ console.log(TAG8, "[DASHBOARD] Building dashboard from cached balances...");
3933
3745
  const dashboardData = {
3934
3746
  networks: [],
3935
3747
  totalValueUsd: 0,
@@ -3937,7 +3749,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3937
3749
  };
3938
3750
  let totalPortfolioValue = 0;
3939
3751
  const networksTemp = [];
3940
- console.log(TAG7, "balances: ", balances);
3752
+ console.log(TAG8, "balances: ", balances);
3941
3753
  for (const blockchain of blockchains) {
3942
3754
  const filteredBalances = balances.filter((b2) => {
3943
3755
  const networkId = import_pioneer_caip6.caipToNetworkId(b2.caip);
@@ -3946,7 +3758,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3946
3758
  const balanceMap = new Map;
3947
3759
  const isBitcoin = blockchain.includes("bip122:000000000019d6689c085ae165831e93");
3948
3760
  if (isBitcoin) {
3949
- console.log(TAG7, "Bitcoin network detected - checking for duplicate balances");
3761
+ console.log(TAG8, "Bitcoin network detected - checking for duplicate balances");
3950
3762
  const bitcoinByValue = new Map;
3951
3763
  filteredBalances.forEach((balance) => {
3952
3764
  const valueKey = `${balance.balance}_${balance.valueUsd}`;
@@ -3957,7 +3769,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3957
3769
  });
3958
3770
  for (const [valueKey, balances2] of bitcoinByValue.entries()) {
3959
3771
  if (balances2.length === 3 && parseFloat(balances2[0].valueUsd || "0") > 0) {
3960
- console.log(TAG7, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
3772
+ console.log(TAG8, "BITCOIN API BUG DETECTED: All 3 address types have same balance, keeping only xpub");
3961
3773
  const xpubBalance = balances2.find((b2) => b2.pubkey?.startsWith("xpub")) || balances2[0];
3962
3774
  const key = `${xpubBalance.caip}_${xpubBalance.pubkey || "default"}`;
3963
3775
  balanceMap.set(key, xpubBalance);
@@ -3980,7 +3792,7 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3980
3792
  const networkTotal = networkBalances.reduce((sum, balance, idx) => {
3981
3793
  const valueUsd = typeof balance.valueUsd === "string" ? parseFloat(balance.valueUsd) : balance.valueUsd || 0;
3982
3794
  if (blockchain.includes("bip122:000000000019d6689c085ae165831e93")) {
3983
- console.log(TAG7, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
3795
+ console.log(TAG8, `[BITCOIN DEBUG ${idx}] pubkey:`, balance.pubkey?.substring(0, 10) + "...", "| balance:", balance.balance, "| valueUsd:", balance.valueUsd, "→ parsed:", valueUsd, "| running sum:", sum + valueUsd);
3984
3796
  }
3985
3797
  return sum + valueUsd;
3986
3798
  }, 0);
@@ -3991,11 +3803,11 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3991
3803
  return sum + balanceNum;
3992
3804
  }, 0).toString();
3993
3805
  const assetInfo = nativeAssetCaip ? assetsMap.get(nativeAssetCaip) : null;
3994
- console.log(TAG7, `[DEBUG] Network: ${blockchain}`);
3995
- console.log(TAG7, `[DEBUG] nativeAssetCaip: ${nativeAssetCaip}`);
3996
- console.log(TAG7, `[DEBUG] assetInfo:`, assetInfo);
3997
- console.log(TAG7, `[DEBUG] gasAsset:`, gasAsset);
3998
- console.log(TAG7, `[DEBUG] Resolved name: ${gasAsset?.name || assetInfo?.name || "NO NAME"}`);
3806
+ console.log(TAG8, `[DEBUG] Network: ${blockchain}`);
3807
+ console.log(TAG8, `[DEBUG] nativeAssetCaip: ${nativeAssetCaip}`);
3808
+ console.log(TAG8, `[DEBUG] assetInfo:`, assetInfo);
3809
+ console.log(TAG8, `[DEBUG] gasAsset:`, gasAsset);
3810
+ console.log(TAG8, `[DEBUG] Resolved name: ${gasAsset?.name || assetInfo?.name || "NO NAME"}`);
3999
3811
  networksTemp.push({
4000
3812
  networkId: blockchain,
4001
3813
  totalValueUsd: networkTotal,
@@ -4019,9 +3831,9 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
4019
3831
  }
4020
3832
 
4021
3833
  // src/utils/sync-market.ts
4022
- var TAG8 = " | sync-market | ";
3834
+ var TAG9 = " | sync-market | ";
4023
3835
  async function syncMarket(balances, pioneer) {
4024
- const tag6 = `${TAG8} | syncMarket | `;
3836
+ const tag6 = `${TAG9} | syncMarket | `;
4025
3837
  try {
4026
3838
  const invalidBalances = balances.filter((b2) => !b2 || !b2.caip || typeof b2.caip !== "string" || !b2.caip.includes(":"));
4027
3839
  if (invalidBalances.length > 0) {
@@ -4073,7 +3885,7 @@ async function syncMarket(balances, pioneer) {
4073
3885
  }
4074
3886
 
4075
3887
  // src/index.ts
4076
- var TAG9 = " | Pioneer-sdk | ";
3888
+ var TAG10 = " | Pioneer-sdk | ";
4077
3889
 
4078
3890
  class SDK {
4079
3891
  status;
@@ -4231,7 +4043,7 @@ class SDK {
4231
4043
  return true;
4232
4044
  };
4233
4045
  this.setPubkeys = (newPubkeys) => {
4234
- const tag6 = `${TAG9} | setPubkeys | `;
4046
+ const tag6 = `${TAG10} | setPubkeys | `;
4235
4047
  this.pubkeys = [];
4236
4048
  this.pubkeySet.clear();
4237
4049
  let added = 0;
@@ -4248,7 +4060,7 @@ class SDK {
4248
4060
  this.pubkeySet.clear();
4249
4061
  }
4250
4062
  this.getUnifiedPortfolio = async function() {
4251
- const tag6 = `${TAG9} | getUnifiedPortfolio | `;
4063
+ const tag6 = `${TAG10} | getUnifiedPortfolio | `;
4252
4064
  try {
4253
4065
  const startTime = performance.now();
4254
4066
  try {
@@ -4356,7 +4168,7 @@ class SDK {
4356
4168
  }
4357
4169
  };
4358
4170
  this.init = async function(walletsVerbose, setup) {
4359
- const tag6 = `${TAG9} | init | `;
4171
+ const tag6 = `${TAG10} | init | `;
4360
4172
  try {
4361
4173
  if (!this.username)
4362
4174
  throw Error("username required!");
@@ -4373,7 +4185,7 @@ class SDK {
4373
4185
  const pioneerConfig = {
4374
4186
  ...config
4375
4187
  };
4376
- const PioneerClient = new import_pioneer_client.Pioneer(this.spec, pioneerConfig);
4188
+ const PioneerClient = new Pioneer(this.spec, pioneerConfig);
4377
4189
  this.pioneer = await PioneerClient.init();
4378
4190
  if (!this.pioneer)
4379
4191
  throw Error("Failed to init pioneer server!");
@@ -4450,7 +4262,7 @@ class SDK {
4450
4262
  return syncMarket(this.balances, this.pioneer);
4451
4263
  };
4452
4264
  this.sync = async function() {
4453
- const tag6 = `${TAG9} | sync | `;
4265
+ const tag6 = `${TAG10} | sync | `;
4454
4266
  try {
4455
4267
  const matchesNetwork = (item, networkId) => {
4456
4268
  if (!item.networks || !Array.isArray(item.networks))
@@ -4603,7 +4415,7 @@ class SDK {
4603
4415
  }
4604
4416
  };
4605
4417
  this.buildTx = async function(sendPayload) {
4606
- let tag6 = TAG9 + " | buildTx | ";
4418
+ let tag6 = TAG10 + " | buildTx | ";
4607
4419
  try {
4608
4420
  const transactionDependencies = {
4609
4421
  context: this.context,
@@ -4625,7 +4437,7 @@ class SDK {
4625
4437
  }
4626
4438
  };
4627
4439
  this.buildDelegateTx = async function(caip, params) {
4628
- let tag6 = TAG9 + " | buildDelegateTx | ";
4440
+ let tag6 = TAG10 + " | buildDelegateTx | ";
4629
4441
  try {
4630
4442
  const delegateParams = {
4631
4443
  ...params,
@@ -4640,7 +4452,7 @@ class SDK {
4640
4452
  }
4641
4453
  };
4642
4454
  this.buildUndelegateTx = async function(caip, params) {
4643
- let tag6 = TAG9 + " | buildUndelegateTx | ";
4455
+ let tag6 = TAG10 + " | buildUndelegateTx | ";
4644
4456
  try {
4645
4457
  const undelegateParams = {
4646
4458
  ...params,
@@ -4655,7 +4467,7 @@ class SDK {
4655
4467
  }
4656
4468
  };
4657
4469
  this.buildClaimRewardsTx = async function(caip, params) {
4658
- let tag6 = TAG9 + " | buildClaimRewardsTx | ";
4470
+ let tag6 = TAG10 + " | buildClaimRewardsTx | ";
4659
4471
  try {
4660
4472
  const claimParams = {
4661
4473
  ...params,
@@ -4670,7 +4482,7 @@ class SDK {
4670
4482
  }
4671
4483
  };
4672
4484
  this.buildClaimAllRewardsTx = async function(caip, params) {
4673
- let tag6 = TAG9 + " | buildClaimAllRewardsTx | ";
4485
+ let tag6 = TAG10 + " | buildClaimAllRewardsTx | ";
4674
4486
  try {
4675
4487
  const claimAllParams = {
4676
4488
  ...params,
@@ -4684,7 +4496,7 @@ class SDK {
4684
4496
  }
4685
4497
  };
4686
4498
  this.signTx = async function(caip, unsignedTx) {
4687
- let tag6 = TAG9 + " | signTx | ";
4499
+ let tag6 = TAG10 + " | signTx | ";
4688
4500
  try {
4689
4501
  const transactionDependencies = {
4690
4502
  context: this.context,
@@ -4705,7 +4517,7 @@ class SDK {
4705
4517
  }
4706
4518
  };
4707
4519
  this.broadcastTx = async function(caip, signedTx) {
4708
- let tag6 = TAG9 + " | broadcastTx | ";
4520
+ let tag6 = TAG10 + " | broadcastTx | ";
4709
4521
  try {
4710
4522
  const transactionDependencies = {
4711
4523
  context: this.context,
@@ -4729,7 +4541,7 @@ class SDK {
4729
4541
  }
4730
4542
  };
4731
4543
  this.swap = async function(swapPayload) {
4732
- let tag6 = `${TAG9} | swap | `;
4544
+ let tag6 = `${TAG10} | swap | `;
4733
4545
  try {
4734
4546
  if (!swapPayload)
4735
4547
  throw Error("swapPayload required!");
@@ -4868,7 +4680,7 @@ class SDK {
4868
4680
  }
4869
4681
  };
4870
4682
  this.transfer = async function(sendPayload) {
4871
- let tag6 = `${TAG9} | transfer | `;
4683
+ let tag6 = `${TAG10} | transfer | `;
4872
4684
  try {
4873
4685
  if (!sendPayload)
4874
4686
  throw Error("sendPayload required!");
@@ -4963,7 +4775,7 @@ class SDK {
4963
4775
  }
4964
4776
  };
4965
4777
  this.setBlockchains = async function(blockchains) {
4966
- const tag6 = `${TAG9} | setBlockchains | `;
4778
+ const tag6 = `${TAG10} | setBlockchains | `;
4967
4779
  try {
4968
4780
  if (!blockchains)
4969
4781
  throw Error("blockchains required!");
@@ -4979,7 +4791,7 @@ class SDK {
4979
4791
  }
4980
4792
  };
4981
4793
  this.addAsset = async function(caip, data) {
4982
- let tag6 = TAG9 + " | addAsset | ";
4794
+ let tag6 = TAG10 + " | addAsset | ";
4983
4795
  try {
4984
4796
  let success = false;
4985
4797
  if (!caip)
@@ -5017,7 +4829,7 @@ class SDK {
5017
4829
  }
5018
4830
  };
5019
4831
  this.clearWalletState = async function() {
5020
- const tag6 = `${TAG9} | clearWalletState | `;
4832
+ const tag6 = `${TAG10} | clearWalletState | `;
5021
4833
  try {
5022
4834
  this.context = null;
5023
4835
  this.paths = [];
@@ -5032,7 +4844,7 @@ class SDK {
5032
4844
  }
5033
4845
  };
5034
4846
  this.addPath = async function(path) {
5035
- const tag6 = `${TAG9} | addPath | `;
4847
+ const tag6 = `${TAG10} | addPath | `;
5036
4848
  try {
5037
4849
  this.paths.push(path);
5038
4850
  const pubkey = await getPubkey(path.networks[0], path, this.keepKeySdk, this.context);
@@ -5046,7 +4858,7 @@ class SDK {
5046
4858
  }
5047
4859
  };
5048
4860
  this.addPaths = async function(paths) {
5049
- const tag6 = `${TAG9} | addPaths | `;
4861
+ const tag6 = `${TAG10} | addPaths | `;
5050
4862
  try {
5051
4863
  console.log(tag6, `Adding ${paths.length} paths in batch mode...`);
5052
4864
  this.paths.push(...paths);
@@ -5082,7 +4894,7 @@ class SDK {
5082
4894
  return this.getGasAssets();
5083
4895
  };
5084
4896
  this.getGasAssets = async function() {
5085
- const tag6 = `${TAG9} | getGasAssets | `;
4897
+ const tag6 = `${TAG10} | getGasAssets | `;
5086
4898
  try {
5087
4899
  for (let i = 0;i < this.blockchains.length; i++) {
5088
4900
  let networkId = this.blockchains[i];
@@ -5125,7 +4937,7 @@ class SDK {
5125
4937
  }
5126
4938
  };
5127
4939
  this.getPubkeys = async function() {
5128
- const tag6 = `${TAG9} | getPubkeys | `;
4940
+ const tag6 = `${TAG10} | getPubkeys | `;
5129
4941
  try {
5130
4942
  if (this.paths.length === 0)
5131
4943
  throw new Error("No paths found!");
@@ -5146,7 +4958,7 @@ class SDK {
5146
4958
  }
5147
4959
  };
5148
4960
  this.getBalancesForNetworks = async function(networkIds) {
5149
- const tag6 = `${TAG9} | getBalancesForNetworks | `;
4961
+ const tag6 = `${TAG10} | getBalancesForNetworks | `;
5150
4962
  try {
5151
4963
  if (!this.pioneer) {
5152
4964
  console.error(tag6, "ERROR: Pioneer client not initialized! this.pioneer is:", this.pioneer);
@@ -5201,7 +5013,7 @@ class SDK {
5201
5013
  }
5202
5014
  };
5203
5015
  this.getBalances = async function() {
5204
- const tag6 = `${TAG9} | getBalances | `;
5016
+ const tag6 = `${TAG10} | getBalances | `;
5205
5017
  try {
5206
5018
  return await this.getBalancesForNetworks(this.blockchains);
5207
5019
  } catch (e) {
@@ -5210,7 +5022,7 @@ class SDK {
5210
5022
  }
5211
5023
  };
5212
5024
  this.getBalance = async function(networkId) {
5213
- const tag6 = `${TAG9} | getBalance | `;
5025
+ const tag6 = `${TAG10} | getBalance | `;
5214
5026
  try {
5215
5027
  const results = await this.getBalancesForNetworks([networkId]);
5216
5028
  const filtered = results.filter(async (b2) => b2.networkId === await import_pioneer_caip7.networkIdToCaip(networkId));
@@ -5221,7 +5033,7 @@ class SDK {
5221
5033
  }
5222
5034
  };
5223
5035
  this.getFees = async function(networkId) {
5224
- const tag6 = `${TAG9} | getFees | `;
5036
+ const tag6 = `${TAG10} | getFees | `;
5225
5037
  try {
5226
5038
  if (!this.pioneer) {
5227
5039
  throw new Error("Pioneer client not initialized. Call init() first.");
@@ -5236,7 +5048,7 @@ class SDK {
5236
5048
  return estimateTransactionFee(feeRate, unit, networkType, txSize);
5237
5049
  };
5238
5050
  this.getCharts = async function() {
5239
- const tag6 = `${TAG9} | getCharts | `;
5051
+ const tag6 = `${TAG10} | getCharts | `;
5240
5052
  try {
5241
5053
  console.log(tag6, "Fetching charts");
5242
5054
  const newBalances = await getCharts(this.blockchains, this.pioneer, this.pubkeys, this.context);
@@ -5258,7 +5070,7 @@ class SDK {
5258
5070
  }
5259
5071
  };
5260
5072
  this.setContext = async (context) => {
5261
- const tag6 = `${TAG9} | setContext | `;
5073
+ const tag6 = `${TAG10} | setContext | `;
5262
5074
  try {
5263
5075
  if (!context)
5264
5076
  throw Error("context required!");
@@ -5271,7 +5083,7 @@ class SDK {
5271
5083
  }
5272
5084
  };
5273
5085
  this.setContextType = async (contextType) => {
5274
- const tag6 = `${TAG9} | setContextType | `;
5086
+ const tag6 = `${TAG10} | setContextType | `;
5275
5087
  try {
5276
5088
  if (!contextType)
5277
5089
  throw Error("contextType required!");
@@ -5284,7 +5096,7 @@ class SDK {
5284
5096
  }
5285
5097
  };
5286
5098
  this.refresh = async () => {
5287
- const tag6 = `${TAG9} | refresh | `;
5099
+ const tag6 = `${TAG10} | refresh | `;
5288
5100
  try {
5289
5101
  await this.sync();
5290
5102
  return this.balances;
@@ -5294,7 +5106,7 @@ class SDK {
5294
5106
  }
5295
5107
  };
5296
5108
  this.setAssetContext = async function(asset) {
5297
- const tag6 = `${TAG9} | setAssetContext | `;
5109
+ const tag6 = `${TAG10} | setAssetContext | `;
5298
5110
  try {
5299
5111
  if (!asset) {
5300
5112
  this.assetContext = null;
@@ -5493,7 +5305,7 @@ class SDK {
5493
5305
  }
5494
5306
  };
5495
5307
  this.setPubkeyContext = async function(pubkey) {
5496
- let tag6 = `${TAG9} | setPubkeyContext | `;
5308
+ let tag6 = `${TAG10} | setPubkeyContext | `;
5497
5309
  try {
5498
5310
  if (!pubkey)
5499
5311
  throw Error("pubkey is required");
@@ -5512,7 +5324,7 @@ class SDK {
5512
5324
  }
5513
5325
  };
5514
5326
  this.setOutboundAssetContext = async function(asset) {
5515
- const tag6 = `${TAG9} | setOutputAssetContext | `;
5327
+ const tag6 = `${TAG10} | setOutputAssetContext | `;
5516
5328
  try {
5517
5329
  console.log(tag6, "0. asset: ", asset);
5518
5330
  if (!asset) {