@pioneer-platform/pioneer-sdk 4.20.6 → 4.20.8

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,6 +23,398 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
23
23
  throw Error('Dynamic require of "' + x + '" is not supported');
24
24
  });
25
25
 
26
+ // node_modules/@pioneer-platform/pioneer-client/lib/index.js
27
+ var require_lib = __commonJS((exports) => {
28
+ var __assign = exports && exports.__assign || function() {
29
+ __assign = Object.assign || function(t) {
30
+ for (var s, i = 1, n = arguments.length;i < n; i++) {
31
+ s = arguments[i];
32
+ for (var p in s)
33
+ if (Object.prototype.hasOwnProperty.call(s, p))
34
+ t[p] = s[p];
35
+ }
36
+ return t;
37
+ };
38
+ return __assign.apply(this, arguments);
39
+ };
40
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
41
+ function adopt(value) {
42
+ return value instanceof P ? value : new P(function(resolve) {
43
+ resolve(value);
44
+ });
45
+ }
46
+ return new (P || (P = Promise))(function(resolve, reject) {
47
+ function fulfilled(value) {
48
+ try {
49
+ step(generator.next(value));
50
+ } catch (e) {
51
+ reject(e);
52
+ }
53
+ }
54
+ function rejected(value) {
55
+ try {
56
+ step(generator["throw"](value));
57
+ } catch (e) {
58
+ reject(e);
59
+ }
60
+ }
61
+ function step(result) {
62
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
63
+ }
64
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
65
+ });
66
+ };
67
+ var __generator = exports && exports.__generator || function(thisArg, body) {
68
+ var _ = { label: 0, sent: function() {
69
+ if (t[0] & 1)
70
+ throw t[1];
71
+ return t[1];
72
+ }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
73
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
74
+ return this;
75
+ }), g;
76
+ function verb(n) {
77
+ return function(v) {
78
+ return step([n, v]);
79
+ };
80
+ }
81
+ function step(op) {
82
+ if (f)
83
+ throw new TypeError("Generator is already executing.");
84
+ while (g && (g = 0, op[0] && (_ = 0)), _)
85
+ try {
86
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
87
+ return t;
88
+ if (y = 0, t)
89
+ op = [op[0] & 2, t.value];
90
+ switch (op[0]) {
91
+ case 0:
92
+ case 1:
93
+ t = op;
94
+ break;
95
+ case 4:
96
+ _.label++;
97
+ return { value: op[1], done: false };
98
+ case 5:
99
+ _.label++;
100
+ y = op[1];
101
+ op = [0];
102
+ continue;
103
+ case 7:
104
+ op = _.ops.pop();
105
+ _.trys.pop();
106
+ continue;
107
+ default:
108
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
109
+ _ = 0;
110
+ continue;
111
+ }
112
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
113
+ _.label = op[1];
114
+ break;
115
+ }
116
+ if (op[0] === 6 && _.label < t[1]) {
117
+ _.label = t[1];
118
+ t = op;
119
+ break;
120
+ }
121
+ if (t && _.label < t[2]) {
122
+ _.label = t[2];
123
+ _.ops.push(op);
124
+ break;
125
+ }
126
+ if (t[2])
127
+ _.ops.pop();
128
+ _.trys.pop();
129
+ continue;
130
+ }
131
+ op = body.call(thisArg, _);
132
+ } catch (e) {
133
+ op = [6, e];
134
+ y = 0;
135
+ } finally {
136
+ f = t = 0;
137
+ }
138
+ if (op[0] & 5)
139
+ throw op[1];
140
+ return { value: op[0] ? op[1] : undefined, done: true };
141
+ }
142
+ };
143
+ Object.defineProperty(exports, "__esModule", { value: true });
144
+ exports.Pioneer = undefined;
145
+ var Swagger;
146
+ var log;
147
+ if (typeof window === "undefined") {
148
+ Swagger = __require("swagger-client");
149
+ log = __require("@pioneer-platform/loggerdog")();
150
+ } else {
151
+ Swagger = null;
152
+ log = {
153
+ debug: function() {
154
+ var args = [];
155
+ for (var _i = 0;_i < arguments.length; _i++) {
156
+ args[_i] = arguments[_i];
157
+ }
158
+ return console.debug.apply(console, args);
159
+ },
160
+ info: function() {
161
+ var args = [];
162
+ for (var _i = 0;_i < arguments.length; _i++) {
163
+ args[_i] = arguments[_i];
164
+ }
165
+ return console.info.apply(console, args);
166
+ },
167
+ warn: function() {
168
+ var args = [];
169
+ for (var _i = 0;_i < arguments.length; _i++) {
170
+ args[_i] = arguments[_i];
171
+ }
172
+ return console.warn.apply(console, args);
173
+ },
174
+ error: function() {
175
+ var args = [];
176
+ for (var _i = 0;_i < arguments.length; _i++) {
177
+ args[_i] = arguments[_i];
178
+ }
179
+ return console.error.apply(console, args);
180
+ }
181
+ };
182
+ }
183
+ var TAG = " | Client | ";
184
+ function customHttpClient(req) {
185
+ var _this = this;
186
+ return new Promise(function(resolve, reject) {
187
+ var timer = setTimeout(function() {
188
+ reject(new Error("Request timed out"));
189
+ }, 60000);
190
+ log.debug(TAG, "HTTP request URL:", req.url);
191
+ log.debug(TAG, "HTTP request details:", req);
192
+ if (Swagger && Swagger.http) {
193
+ Swagger.http(req).then(function(response) {
194
+ clearTimeout(timer);
195
+ resolve(response);
196
+ }).catch(function(err) {
197
+ clearTimeout(timer);
198
+ reject(err);
199
+ });
200
+ } else {
201
+ var fetchOptions = {
202
+ method: req.method || "GET",
203
+ headers: req.headers,
204
+ body: req.body ? typeof req.body === "string" ? req.body : JSON.stringify(req.body) : undefined
205
+ };
206
+ fetch(req.url, fetchOptions).then(function(response) {
207
+ return __awaiter(_this, undefined, undefined, function() {
208
+ var text, body, headers;
209
+ return __generator(this, function(_a) {
210
+ switch (_a.label) {
211
+ case 0:
212
+ clearTimeout(timer);
213
+ return [4, response.text()];
214
+ case 1:
215
+ text = _a.sent();
216
+ try {
217
+ body = JSON.parse(text);
218
+ } catch (jsonError) {
219
+ body = text;
220
+ }
221
+ headers = {};
222
+ response.headers.forEach(function(value, key) {
223
+ headers[key] = value;
224
+ });
225
+ resolve({
226
+ status: response.status,
227
+ body,
228
+ headers
229
+ });
230
+ return [2];
231
+ }
232
+ });
233
+ });
234
+ }).catch(function(err) {
235
+ clearTimeout(timer);
236
+ reject(err);
237
+ });
238
+ }
239
+ });
240
+ }
241
+ var Pioneer = function() {
242
+ function Pioneer2(spec, config) {
243
+ this.spec = spec;
244
+ this.queryKey = config.queryKey;
245
+ this.pioneer = {};
246
+ this.timeout = config.queryKey || 45000;
247
+ }
248
+ Pioneer2.prototype.init = function() {
249
+ return __awaiter(this, undefined, undefined, function() {
250
+ var tag, _a, specResponse, specData_1, e_1;
251
+ var _this = this;
252
+ return __generator(this, function(_b) {
253
+ switch (_b.label) {
254
+ case 0:
255
+ tag = TAG + " | init | ";
256
+ _b.label = 1;
257
+ case 1:
258
+ _b.trys.push([1, 7, , 8]);
259
+ if (!this.queryKey)
260
+ throw Error(" You must create an api key! ");
261
+ if (!Swagger)
262
+ return [3, 3];
263
+ _a = this;
264
+ return [4, new Swagger({
265
+ url: this.spec,
266
+ requestInterceptor: function(req) {
267
+ req.headers.Authorization = _this.queryKey;
268
+ if ((req.method === "POST" || req.method === "post") && req.body) {
269
+ log.debug(TAG, "Request interceptor - method:", req.method);
270
+ log.debug(TAG, "Body type:", typeof req.body);
271
+ log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
272
+ if (!req.headers)
273
+ req.headers = {};
274
+ if (!req.headers["Content-Type"]) {
275
+ req.headers["Content-Type"] = "application/json";
276
+ }
277
+ if (typeof req.body !== "string") {
278
+ log.debug(TAG, "Converting body to JSON string");
279
+ req.body = JSON.stringify(req.body);
280
+ }
281
+ }
282
+ return req;
283
+ },
284
+ http: customHttpClient
285
+ })];
286
+ case 2:
287
+ _a.client = _b.sent();
288
+ return [3, 6];
289
+ case 3:
290
+ return [4, fetch(this.spec)];
291
+ case 4:
292
+ specResponse = _b.sent();
293
+ return [4, specResponse.json()];
294
+ case 5:
295
+ specData_1 = _b.sent();
296
+ this.client = {
297
+ spec: specData_1,
298
+ execute: function(request) {
299
+ return __awaiter(_this, undefined, undefined, function() {
300
+ var operationId, parameters, requestBody, targetPath, targetMethod, path, method, baseUrl, url, httpReq;
301
+ return __generator(this, function(_a2) {
302
+ switch (_a2.label) {
303
+ case 0:
304
+ operationId = request.operationId, parameters = request.parameters, requestBody = request.requestBody;
305
+ targetPath = "";
306
+ targetMethod = "";
307
+ for (path in specData_1.paths) {
308
+ for (method in specData_1.paths[path]) {
309
+ if (specData_1.paths[path][method].operationId === operationId) {
310
+ targetPath = path;
311
+ targetMethod = method;
312
+ break;
313
+ }
314
+ }
315
+ if (targetPath)
316
+ break;
317
+ }
318
+ if (!targetPath) {
319
+ throw new Error("Operation ".concat(operationId, " not found in spec"));
320
+ }
321
+ baseUrl = this.spec.replace("/spec/swagger.json", "");
322
+ if (specData_1.servers && specData_1.servers.length > 0) {
323
+ baseUrl = specData_1.servers[0].url;
324
+ }
325
+ url = "".concat(baseUrl).concat(targetPath);
326
+ httpReq = {
327
+ method: targetMethod.toUpperCase(),
328
+ url,
329
+ headers: {
330
+ Authorization: this.queryKey,
331
+ "Content-Type": "application/json"
332
+ },
333
+ body: requestBody
334
+ };
335
+ return [4, customHttpClient(httpReq)];
336
+ case 1:
337
+ return [2, _a2.sent()];
338
+ }
339
+ });
340
+ });
341
+ }
342
+ };
343
+ _b.label = 6;
344
+ case 6:
345
+ Object.keys(this.client.spec.paths).forEach(function(path) {
346
+ Object.keys(_this.client.spec.paths[path]).forEach(function(method) {
347
+ var operationId = _this.client.spec.paths[path][method].operationId;
348
+ _this.pioneer[operationId] = function(parameters) {
349
+ return __awaiter(_this, undefined, undefined, function() {
350
+ var invalidElements, request, result, e_2;
351
+ return __generator(this, function(_a2) {
352
+ switch (_a2.label) {
353
+ case 0:
354
+ _a2.trys.push([0, 2, , 3]);
355
+ log.debug(TAG, "".concat(operationId, " called with:"), parameters);
356
+ if (operationId === "GetMarketInfo") {
357
+ if (!Array.isArray(parameters)) {
358
+ throw new Error("GetMarketInfo requires an array of CAIP strings, got ".concat(typeof parameters));
359
+ }
360
+ invalidElements = parameters.map(function(item, index) {
361
+ return { item, index, type: typeof item };
362
+ }).filter(function(_a3) {
363
+ var item = _a3.item;
364
+ return !item || typeof item !== "string";
365
+ });
366
+ if (invalidElements.length > 0) {
367
+ console.error("\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:", invalidElements);
368
+ throw new Error("GetMarketInfo array contains ".concat(invalidElements.length, " invalid element(s). ") + "All elements must be CAIP strings. First invalid at index ".concat(invalidElements[0].index, ": ") + "".concat(JSON.stringify(invalidElements[0].item), " (type: ").concat(invalidElements[0].type, ")"));
369
+ }
370
+ log.debug(TAG, "GetMarketInfo validation passed: ".concat(parameters.length, " valid CAIP strings"));
371
+ }
372
+ request = {
373
+ operationId,
374
+ parameters: {
375
+ Authorization: this.queryKey
376
+ },
377
+ responseContentType: "application/json"
378
+ };
379
+ if (method === "post") {
380
+ request.requestBody = parameters;
381
+ } else {
382
+ request.parameters = __assign(__assign({}, parameters), { Authorization: this.queryKey });
383
+ }
384
+ log.debug(TAG, "".concat(operationId, " request:"), request);
385
+ return [4, this.client.execute(request)];
386
+ case 1:
387
+ result = _a2.sent();
388
+ return [2, { data: result.body }];
389
+ case 2:
390
+ e_2 = _a2.sent();
391
+ log.error(TAG, "Operation error:", e_2);
392
+ throw e_2;
393
+ case 3:
394
+ return [2];
395
+ }
396
+ });
397
+ });
398
+ };
399
+ });
400
+ });
401
+ return [2, this.pioneer];
402
+ case 7:
403
+ e_1 = _b.sent();
404
+ log.error(TAG, "Initialization error:", e_1);
405
+ throw e_1;
406
+ case 8:
407
+ return [2];
408
+ }
409
+ });
410
+ });
411
+ };
412
+ return Pioneer2;
413
+ }();
414
+ exports.Pioneer = Pioneer;
415
+ exports.default = Pioneer;
416
+ });
417
+
26
418
  // node_modules/coinselect/utils.js
27
419
  var require_utils = __commonJS((exports, module) => {
28
420
  var TX_EMPTY_SIZE = 4 + 1 + 1 + 4;
@@ -220,9 +612,9 @@ var require_split = __commonJS((exports, module) => {
220
612
  });
221
613
 
222
614
  // src/index.ts
615
+ var import_pioneer_client = __toESM(require_lib(), 1);
223
616
  import { KeepKeySdk } from "@keepkey/keepkey-sdk";
224
617
  import { caipToNetworkId as caipToNetworkId7, networkIdToCaip as networkIdToCaip2 } from "@pioneer-platform/pioneer-caip";
225
- import Pioneer from "@pioneer-platform/pioneer-client";
226
618
  import { addressNListToBIP32 as addressNListToBIP322, getPaths } from "@pioneer-platform/pioneer-coins";
227
619
  import { assetData as assetData2 } from "@pioneer-platform/pioneer-discovery";
228
620
  import { Events } from "@pioneer-platform/pioneer-events";
@@ -3707,8 +4099,62 @@ function buildDashboardFromBalances(balances, blockchains, assetsMap) {
3707
4099
  return dashboardData;
3708
4100
  }
3709
4101
 
4102
+ // src/utils/sync-market.ts
4103
+ var TAG8 = " | sync-market | ";
4104
+ async function syncMarket(balances, pioneer) {
4105
+ const tag5 = `${TAG8} | syncMarket | `;
4106
+ try {
4107
+ const invalidBalances = balances.filter((b3) => !b3 || !b3.caip || typeof b3.caip !== "string" || !b3.caip.includes(":"));
4108
+ if (invalidBalances.length > 0) {
4109
+ console.warn(tag5, `Found ${invalidBalances.length} balances with invalid CAIPs:`, invalidBalances.map((b3) => ({
4110
+ caip: b3?.caip,
4111
+ type: typeof b3?.caip,
4112
+ symbol: b3?.symbol,
4113
+ balance: b3?.balance
4114
+ })));
4115
+ }
4116
+ let allCaips = balances.filter((b3) => b3 && b3.caip && typeof b3.caip === "string" && b3.caip.trim().length > 0).map((b3) => b3.caip);
4117
+ allCaips = [...new Set(allCaips)];
4118
+ allCaips = allCaips.filter((caip) => caip && typeof caip === "string" && caip.trim().length > 0 && caip.includes(":"));
4119
+ console.log("GetMarketInfo: payload: ", allCaips);
4120
+ console.log("GetMarketInfo: payload type: ", typeof allCaips);
4121
+ console.log("GetMarketInfo: payload length: ", allCaips.length);
4122
+ const invalidEntries = allCaips.filter((caip) => typeof caip !== "string");
4123
+ if (invalidEntries.length > 0) {
4124
+ console.error(tag5, "CRITICAL: Invalid entries detected in allCaips:", invalidEntries);
4125
+ throw new Error("Invalid CAIP entries detected - aborting market sync");
4126
+ }
4127
+ if (allCaips && allCaips.length > 0) {
4128
+ try {
4129
+ let allPrices = await pioneer.GetMarketInfo(allCaips);
4130
+ console.log("GetMarketInfo: response: ", allPrices);
4131
+ const priceMap = {};
4132
+ if (allPrices && allPrices.data) {
4133
+ for (let i = 0;i < allCaips.length && i < allPrices.data.length; i++) {
4134
+ priceMap[allCaips[i]] = allPrices.data[i];
4135
+ }
4136
+ }
4137
+ for (let balance of balances) {
4138
+ if (balance && balance.caip && priceMap[balance.caip] !== undefined) {
4139
+ balance.price = priceMap[balance.caip];
4140
+ balance.priceUsd = priceMap[balance.caip];
4141
+ balance.valueUsd = balance.price * (balance.balance || 0);
4142
+ }
4143
+ }
4144
+ } catch (apiError) {
4145
+ console.error(tag5, "API error fetching market info:", apiError);
4146
+ console.warn(tag5, "Continuing without market prices");
4147
+ }
4148
+ }
4149
+ return true;
4150
+ } catch (e) {
4151
+ console.error(tag5, "e:", e);
4152
+ throw e;
4153
+ }
4154
+ }
4155
+
3710
4156
  // src/index.ts
3711
- var TAG8 = " | Pioneer-sdk | ";
4157
+ var TAG9 = " | Pioneer-sdk | ";
3712
4158
 
3713
4159
  class SDK {
3714
4160
  status;
@@ -3872,7 +4318,7 @@ class SDK {
3872
4318
  return true;
3873
4319
  };
3874
4320
  this.setPubkeys = (newPubkeys) => {
3875
- const tag5 = `${TAG8} | setPubkeys | `;
4321
+ const tag5 = `${TAG9} | setPubkeys | `;
3876
4322
  this.pubkeys = [];
3877
4323
  this.pubkeySet.clear();
3878
4324
  let added = 0;
@@ -3883,7 +4329,7 @@ class SDK {
3883
4329
  }
3884
4330
  };
3885
4331
  this.getUnifiedPortfolio = async function() {
3886
- const tag5 = `${TAG8} | getUnifiedPortfolio | `;
4332
+ const tag5 = `${TAG9} | getUnifiedPortfolio | `;
3887
4333
  try {
3888
4334
  const startTime = performance.now();
3889
4335
  try {
@@ -3991,7 +4437,7 @@ class SDK {
3991
4437
  }
3992
4438
  };
3993
4439
  this.init = async function(walletsVerbose, setup) {
3994
- const tag5 = `${TAG8} | init | `;
4440
+ const tag5 = `${TAG9} | init | `;
3995
4441
  try {
3996
4442
  if (!this.username)
3997
4443
  throw Error("username required!");
@@ -4008,7 +4454,7 @@ class SDK {
4008
4454
  const pioneerConfig = {
4009
4455
  ...config
4010
4456
  };
4011
- const PioneerClient = new Pioneer(this.spec, pioneerConfig);
4457
+ const PioneerClient = new import_pioneer_client.default(this.spec, pioneerConfig);
4012
4458
  this.pioneer = await PioneerClient.init();
4013
4459
  if (!this.pioneer)
4014
4460
  throw Error("Failed to init pioneer server!");
@@ -4082,58 +4528,10 @@ class SDK {
4082
4528
  return buildDashboardFromBalances(this.balances, this.blockchains, this.assetsMap);
4083
4529
  };
4084
4530
  this.syncMarket = async function() {
4085
- const tag5 = `${TAG8} | syncMarket | `;
4086
- try {
4087
- const invalidBalances = this.balances.filter((b3) => !b3 || !b3.caip || typeof b3.caip !== "string" || !b3.caip.includes(":"));
4088
- if (invalidBalances.length > 0) {
4089
- console.warn(tag5, `Found ${invalidBalances.length} balances with invalid CAIPs:`, invalidBalances.map((b3) => ({
4090
- caip: b3?.caip,
4091
- type: typeof b3?.caip,
4092
- symbol: b3?.symbol,
4093
- balance: b3?.balance
4094
- })));
4095
- }
4096
- let allCaips = this.balances.filter((b3) => b3 && b3.caip && typeof b3.caip === "string" && b3.caip.trim().length > 0).map((b3) => b3.caip);
4097
- allCaips = [...new Set(allCaips)];
4098
- allCaips = allCaips.filter((caip) => caip && typeof caip === "string" && caip.trim().length > 0 && caip.includes(":"));
4099
- console.log("GetMarketInfo: payload: ", allCaips);
4100
- console.log("GetMarketInfo: payload type: ", typeof allCaips);
4101
- console.log("GetMarketInfo: payload length: ", allCaips.length);
4102
- const invalidEntries = allCaips.filter((caip) => typeof caip !== "string");
4103
- if (invalidEntries.length > 0) {
4104
- console.error(tag5, "CRITICAL: Invalid entries detected in allCaips:", invalidEntries);
4105
- throw new Error("Invalid CAIP entries detected - aborting market sync");
4106
- }
4107
- if (allCaips && allCaips.length > 0) {
4108
- try {
4109
- let allPrices = await this.pioneer.GetMarketInfo(allCaips);
4110
- console.log("GetMarketInfo: response: ", allPrices);
4111
- const priceMap = {};
4112
- if (allPrices && allPrices.data) {
4113
- for (let i = 0;i < allCaips.length && i < allPrices.data.length; i++) {
4114
- priceMap[allCaips[i]] = allPrices.data[i];
4115
- }
4116
- }
4117
- for (let balance of this.balances) {
4118
- if (balance && balance.caip && priceMap[balance.caip] !== undefined) {
4119
- balance.price = priceMap[balance.caip];
4120
- balance.priceUsd = priceMap[balance.caip];
4121
- balance.valueUsd = balance.price * (balance.balance || 0);
4122
- }
4123
- }
4124
- } catch (apiError) {
4125
- console.error(tag5, "API error fetching market info:", apiError);
4126
- console.warn(tag5, "Continuing without market prices");
4127
- }
4128
- }
4129
- return true;
4130
- } catch (e) {
4131
- console.error(tag5, "e:", e);
4132
- throw e;
4133
- }
4531
+ return syncMarket(this.balances, this.pioneer);
4134
4532
  };
4135
4533
  this.sync = async function() {
4136
- const tag5 = `${TAG8} | sync | `;
4534
+ const tag5 = `${TAG9} | sync | `;
4137
4535
  try {
4138
4536
  const matchesNetwork = (item, networkId) => {
4139
4537
  if (!item.networks || !Array.isArray(item.networks))
@@ -4286,7 +4684,7 @@ class SDK {
4286
4684
  }
4287
4685
  };
4288
4686
  this.buildTx = async function(sendPayload) {
4289
- let tag5 = TAG8 + " | buildTx | ";
4687
+ let tag5 = TAG9 + " | buildTx | ";
4290
4688
  try {
4291
4689
  const transactionDependencies = {
4292
4690
  context: this.context,
@@ -4308,7 +4706,7 @@ class SDK {
4308
4706
  }
4309
4707
  };
4310
4708
  this.buildDelegateTx = async function(caip, params) {
4311
- let tag5 = TAG8 + " | buildDelegateTx | ";
4709
+ let tag5 = TAG9 + " | buildDelegateTx | ";
4312
4710
  try {
4313
4711
  const delegateParams = {
4314
4712
  ...params,
@@ -4323,7 +4721,7 @@ class SDK {
4323
4721
  }
4324
4722
  };
4325
4723
  this.buildUndelegateTx = async function(caip, params) {
4326
- let tag5 = TAG8 + " | buildUndelegateTx | ";
4724
+ let tag5 = TAG9 + " | buildUndelegateTx | ";
4327
4725
  try {
4328
4726
  const undelegateParams = {
4329
4727
  ...params,
@@ -4338,7 +4736,7 @@ class SDK {
4338
4736
  }
4339
4737
  };
4340
4738
  this.buildClaimRewardsTx = async function(caip, params) {
4341
- let tag5 = TAG8 + " | buildClaimRewardsTx | ";
4739
+ let tag5 = TAG9 + " | buildClaimRewardsTx | ";
4342
4740
  try {
4343
4741
  const claimParams = {
4344
4742
  ...params,
@@ -4353,7 +4751,7 @@ class SDK {
4353
4751
  }
4354
4752
  };
4355
4753
  this.buildClaimAllRewardsTx = async function(caip, params) {
4356
- let tag5 = TAG8 + " | buildClaimAllRewardsTx | ";
4754
+ let tag5 = TAG9 + " | buildClaimAllRewardsTx | ";
4357
4755
  try {
4358
4756
  const claimAllParams = {
4359
4757
  ...params,
@@ -4367,7 +4765,7 @@ class SDK {
4367
4765
  }
4368
4766
  };
4369
4767
  this.signTx = async function(unsignedTx) {
4370
- let tag5 = TAG8 + " | signTx | ";
4768
+ let tag5 = TAG9 + " | signTx | ";
4371
4769
  try {
4372
4770
  const transactionDependencies = {
4373
4771
  context: this.context,
@@ -4388,7 +4786,7 @@ class SDK {
4388
4786
  }
4389
4787
  };
4390
4788
  this.broadcastTx = async function(caip, signedTx) {
4391
- let tag5 = TAG8 + " | broadcastTx | ";
4789
+ let tag5 = TAG9 + " | broadcastTx | ";
4392
4790
  try {
4393
4791
  const transactionDependencies = {
4394
4792
  context: this.context,
@@ -4412,7 +4810,7 @@ class SDK {
4412
4810
  }
4413
4811
  };
4414
4812
  this.swap = async function(swapPayload) {
4415
- let tag5 = `${TAG8} | swap | `;
4813
+ let tag5 = `${TAG9} | swap | `;
4416
4814
  try {
4417
4815
  if (!swapPayload)
4418
4816
  throw Error("swapPayload required!");
@@ -4547,7 +4945,7 @@ class SDK {
4547
4945
  }
4548
4946
  };
4549
4947
  this.transfer = async function(sendPayload) {
4550
- let tag5 = `${TAG8} | transfer | `;
4948
+ let tag5 = `${TAG9} | transfer | `;
4551
4949
  try {
4552
4950
  if (!sendPayload)
4553
4951
  throw Error("sendPayload required!");
@@ -4642,7 +5040,7 @@ class SDK {
4642
5040
  }
4643
5041
  };
4644
5042
  this.setBlockchains = async function(blockchains) {
4645
- const tag5 = `${TAG8} | setBlockchains | `;
5043
+ const tag5 = `${TAG9} | setBlockchains | `;
4646
5044
  try {
4647
5045
  if (!blockchains)
4648
5046
  throw Error("blockchains required!");
@@ -4658,7 +5056,7 @@ class SDK {
4658
5056
  }
4659
5057
  };
4660
5058
  this.addAsset = async function(caip, data) {
4661
- let tag5 = TAG8 + " | addAsset | ";
5059
+ let tag5 = TAG9 + " | addAsset | ";
4662
5060
  try {
4663
5061
  let success = false;
4664
5062
  if (!caip)
@@ -4696,7 +5094,7 @@ class SDK {
4696
5094
  }
4697
5095
  };
4698
5096
  this.clearWalletState = async function() {
4699
- const tag5 = `${TAG8} | clearWalletState | `;
5097
+ const tag5 = `${TAG9} | clearWalletState | `;
4700
5098
  try {
4701
5099
  this.context = null;
4702
5100
  this.paths = [];
@@ -4711,7 +5109,7 @@ class SDK {
4711
5109
  }
4712
5110
  };
4713
5111
  this.addPath = async function(path) {
4714
- const tag5 = `${TAG8} | addPath | `;
5112
+ const tag5 = `${TAG9} | addPath | `;
4715
5113
  try {
4716
5114
  this.paths.push(path);
4717
5115
  const pubkey = await getPubkey(path.networks[0], path, this.keepKeySdk, this.context);
@@ -4725,7 +5123,7 @@ class SDK {
4725
5123
  }
4726
5124
  };
4727
5125
  this.addPaths = async function(paths) {
4728
- const tag5 = `${TAG8} | addPaths | `;
5126
+ const tag5 = `${TAG9} | addPaths | `;
4729
5127
  try {
4730
5128
  console.log(tag5, `Adding ${paths.length} paths in batch mode...`);
4731
5129
  this.paths.push(...paths);
@@ -4761,7 +5159,7 @@ class SDK {
4761
5159
  return this.getGasAssets();
4762
5160
  };
4763
5161
  this.getGasAssets = async function() {
4764
- const tag5 = `${TAG8} | getGasAssets | `;
5162
+ const tag5 = `${TAG9} | getGasAssets | `;
4765
5163
  try {
4766
5164
  for (let i = 0;i < this.blockchains.length; i++) {
4767
5165
  let networkId = this.blockchains[i];
@@ -4804,7 +5202,7 @@ class SDK {
4804
5202
  }
4805
5203
  };
4806
5204
  this.getPubkeys = async function() {
4807
- const tag5 = `${TAG8} | getPubkeys | `;
5205
+ const tag5 = `${TAG9} | getPubkeys | `;
4808
5206
  try {
4809
5207
  if (this.paths.length === 0)
4810
5208
  throw new Error("No paths found!");
@@ -4825,7 +5223,7 @@ class SDK {
4825
5223
  }
4826
5224
  };
4827
5225
  this.getBalancesForNetworks = async function(networkIds) {
4828
- const tag5 = `${TAG8} | getBalancesForNetworks | `;
5226
+ const tag5 = `${TAG9} | getBalancesForNetworks | `;
4829
5227
  try {
4830
5228
  if (!this.pioneer) {
4831
5229
  console.error(tag5, "ERROR: Pioneer client not initialized! this.pioneer is:", this.pioneer);
@@ -4880,7 +5278,7 @@ class SDK {
4880
5278
  }
4881
5279
  };
4882
5280
  this.getBalances = async function() {
4883
- const tag5 = `${TAG8} | getBalances | `;
5281
+ const tag5 = `${TAG9} | getBalances | `;
4884
5282
  try {
4885
5283
  return await this.getBalancesForNetworks(this.blockchains);
4886
5284
  } catch (e) {
@@ -4889,7 +5287,7 @@ class SDK {
4889
5287
  }
4890
5288
  };
4891
5289
  this.getBalance = async function(networkId) {
4892
- const tag5 = `${TAG8} | getBalance | `;
5290
+ const tag5 = `${TAG9} | getBalance | `;
4893
5291
  try {
4894
5292
  const results = await this.getBalancesForNetworks([networkId]);
4895
5293
  const filtered = results.filter(async (b3) => b3.networkId === await networkIdToCaip2(networkId));
@@ -4900,7 +5298,7 @@ class SDK {
4900
5298
  }
4901
5299
  };
4902
5300
  this.getFees = async function(networkId) {
4903
- const tag5 = `${TAG8} | getFees | `;
5301
+ const tag5 = `${TAG9} | getFees | `;
4904
5302
  try {
4905
5303
  if (!this.pioneer) {
4906
5304
  throw new Error("Pioneer client not initialized. Call init() first.");
@@ -4915,7 +5313,7 @@ class SDK {
4915
5313
  return estimateTransactionFee(feeRate, unit, networkType, txSize);
4916
5314
  };
4917
5315
  this.getCharts = async function() {
4918
- const tag5 = `${TAG8} | getCharts | `;
5316
+ const tag5 = `${TAG9} | getCharts | `;
4919
5317
  try {
4920
5318
  console.log(tag5, "Fetching charts");
4921
5319
  const newBalances = await getCharts(this.blockchains, this.pioneer, this.pubkeys, this.context);
@@ -4937,7 +5335,7 @@ class SDK {
4937
5335
  }
4938
5336
  };
4939
5337
  this.setContext = async (context) => {
4940
- const tag5 = `${TAG8} | setContext | `;
5338
+ const tag5 = `${TAG9} | setContext | `;
4941
5339
  try {
4942
5340
  if (!context)
4943
5341
  throw Error("context required!");
@@ -4950,7 +5348,7 @@ class SDK {
4950
5348
  }
4951
5349
  };
4952
5350
  this.setContextType = async (contextType) => {
4953
- const tag5 = `${TAG8} | setContextType | `;
5351
+ const tag5 = `${TAG9} | setContextType | `;
4954
5352
  try {
4955
5353
  if (!contextType)
4956
5354
  throw Error("contextType required!");
@@ -4963,7 +5361,7 @@ class SDK {
4963
5361
  }
4964
5362
  };
4965
5363
  this.refresh = async () => {
4966
- const tag5 = `${TAG8} | refresh | `;
5364
+ const tag5 = `${TAG9} | refresh | `;
4967
5365
  try {
4968
5366
  await this.sync();
4969
5367
  return this.balances;
@@ -4973,7 +5371,7 @@ class SDK {
4973
5371
  }
4974
5372
  };
4975
5373
  this.setAssetContext = async function(asset) {
4976
- const tag5 = `${TAG8} | setAssetContext | `;
5374
+ const tag5 = `${TAG9} | setAssetContext | `;
4977
5375
  try {
4978
5376
  if (!asset) {
4979
5377
  this.assetContext = null;
@@ -5172,7 +5570,7 @@ class SDK {
5172
5570
  }
5173
5571
  };
5174
5572
  this.setPubkeyContext = async function(pubkey) {
5175
- let tag5 = `${TAG8} | setPubkeyContext | `;
5573
+ let tag5 = `${TAG9} | setPubkeyContext | `;
5176
5574
  try {
5177
5575
  if (!pubkey)
5178
5576
  throw Error("pubkey is required");
@@ -5191,7 +5589,7 @@ class SDK {
5191
5589
  }
5192
5590
  };
5193
5591
  this.setOutboundAssetContext = async function(asset) {
5194
- const tag5 = `${TAG8} | setOutputAssetContext | `;
5592
+ const tag5 = `${TAG9} | setOutputAssetContext | `;
5195
5593
  try {
5196
5594
  console.log(tag5, "0. asset: ", asset);
5197
5595
  if (!asset) {