@routstr/sdk 0.3.0 → 0.3.1
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 +5 -4
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +5 -4
- package/dist/client/index.mjs.map +1 -1
- package/dist/discovery/index.js +2 -0
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +2 -0
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -385,6 +385,7 @@ var ModelManager = class _ModelManager {
|
|
|
385
385
|
if (!(error instanceof Error)) return false;
|
|
386
386
|
const msg = error.message.toLowerCase();
|
|
387
387
|
if (msg.includes("fetch failed")) return true;
|
|
388
|
+
if (msg.includes("429")) return true;
|
|
388
389
|
if (msg.includes("502")) return true;
|
|
389
390
|
if (msg.includes("503")) return true;
|
|
390
391
|
if (msg.includes("504")) return true;
|
|
@@ -663,6 +664,7 @@ var MintDiscovery = class {
|
|
|
663
664
|
if (!(error instanceof Error)) return false;
|
|
664
665
|
const msg = error.message.toLowerCase();
|
|
665
666
|
if (msg.includes("fetch failed")) return true;
|
|
667
|
+
if (msg.includes("429")) return true;
|
|
666
668
|
if (msg.includes("502")) return true;
|
|
667
669
|
if (msg.includes("503")) return true;
|
|
668
670
|
if (msg.includes("504")) return true;
|
|
@@ -5290,11 +5292,12 @@ var RoutstrClient = class {
|
|
|
5290
5292
|
baseUrl
|
|
5291
5293
|
);
|
|
5292
5294
|
const currentBalance = currentBalanceInfo.unit === "msat" ? currentBalanceInfo.amount / 1e3 : currentBalanceInfo.amount;
|
|
5293
|
-
const
|
|
5295
|
+
const reservedBalance = currentBalanceInfo.unit === "msat" ? (currentBalanceInfo.reserved ?? 0) / 1e3 : currentBalanceInfo.reserved ?? 0;
|
|
5296
|
+
const shortfall = Math.max(0, params.requiredSats - currentBalance + reservedBalance);
|
|
5294
5297
|
topupAmount = shortfall > 0.21 * params.requiredSats ? shortfall : 0.21 * params.requiredSats;
|
|
5295
5298
|
this._log(
|
|
5296
5299
|
"DEBUG",
|
|
5297
|
-
`The shortfall is: ${shortfall}. requiredSats: ${params.requiredSats}. Current Balance: ${currentBalance} `
|
|
5300
|
+
`The shortfall is: ${shortfall}. requiredSats: ${params.requiredSats}. Current Balance: ${currentBalance}. Reserved Balance: ${reservedBalance}. Available Balance: ${currentBalance - reservedBalance}`
|
|
5298
5301
|
);
|
|
5299
5302
|
} catch (e) {
|
|
5300
5303
|
this._log(
|
|
@@ -5439,10 +5442,10 @@ var RoutstrClient = class {
|
|
|
5439
5442
|
tryNextProvider = true;
|
|
5440
5443
|
}
|
|
5441
5444
|
}
|
|
5442
|
-
if ((status === 401 || status === 403 || status === 413 || status === 400 || status === 500 || status === 502 || status === 503 || status === 504 || status === 521) && !tryNextProvider) {
|
|
5445
|
+
if ((status === 401 || status === 403 || status === 413 || status === 400 || status === 429 || status === 500 || status === 502 || status === 503 || status === 504 || status === 521) && !tryNextProvider) {
|
|
5443
5446
|
this._log(
|
|
5444
5447
|
"DEBUG",
|
|
5445
|
-
`[RoutstrClient] _handleErrorResponse: Status ${status} (auth/server error), attempting refund for ${baseUrl}, mode=${this.mode}`
|
|
5448
|
+
`[RoutstrClient] _handleErrorResponse: Status ${status} (${status === 429 ? "rate limited" : "auth/server error"}), attempting refund for ${baseUrl}, mode=${this.mode}`
|
|
5446
5449
|
);
|
|
5447
5450
|
if (this.mode === "apikeys") {
|
|
5448
5451
|
this._log(
|