btc-wallet 0.5.38-beta → 0.5.40-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/README.md CHANGED
@@ -103,7 +103,11 @@ Get the native BTC balance for a given Bitcoin address.
103
103
  ```typescript
104
104
  import { getBtcBalance } from 'btc-wallet';
105
105
 
106
- const balance = await getBtcBalance(address: string);
106
+ const balance = await getBtcBalance(address: string, option?: {
107
+ /** if csna is provided, available balance will be calculated protocol fee and repay amount */
108
+ csna?: string;
109
+ env?: ENV;
110
+ });
107
111
  // Returns balance in satoshis
108
112
  ```
109
113
 
@@ -17,6 +17,8 @@ export declare function getBtcUtxos(account: string): Promise<{
17
17
  }[]>;
18
18
  export declare function calculateGasFee(account: string, amount: number, feeRate?: number): Promise<any>;
19
19
  export declare function getBtcBalance(account?: string, option?: {
20
+ /** if csna is provided, available balance will be calculated protocol fee and repay amount */
21
+ csna?: string;
20
22
  env?: ENV;
21
23
  }): Promise<{
22
24
  rawBalance: number;
package/dist/index.js CHANGED
@@ -3284,9 +3284,9 @@ function receiveDepositMsg(_0, _1) {
3284
3284
  function checkBridgeTransactionStatus(url, txHash) {
3285
3285
  return __async(this, null, function* () {
3286
3286
  const { result_code, result_message, result_data } = yield request(`${url}/v1/bridgeFromTx?fromTxHash=${txHash}&fromChainId=1`, {
3287
- timeout: 3e5,
3287
+ timeout: 3 * 60 * 60 * 1e3,
3288
3288
  pollingInterval: 5e3,
3289
- maxPollingAttempts: 60,
3289
+ maxPollingAttempts: 3e3,
3290
3290
  shouldStopPolling: (res) => {
3291
3291
  var _a;
3292
3292
  const status = ((_a = res.result_data) == null ? void 0 : _a.Status) || 0;
@@ -3945,8 +3945,6 @@ function calculateGasFee(account, amount, feeRate) {
3945
3945
  }
3946
3946
  function getBtcBalance(account, option) {
3947
3947
  return __async(this, null, function* () {
3948
- const env = (option == null ? void 0 : option.env) || "mainnet";
3949
- let csna = "";
3950
3948
  if (!account) {
3951
3949
  const res = yield retryOperation(getBtcProvider, (res2) => !!res2.account);
3952
3950
  if (!res.account) {
@@ -3954,7 +3952,6 @@ function getBtcBalance(account, option) {
3954
3952
  return { rawBalance: 0, balance: 0, availableBalance: 0 };
3955
3953
  }
3956
3954
  account = res.account;
3957
- csna = yield getCsnaAccountId(env);
3958
3955
  }
3959
3956
  const utxos = yield getBtcUtxos(account);
3960
3957
  const btcDecimals = 8;
@@ -3962,11 +3959,8 @@ function getBtcBalance(account, option) {
3962
3959
  const balance = rawBalance / __pow(10, btcDecimals);
3963
3960
  const estimatedFee = yield calculateGasFee(account, rawBalance);
3964
3961
  let availableRawBalance = (rawBalance - estimatedFee).toFixed(0);
3965
- if (csna) {
3966
- const { protocolFee, repayAmount } = yield getDepositAmount(rawBalance.toString(), {
3967
- env,
3968
- csna
3969
- });
3962
+ if (option == null ? void 0 : option.csna) {
3963
+ const { protocolFee, repayAmount } = yield getDepositAmount(rawBalance.toString(), option);
3970
3964
  availableRawBalance = new import_big2.default(availableRawBalance).minus(protocolFee).minus(repayAmount).toFixed(0);
3971
3965
  }
3972
3966
  const availableBalance = new import_big2.default(availableRawBalance).div(__pow(10, btcDecimals)).round(btcDecimals, import_big2.default.roundDown).toNumber();
@@ -4922,7 +4916,7 @@ function getGroup(state) {
4922
4916
 
4923
4917
  // src/index.ts
4924
4918
  var getVersion = () => {
4925
- return "0.5.38-beta";
4919
+ return "0.5.40-beta";
4926
4920
  };
4927
4921
  if (typeof window !== "undefined") {
4928
4922
  window.__BTC_WALLET_VERSION = getVersion();