@routstr/sdk 0.1.4 → 0.1.5

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.js CHANGED
@@ -1316,6 +1316,9 @@ var BalanceManager = class {
1316
1316
  fetchResult.token
1317
1317
  );
1318
1318
  const totalAmountMsat = receiveResult.unit === "msat" ? receiveResult.amount : receiveResult.amount * 1e3;
1319
+ if (receiveResult.success) {
1320
+ this.storageAdapter.removeApiKey(baseUrl);
1321
+ }
1319
1322
  return {
1320
1323
  success: receiveResult.success,
1321
1324
  refundedAmount: totalAmountMsat,
@@ -2452,7 +2455,7 @@ var ProviderManager = class {
2452
2455
  };
2453
2456
 
2454
2457
  // client/RoutstrClient.ts
2455
- var TOPUP_MARGIN = 0.7;
2458
+ var TOPUP_MARGIN = 1.2;
2456
2459
  var RoutstrClient = class {
2457
2460
  constructor(walletAdapter, storageAdapter, providerRegistry, alertLevel, mode = "xcashu") {
2458
2461
  this.walletAdapter = walletAdapter;
@@ -2956,8 +2959,6 @@ var RoutstrClient = class {
2956
2959
  status,
2957
2960
  refundResult.message ?? "Unknown error"
2958
2961
  );
2959
- } else {
2960
- this.storageAdapter.removeApiKey(baseUrl);
2961
2962
  }
2962
2963
  }
2963
2964
  }
@@ -3056,7 +3057,11 @@ var RoutstrClient = class {
3056
3057
  baseUrl
3057
3058
  );
3058
3059
  const latestTokenBalance = latestBalanceInfo.unit === "msat" ? latestBalanceInfo.amount / 1e3 : latestBalanceInfo.amount;
3059
- this.storageAdapter.updateChildKeyBalance(baseUrl, latestTokenBalance);
3060
+ const storedApiKeyEntry = this.storageAdapter.getApiKey(baseUrl);
3061
+ if (storedApiKeyEntry?.key.startsWith("cashu") && latestBalanceInfo.apiKey) {
3062
+ this.storageAdapter.removeApiKey(baseUrl);
3063
+ this.storageAdapter.setApiKey(baseUrl, latestBalanceInfo.apiKey);
3064
+ }
3060
3065
  this.storageAdapter.updateApiKeyBalance(baseUrl, latestTokenBalance);
3061
3066
  satsSpent = initialTokenBalance - latestTokenBalance;
3062
3067
  } catch (e) {