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