btc-wallet 0.5.37-beta → 0.5.38-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 +3 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +2 -2
- package/esm/index.js +13 -3
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
package/esm/index.js
CHANGED
@@ -3874,8 +3874,10 @@ function calculateGasFee(account, amount, feeRate) {
|
|
3874
3874
|
return fee;
|
3875
3875
|
});
|
3876
3876
|
}
|
3877
|
-
function getBtcBalance(account) {
|
3877
|
+
function getBtcBalance(account, option) {
|
3878
3878
|
return __async(this, null, function* () {
|
3879
|
+
const env = (option == null ? void 0 : option.env) || "mainnet";
|
3880
|
+
let csna = "";
|
3879
3881
|
if (!account) {
|
3880
3882
|
const res = yield retryOperation(getBtcProvider, (res2) => !!res2.account);
|
3881
3883
|
if (!res.account) {
|
@@ -3883,13 +3885,21 @@ function getBtcBalance(account) {
|
|
3883
3885
|
return { rawBalance: 0, balance: 0, availableBalance: 0 };
|
3884
3886
|
}
|
3885
3887
|
account = res.account;
|
3888
|
+
csna = yield getCsnaAccountId(env);
|
3886
3889
|
}
|
3887
3890
|
const utxos = yield getBtcUtxos(account);
|
3888
3891
|
const btcDecimals = 8;
|
3889
3892
|
const rawBalance = (utxos == null ? void 0 : utxos.reduce((acc, cur) => acc + cur.value, 0)) || 0;
|
3890
3893
|
const balance = rawBalance / __pow(10, btcDecimals);
|
3891
3894
|
const estimatedFee = yield calculateGasFee(account, rawBalance);
|
3892
|
-
|
3895
|
+
let availableRawBalance = (rawBalance - estimatedFee).toFixed(0);
|
3896
|
+
if (csna) {
|
3897
|
+
const { protocolFee, repayAmount } = yield getDepositAmount(rawBalance.toString(), {
|
3898
|
+
env,
|
3899
|
+
csna
|
3900
|
+
});
|
3901
|
+
availableRawBalance = new Big2(availableRawBalance).minus(protocolFee).minus(repayAmount).toFixed(0);
|
3902
|
+
}
|
3893
3903
|
const availableBalance = new Big2(availableRawBalance).div(__pow(10, btcDecimals)).round(btcDecimals, Big2.roundDown).toNumber();
|
3894
3904
|
return {
|
3895
3905
|
rawBalance,
|
@@ -4845,7 +4855,7 @@ function getGroup(state) {
|
|
4845
4855
|
|
4846
4856
|
// src/index.ts
|
4847
4857
|
var getVersion = () => {
|
4848
|
-
return "0.5.
|
4858
|
+
return "0.5.38-beta";
|
4849
4859
|
};
|
4850
4860
|
if (typeof window !== "undefined") {
|
4851
4861
|
window.__BTC_WALLET_VERSION = getVersion();
|