btc-wallet 0.5.41-beta → 0.5.43-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,11 +103,7 @@ 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, option?: {
107
- /** if csna is provided, available balance will be calculated protocol fee and repay amount */
108
- csna?: string;
109
- env?: ENV;
110
- });
106
+ const balance = await getBtcBalance(address: string);
111
107
  // Returns balance in satoshis
112
108
  ```
113
109
 
@@ -16,11 +16,7 @@ export declare function getBtcUtxos(account: string): Promise<{
16
16
  };
17
17
  }[]>;
18
18
  export declare function calculateGasFee(account: string, amount: number, feeRate?: number): Promise<any>;
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;
22
- env?: ENV;
23
- }): Promise<{
19
+ export declare function getBtcBalance(account?: string): Promise<{
24
20
  rawBalance: number;
25
21
  balance: number;
26
22
  availableBalance: number;
package/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@ export * from './core/setupBTCWallet/index';
6
6
  export * from './core/btcUtils';
7
7
  export * from './config';
8
8
  export * from './core/setupModal';
9
+ export * from './utils/satoshi';
9
10
  export declare const getVersion: () => string;
package/dist/index.js CHANGED
@@ -94,20 +94,35 @@ __export(src_exports, {
94
94
  btcRpcUrls: () => btcRpcUrls,
95
95
  calculateGasFee: () => calculateGasFee,
96
96
  calculateGasLimit: () => calculateGasLimit,
97
+ calculateGasStrategy: () => calculateGasStrategy,
97
98
  calculateWithdraw: () => calculateWithdraw,
99
+ checkBridgeTransactionStatus: () => checkBridgeTransactionStatus,
100
+ checkBtcTransactionStatus: () => checkBtcTransactionStatus,
101
+ checkGasTokenBalance: () => checkGasTokenBalance,
98
102
  checkGasTokenDebt: () => checkGasTokenDebt,
99
103
  checkSatoshiWhitelist: () => checkSatoshiWhitelist,
104
+ convertTransactionToTxHex: () => convertTransactionToTxHex,
100
105
  estimateDepositAmount: () => estimateDepositAmount,
101
106
  executeBTCDepositAndAction: () => executeBTCDepositAndAction,
107
+ getAccountInfo: () => getAccountInfo,
108
+ getBridgeConfig: () => getBridgeConfig,
102
109
  getBtcBalance: () => getBtcBalance,
103
110
  getBtcGasPrice: () => getBtcGasPrice,
104
111
  getBtcUtxos: () => getBtcUtxos,
105
112
  getCsnaAccountId: () => getCsnaAccountId,
106
113
  getDepositAmount: () => getDepositAmount,
114
+ getNearNonce: () => getNearNonce,
115
+ getNonce: () => getNonce,
116
+ getTokenBalance: () => getTokenBalance,
107
117
  getVersion: () => getVersion,
108
118
  getWalletConfig: () => getWalletConfig,
119
+ getWhitelist: () => getWhitelist,
109
120
  getWithdrawTransaction: () => getWithdrawTransaction,
110
121
  nearRpcUrls: () => nearRpcUrls,
122
+ preReceiveDepositMsg: () => preReceiveDepositMsg,
123
+ receiveDepositMsg: () => receiveDepositMsg,
124
+ receiveTransaction: () => receiveTransaction,
125
+ receiveWithdrawMsg: () => receiveWithdrawMsg,
111
126
  sendBitcoin: () => sendBitcoin,
112
127
  setupBTCWallet: () => setupBTCWallet,
113
128
  setupWalletSelectorModal: () => setupWalletSelectorModal,
@@ -3328,6 +3343,22 @@ function getWhitelist(url) {
3328
3343
  return data;
3329
3344
  });
3330
3345
  }
3346
+ function receiveWithdrawMsg(url, txHash) {
3347
+ return __async(this, null, function* () {
3348
+ const { result_code, result_message, result_data } = yield request(
3349
+ `${url}/v1/receiveWithdrawMsg`,
3350
+ {
3351
+ method: "POST",
3352
+ body: { txHash }
3353
+ }
3354
+ );
3355
+ console.log("receiveWithdrawMsg resp:", { result_code, result_message, result_data });
3356
+ if (result_code !== 0) {
3357
+ throw new Error(result_message);
3358
+ }
3359
+ return result_data;
3360
+ });
3361
+ }
3331
3362
  function getAccountInfo(_0) {
3332
3363
  return __async(this, arguments, function* ({ csna, env }) {
3333
3364
  const config = getWalletConfig(env);
@@ -3943,7 +3974,7 @@ function calculateGasFee(account, amount, feeRate) {
3943
3974
  return fee;
3944
3975
  });
3945
3976
  }
3946
- function getBtcBalance(account, option) {
3977
+ function getBtcBalance(account) {
3947
3978
  return __async(this, null, function* () {
3948
3979
  if (!account) {
3949
3980
  const res = yield retryOperation(getBtcProvider, (res2) => !!res2.account);
@@ -3958,11 +3989,7 @@ function getBtcBalance(account, option) {
3958
3989
  const rawBalance = (utxos == null ? void 0 : utxos.reduce((acc, cur) => acc + cur.value, 0)) || 0;
3959
3990
  const balance = rawBalance / __pow(10, btcDecimals);
3960
3991
  const estimatedFee = yield calculateGasFee(account, rawBalance);
3961
- let availableRawBalance = (rawBalance - estimatedFee).toFixed(0);
3962
- if (option == null ? void 0 : option.csna) {
3963
- const { protocolFee, repayAmount } = yield getDepositAmount(rawBalance.toString(), option);
3964
- availableRawBalance = new import_big2.default(availableRawBalance).minus(protocolFee).minus(repayAmount).toFixed(0);
3965
- }
3992
+ const availableRawBalance = (rawBalance - estimatedFee).toFixed(0);
3966
3993
  const availableBalance = new import_big2.default(availableRawBalance).div(__pow(10, btcDecimals)).round(btcDecimals, import_big2.default.roundDown).toNumber();
3967
3994
  return {
3968
3995
  rawBalance,
@@ -4921,7 +4948,7 @@ function getGroup(state) {
4921
4948
 
4922
4949
  // src/index.ts
4923
4950
  var getVersion = () => {
4924
- return "0.5.41-beta";
4951
+ return "0.5.43-beta";
4925
4952
  };
4926
4953
  if (typeof window !== "undefined") {
4927
4954
  window.__BTC_WALLET_VERSION = getVersion();