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/dist/index.js
CHANGED
@@ -3094,7 +3094,7 @@ function withCache(key, fetcher, timeout = defaultCacheTimeout) {
|
|
3094
3094
|
}
|
3095
3095
|
function request(url, options) {
|
3096
3096
|
return __async(this, null, function* () {
|
3097
|
-
var _a;
|
3097
|
+
var _a, _b;
|
3098
3098
|
const defaultHeaders = {
|
3099
3099
|
"Content-Type": "application/json"
|
3100
3100
|
};
|
@@ -3113,6 +3113,15 @@ function request(url, options) {
|
|
3113
3113
|
return Promise.resolve(cached.data);
|
3114
3114
|
}
|
3115
3115
|
}
|
3116
|
+
const setCacheAndReturn = (data) => {
|
3117
|
+
if (cacheKey) {
|
3118
|
+
cache.set(cacheKey, { timestamp: Date.now(), data });
|
3119
|
+
setTimeout(() => {
|
3120
|
+
cache.delete(cacheKey);
|
3121
|
+
}, cacheTimeout);
|
3122
|
+
}
|
3123
|
+
return data;
|
3124
|
+
};
|
3116
3125
|
const newOptions = __spreadProps(__spreadValues({}, options), {
|
3117
3126
|
headers,
|
3118
3127
|
body,
|
@@ -3129,33 +3138,22 @@ function request(url, options) {
|
|
3129
3138
|
if (!res.ok)
|
3130
3139
|
throw new Error(res.statusText);
|
3131
3140
|
const data = yield res.json();
|
3132
|
-
if (options == null ? void 0 : options.shouldStopPolling) {
|
3133
|
-
if (options.
|
3134
|
-
return data;
|
3135
|
-
}
|
3136
|
-
throw new Error("Polling should continue");
|
3137
|
-
}
|
3138
|
-
if (cacheKey) {
|
3139
|
-
cache.set(cacheKey, { timestamp: Date.now(), data });
|
3140
|
-
setTimeout(() => {
|
3141
|
-
cache.delete(cacheKey);
|
3142
|
-
}, cacheTimeout);
|
3143
|
-
}
|
3144
|
-
return data;
|
3145
|
-
} catch (err) {
|
3146
|
-
if (retryCount > 0) {
|
3147
|
-
console.log(`Retrying... attempts left: ${retryCount}`);
|
3148
|
-
return request(url, __spreadProps(__spreadValues({}, options), { retryCount: retryCount - 1 }));
|
3149
|
-
} else if ((options == null ? void 0 : options.pollingInterval) && (options == null ? void 0 : options.maxPollingAttempts)) {
|
3150
|
-
if (options.maxPollingAttempts > 0) {
|
3141
|
+
if ((options == null ? void 0 : options.shouldStopPolling) && !options.shouldStopPolling(data)) {
|
3142
|
+
if ((options == null ? void 0 : options.pollingInterval) && (options == null ? void 0 : options.maxPollingAttempts) && options.maxPollingAttempts > 0) {
|
3151
3143
|
console.log(`Polling... attempts left: ${options.maxPollingAttempts}`);
|
3152
3144
|
yield new Promise((resolve) => setTimeout(resolve, options.pollingInterval));
|
3153
3145
|
return request(url, __spreadProps(__spreadValues({}, options), {
|
3154
3146
|
maxPollingAttempts: options.maxPollingAttempts - 1,
|
3155
|
-
retryCount
|
3147
|
+
retryCount: (_b = options == null ? void 0 : options.retryCount) != null ? _b : 1
|
3156
3148
|
}));
|
3157
3149
|
}
|
3158
3150
|
}
|
3151
|
+
return setCacheAndReturn(data);
|
3152
|
+
} catch (err) {
|
3153
|
+
if (retryCount > 0) {
|
3154
|
+
console.log(`Retrying... attempts left: ${retryCount}`);
|
3155
|
+
return request(url, __spreadProps(__spreadValues({}, options), { retryCount: retryCount - 1 }));
|
3156
|
+
}
|
3159
3157
|
console.error(err);
|
3160
3158
|
return Promise.reject(err);
|
3161
3159
|
}
|
@@ -3508,7 +3506,6 @@ function getAccountInfo(_0) {
|
|
3508
3506
|
console.log(`get_account error, please try again later`, error);
|
3509
3507
|
throw error;
|
3510
3508
|
});
|
3511
|
-
console.log("getAccountInfo resp:", accountInfo);
|
3512
3509
|
return accountInfo;
|
3513
3510
|
});
|
3514
3511
|
}
|
@@ -3679,12 +3676,12 @@ function calculateGasStrategy(_0) {
|
|
3679
3676
|
{ near: new import_big.default(0), btc: new import_big.default(0) }
|
3680
3677
|
);
|
3681
3678
|
const nearAvailableBalance = new import_big.default(nearBalance).minus(transferAmount.near).toNumber();
|
3682
|
-
if (nearAvailableBalance < 0.25) {
|
3683
|
-
throw new Error("NEAR balance is insufficient, please deposit more NEAR");
|
3684
|
-
}
|
3685
3679
|
console.log("available near balance:", nearAvailableBalance);
|
3686
3680
|
console.log("available gas token balance:", gasTokenBalance);
|
3687
3681
|
console.log("gas strategy:", gasStrategy);
|
3682
|
+
if (nearAvailableBalance < 0.25) {
|
3683
|
+
throw new Error("NEAR balance is insufficient, please deposit more NEAR");
|
3684
|
+
}
|
3688
3685
|
const convertTx = yield Promise.all(
|
3689
3686
|
transactions2.map(
|
3690
3687
|
(transaction, index) => convertTransactionToTxHex({
|
@@ -4374,7 +4371,7 @@ function calculateWithdraw(_0) {
|
|
4374
4371
|
amount: "100",
|
4375
4372
|
msg: ""
|
4376
4373
|
},
|
4377
|
-
gas: "
|
4374
|
+
gas: "30000000000000",
|
4378
4375
|
deposit: "1"
|
4379
4376
|
}
|
4380
4377
|
}
|
@@ -5414,7 +5411,7 @@ function getGroup(state) {
|
|
5414
5411
|
|
5415
5412
|
// src/index.ts
|
5416
5413
|
var getVersion = () => {
|
5417
|
-
return "0.5.
|
5414
|
+
return "0.5.94-beta";
|
5418
5415
|
};
|
5419
5416
|
if (typeof window !== "undefined") {
|
5420
5417
|
window.__BTC_WALLET_VERSION = getVersion();
|