btc-wallet 0.5.92-beta → 0.5.94-beta
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 +24 -27
- package/dist/index.js.map +2 -2
- package/esm/index.js +24 -27
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/esm/index.js
CHANGED
@@ -3021,7 +3021,7 @@ function withCache(key, fetcher, timeout = defaultCacheTimeout) {
|
|
3021
3021
|
}
|
3022
3022
|
function request(url, options) {
|
3023
3023
|
return __async(this, null, function* () {
|
3024
|
-
var _a;
|
3024
|
+
var _a, _b;
|
3025
3025
|
const defaultHeaders = {
|
3026
3026
|
"Content-Type": "application/json"
|
3027
3027
|
};
|
@@ -3040,6 +3040,15 @@ function request(url, options) {
|
|
3040
3040
|
return Promise.resolve(cached.data);
|
3041
3041
|
}
|
3042
3042
|
}
|
3043
|
+
const setCacheAndReturn = (data) => {
|
3044
|
+
if (cacheKey) {
|
3045
|
+
cache.set(cacheKey, { timestamp: Date.now(), data });
|
3046
|
+
setTimeout(() => {
|
3047
|
+
cache.delete(cacheKey);
|
3048
|
+
}, cacheTimeout);
|
3049
|
+
}
|
3050
|
+
return data;
|
3051
|
+
};
|
3043
3052
|
const newOptions = __spreadProps(__spreadValues({}, options), {
|
3044
3053
|
headers,
|
3045
3054
|
body,
|
@@ -3056,33 +3065,22 @@ function request(url, options) {
|
|
3056
3065
|
if (!res.ok)
|
3057
3066
|
throw new Error(res.statusText);
|
3058
3067
|
const data = yield res.json();
|
3059
|
-
if (options == null ? void 0 : options.shouldStopPolling) {
|
3060
|
-
if (options.
|
3061
|
-
return data;
|
3062
|
-
}
|
3063
|
-
throw new Error("Polling should continue");
|
3064
|
-
}
|
3065
|
-
if (cacheKey) {
|
3066
|
-
cache.set(cacheKey, { timestamp: Date.now(), data });
|
3067
|
-
setTimeout(() => {
|
3068
|
-
cache.delete(cacheKey);
|
3069
|
-
}, cacheTimeout);
|
3070
|
-
}
|
3071
|
-
return data;
|
3072
|
-
} catch (err) {
|
3073
|
-
if (retryCount > 0) {
|
3074
|
-
console.log(`Retrying... attempts left: ${retryCount}`);
|
3075
|
-
return request(url, __spreadProps(__spreadValues({}, options), { retryCount: retryCount - 1 }));
|
3076
|
-
} else if ((options == null ? void 0 : options.pollingInterval) && (options == null ? void 0 : options.maxPollingAttempts)) {
|
3077
|
-
if (options.maxPollingAttempts > 0) {
|
3068
|
+
if ((options == null ? void 0 : options.shouldStopPolling) && !options.shouldStopPolling(data)) {
|
3069
|
+
if ((options == null ? void 0 : options.pollingInterval) && (options == null ? void 0 : options.maxPollingAttempts) && options.maxPollingAttempts > 0) {
|
3078
3070
|
console.log(`Polling... attempts left: ${options.maxPollingAttempts}`);
|
3079
3071
|
yield new Promise((resolve) => setTimeout(resolve, options.pollingInterval));
|
3080
3072
|
return request(url, __spreadProps(__spreadValues({}, options), {
|
3081
3073
|
maxPollingAttempts: options.maxPollingAttempts - 1,
|
3082
|
-
retryCount
|
3074
|
+
retryCount: (_b = options == null ? void 0 : options.retryCount) != null ? _b : 1
|
3083
3075
|
}));
|
3084
3076
|
}
|
3085
3077
|
}
|
3078
|
+
return setCacheAndReturn(data);
|
3079
|
+
} catch (err) {
|
3080
|
+
if (retryCount > 0) {
|
3081
|
+
console.log(`Retrying... attempts left: ${retryCount}`);
|
3082
|
+
return request(url, __spreadProps(__spreadValues({}, options), { retryCount: retryCount - 1 }));
|
3083
|
+
}
|
3086
3084
|
console.error(err);
|
3087
3085
|
return Promise.reject(err);
|
3088
3086
|
}
|
@@ -3435,7 +3433,6 @@ function getAccountInfo(_0) {
|
|
3435
3433
|
console.log(`get_account error, please try again later`, error);
|
3436
3434
|
throw error;
|
3437
3435
|
});
|
3438
|
-
console.log("getAccountInfo resp:", accountInfo);
|
3439
3436
|
return accountInfo;
|
3440
3437
|
});
|
3441
3438
|
}
|
@@ -3606,12 +3603,12 @@ function calculateGasStrategy(_0) {
|
|
3606
3603
|
{ near: new Big(0), btc: new Big(0) }
|
3607
3604
|
);
|
3608
3605
|
const nearAvailableBalance = new Big(nearBalance).minus(transferAmount.near).toNumber();
|
3609
|
-
if (nearAvailableBalance < 0.25) {
|
3610
|
-
throw new Error("NEAR balance is insufficient, please deposit more NEAR");
|
3611
|
-
}
|
3612
3606
|
console.log("available near balance:", nearAvailableBalance);
|
3613
3607
|
console.log("available gas token balance:", gasTokenBalance);
|
3614
3608
|
console.log("gas strategy:", gasStrategy);
|
3609
|
+
if (nearAvailableBalance < 0.25) {
|
3610
|
+
throw new Error("NEAR balance is insufficient, please deposit more NEAR");
|
3611
|
+
}
|
3615
3612
|
const convertTx = yield Promise.all(
|
3616
3613
|
transactions2.map(
|
3617
3614
|
(transaction, index) => convertTransactionToTxHex({
|
@@ -4301,7 +4298,7 @@ function calculateWithdraw(_0) {
|
|
4301
4298
|
amount: "100",
|
4302
4299
|
msg: ""
|
4303
4300
|
},
|
4304
|
-
gas: "
|
4301
|
+
gas: "30000000000000",
|
4305
4302
|
deposit: "1"
|
4306
4303
|
}
|
4307
4304
|
}
|
@@ -5343,7 +5340,7 @@ function getGroup(state) {
|
|
5343
5340
|
|
5344
5341
|
// src/index.ts
|
5345
5342
|
var getVersion = () => {
|
5346
|
-
return "0.5.
|
5343
|
+
return "0.5.94-beta";
|
5347
5344
|
};
|
5348
5345
|
if (typeof window !== "undefined") {
|
5349
5346
|
window.__BTC_WALLET_VERSION = getVersion();
|