btc-wallet 0.5.36-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/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
- const availableRawBalance = (rawBalance - estimatedFee).toFixed(0);
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,
@@ -4707,7 +4717,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
4707
4717
  gas_limit: gasLimit,
4708
4718
  use_near_pay_gas: useNearPayGas,
4709
4719
  nonce,
4710
- replace: true
4720
+ replace: env === "private_mainnet" ? true : void 0
4711
4721
  };
4712
4722
  const strIntention = JSON.stringify(intention);
4713
4723
  const signature = yield btcContext.signMessage(strIntention);
@@ -4845,7 +4855,7 @@ function getGroup(state) {
4845
4855
 
4846
4856
  // src/index.ts
4847
4857
  var getVersion = () => {
4848
- return "0.5.36-beta";
4858
+ return "0.5.38-beta";
4849
4859
  };
4850
4860
  if (typeof window !== "undefined") {
4851
4861
  window.__BTC_WALLET_VERSION = getVersion();