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/dist/core/btcUtils.d.ts
CHANGED
@@ -13,7 +13,7 @@ export declare function checkGasTokenDebt<T extends boolean>({ csna, btcAccount,
|
|
13
13
|
env: ENV;
|
14
14
|
autoDeposit?: T;
|
15
15
|
}): Promise<CheckGasTokenDebtReturnType<T>>;
|
16
|
-
export declare function getBtcGasPrice(): Promise<number>;
|
16
|
+
export declare function getBtcGasPrice(type?: 'fastest' | 'halfHour' | 'hour' | 'economy' | 'minimum'): Promise<number>;
|
17
17
|
export declare function getBtcUtxos(account: string): Promise<{
|
18
18
|
value: number;
|
19
19
|
status: {
|
package/dist/index.js
CHANGED
@@ -3679,6 +3679,9 @@ function calculateGasStrategy(_0) {
|
|
3679
3679
|
{ near: new import_big.default(0), btc: new import_big.default(0) }
|
3680
3680
|
);
|
3681
3681
|
const nearAvailableBalance = new import_big.default(nearBalance).minus(transferAmount.near).toNumber();
|
3682
|
+
if (nearAvailableBalance < 0.3) {
|
3683
|
+
throw new Error("NEAR balance is insufficient, please deposit more NEAR");
|
3684
|
+
}
|
3682
3685
|
console.log("available near balance:", nearAvailableBalance);
|
3683
3686
|
console.log("available gas token balance:", gasTokenBalance);
|
3684
3687
|
console.log("gas strategy:", gasStrategy);
|
@@ -3910,14 +3913,14 @@ function checkGasTokenDebt(_0) {
|
|
3910
3913
|
}
|
3911
3914
|
});
|
3912
3915
|
}
|
3913
|
-
function getBtcGasPrice() {
|
3916
|
+
function getBtcGasPrice(type = "halfHour") {
|
3914
3917
|
return __async(this, null, function* () {
|
3915
3918
|
const network = yield getNetwork();
|
3916
3919
|
const defaultFeeRate = network === "mainnet" ? 5 : 2500;
|
3917
3920
|
try {
|
3918
3921
|
const btcRpcUrl = yield getBtcRpcUrl();
|
3919
3922
|
const res = yield fetch(`${btcRpcUrl}/v1/fees/recommended`).then((res2) => res2.json());
|
3920
|
-
const feeRate = res
|
3923
|
+
const feeRate = res[type + "Fee"] ? Number(res[type + "Fee"]) : defaultFeeRate;
|
3921
3924
|
return feeRate;
|
3922
3925
|
} catch (error) {
|
3923
3926
|
return defaultFeeRate;
|
@@ -3938,7 +3941,7 @@ function calculateGasFee(account, amount, feeRate) {
|
|
3938
3941
|
const _feeRate = feeRate || (yield getBtcGasPrice());
|
3939
3942
|
const utxos = yield getBtcUtxos(account);
|
3940
3943
|
const { fee } = (0, import_coinselect.default)(utxos, [{ address: account, value: amount }], Math.ceil(_feeRate));
|
3941
|
-
console.log("calculateGasFee fee:", fee);
|
3944
|
+
console.log("calculateGasFee fee:", fee, "feeRate:", _feeRate);
|
3942
3945
|
return fee;
|
3943
3946
|
});
|
3944
3947
|
}
|
@@ -5411,7 +5414,7 @@ function getGroup(state) {
|
|
5411
5414
|
|
5412
5415
|
// src/index.ts
|
5413
5416
|
var getVersion = () => {
|
5414
|
-
return "0.5.
|
5417
|
+
return "0.5.90-beta";
|
5415
5418
|
};
|
5416
5419
|
if (typeof window !== "undefined") {
|
5417
5420
|
window.__BTC_WALLET_VERSION = getVersion();
|