@routstr/sdk 0.1.3 → 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/client/index.js +12 -4
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +12 -4
- package/dist/client/index.mjs.map +1 -1
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -5
- package/dist/index.mjs.map +1 -1
- package/dist/wallet/index.js +3 -0
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +3 -0
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -681,6 +681,9 @@ var BalanceManager = class {
|
|
|
681
681
|
fetchResult.token
|
|
682
682
|
);
|
|
683
683
|
const totalAmountMsat = receiveResult.unit === "msat" ? receiveResult.amount : receiveResult.amount * 1e3;
|
|
684
|
+
if (receiveResult.success) {
|
|
685
|
+
this.storageAdapter.removeApiKey(baseUrl);
|
|
686
|
+
}
|
|
684
687
|
return {
|
|
685
688
|
success: receiveResult.success,
|
|
686
689
|
refundedAmount: totalAmountMsat,
|
|
@@ -1761,7 +1764,7 @@ var ProviderManager = class {
|
|
|
1761
1764
|
};
|
|
1762
1765
|
|
|
1763
1766
|
// client/RoutstrClient.ts
|
|
1764
|
-
var TOPUP_MARGIN =
|
|
1767
|
+
var TOPUP_MARGIN = 1.2;
|
|
1765
1768
|
var RoutstrClient = class {
|
|
1766
1769
|
constructor(walletAdapter, storageAdapter, providerRegistry, alertLevel, mode = "xcashu") {
|
|
1767
1770
|
this.walletAdapter = walletAdapter;
|
|
@@ -2048,12 +2051,14 @@ var RoutstrClient = class {
|
|
|
2048
2051
|
try {
|
|
2049
2052
|
const url = `${baseUrl.replace(/\/$/, "")}${path}`;
|
|
2050
2053
|
if (this.mode === "xcashu") this._log("DEBUG", "HEADERS,", headers);
|
|
2054
|
+
this._log("DEBUG", "HEADERS,", headers);
|
|
2051
2055
|
const response = await fetch(url, {
|
|
2052
2056
|
method,
|
|
2053
2057
|
headers,
|
|
2054
2058
|
body: body === void 0 || method === "GET" ? void 0 : JSON.stringify(body)
|
|
2055
2059
|
});
|
|
2056
2060
|
if (this.mode === "xcashu") this._log("DEBUG", "response,", response);
|
|
2061
|
+
this._log("DEBUG", "response,", response);
|
|
2057
2062
|
response.baseUrl = baseUrl;
|
|
2058
2063
|
response.token = token;
|
|
2059
2064
|
if (!response.ok) {
|
|
@@ -2160,6 +2165,7 @@ var RoutstrClient = class {
|
|
|
2160
2165
|
}
|
|
2161
2166
|
}
|
|
2162
2167
|
if ((status === 402 || status === 413 && responseBody?.includes("Insufficient balance")) && !tryNextProvider && (this.mode === "apikeys" || this.mode === "lazyrefund")) {
|
|
2168
|
+
console.log("RESPONSFE ", responseBody);
|
|
2163
2169
|
const topupResult = await this.balanceManager.topUp({
|
|
2164
2170
|
mintUrl,
|
|
2165
2171
|
baseUrl,
|
|
@@ -2262,8 +2268,6 @@ var RoutstrClient = class {
|
|
|
2262
2268
|
status,
|
|
2263
2269
|
refundResult.message ?? "Unknown error"
|
|
2264
2270
|
);
|
|
2265
|
-
} else {
|
|
2266
|
-
this.storageAdapter.removeApiKey(baseUrl);
|
|
2267
2271
|
}
|
|
2268
2272
|
}
|
|
2269
2273
|
}
|
|
@@ -2362,7 +2366,11 @@ var RoutstrClient = class {
|
|
|
2362
2366
|
baseUrl
|
|
2363
2367
|
);
|
|
2364
2368
|
const latestTokenBalance = latestBalanceInfo.unit === "msat" ? latestBalanceInfo.amount / 1e3 : latestBalanceInfo.amount;
|
|
2365
|
-
this.storageAdapter.
|
|
2369
|
+
const storedApiKeyEntry = this.storageAdapter.getApiKey(baseUrl);
|
|
2370
|
+
if (storedApiKeyEntry?.key.startsWith("cashu") && latestBalanceInfo.apiKey) {
|
|
2371
|
+
this.storageAdapter.removeApiKey(baseUrl);
|
|
2372
|
+
this.storageAdapter.setApiKey(baseUrl, latestBalanceInfo.apiKey);
|
|
2373
|
+
}
|
|
2366
2374
|
this.storageAdapter.updateApiKeyBalance(baseUrl, latestTokenBalance);
|
|
2367
2375
|
satsSpent = initialTokenBalance - latestTokenBalance;
|
|
2368
2376
|
} catch (e) {
|