@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.
@@ -679,6 +679,9 @@ var BalanceManager = class {
679
679
  fetchResult.token
680
680
  );
681
681
  const totalAmountMsat = receiveResult.unit === "msat" ? receiveResult.amount : receiveResult.amount * 1e3;
682
+ if (receiveResult.success) {
683
+ this.storageAdapter.removeApiKey(baseUrl);
684
+ }
682
685
  return {
683
686
  success: receiveResult.success,
684
687
  refundedAmount: totalAmountMsat,
@@ -1759,7 +1762,7 @@ var ProviderManager = class {
1759
1762
  };
1760
1763
 
1761
1764
  // client/RoutstrClient.ts
1762
- var TOPUP_MARGIN = 0.7;
1765
+ var TOPUP_MARGIN = 1.2;
1763
1766
  var RoutstrClient = class {
1764
1767
  constructor(walletAdapter, storageAdapter, providerRegistry, alertLevel, mode = "xcashu") {
1765
1768
  this.walletAdapter = walletAdapter;
@@ -2263,8 +2266,6 @@ var RoutstrClient = class {
2263
2266
  status,
2264
2267
  refundResult.message ?? "Unknown error"
2265
2268
  );
2266
- } else {
2267
- this.storageAdapter.removeApiKey(baseUrl);
2268
2269
  }
2269
2270
  }
2270
2271
  }
@@ -2363,7 +2364,11 @@ var RoutstrClient = class {
2363
2364
  baseUrl
2364
2365
  );
2365
2366
  const latestTokenBalance = latestBalanceInfo.unit === "msat" ? latestBalanceInfo.amount / 1e3 : latestBalanceInfo.amount;
2366
- this.storageAdapter.updateChildKeyBalance(baseUrl, latestTokenBalance);
2367
+ const storedApiKeyEntry = this.storageAdapter.getApiKey(baseUrl);
2368
+ if (storedApiKeyEntry?.key.startsWith("cashu") && latestBalanceInfo.apiKey) {
2369
+ this.storageAdapter.removeApiKey(baseUrl);
2370
+ this.storageAdapter.setApiKey(baseUrl, latestBalanceInfo.apiKey);
2371
+ }
2367
2372
  this.storageAdapter.updateApiKeyBalance(baseUrl, latestTokenBalance);
2368
2373
  satsSpent = initialTokenBalance - latestTokenBalance;
2369
2374
  } catch (e) {