btc-wallet 0.5.88-beta → 0.5.90-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/core/btcUtils.d.ts +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +2 -2
- package/esm/index.js +7 -4
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/esm/index.js
CHANGED
@@ -3606,6 +3606,9 @@ function calculateGasStrategy(_0) {
|
|
3606
3606
|
{ near: new Big(0), btc: new Big(0) }
|
3607
3607
|
);
|
3608
3608
|
const nearAvailableBalance = new Big(nearBalance).minus(transferAmount.near).toNumber();
|
3609
|
+
if (nearAvailableBalance < 0.3) {
|
3610
|
+
throw new Error("NEAR balance is insufficient, please deposit more NEAR");
|
3611
|
+
}
|
3609
3612
|
console.log("available near balance:", nearAvailableBalance);
|
3610
3613
|
console.log("available gas token balance:", gasTokenBalance);
|
3611
3614
|
console.log("gas strategy:", gasStrategy);
|
@@ -3837,14 +3840,14 @@ function checkGasTokenDebt(_0) {
|
|
3837
3840
|
}
|
3838
3841
|
});
|
3839
3842
|
}
|
3840
|
-
function getBtcGasPrice() {
|
3843
|
+
function getBtcGasPrice(type = "halfHour") {
|
3841
3844
|
return __async(this, null, function* () {
|
3842
3845
|
const network = yield getNetwork();
|
3843
3846
|
const defaultFeeRate = network === "mainnet" ? 5 : 2500;
|
3844
3847
|
try {
|
3845
3848
|
const btcRpcUrl = yield getBtcRpcUrl();
|
3846
3849
|
const res = yield fetch(`${btcRpcUrl}/v1/fees/recommended`).then((res2) => res2.json());
|
3847
|
-
const feeRate = res
|
3850
|
+
const feeRate = res[type + "Fee"] ? Number(res[type + "Fee"]) : defaultFeeRate;
|
3848
3851
|
return feeRate;
|
3849
3852
|
} catch (error) {
|
3850
3853
|
return defaultFeeRate;
|
@@ -3865,7 +3868,7 @@ function calculateGasFee(account, amount, feeRate) {
|
|
3865
3868
|
const _feeRate = feeRate || (yield getBtcGasPrice());
|
3866
3869
|
const utxos = yield getBtcUtxos(account);
|
3867
3870
|
const { fee } = coinselect(utxos, [{ address: account, value: amount }], Math.ceil(_feeRate));
|
3868
|
-
console.log("calculateGasFee fee:", fee);
|
3871
|
+
console.log("calculateGasFee fee:", fee, "feeRate:", _feeRate);
|
3869
3872
|
return fee;
|
3870
3873
|
});
|
3871
3874
|
}
|
@@ -5340,7 +5343,7 @@ function getGroup(state) {
|
|
5340
5343
|
|
5341
5344
|
// src/index.ts
|
5342
5345
|
var getVersion = () => {
|
5343
|
-
return "0.5.
|
5346
|
+
return "0.5.90-beta";
|
5344
5347
|
};
|
5345
5348
|
if (typeof window !== "undefined") {
|
5346
5349
|
window.__BTC_WALLET_VERSION = getVersion();
|