btc-wallet 0.5.28-beta → 0.5.29-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.
@@ -9,7 +9,12 @@ type CheckGasTokenDebtReturnType<T extends boolean> = T extends true ? void : {
9
9
  } | undefined;
10
10
  export declare function checkGasTokenDebt<T extends boolean>(csna: string, env: ENV, autoDeposit?: T): Promise<CheckGasTokenDebtReturnType<T>>;
11
11
  export declare function getBtcGasPrice(): Promise<number>;
12
- export declare function getBtcUtxos(account: string): Promise<any>;
12
+ export declare function getBtcUtxos(account: string): Promise<{
13
+ value: number;
14
+ status: {
15
+ confirmed: boolean;
16
+ };
17
+ }[]>;
13
18
  export declare function calculateGasFee(account: string, amount: number, feeRate?: number): Promise<any>;
14
19
  export declare function getBtcBalance(account?: string): Promise<{
15
20
  rawBalance: number;
package/dist/index.js CHANGED
@@ -3926,8 +3926,10 @@ function getBtcGasPrice() {
3926
3926
  function getBtcUtxos(account) {
3927
3927
  return __async(this, null, function* () {
3928
3928
  const btcRpcUrl = yield getBtcRpcUrl();
3929
- const utxos = yield fetch(`${btcRpcUrl}/address/${account}/utxo`).then((res) => res.json());
3930
- return utxos;
3929
+ const utxos = yield fetch(
3930
+ `${btcRpcUrl}/address/${account}/utxo`
3931
+ ).then((res) => res.json());
3932
+ return utxos.filter((item) => item.status.confirmed);
3931
3933
  });
3932
3934
  }
3933
3935
  function calculateGasFee(account, amount, feeRate) {
@@ -4251,7 +4253,7 @@ function getWithdrawTransaction(_0) {
4251
4253
  methodName: "ft_transfer_call",
4252
4254
  args: {
4253
4255
  receiver_id: config.bridgeContractId,
4254
- amount: fromAmount,
4256
+ amount: fromAmount == null ? void 0 : fromAmount.toString(),
4255
4257
  msg: JSON.stringify(msg)
4256
4258
  },
4257
4259
  gas: "300000000000000",
@@ -4426,6 +4428,7 @@ function createIframe({
4426
4428
  document.body.appendChild(iframe);
4427
4429
  return iframe;
4428
4430
  }
4431
+ var currentMessageHandler = null;
4429
4432
  function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
4430
4433
  return __async(this, null, function* () {
4431
4434
  var _a;
@@ -4445,7 +4448,11 @@ function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
4445
4448
  executeBTCDepositAndAction,
4446
4449
  getWithdrawTransaction
4447
4450
  };
4448
- window.addEventListener("message", (event) => __async(this, null, function* () {
4451
+ if (currentMessageHandler) {
4452
+ window.removeEventListener("message", currentMessageHandler);
4453
+ currentMessageHandler = null;
4454
+ }
4455
+ const handleWalletMessage = (event) => __async(this, null, function* () {
4449
4456
  var _a2, _b;
4450
4457
  if (event.origin !== iframeSrc.origin)
4451
4458
  return;
@@ -4476,7 +4483,9 @@ function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
4476
4483
  { targetOrigin: event.origin }
4477
4484
  );
4478
4485
  }
4479
- }));
4486
+ });
4487
+ currentMessageHandler = handleWalletMessage;
4488
+ window.addEventListener("message", handleWalletMessage);
4480
4489
  });
4481
4490
  }
4482
4491
  function removeWalletButton() {
@@ -4897,7 +4906,7 @@ function getGroup(state) {
4897
4906
 
4898
4907
  // src/index.ts
4899
4908
  var getVersion = () => {
4900
- return "0.5.28-beta";
4909
+ return "0.5.29-beta";
4901
4910
  };
4902
4911
  if (typeof window !== "undefined") {
4903
4912
  window.__BTC_WALLET_VERSION = getVersion();