btc-wallet 0.5.93-beta → 0.5.95-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 +36 -25
- package/dist/index.js.map +2 -2
- package/esm/index.js +36 -25
- package/esm/index.js.map +2 -2
- package/package.json +2 -2
package/esm/index.js
CHANGED
@@ -2988,7 +2988,7 @@ function getWalletConfig(env) {
|
|
2988
2988
|
});
|
2989
2989
|
}
|
2990
2990
|
var nearRpcUrls = {
|
2991
|
-
mainnet: ["https://
|
2991
|
+
mainnet: ["https://near.lava.build", "https://free.rpc.fastnear.com"],
|
2992
2992
|
testnet: ["https://rpc.testnet.near.org"]
|
2993
2993
|
};
|
2994
2994
|
var btcRpcUrls = {
|
@@ -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
|
}
|
@@ -4365,11 +4362,25 @@ function calculateWithdraw(_0) {
|
|
4365
4362
|
}
|
4366
4363
|
const userSatoshis = Number(satoshis);
|
4367
4364
|
const maxBtcFee = Number(brgConfig.max_btc_gas_fee);
|
4368
|
-
|
4365
|
+
let { inputs, outputs, fee } = coinselect(
|
4369
4366
|
utxos,
|
4370
4367
|
[{ address: btcAddress, value: userSatoshis }],
|
4371
4368
|
Math.ceil(feeRate)
|
4372
4369
|
);
|
4370
|
+
if (inputs && inputs.length > 10) {
|
4371
|
+
const filteredUtxos = utxos.filter((utxo) => utxo.value >= userSatoshis);
|
4372
|
+
console.log("filteredUtxos", filteredUtxos);
|
4373
|
+
if (filteredUtxos.length > 0) {
|
4374
|
+
const result = coinselect(
|
4375
|
+
filteredUtxos,
|
4376
|
+
[{ address: btcAddress, value: userSatoshis }],
|
4377
|
+
Math.ceil(feeRate)
|
4378
|
+
);
|
4379
|
+
inputs = result.inputs;
|
4380
|
+
outputs = result.outputs;
|
4381
|
+
fee = result.fee;
|
4382
|
+
}
|
4383
|
+
}
|
4373
4384
|
const newInputs = inputs;
|
4374
4385
|
let newOutputs = outputs;
|
4375
4386
|
let newFee = fee;
|
@@ -5343,7 +5354,7 @@ function getGroup(state) {
|
|
5343
5354
|
|
5344
5355
|
// src/index.ts
|
5345
5356
|
var getVersion = () => {
|
5346
|
-
return "0.5.
|
5357
|
+
return "0.5.95-beta";
|
5347
5358
|
};
|
5348
5359
|
if (typeof window !== "undefined") {
|
5349
5360
|
window.__BTC_WALLET_VERSION = getVersion();
|