@routstr/sdk 0.2.3 → 0.2.4

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.
@@ -866,9 +866,13 @@ var BalanceManager = class {
866
866
  p2pkPubkey
867
867
  } = options;
868
868
  const adjustedAmount = Math.ceil(amount);
869
- console.log(`[BalanceManager.createProviderToken] Starting: baseUrl=${baseUrl}, mintUrl=${mintUrl}, amount=${amount}, adjustedAmount=${adjustedAmount}, retryCount=${retryCount}`);
869
+ console.log(
870
+ `[BalanceManager.createProviderToken] Starting: baseUrl=${baseUrl}, mintUrl=${mintUrl}, amount=${amount}, adjustedAmount=${adjustedAmount}, retryCount=${retryCount}`
871
+ );
870
872
  if (!adjustedAmount || isNaN(adjustedAmount)) {
871
- console.error(`[BalanceManager.createProviderToken] FAILURE: Invalid amount - amount=${amount}, adjustedAmount=${adjustedAmount}`);
873
+ console.error(
874
+ `[BalanceManager.createProviderToken] FAILURE: Invalid amount - amount=${amount}, adjustedAmount=${adjustedAmount}`
875
+ );
872
876
  return { success: false, error: "Invalid top up amount" };
873
877
  }
874
878
  const balanceState = await this.getBalanceState();
@@ -899,15 +903,11 @@ var BalanceManager = class {
899
903
  { url: "", balance: 0 }
900
904
  ).url
901
905
  );
902
- console.error(`[BalanceManager.createProviderToken] FAILURE: Insufficient balance - required=${adjustedAmount}, available=${totalMintBalance + targetProviderBalance}, totalMintBalance=${totalMintBalance}, targetProviderBalance=${targetProviderBalance}, refundableProviderBalance=${refundableProviderBalance}`);
906
+ console.error(
907
+ `[BalanceManager.createProviderToken] FAILURE: Insufficient balance - required=${adjustedAmount}, available=${totalMintBalance + targetProviderBalance}, totalMintBalance=${totalMintBalance}, targetProviderBalance=${targetProviderBalance}, refundableProviderBalance=${refundableProviderBalance}`
908
+ );
903
909
  return { success: false, error: error.message };
904
910
  }
905
- if (targetProviderBalance >= adjustedAmount) {
906
- return {
907
- success: true,
908
- amountSpent: 0
909
- };
910
- }
911
911
  const providerMints = baseUrl && this.providerRegistry ? this.providerRegistry.getProviderMints(baseUrl) : [];
912
912
  let requiredAmount = adjustedAmount;
913
913
  const supportedMintsOnly = providerMints.length > 0;
@@ -941,7 +941,9 @@ var BalanceManager = class {
941
941
  maxMintUrl = mintUrl2;
942
942
  }
943
943
  }
944
- console.error(`[BalanceManager.createProviderToken] FAILURE: No candidate mints found - requiredAmount=${requiredAmount}, totalMintBalance=${totalMintBalance}, maxBalance=${maxBalance}, maxMintUrl=${maxMintUrl}, providerMints=${JSON.stringify(providerMints)}`);
944
+ console.error(
945
+ `[BalanceManager.createProviderToken] FAILURE: No candidate mints found - requiredAmount=${requiredAmount}, totalMintBalance=${totalMintBalance}, maxBalance=${maxBalance}, maxMintUrl=${maxMintUrl}, providerMints=${JSON.stringify(providerMints)}`
946
+ );
945
947
  const error = new InsufficientBalanceError(
946
948
  adjustedAmount,
947
949
  totalMintBalance,
@@ -953,13 +955,17 @@ var BalanceManager = class {
953
955
  let lastError;
954
956
  for (const candidateMint of candidates) {
955
957
  try {
956
- console.log(`[BalanceManager.createProviderToken] Attempting mint: ${candidateMint}, amount: ${requiredAmount}`);
958
+ console.log(
959
+ `[BalanceManager.createProviderToken] Attempting mint: ${candidateMint}, amount: ${requiredAmount}`
960
+ );
957
961
  const token = await this.walletAdapter.sendToken(
958
962
  candidateMint,
959
963
  requiredAmount,
960
964
  p2pkPubkey
961
965
  );
962
- console.log(`[BalanceManager.createProviderToken] SUCCESS: Token created from mint ${candidateMint}`);
966
+ console.log(
967
+ `[BalanceManager.createProviderToken] SUCCESS: Token created from mint ${candidateMint}`
968
+ );
963
969
  return {
964
970
  success: true,
965
971
  token,
@@ -968,11 +974,15 @@ var BalanceManager = class {
968
974
  };
969
975
  } catch (error) {
970
976
  const errorMsg = error instanceof Error ? error.message : String(error);
971
- console.error(`[BalanceManager.createProviderToken] FAILURE: Mint ${candidateMint} failed with error: ${errorMsg}`);
977
+ console.error(
978
+ `[BalanceManager.createProviderToken] FAILURE: Mint ${candidateMint} failed with error: ${errorMsg}`
979
+ );
972
980
  if (error instanceof Error) {
973
981
  lastError = errorMsg;
974
982
  if (isNetworkErrorMessage(error.message)) {
975
- console.warn(`[BalanceManager.createProviderToken] Network error from ${candidateMint}, trying next mint...`);
983
+ console.warn(
984
+ `[BalanceManager.createProviderToken] Network error from ${candidateMint}, trying next mint...`
985
+ );
976
986
  continue;
977
987
  }
978
988
  }
@@ -982,7 +992,9 @@ var BalanceManager = class {
982
992
  };
983
993
  }
984
994
  }
985
- console.error(`[BalanceManager.createProviderToken] FAILURE: All candidate mints exhausted - lastError=${lastError}, candidates=${JSON.stringify(candidates)}`);
995
+ console.error(
996
+ `[BalanceManager.createProviderToken] FAILURE: All candidate mints exhausted - lastError=${lastError}, candidates=${JSON.stringify(candidates)}`
997
+ );
986
998
  return {
987
999
  success: false,
988
1000
  error: lastError || "All candidate mints failed while creating top up token"