@pioneer-platform/pioneer-sdk 8.15.15 → 8.15.17

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
@@ -798,13 +798,27 @@ var import_pioneer_caip8 = require("@pioneer-platform/pioneer-caip");
798
798
 
799
799
  // ../pioneer-client/lib/index.js
800
800
  var import_swagger_client = __toESM(require("swagger-client"));
801
- var import_loggerdog = __toESM(require("@pioneer-platform/loggerdog"));
802
- var log = typeof window === "undefined" ? import_loggerdog.default() : {
803
- debug: (...args) => console.debug(...args),
804
- info: (...args) => console.info(...args),
805
- warn: (...args) => console.warn(...args),
806
- error: (...args) => console.error(...args)
801
+
802
+ // ../pioneer-client/lib/utils/logger.js
803
+ var DEBUG = process.env.DEBUG === "true" || typeof window !== "undefined" && window.DEBUG;
804
+ var logger = {
805
+ info: (tag, ...args) => {
806
+ console.log(`[INFO] ${tag}`, ...args);
807
+ },
808
+ debug: (tag, ...args) => {
809
+ if (DEBUG) {
810
+ console.log(`[DEBUG] ${tag}`, ...args);
811
+ }
812
+ },
813
+ warn: (tag, ...args) => {
814
+ console.warn(`[WARN] ${tag}`, ...args);
815
+ },
816
+ error: (tag, ...args) => {
817
+ console.error(`[ERROR] ${tag}`, ...args);
818
+ }
807
819
  };
820
+
821
+ // ../pioneer-client/lib/index.js
808
822
  var Swagger = import_swagger_client.default;
809
823
  var TAG = " | Client | ";
810
824
  function customHttpClient(req) {
@@ -812,8 +826,8 @@ function customHttpClient(req) {
812
826
  const timer = setTimeout(() => {
813
827
  reject(new Error("Request timed out"));
814
828
  }, 60000);
815
- log.debug(TAG, "HTTP request URL:", req.url);
816
- log.debug(TAG, "HTTP request details:", req);
829
+ logger.debug(TAG, "HTTP request URL:", req.url);
830
+ logger.debug(TAG, "HTTP request details:", req);
817
831
  if (Swagger.http) {
818
832
  Swagger.http(req).then((response) => {
819
833
  clearTimeout(timer);
@@ -871,16 +885,16 @@ class Pioneer {
871
885
  requestInterceptor: (req) => {
872
886
  req.headers.Authorization = this.queryKey;
873
887
  if ((req.method === "POST" || req.method === "post") && req.body) {
874
- log.debug(TAG, "Request interceptor - method:", req.method);
875
- log.debug(TAG, "Body type:", typeof req.body);
876
- log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
888
+ logger.debug(TAG, "Request interceptor - method:", req.method);
889
+ logger.debug(TAG, "Body type:", typeof req.body);
890
+ logger.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
877
891
  if (!req.headers)
878
892
  req.headers = {};
879
893
  if (!req.headers["Content-Type"]) {
880
894
  req.headers["Content-Type"] = "application/json";
881
895
  }
882
896
  if (typeof req.body !== "string") {
883
- log.debug(TAG, "Converting body to JSON string");
897
+ logger.debug(TAG, "Converting body to JSON string");
884
898
  req.body = JSON.stringify(req.body);
885
899
  }
886
900
  }
@@ -893,9 +907,9 @@ class Pioneer {
893
907
  const operationId = this.client.spec.paths[path][method].operationId;
894
908
  this.pioneer[operationId] = async (parameters, queryParams) => {
895
909
  try {
896
- log.debug(TAG, `${operationId} called with:`, parameters);
910
+ logger.debug(TAG, `${operationId} called with:`, parameters);
897
911
  if (queryParams) {
898
- log.debug(TAG, `${operationId} query params:`, queryParams);
912
+ logger.debug(TAG, `${operationId} query params:`, queryParams);
899
913
  }
900
914
  if (operationId === "GetMarketInfo") {
901
915
  if (!Array.isArray(parameters)) {
@@ -906,7 +920,7 @@ class Pioneer {
906
920
  console.error(`\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:`, invalidElements);
907
921
  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})`);
908
922
  }
909
- log.debug(TAG, `GetMarketInfo validation passed: ${parameters.length} valid CAIP strings`);
923
+ logger.debug(TAG, `GetMarketInfo validation passed: ${parameters.length} valid CAIP strings`);
910
924
  }
911
925
  let request = {
912
926
  operationId,
@@ -925,11 +939,11 @@ class Pioneer {
925
939
  Authorization: this.queryKey
926
940
  };
927
941
  }
928
- log.debug(TAG, `${operationId} request:`, request);
942
+ logger.debug(TAG, `${operationId} request:`, request);
929
943
  const result = await this.client.execute(request);
930
944
  return { data: result.body };
931
945
  } catch (e) {
932
- log.error(TAG, "Operation error:", e);
946
+ logger.error(TAG, "Operation error:", e);
933
947
  throw e;
934
948
  }
935
949
  };
@@ -937,7 +951,7 @@ class Pioneer {
937
951
  });
938
952
  return this.pioneer;
939
953
  } catch (e) {
940
- log.error(TAG, "Initialization error:", e);
954
+ logger.error(TAG, "Initialization error:", e);
941
955
  throw e;
942
956
  }
943
957
  }
@@ -949,6 +963,25 @@ var import_pioneer_discovery2 = require("@pioneer-platform/pioneer-discovery");
949
963
  var import_pioneer_events = require("@pioneer-platform/pioneer-events");
950
964
  var import_events = __toESM(require("events"));
951
965
 
966
+ // src/utils/logger.ts
967
+ var DEBUG2 = process.env.DEBUG === "true" || typeof window !== "undefined" && window.DEBUG;
968
+ var logger2 = {
969
+ info: (tag, ...args) => {
970
+ console.log(`[INFO] ${tag}`, ...args);
971
+ },
972
+ debug: (tag, ...args) => {
973
+ if (DEBUG2) {
974
+ console.log(`[DEBUG] ${tag}`, ...args);
975
+ }
976
+ },
977
+ warn: (tag, ...args) => {
978
+ console.warn(`[WARN] ${tag}`, ...args);
979
+ },
980
+ error: (tag, ...args) => {
981
+ console.error(`[ERROR] ${tag}`, ...args);
982
+ }
983
+ };
984
+
952
985
  // src/getPubkey.ts
953
986
  var import_pioneer_caip = require("@pioneer-platform/pioneer-caip");
954
987
  var import_pioneer_coins = require("@pioneer-platform/pioneer-coins");
@@ -4059,7 +4092,6 @@ function filterPubkeysForAsset(pubkeys, caip, caipToNetworkId7) {
4059
4092
  }
4060
4093
 
4061
4094
  // src/utils/portfolio-helpers.ts
4062
- var log2 = require("@pioneer-platform/loggerdog")();
4063
4095
  var TAG9 = " | portfolio-helpers | ";
4064
4096
  function isCacheDataValid(portfolioData) {
4065
4097
  if (!portfolioData.networks || !Array.isArray(portfolioData.networks)) {
@@ -4082,22 +4114,22 @@ async function fetchMarketPrice(pioneer, caip) {
4082
4114
  const tag = TAG9 + " | fetchMarketPrice | ";
4083
4115
  try {
4084
4116
  if (!caip || typeof caip !== "string" || !caip.includes(":")) {
4085
- log2.warn(tag, "Invalid or missing CAIP, skipping market price fetch:", caip);
4117
+ logger2.warn(tag, "Invalid or missing CAIP, skipping market price fetch:", caip);
4086
4118
  return 0;
4087
4119
  }
4088
- log2.debug(tag, "Fetching fresh market price for:", caip);
4120
+ logger2.debug(tag, "Fetching fresh market price for:", caip);
4089
4121
  const marketData = await pioneer.GetMarketInfo([caip]);
4090
- log2.debug(tag, "Market data response:", marketData);
4122
+ logger2.debug(tag, "Market data response:", marketData);
4091
4123
  if (marketData && marketData.data && marketData.data.length > 0) {
4092
4124
  const price = marketData.data[0];
4093
- log2.debug(tag, "✅ Fresh market price:", price);
4125
+ logger2.debug(tag, "✅ Fresh market price:", price);
4094
4126
  return price;
4095
4127
  } else {
4096
- log2.warn(tag, "No market data returned for:", caip);
4128
+ logger2.warn(tag, "No market data returned for:", caip);
4097
4129
  return 0;
4098
4130
  }
4099
4131
  } catch (marketError) {
4100
- log2.error(tag, "Error fetching market price:", marketError);
4132
+ logger2.error(tag, "Error fetching market price:", marketError);
4101
4133
  return 0;
4102
4134
  }
4103
4135
  }
@@ -4111,7 +4143,7 @@ function extractPriceFromBalances(balances) {
4111
4143
  const valueUsd = parseFloat(balances[0].valueUsd);
4112
4144
  if (balance > 0 && valueUsd > 0) {
4113
4145
  priceValue = valueUsd / balance;
4114
- log2.debug(tag, "Calculated priceUsd from valueUsd/balance:", priceValue);
4146
+ logger2.debug(tag, "Calculated priceUsd from valueUsd/balance:", priceValue);
4115
4147
  }
4116
4148
  }
4117
4149
  return priceValue || 0;
@@ -4120,15 +4152,15 @@ function aggregateBalances(balances, caip) {
4120
4152
  const tag = TAG9 + " | aggregateBalances | ";
4121
4153
  let totalBalance = 0;
4122
4154
  let totalValueUsd = 0;
4123
- log2.debug(tag, `Aggregating ${balances.length} balance entries for ${caip}`);
4155
+ logger2.debug(tag, `Aggregating ${balances.length} balance entries for ${caip}`);
4124
4156
  for (const balanceEntry of balances) {
4125
4157
  const balance = parseFloat(balanceEntry.balance) || 0;
4126
4158
  const valueUsd = parseFloat(balanceEntry.valueUsd) || 0;
4127
4159
  totalBalance += balance;
4128
4160
  totalValueUsd += valueUsd;
4129
- log2.debug(tag, ` Balance entry: ${balance} (${valueUsd} USD)`);
4161
+ logger2.debug(tag, ` Balance entry: ${balance} (${valueUsd} USD)`);
4130
4162
  }
4131
- log2.debug(tag, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
4163
+ logger2.debug(tag, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
4132
4164
  return { totalBalance, totalValueUsd };
4133
4165
  }
4134
4166
  function updateBalancesWithPrice(balances, freshPriceUsd) {
@@ -4139,7 +4171,7 @@ function updateBalancesWithPrice(balances, freshPriceUsd) {
4139
4171
  const balanceAmount = parseFloat(balance.balance || 0);
4140
4172
  balance.valueUsd = (balanceAmount * freshPriceUsd).toString();
4141
4173
  }
4142
- log2.debug(tag, "Updated all balances with fresh price data");
4174
+ logger2.debug(tag, "Updated all balances with fresh price data");
4143
4175
  }
4144
4176
  function buildDashboardFromPortfolioData(portfolioData) {
4145
4177
  const cacheAge = portfolioData.lastUpdated ? Math.floor((Date.now() - portfolioData.lastUpdated) / 1000) : 0;
@@ -4197,19 +4229,18 @@ function enrichBalancesWithAssetInfo(balances, assetsMap, caipToNetworkId7) {
4197
4229
  }
4198
4230
 
4199
4231
  // src/utils/sync-state.ts
4200
- var log3 = require("@pioneer-platform/loggerdog")();
4201
4232
  var TAG10 = " | sync-state | ";
4202
4233
  function resolveAssetInfo(assetsMap, assetData, asset) {
4203
4234
  const tag = TAG10 + " | resolveAssetInfo | ";
4204
4235
  let assetInfo = assetsMap.get(asset.caip.toLowerCase());
4205
- log3.debug(tag, "assetInfo from assetsMap:", assetInfo);
4236
+ logger2.debug(tag, "assetInfo from assetsMap:", assetInfo);
4206
4237
  const assetInfoDiscovery = assetData[asset.caip];
4207
- log3.debug(tag, "assetInfoDiscovery:", assetInfoDiscovery);
4238
+ logger2.debug(tag, "assetInfoDiscovery:", assetInfoDiscovery);
4208
4239
  if (assetInfoDiscovery) {
4209
4240
  assetInfo = assetInfoDiscovery;
4210
4241
  }
4211
4242
  if (!assetInfo) {
4212
- log3.debug(tag, "Building placeholder asset for", asset.caip);
4243
+ logger2.debug(tag, "Building placeholder asset for", asset.caip);
4213
4244
  assetInfo = {
4214
4245
  caip: asset.caip.toLowerCase(),
4215
4246
  networkId: asset.networkId,
@@ -4331,19 +4362,18 @@ function validatePubkeysNetworks(pubkeys, tag = "") {
4331
4362
 
4332
4363
  // src/utils/path-discovery.ts
4333
4364
  var import_pioneer_coins4 = require("@pioneer-platform/pioneer-coins");
4334
- var log4 = require("@pioneer-platform/loggerdog")();
4335
4365
  async function ensurePathsForBlockchains(blockchains, currentPaths, tag) {
4336
4366
  let allPaths = [...currentPaths];
4337
4367
  for (const blockchain of blockchains) {
4338
4368
  const networkId = normalizeNetworkId(blockchain);
4339
4369
  const existingPaths = allPaths.filter((path) => matchesNetwork(path, networkId));
4340
4370
  if (existingPaths.length === 0) {
4341
- log4.info(tag, `Discovering paths for ${networkId}...`);
4371
+ logger2.info(tag, `Discovering paths for ${networkId}...`);
4342
4372
  const newPaths = import_pioneer_coins4.getPaths([networkId]);
4343
4373
  if (!newPaths || newPaths.length === 0) {
4344
4374
  throw new Error(`Path discovery failed for ${networkId}. ` + `Available blockchains: ${blockchains.join(", ")}`);
4345
4375
  }
4346
- log4.debug(tag, `Added ${newPaths.length} paths for ${networkId}`);
4376
+ logger2.debug(tag, `Added ${newPaths.length} paths for ${networkId}`);
4347
4377
  allPaths = allPaths.concat(newPaths);
4348
4378
  }
4349
4379
  }
@@ -4352,7 +4382,6 @@ async function ensurePathsForBlockchains(blockchains, currentPaths, tag) {
4352
4382
 
4353
4383
  // src/utils/pubkey-sync.ts
4354
4384
  var import_pioneer_coins5 = require("@pioneer-platform/pioneer-coins");
4355
- var log5 = require("@pioneer-platform/loggerdog")();
4356
4385
  async function syncPubkeysForBlockchains(blockchains, paths, existingPubkeys, keepKeySdk, context, getPubkeyFn, addPubkeyCallback, tag) {
4357
4386
  for (const blockchain of blockchains) {
4358
4387
  const networkId = normalizeNetworkId(blockchain);
@@ -4361,22 +4390,22 @@ async function syncPubkeysForBlockchains(blockchains, paths, existingPubkeys, ke
4361
4390
  const availablePaths = paths.map((p) => p.note || p.path || "unnamed").join(", ");
4362
4391
  throw new Error(`No paths found for ${networkId}. ` + `Available paths: ${availablePaths || "none"}`);
4363
4392
  }
4364
- log5.info(tag, `Syncing ${pathsForChain.length} pubkeys for ${networkId}...`);
4393
+ logger2.info(tag, `Syncing ${pathsForChain.length} pubkeys for ${networkId}...`);
4365
4394
  for (const path of pathsForChain) {
4366
4395
  const pathBip32 = import_pioneer_coins5.addressNListToBIP32(path.addressNListMaster);
4367
4396
  const existingPubkey = existingPubkeys.find((p) => p.pathMaster === pathBip32);
4368
4397
  if (!existingPubkey) {
4369
- log5.debug(tag, `Fetching pubkey for path ${pathBip32}...`);
4398
+ logger2.debug(tag, `Fetching pubkey for path ${pathBip32}...`);
4370
4399
  const newPubkey = await getPubkeyFn(blockchain, path, keepKeySdk, context);
4371
4400
  if (!newPubkey) {
4372
4401
  throw new Error(`Pubkey fetch failed for ${networkId} at path ${pathBip32}. ` + `Ensure hardware wallet is connected and unlocked.`);
4373
4402
  }
4374
4403
  addPubkeyCallback(newPubkey);
4375
- log5.debug(tag, `✓ Added pubkey for ${pathBip32}`);
4404
+ logger2.debug(tag, `✓ Added pubkey for ${pathBip32}`);
4376
4405
  }
4377
4406
  }
4378
4407
  }
4379
- log5.info(tag, `✅ Pubkey sync complete. Total pubkeys: ${existingPubkeys.length}`);
4408
+ logger2.info(tag, `✅ Pubkey sync complete. Total pubkeys: ${existingPubkeys.length}`);
4380
4409
  }
4381
4410
 
4382
4411
  // src/index.ts
@@ -4797,48 +4826,48 @@ class SDK {
4797
4826
  };
4798
4827
  this.sync = async function() {
4799
4828
  const tag6 = `${TAG12} | sync | `;
4800
- const log6 = require("@pioneer-platform/loggerdog")();
4829
+ const log = logger2;
4801
4830
  try {
4802
4831
  this.syncState = {
4803
4832
  ...createInitialSyncState(this.blockchains.length),
4804
4833
  syncProgress: 10
4805
4834
  };
4806
4835
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4807
- log6.info(tag6, "Fetching initial pubkeys...");
4836
+ log.info(tag6, "Fetching initial pubkeys...");
4808
4837
  await this.getPubkeys();
4809
4838
  this.syncState.syncProgress = 20;
4810
4839
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4811
- log6.info(tag6, "Discovering paths for blockchains...");
4840
+ log.info(tag6, "Discovering paths for blockchains...");
4812
4841
  this.paths = await ensurePathsForBlockchains(this.blockchains, this.paths, tag6);
4813
4842
  this.syncState.syncProgress = 30;
4814
4843
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4815
- log6.info(tag6, "Synchronizing pubkeys...");
4844
+ log.info(tag6, "Synchronizing pubkeys...");
4816
4845
  await syncPubkeysForBlockchains(this.blockchains, this.paths, this.pubkeys, this.keepKeySdk, this.context, getPubkey, (pubkey) => this.addPubkey(pubkey), tag6);
4817
4846
  this.syncState.syncProgress = 50;
4818
4847
  this.syncState.syncedChains = this.blockchains.length;
4819
4848
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4820
- log6.info(tag6, "Fetching balances...");
4849
+ log.info(tag6, "Fetching balances...");
4821
4850
  await this.getBalances();
4822
4851
  this.syncState.syncProgress = 70;
4823
4852
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4824
- log6.info(tag6, "Loading charts (tokens + portfolio)...");
4853
+ log.info(tag6, "Loading charts (tokens + portfolio)...");
4825
4854
  await this.getCharts();
4826
- log6.info(tag6, `Charts loaded. Total balances: ${this.balances.length}`);
4855
+ log.info(tag6, `Charts loaded. Total balances: ${this.balances.length}`);
4827
4856
  this.syncState.syncProgress = 85;
4828
4857
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4829
- log6.info(tag6, "Syncing market prices...");
4858
+ log.info(tag6, "Syncing market prices...");
4830
4859
  await this.syncMarket();
4831
4860
  this.syncState.syncProgress = 95;
4832
4861
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4833
- log6.info(tag6, "Building dashboard...");
4862
+ log.info(tag6, "Building dashboard...");
4834
4863
  this.dashboard = buildDashboardFromBalances(this.balances, [...new Set(this.blockchains)], this.assetsMap);
4835
4864
  this.syncState = createFreshSyncState(this.blockchains.length);
4836
4865
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4837
4866
  this.events.emit("SYNC_COMPLETE", this.syncState);
4838
- log6.info(tag6, "✅ Sync complete!");
4867
+ log.info(tag6, "✅ Sync complete!");
4839
4868
  return true;
4840
4869
  } catch (e) {
4841
- log6.error(tag6, "Sync failed:", e);
4870
+ log.error(tag6, "Sync failed:", e);
4842
4871
  this.syncState = {
4843
4872
  ...this.syncState,
4844
4873
  isSynced: false,
package/dist/index.es.js CHANGED
@@ -783,13 +783,27 @@ import { caipToNetworkId as caipToNetworkId7, networkIdToCaip as networkIdToCaip
783
783
 
784
784
  // ../pioneer-client/lib/index.js
785
785
  import SwaggerClient from "swagger-client";
786
- import loggerdog from "@pioneer-platform/loggerdog";
787
- var log = typeof window === "undefined" ? loggerdog() : {
788
- debug: (...args) => console.debug(...args),
789
- info: (...args) => console.info(...args),
790
- warn: (...args) => console.warn(...args),
791
- error: (...args) => console.error(...args)
786
+
787
+ // ../pioneer-client/lib/utils/logger.js
788
+ var DEBUG = process.env.DEBUG === "true" || typeof window !== "undefined" && window.DEBUG;
789
+ var logger = {
790
+ info: (tag, ...args) => {
791
+ console.log(`[INFO] ${tag}`, ...args);
792
+ },
793
+ debug: (tag, ...args) => {
794
+ if (DEBUG) {
795
+ console.log(`[DEBUG] ${tag}`, ...args);
796
+ }
797
+ },
798
+ warn: (tag, ...args) => {
799
+ console.warn(`[WARN] ${tag}`, ...args);
800
+ },
801
+ error: (tag, ...args) => {
802
+ console.error(`[ERROR] ${tag}`, ...args);
803
+ }
792
804
  };
805
+
806
+ // ../pioneer-client/lib/index.js
793
807
  var Swagger = SwaggerClient;
794
808
  var TAG = " | Client | ";
795
809
  function customHttpClient(req) {
@@ -797,8 +811,8 @@ function customHttpClient(req) {
797
811
  const timer = setTimeout(() => {
798
812
  reject(new Error("Request timed out"));
799
813
  }, 60000);
800
- log.debug(TAG, "HTTP request URL:", req.url);
801
- log.debug(TAG, "HTTP request details:", req);
814
+ logger.debug(TAG, "HTTP request URL:", req.url);
815
+ logger.debug(TAG, "HTTP request details:", req);
802
816
  if (Swagger.http) {
803
817
  Swagger.http(req).then((response) => {
804
818
  clearTimeout(timer);
@@ -856,16 +870,16 @@ class Pioneer {
856
870
  requestInterceptor: (req) => {
857
871
  req.headers.Authorization = this.queryKey;
858
872
  if ((req.method === "POST" || req.method === "post") && req.body) {
859
- log.debug(TAG, "Request interceptor - method:", req.method);
860
- log.debug(TAG, "Body type:", typeof req.body);
861
- log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
873
+ logger.debug(TAG, "Request interceptor - method:", req.method);
874
+ logger.debug(TAG, "Body type:", typeof req.body);
875
+ logger.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
862
876
  if (!req.headers)
863
877
  req.headers = {};
864
878
  if (!req.headers["Content-Type"]) {
865
879
  req.headers["Content-Type"] = "application/json";
866
880
  }
867
881
  if (typeof req.body !== "string") {
868
- log.debug(TAG, "Converting body to JSON string");
882
+ logger.debug(TAG, "Converting body to JSON string");
869
883
  req.body = JSON.stringify(req.body);
870
884
  }
871
885
  }
@@ -878,9 +892,9 @@ class Pioneer {
878
892
  const operationId = this.client.spec.paths[path][method].operationId;
879
893
  this.pioneer[operationId] = async (parameters, queryParams) => {
880
894
  try {
881
- log.debug(TAG, `${operationId} called with:`, parameters);
895
+ logger.debug(TAG, `${operationId} called with:`, parameters);
882
896
  if (queryParams) {
883
- log.debug(TAG, `${operationId} query params:`, queryParams);
897
+ logger.debug(TAG, `${operationId} query params:`, queryParams);
884
898
  }
885
899
  if (operationId === "GetMarketInfo") {
886
900
  if (!Array.isArray(parameters)) {
@@ -891,7 +905,7 @@ class Pioneer {
891
905
  console.error(`\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:`, invalidElements);
892
906
  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})`);
893
907
  }
894
- log.debug(TAG, `GetMarketInfo validation passed: ${parameters.length} valid CAIP strings`);
908
+ logger.debug(TAG, `GetMarketInfo validation passed: ${parameters.length} valid CAIP strings`);
895
909
  }
896
910
  let request = {
897
911
  operationId,
@@ -910,11 +924,11 @@ class Pioneer {
910
924
  Authorization: this.queryKey
911
925
  };
912
926
  }
913
- log.debug(TAG, `${operationId} request:`, request);
927
+ logger.debug(TAG, `${operationId} request:`, request);
914
928
  const result = await this.client.execute(request);
915
929
  return { data: result.body };
916
930
  } catch (e) {
917
- log.error(TAG, "Operation error:", e);
931
+ logger.error(TAG, "Operation error:", e);
918
932
  throw e;
919
933
  }
920
934
  };
@@ -922,7 +936,7 @@ class Pioneer {
922
936
  });
923
937
  return this.pioneer;
924
938
  } catch (e) {
925
- log.error(TAG, "Initialization error:", e);
939
+ logger.error(TAG, "Initialization error:", e);
926
940
  throw e;
927
941
  }
928
942
  }
@@ -1129,6 +1143,25 @@ function R(t) {
1129
1143
  var A = o;
1130
1144
  var P = o.prototype;
1131
1145
 
1146
+ // src/utils/logger.ts
1147
+ var DEBUG2 = process.env.DEBUG === "true" || typeof window !== "undefined" && window.DEBUG;
1148
+ var logger2 = {
1149
+ info: (tag, ...args) => {
1150
+ console.log(`[INFO] ${tag}`, ...args);
1151
+ },
1152
+ debug: (tag, ...args) => {
1153
+ if (DEBUG2) {
1154
+ console.log(`[DEBUG] ${tag}`, ...args);
1155
+ }
1156
+ },
1157
+ warn: (tag, ...args) => {
1158
+ console.warn(`[WARN] ${tag}`, ...args);
1159
+ },
1160
+ error: (tag, ...args) => {
1161
+ console.error(`[ERROR] ${tag}`, ...args);
1162
+ }
1163
+ };
1164
+
1132
1165
  // src/getPubkey.ts
1133
1166
  import { NetworkIdToChain } from "@pioneer-platform/pioneer-caip";
1134
1167
  import {
@@ -4243,7 +4276,6 @@ function filterPubkeysForAsset(pubkeys, caip, caipToNetworkId7) {
4243
4276
  }
4244
4277
 
4245
4278
  // src/utils/portfolio-helpers.ts
4246
- var log2 = __require("@pioneer-platform/loggerdog")();
4247
4279
  var TAG9 = " | portfolio-helpers | ";
4248
4280
  function isCacheDataValid(portfolioData) {
4249
4281
  if (!portfolioData.networks || !Array.isArray(portfolioData.networks)) {
@@ -4266,22 +4298,22 @@ async function fetchMarketPrice(pioneer, caip) {
4266
4298
  const tag = TAG9 + " | fetchMarketPrice | ";
4267
4299
  try {
4268
4300
  if (!caip || typeof caip !== "string" || !caip.includes(":")) {
4269
- log2.warn(tag, "Invalid or missing CAIP, skipping market price fetch:", caip);
4301
+ logger2.warn(tag, "Invalid or missing CAIP, skipping market price fetch:", caip);
4270
4302
  return 0;
4271
4303
  }
4272
- log2.debug(tag, "Fetching fresh market price for:", caip);
4304
+ logger2.debug(tag, "Fetching fresh market price for:", caip);
4273
4305
  const marketData = await pioneer.GetMarketInfo([caip]);
4274
- log2.debug(tag, "Market data response:", marketData);
4306
+ logger2.debug(tag, "Market data response:", marketData);
4275
4307
  if (marketData && marketData.data && marketData.data.length > 0) {
4276
4308
  const price = marketData.data[0];
4277
- log2.debug(tag, "✅ Fresh market price:", price);
4309
+ logger2.debug(tag, "✅ Fresh market price:", price);
4278
4310
  return price;
4279
4311
  } else {
4280
- log2.warn(tag, "No market data returned for:", caip);
4312
+ logger2.warn(tag, "No market data returned for:", caip);
4281
4313
  return 0;
4282
4314
  }
4283
4315
  } catch (marketError) {
4284
- log2.error(tag, "Error fetching market price:", marketError);
4316
+ logger2.error(tag, "Error fetching market price:", marketError);
4285
4317
  return 0;
4286
4318
  }
4287
4319
  }
@@ -4295,7 +4327,7 @@ function extractPriceFromBalances(balances) {
4295
4327
  const valueUsd = parseFloat(balances[0].valueUsd);
4296
4328
  if (balance > 0 && valueUsd > 0) {
4297
4329
  priceValue = valueUsd / balance;
4298
- log2.debug(tag, "Calculated priceUsd from valueUsd/balance:", priceValue);
4330
+ logger2.debug(tag, "Calculated priceUsd from valueUsd/balance:", priceValue);
4299
4331
  }
4300
4332
  }
4301
4333
  return priceValue || 0;
@@ -4304,15 +4336,15 @@ function aggregateBalances(balances, caip) {
4304
4336
  const tag = TAG9 + " | aggregateBalances | ";
4305
4337
  let totalBalance = 0;
4306
4338
  let totalValueUsd = 0;
4307
- log2.debug(tag, `Aggregating ${balances.length} balance entries for ${caip}`);
4339
+ logger2.debug(tag, `Aggregating ${balances.length} balance entries for ${caip}`);
4308
4340
  for (const balanceEntry of balances) {
4309
4341
  const balance = parseFloat(balanceEntry.balance) || 0;
4310
4342
  const valueUsd = parseFloat(balanceEntry.valueUsd) || 0;
4311
4343
  totalBalance += balance;
4312
4344
  totalValueUsd += valueUsd;
4313
- log2.debug(tag, ` Balance entry: ${balance} (${valueUsd} USD)`);
4345
+ logger2.debug(tag, ` Balance entry: ${balance} (${valueUsd} USD)`);
4314
4346
  }
4315
- log2.debug(tag, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
4347
+ logger2.debug(tag, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
4316
4348
  return { totalBalance, totalValueUsd };
4317
4349
  }
4318
4350
  function updateBalancesWithPrice(balances, freshPriceUsd) {
@@ -4323,7 +4355,7 @@ function updateBalancesWithPrice(balances, freshPriceUsd) {
4323
4355
  const balanceAmount = parseFloat(balance.balance || 0);
4324
4356
  balance.valueUsd = (balanceAmount * freshPriceUsd).toString();
4325
4357
  }
4326
- log2.debug(tag, "Updated all balances with fresh price data");
4358
+ logger2.debug(tag, "Updated all balances with fresh price data");
4327
4359
  }
4328
4360
  function buildDashboardFromPortfolioData(portfolioData) {
4329
4361
  const cacheAge = portfolioData.lastUpdated ? Math.floor((Date.now() - portfolioData.lastUpdated) / 1000) : 0;
@@ -4381,19 +4413,18 @@ function enrichBalancesWithAssetInfo(balances, assetsMap, caipToNetworkId7) {
4381
4413
  }
4382
4414
 
4383
4415
  // src/utils/sync-state.ts
4384
- var log3 = __require("@pioneer-platform/loggerdog")();
4385
4416
  var TAG10 = " | sync-state | ";
4386
4417
  function resolveAssetInfo(assetsMap, assetData, asset) {
4387
4418
  const tag = TAG10 + " | resolveAssetInfo | ";
4388
4419
  let assetInfo = assetsMap.get(asset.caip.toLowerCase());
4389
- log3.debug(tag, "assetInfo from assetsMap:", assetInfo);
4420
+ logger2.debug(tag, "assetInfo from assetsMap:", assetInfo);
4390
4421
  const assetInfoDiscovery = assetData[asset.caip];
4391
- log3.debug(tag, "assetInfoDiscovery:", assetInfoDiscovery);
4422
+ logger2.debug(tag, "assetInfoDiscovery:", assetInfoDiscovery);
4392
4423
  if (assetInfoDiscovery) {
4393
4424
  assetInfo = assetInfoDiscovery;
4394
4425
  }
4395
4426
  if (!assetInfo) {
4396
- log3.debug(tag, "Building placeholder asset for", asset.caip);
4427
+ logger2.debug(tag, "Building placeholder asset for", asset.caip);
4397
4428
  assetInfo = {
4398
4429
  caip: asset.caip.toLowerCase(),
4399
4430
  networkId: asset.networkId,
@@ -4515,19 +4546,18 @@ function validatePubkeysNetworks(pubkeys, tag = "") {
4515
4546
 
4516
4547
  // src/utils/path-discovery.ts
4517
4548
  import { getPaths } from "@pioneer-platform/pioneer-coins";
4518
- var log4 = __require("@pioneer-platform/loggerdog")();
4519
4549
  async function ensurePathsForBlockchains(blockchains, currentPaths, tag) {
4520
4550
  let allPaths = [...currentPaths];
4521
4551
  for (const blockchain of blockchains) {
4522
4552
  const networkId = normalizeNetworkId(blockchain);
4523
4553
  const existingPaths = allPaths.filter((path) => matchesNetwork(path, networkId));
4524
4554
  if (existingPaths.length === 0) {
4525
- log4.info(tag, `Discovering paths for ${networkId}...`);
4555
+ logger2.info(tag, `Discovering paths for ${networkId}...`);
4526
4556
  const newPaths = getPaths([networkId]);
4527
4557
  if (!newPaths || newPaths.length === 0) {
4528
4558
  throw new Error(`Path discovery failed for ${networkId}. ` + `Available blockchains: ${blockchains.join(", ")}`);
4529
4559
  }
4530
- log4.debug(tag, `Added ${newPaths.length} paths for ${networkId}`);
4560
+ logger2.debug(tag, `Added ${newPaths.length} paths for ${networkId}`);
4531
4561
  allPaths = allPaths.concat(newPaths);
4532
4562
  }
4533
4563
  }
@@ -4536,7 +4566,6 @@ async function ensurePathsForBlockchains(blockchains, currentPaths, tag) {
4536
4566
 
4537
4567
  // src/utils/pubkey-sync.ts
4538
4568
  import { addressNListToBIP32 as addressNListToBIP322 } from "@pioneer-platform/pioneer-coins";
4539
- var log5 = __require("@pioneer-platform/loggerdog")();
4540
4569
  async function syncPubkeysForBlockchains(blockchains, paths, existingPubkeys, keepKeySdk, context, getPubkeyFn, addPubkeyCallback, tag) {
4541
4570
  for (const blockchain of blockchains) {
4542
4571
  const networkId = normalizeNetworkId(blockchain);
@@ -4545,22 +4574,22 @@ async function syncPubkeysForBlockchains(blockchains, paths, existingPubkeys, ke
4545
4574
  const availablePaths = paths.map((p) => p.note || p.path || "unnamed").join(", ");
4546
4575
  throw new Error(`No paths found for ${networkId}. ` + `Available paths: ${availablePaths || "none"}`);
4547
4576
  }
4548
- log5.info(tag, `Syncing ${pathsForChain.length} pubkeys for ${networkId}...`);
4577
+ logger2.info(tag, `Syncing ${pathsForChain.length} pubkeys for ${networkId}...`);
4549
4578
  for (const path of pathsForChain) {
4550
4579
  const pathBip32 = addressNListToBIP322(path.addressNListMaster);
4551
4580
  const existingPubkey = existingPubkeys.find((p) => p.pathMaster === pathBip32);
4552
4581
  if (!existingPubkey) {
4553
- log5.debug(tag, `Fetching pubkey for path ${pathBip32}...`);
4582
+ logger2.debug(tag, `Fetching pubkey for path ${pathBip32}...`);
4554
4583
  const newPubkey = await getPubkeyFn(blockchain, path, keepKeySdk, context);
4555
4584
  if (!newPubkey) {
4556
4585
  throw new Error(`Pubkey fetch failed for ${networkId} at path ${pathBip32}. ` + `Ensure hardware wallet is connected and unlocked.`);
4557
4586
  }
4558
4587
  addPubkeyCallback(newPubkey);
4559
- log5.debug(tag, `✓ Added pubkey for ${pathBip32}`);
4588
+ logger2.debug(tag, `✓ Added pubkey for ${pathBip32}`);
4560
4589
  }
4561
4590
  }
4562
4591
  }
4563
- log5.info(tag, `✅ Pubkey sync complete. Total pubkeys: ${existingPubkeys.length}`);
4592
+ logger2.info(tag, `✅ Pubkey sync complete. Total pubkeys: ${existingPubkeys.length}`);
4564
4593
  }
4565
4594
 
4566
4595
  // src/index.ts
@@ -4981,48 +5010,48 @@ class SDK {
4981
5010
  };
4982
5011
  this.sync = async function() {
4983
5012
  const tag6 = `${TAG12} | sync | `;
4984
- const log6 = __require("@pioneer-platform/loggerdog")();
5013
+ const log = logger2;
4985
5014
  try {
4986
5015
  this.syncState = {
4987
5016
  ...createInitialSyncState(this.blockchains.length),
4988
5017
  syncProgress: 10
4989
5018
  };
4990
5019
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4991
- log6.info(tag6, "Fetching initial pubkeys...");
5020
+ log.info(tag6, "Fetching initial pubkeys...");
4992
5021
  await this.getPubkeys();
4993
5022
  this.syncState.syncProgress = 20;
4994
5023
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4995
- log6.info(tag6, "Discovering paths for blockchains...");
5024
+ log.info(tag6, "Discovering paths for blockchains...");
4996
5025
  this.paths = await ensurePathsForBlockchains(this.blockchains, this.paths, tag6);
4997
5026
  this.syncState.syncProgress = 30;
4998
5027
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4999
- log6.info(tag6, "Synchronizing pubkeys...");
5028
+ log.info(tag6, "Synchronizing pubkeys...");
5000
5029
  await syncPubkeysForBlockchains(this.blockchains, this.paths, this.pubkeys, this.keepKeySdk, this.context, getPubkey, (pubkey) => this.addPubkey(pubkey), tag6);
5001
5030
  this.syncState.syncProgress = 50;
5002
5031
  this.syncState.syncedChains = this.blockchains.length;
5003
5032
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5004
- log6.info(tag6, "Fetching balances...");
5033
+ log.info(tag6, "Fetching balances...");
5005
5034
  await this.getBalances();
5006
5035
  this.syncState.syncProgress = 70;
5007
5036
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5008
- log6.info(tag6, "Loading charts (tokens + portfolio)...");
5037
+ log.info(tag6, "Loading charts (tokens + portfolio)...");
5009
5038
  await this.getCharts();
5010
- log6.info(tag6, `Charts loaded. Total balances: ${this.balances.length}`);
5039
+ log.info(tag6, `Charts loaded. Total balances: ${this.balances.length}`);
5011
5040
  this.syncState.syncProgress = 85;
5012
5041
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5013
- log6.info(tag6, "Syncing market prices...");
5042
+ log.info(tag6, "Syncing market prices...");
5014
5043
  await this.syncMarket();
5015
5044
  this.syncState.syncProgress = 95;
5016
5045
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5017
- log6.info(tag6, "Building dashboard...");
5046
+ log.info(tag6, "Building dashboard...");
5018
5047
  this.dashboard = buildDashboardFromBalances(this.balances, [...new Set(this.blockchains)], this.assetsMap);
5019
5048
  this.syncState = createFreshSyncState(this.blockchains.length);
5020
5049
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5021
5050
  this.events.emit("SYNC_COMPLETE", this.syncState);
5022
- log6.info(tag6, "✅ Sync complete!");
5051
+ log.info(tag6, "✅ Sync complete!");
5023
5052
  return true;
5024
5053
  } catch (e) {
5025
- log6.error(tag6, "Sync failed:", e);
5054
+ log.error(tag6, "Sync failed:", e);
5026
5055
  this.syncState = {
5027
5056
  ...this.syncState,
5028
5057
  isSynced: false,
package/dist/index.js CHANGED
@@ -783,13 +783,27 @@ import { caipToNetworkId as caipToNetworkId7, networkIdToCaip as networkIdToCaip
783
783
 
784
784
  // ../pioneer-client/lib/index.js
785
785
  import SwaggerClient from "swagger-client";
786
- import loggerdog from "@pioneer-platform/loggerdog";
787
- var log = typeof window === "undefined" ? loggerdog() : {
788
- debug: (...args) => console.debug(...args),
789
- info: (...args) => console.info(...args),
790
- warn: (...args) => console.warn(...args),
791
- error: (...args) => console.error(...args)
786
+
787
+ // ../pioneer-client/lib/utils/logger.js
788
+ var DEBUG = process.env.DEBUG === "true" || typeof window !== "undefined" && window.DEBUG;
789
+ var logger = {
790
+ info: (tag, ...args) => {
791
+ console.log(`[INFO] ${tag}`, ...args);
792
+ },
793
+ debug: (tag, ...args) => {
794
+ if (DEBUG) {
795
+ console.log(`[DEBUG] ${tag}`, ...args);
796
+ }
797
+ },
798
+ warn: (tag, ...args) => {
799
+ console.warn(`[WARN] ${tag}`, ...args);
800
+ },
801
+ error: (tag, ...args) => {
802
+ console.error(`[ERROR] ${tag}`, ...args);
803
+ }
792
804
  };
805
+
806
+ // ../pioneer-client/lib/index.js
793
807
  var Swagger = SwaggerClient;
794
808
  var TAG = " | Client | ";
795
809
  function customHttpClient(req) {
@@ -797,8 +811,8 @@ function customHttpClient(req) {
797
811
  const timer = setTimeout(() => {
798
812
  reject(new Error("Request timed out"));
799
813
  }, 60000);
800
- log.debug(TAG, "HTTP request URL:", req.url);
801
- log.debug(TAG, "HTTP request details:", req);
814
+ logger.debug(TAG, "HTTP request URL:", req.url);
815
+ logger.debug(TAG, "HTTP request details:", req);
802
816
  if (Swagger.http) {
803
817
  Swagger.http(req).then((response) => {
804
818
  clearTimeout(timer);
@@ -856,16 +870,16 @@ class Pioneer {
856
870
  requestInterceptor: (req) => {
857
871
  req.headers.Authorization = this.queryKey;
858
872
  if ((req.method === "POST" || req.method === "post") && req.body) {
859
- log.debug(TAG, "Request interceptor - method:", req.method);
860
- log.debug(TAG, "Body type:", typeof req.body);
861
- log.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
873
+ logger.debug(TAG, "Request interceptor - method:", req.method);
874
+ logger.debug(TAG, "Body type:", typeof req.body);
875
+ logger.debug(TAG, "Body preview:", typeof req.body === "string" ? req.body.substring(0, 200) : JSON.stringify(req.body).substring(0, 200));
862
876
  if (!req.headers)
863
877
  req.headers = {};
864
878
  if (!req.headers["Content-Type"]) {
865
879
  req.headers["Content-Type"] = "application/json";
866
880
  }
867
881
  if (typeof req.body !== "string") {
868
- log.debug(TAG, "Converting body to JSON string");
882
+ logger.debug(TAG, "Converting body to JSON string");
869
883
  req.body = JSON.stringify(req.body);
870
884
  }
871
885
  }
@@ -878,9 +892,9 @@ class Pioneer {
878
892
  const operationId = this.client.spec.paths[path][method].operationId;
879
893
  this.pioneer[operationId] = async (parameters, queryParams) => {
880
894
  try {
881
- log.debug(TAG, `${operationId} called with:`, parameters);
895
+ logger.debug(TAG, `${operationId} called with:`, parameters);
882
896
  if (queryParams) {
883
- log.debug(TAG, `${operationId} query params:`, queryParams);
897
+ logger.debug(TAG, `${operationId} query params:`, queryParams);
884
898
  }
885
899
  if (operationId === "GetMarketInfo") {
886
900
  if (!Array.isArray(parameters)) {
@@ -891,7 +905,7 @@ class Pioneer {
891
905
  console.error(`\uD83D\uDEA8 [PIONEER CLIENT] GetMarketInfo validation failed:`, invalidElements);
892
906
  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})`);
893
907
  }
894
- log.debug(TAG, `GetMarketInfo validation passed: ${parameters.length} valid CAIP strings`);
908
+ logger.debug(TAG, `GetMarketInfo validation passed: ${parameters.length} valid CAIP strings`);
895
909
  }
896
910
  let request = {
897
911
  operationId,
@@ -910,11 +924,11 @@ class Pioneer {
910
924
  Authorization: this.queryKey
911
925
  };
912
926
  }
913
- log.debug(TAG, `${operationId} request:`, request);
927
+ logger.debug(TAG, `${operationId} request:`, request);
914
928
  const result = await this.client.execute(request);
915
929
  return { data: result.body };
916
930
  } catch (e) {
917
- log.error(TAG, "Operation error:", e);
931
+ logger.error(TAG, "Operation error:", e);
918
932
  throw e;
919
933
  }
920
934
  };
@@ -922,7 +936,7 @@ class Pioneer {
922
936
  });
923
937
  return this.pioneer;
924
938
  } catch (e) {
925
- log.error(TAG, "Initialization error:", e);
939
+ logger.error(TAG, "Initialization error:", e);
926
940
  throw e;
927
941
  }
928
942
  }
@@ -1129,6 +1143,25 @@ function R(t) {
1129
1143
  var A = o;
1130
1144
  var P = o.prototype;
1131
1145
 
1146
+ // src/utils/logger.ts
1147
+ var DEBUG2 = process.env.DEBUG === "true" || typeof window !== "undefined" && window.DEBUG;
1148
+ var logger2 = {
1149
+ info: (tag, ...args) => {
1150
+ console.log(`[INFO] ${tag}`, ...args);
1151
+ },
1152
+ debug: (tag, ...args) => {
1153
+ if (DEBUG2) {
1154
+ console.log(`[DEBUG] ${tag}`, ...args);
1155
+ }
1156
+ },
1157
+ warn: (tag, ...args) => {
1158
+ console.warn(`[WARN] ${tag}`, ...args);
1159
+ },
1160
+ error: (tag, ...args) => {
1161
+ console.error(`[ERROR] ${tag}`, ...args);
1162
+ }
1163
+ };
1164
+
1132
1165
  // src/getPubkey.ts
1133
1166
  import { NetworkIdToChain } from "@pioneer-platform/pioneer-caip";
1134
1167
  import {
@@ -4243,7 +4276,6 @@ function filterPubkeysForAsset(pubkeys, caip, caipToNetworkId7) {
4243
4276
  }
4244
4277
 
4245
4278
  // src/utils/portfolio-helpers.ts
4246
- var log2 = __require("@pioneer-platform/loggerdog")();
4247
4279
  var TAG9 = " | portfolio-helpers | ";
4248
4280
  function isCacheDataValid(portfolioData) {
4249
4281
  if (!portfolioData.networks || !Array.isArray(portfolioData.networks)) {
@@ -4266,22 +4298,22 @@ async function fetchMarketPrice(pioneer, caip) {
4266
4298
  const tag = TAG9 + " | fetchMarketPrice | ";
4267
4299
  try {
4268
4300
  if (!caip || typeof caip !== "string" || !caip.includes(":")) {
4269
- log2.warn(tag, "Invalid or missing CAIP, skipping market price fetch:", caip);
4301
+ logger2.warn(tag, "Invalid or missing CAIP, skipping market price fetch:", caip);
4270
4302
  return 0;
4271
4303
  }
4272
- log2.debug(tag, "Fetching fresh market price for:", caip);
4304
+ logger2.debug(tag, "Fetching fresh market price for:", caip);
4273
4305
  const marketData = await pioneer.GetMarketInfo([caip]);
4274
- log2.debug(tag, "Market data response:", marketData);
4306
+ logger2.debug(tag, "Market data response:", marketData);
4275
4307
  if (marketData && marketData.data && marketData.data.length > 0) {
4276
4308
  const price = marketData.data[0];
4277
- log2.debug(tag, "✅ Fresh market price:", price);
4309
+ logger2.debug(tag, "✅ Fresh market price:", price);
4278
4310
  return price;
4279
4311
  } else {
4280
- log2.warn(tag, "No market data returned for:", caip);
4312
+ logger2.warn(tag, "No market data returned for:", caip);
4281
4313
  return 0;
4282
4314
  }
4283
4315
  } catch (marketError) {
4284
- log2.error(tag, "Error fetching market price:", marketError);
4316
+ logger2.error(tag, "Error fetching market price:", marketError);
4285
4317
  return 0;
4286
4318
  }
4287
4319
  }
@@ -4295,7 +4327,7 @@ function extractPriceFromBalances(balances) {
4295
4327
  const valueUsd = parseFloat(balances[0].valueUsd);
4296
4328
  if (balance > 0 && valueUsd > 0) {
4297
4329
  priceValue = valueUsd / balance;
4298
- log2.debug(tag, "Calculated priceUsd from valueUsd/balance:", priceValue);
4330
+ logger2.debug(tag, "Calculated priceUsd from valueUsd/balance:", priceValue);
4299
4331
  }
4300
4332
  }
4301
4333
  return priceValue || 0;
@@ -4304,15 +4336,15 @@ function aggregateBalances(balances, caip) {
4304
4336
  const tag = TAG9 + " | aggregateBalances | ";
4305
4337
  let totalBalance = 0;
4306
4338
  let totalValueUsd = 0;
4307
- log2.debug(tag, `Aggregating ${balances.length} balance entries for ${caip}`);
4339
+ logger2.debug(tag, `Aggregating ${balances.length} balance entries for ${caip}`);
4308
4340
  for (const balanceEntry of balances) {
4309
4341
  const balance = parseFloat(balanceEntry.balance) || 0;
4310
4342
  const valueUsd = parseFloat(balanceEntry.valueUsd) || 0;
4311
4343
  totalBalance += balance;
4312
4344
  totalValueUsd += valueUsd;
4313
- log2.debug(tag, ` Balance entry: ${balance} (${valueUsd} USD)`);
4345
+ logger2.debug(tag, ` Balance entry: ${balance} (${valueUsd} USD)`);
4314
4346
  }
4315
- log2.debug(tag, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
4347
+ logger2.debug(tag, `Aggregated balance: ${totalBalance} (${totalValueUsd.toFixed(2)} USD)`);
4316
4348
  return { totalBalance, totalValueUsd };
4317
4349
  }
4318
4350
  function updateBalancesWithPrice(balances, freshPriceUsd) {
@@ -4323,7 +4355,7 @@ function updateBalancesWithPrice(balances, freshPriceUsd) {
4323
4355
  const balanceAmount = parseFloat(balance.balance || 0);
4324
4356
  balance.valueUsd = (balanceAmount * freshPriceUsd).toString();
4325
4357
  }
4326
- log2.debug(tag, "Updated all balances with fresh price data");
4358
+ logger2.debug(tag, "Updated all balances with fresh price data");
4327
4359
  }
4328
4360
  function buildDashboardFromPortfolioData(portfolioData) {
4329
4361
  const cacheAge = portfolioData.lastUpdated ? Math.floor((Date.now() - portfolioData.lastUpdated) / 1000) : 0;
@@ -4381,19 +4413,18 @@ function enrichBalancesWithAssetInfo(balances, assetsMap, caipToNetworkId7) {
4381
4413
  }
4382
4414
 
4383
4415
  // src/utils/sync-state.ts
4384
- var log3 = __require("@pioneer-platform/loggerdog")();
4385
4416
  var TAG10 = " | sync-state | ";
4386
4417
  function resolveAssetInfo(assetsMap, assetData, asset) {
4387
4418
  const tag = TAG10 + " | resolveAssetInfo | ";
4388
4419
  let assetInfo = assetsMap.get(asset.caip.toLowerCase());
4389
- log3.debug(tag, "assetInfo from assetsMap:", assetInfo);
4420
+ logger2.debug(tag, "assetInfo from assetsMap:", assetInfo);
4390
4421
  const assetInfoDiscovery = assetData[asset.caip];
4391
- log3.debug(tag, "assetInfoDiscovery:", assetInfoDiscovery);
4422
+ logger2.debug(tag, "assetInfoDiscovery:", assetInfoDiscovery);
4392
4423
  if (assetInfoDiscovery) {
4393
4424
  assetInfo = assetInfoDiscovery;
4394
4425
  }
4395
4426
  if (!assetInfo) {
4396
- log3.debug(tag, "Building placeholder asset for", asset.caip);
4427
+ logger2.debug(tag, "Building placeholder asset for", asset.caip);
4397
4428
  assetInfo = {
4398
4429
  caip: asset.caip.toLowerCase(),
4399
4430
  networkId: asset.networkId,
@@ -4515,19 +4546,18 @@ function validatePubkeysNetworks(pubkeys, tag = "") {
4515
4546
 
4516
4547
  // src/utils/path-discovery.ts
4517
4548
  import { getPaths } from "@pioneer-platform/pioneer-coins";
4518
- var log4 = __require("@pioneer-platform/loggerdog")();
4519
4549
  async function ensurePathsForBlockchains(blockchains, currentPaths, tag) {
4520
4550
  let allPaths = [...currentPaths];
4521
4551
  for (const blockchain of blockchains) {
4522
4552
  const networkId = normalizeNetworkId(blockchain);
4523
4553
  const existingPaths = allPaths.filter((path) => matchesNetwork(path, networkId));
4524
4554
  if (existingPaths.length === 0) {
4525
- log4.info(tag, `Discovering paths for ${networkId}...`);
4555
+ logger2.info(tag, `Discovering paths for ${networkId}...`);
4526
4556
  const newPaths = getPaths([networkId]);
4527
4557
  if (!newPaths || newPaths.length === 0) {
4528
4558
  throw new Error(`Path discovery failed for ${networkId}. ` + `Available blockchains: ${blockchains.join(", ")}`);
4529
4559
  }
4530
- log4.debug(tag, `Added ${newPaths.length} paths for ${networkId}`);
4560
+ logger2.debug(tag, `Added ${newPaths.length} paths for ${networkId}`);
4531
4561
  allPaths = allPaths.concat(newPaths);
4532
4562
  }
4533
4563
  }
@@ -4536,7 +4566,6 @@ async function ensurePathsForBlockchains(blockchains, currentPaths, tag) {
4536
4566
 
4537
4567
  // src/utils/pubkey-sync.ts
4538
4568
  import { addressNListToBIP32 as addressNListToBIP322 } from "@pioneer-platform/pioneer-coins";
4539
- var log5 = __require("@pioneer-platform/loggerdog")();
4540
4569
  async function syncPubkeysForBlockchains(blockchains, paths, existingPubkeys, keepKeySdk, context, getPubkeyFn, addPubkeyCallback, tag) {
4541
4570
  for (const blockchain of blockchains) {
4542
4571
  const networkId = normalizeNetworkId(blockchain);
@@ -4545,22 +4574,22 @@ async function syncPubkeysForBlockchains(blockchains, paths, existingPubkeys, ke
4545
4574
  const availablePaths = paths.map((p) => p.note || p.path || "unnamed").join(", ");
4546
4575
  throw new Error(`No paths found for ${networkId}. ` + `Available paths: ${availablePaths || "none"}`);
4547
4576
  }
4548
- log5.info(tag, `Syncing ${pathsForChain.length} pubkeys for ${networkId}...`);
4577
+ logger2.info(tag, `Syncing ${pathsForChain.length} pubkeys for ${networkId}...`);
4549
4578
  for (const path of pathsForChain) {
4550
4579
  const pathBip32 = addressNListToBIP322(path.addressNListMaster);
4551
4580
  const existingPubkey = existingPubkeys.find((p) => p.pathMaster === pathBip32);
4552
4581
  if (!existingPubkey) {
4553
- log5.debug(tag, `Fetching pubkey for path ${pathBip32}...`);
4582
+ logger2.debug(tag, `Fetching pubkey for path ${pathBip32}...`);
4554
4583
  const newPubkey = await getPubkeyFn(blockchain, path, keepKeySdk, context);
4555
4584
  if (!newPubkey) {
4556
4585
  throw new Error(`Pubkey fetch failed for ${networkId} at path ${pathBip32}. ` + `Ensure hardware wallet is connected and unlocked.`);
4557
4586
  }
4558
4587
  addPubkeyCallback(newPubkey);
4559
- log5.debug(tag, `✓ Added pubkey for ${pathBip32}`);
4588
+ logger2.debug(tag, `✓ Added pubkey for ${pathBip32}`);
4560
4589
  }
4561
4590
  }
4562
4591
  }
4563
- log5.info(tag, `✅ Pubkey sync complete. Total pubkeys: ${existingPubkeys.length}`);
4592
+ logger2.info(tag, `✅ Pubkey sync complete. Total pubkeys: ${existingPubkeys.length}`);
4564
4593
  }
4565
4594
 
4566
4595
  // src/index.ts
@@ -4981,48 +5010,48 @@ class SDK {
4981
5010
  };
4982
5011
  this.sync = async function() {
4983
5012
  const tag6 = `${TAG12} | sync | `;
4984
- const log6 = __require("@pioneer-platform/loggerdog")();
5013
+ const log = logger2;
4985
5014
  try {
4986
5015
  this.syncState = {
4987
5016
  ...createInitialSyncState(this.blockchains.length),
4988
5017
  syncProgress: 10
4989
5018
  };
4990
5019
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4991
- log6.info(tag6, "Fetching initial pubkeys...");
5020
+ log.info(tag6, "Fetching initial pubkeys...");
4992
5021
  await this.getPubkeys();
4993
5022
  this.syncState.syncProgress = 20;
4994
5023
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4995
- log6.info(tag6, "Discovering paths for blockchains...");
5024
+ log.info(tag6, "Discovering paths for blockchains...");
4996
5025
  this.paths = await ensurePathsForBlockchains(this.blockchains, this.paths, tag6);
4997
5026
  this.syncState.syncProgress = 30;
4998
5027
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
4999
- log6.info(tag6, "Synchronizing pubkeys...");
5028
+ log.info(tag6, "Synchronizing pubkeys...");
5000
5029
  await syncPubkeysForBlockchains(this.blockchains, this.paths, this.pubkeys, this.keepKeySdk, this.context, getPubkey, (pubkey) => this.addPubkey(pubkey), tag6);
5001
5030
  this.syncState.syncProgress = 50;
5002
5031
  this.syncState.syncedChains = this.blockchains.length;
5003
5032
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5004
- log6.info(tag6, "Fetching balances...");
5033
+ log.info(tag6, "Fetching balances...");
5005
5034
  await this.getBalances();
5006
5035
  this.syncState.syncProgress = 70;
5007
5036
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5008
- log6.info(tag6, "Loading charts (tokens + portfolio)...");
5037
+ log.info(tag6, "Loading charts (tokens + portfolio)...");
5009
5038
  await this.getCharts();
5010
- log6.info(tag6, `Charts loaded. Total balances: ${this.balances.length}`);
5039
+ log.info(tag6, `Charts loaded. Total balances: ${this.balances.length}`);
5011
5040
  this.syncState.syncProgress = 85;
5012
5041
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5013
- log6.info(tag6, "Syncing market prices...");
5042
+ log.info(tag6, "Syncing market prices...");
5014
5043
  await this.syncMarket();
5015
5044
  this.syncState.syncProgress = 95;
5016
5045
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5017
- log6.info(tag6, "Building dashboard...");
5046
+ log.info(tag6, "Building dashboard...");
5018
5047
  this.dashboard = buildDashboardFromBalances(this.balances, [...new Set(this.blockchains)], this.assetsMap);
5019
5048
  this.syncState = createFreshSyncState(this.blockchains.length);
5020
5049
  this.events.emit("SYNC_STATE_CHANGED", this.syncState);
5021
5050
  this.events.emit("SYNC_COMPLETE", this.syncState);
5022
- log6.info(tag6, "✅ Sync complete!");
5051
+ log.info(tag6, "✅ Sync complete!");
5023
5052
  return true;
5024
5053
  } catch (e) {
5025
- log6.error(tag6, "Sync failed:", e);
5054
+ log.error(tag6, "Sync failed:", e);
5026
5055
  this.syncState = {
5027
5056
  ...this.syncState,
5028
5057
  isSynced: false,
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "author": "highlander",
3
3
  "name": "@pioneer-platform/pioneer-sdk",
4
- "version": "8.15.15",
4
+ "version": "8.15.17",
5
5
  "dependencies": {
6
6
  "@keepkey/keepkey-sdk": "^0.2.62",
7
- "@pioneer-platform/loggerdog": "^8.11.0",
8
7
  "@pioneer-platform/pioneer-caip": "^9.10.2",
9
- "@pioneer-platform/pioneer-client": "^9.10.11",
8
+ "@pioneer-platform/pioneer-client": "^9.10.12",
10
9
  "@pioneer-platform/pioneer-coins": "^9.11.2",
11
- "@pioneer-platform/pioneer-discovery": "^8.15.15",
10
+ "@pioneer-platform/pioneer-discovery": "^8.15.17",
12
11
  "@pioneer-platform/pioneer-events": "^8.12.0",
13
12
  "coinselect": "^3.1.13",
14
13
  "eventemitter3": "^5.0.1",
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ import EventEmitter from 'events';
8
8
 
9
9
  import { getCharts } from './charts/index.js';
10
10
  //internal
11
+ import { logger } from './utils/logger.js';
11
12
  import { getPubkey } from './getPubkey.js';
12
13
  import { optimizedGetPubkeys } from './kkapi-batch-client.js';
13
14
  import { OfflineClient } from './offline-client.js';
@@ -660,7 +661,7 @@ export class SDK {
660
661
  };
661
662
  this.sync = async function () {
662
663
  const tag = `${TAG} | sync | `;
663
- const log = require('@pioneer-platform/loggerdog')();
664
+ const log = logger;
664
665
 
665
666
  try {
666
667
  // Update sync state: starting
@@ -0,0 +1,21 @@
1
+ // Simple client-side logger for Pioneer SDK
2
+ // Replaces server-side loggerdog dependency
3
+
4
+ const DEBUG = process.env.DEBUG === 'true' || typeof window !== 'undefined' && (window as any).DEBUG;
5
+
6
+ export const logger = {
7
+ info: (tag: string, ...args: any[]) => {
8
+ console.log(`[INFO] ${tag}`, ...args);
9
+ },
10
+ debug: (tag: string, ...args: any[]) => {
11
+ if (DEBUG) {
12
+ console.log(`[DEBUG] ${tag}`, ...args);
13
+ }
14
+ },
15
+ warn: (tag: string, ...args: any[]) => {
16
+ console.warn(`[WARN] ${tag}`, ...args);
17
+ },
18
+ error: (tag: string, ...args: any[]) => {
19
+ console.error(`[ERROR] ${tag}`, ...args);
20
+ },
21
+ };
@@ -2,8 +2,7 @@
2
2
 
3
3
  import { getPaths } from '@pioneer-platform/pioneer-coins';
4
4
  import { matchesNetwork, normalizeNetworkId } from './network-helpers.js';
5
-
6
- const log = require('@pioneer-platform/loggerdog')();
5
+ import { logger as log } from './logger.js';
7
6
 
8
7
  /**
9
8
  * Ensure paths exist for all blockchains
@@ -1,6 +1,6 @@
1
1
  // Portfolio validation and helper utilities
2
2
 
3
- const log = require('@pioneer-platform/loggerdog')();
3
+ import { logger as log } from './logger.js';
4
4
  const TAG = ' | portfolio-helpers | ';
5
5
 
6
6
  export function isCacheDataValid(portfolioData: any): boolean {
@@ -2,8 +2,7 @@
2
2
 
3
3
  import { addressNListToBIP32 } from '@pioneer-platform/pioneer-coins';
4
4
  import { matchesNetwork, normalizeNetworkId } from './network-helpers.js';
5
-
6
- const log = require('@pioneer-platform/loggerdog')();
5
+ import { logger as log } from './logger.js';
7
6
 
8
7
  /**
9
8
  * Synchronize pubkeys for all blockchains
@@ -1,6 +1,6 @@
1
1
  // Sync state management and asset info utilities
2
2
 
3
- const log = require('@pioneer-platform/loggerdog')();
3
+ import { logger as log } from './logger.js';
4
4
  const TAG = ' | sync-state | ';
5
5
 
6
6
  export interface SyncState {