btc-wallet 0.5.30-beta → 0.5.32-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.
@@ -8,7 +8,7 @@ export declare function useBtcWalletSelector(): {
8
8
  autoConnect: () => Promise<void>;
9
9
  logout: () => void;
10
10
  account: string;
11
- getPublicKey: () => any;
11
+ getPublicKey: () => Promise<string | undefined>;
12
12
  signMessage: (msg: string) => any;
13
13
  getContext: () => any;
14
14
  getNetwork: () => Promise<"livenet" | "testnet">;
package/dist/index.js CHANGED
@@ -2792,7 +2792,8 @@ function useBtcWalletSelector() {
2792
2792
  }, [signMessage]);
2793
2793
  (0, import_react11.useEffect)(() => {
2794
2794
  const fn = (account) => {
2795
- if (account) {
2795
+ console.log("accountsChanged account", account);
2796
+ if (account == null ? void 0 : account.length) {
2796
2797
  getPublicKey().then((res) => {
2797
2798
  publicKey.current = res;
2798
2799
  context.emit("updatePublicKey", res);
@@ -2854,9 +2855,21 @@ function useBtcWalletSelector() {
2854
2855
  context.emit("btcLogOut");
2855
2856
  },
2856
2857
  account: accounts == null ? void 0 : accounts[0],
2857
- getPublicKey: () => {
2858
- return publicKey.current;
2859
- },
2858
+ getPublicKey: () => __async(this, null, function* () {
2859
+ const publicKey2 = yield getPublicKey();
2860
+ if (publicKey2)
2861
+ return publicKey2;
2862
+ if (connectModalOpen)
2863
+ return;
2864
+ try {
2865
+ yield requestDirectAccount(connectorRef.current);
2866
+ return yield getPublicKey();
2867
+ } catch (error) {
2868
+ console.error("btcLoginError", error);
2869
+ context.emit("btcLoginError");
2870
+ return;
2871
+ }
2872
+ }),
2860
2873
  signMessage: (msg) => {
2861
2874
  return signMessageFn.current(msg);
2862
2875
  },
@@ -2872,10 +2885,12 @@ function useBtcWalletSelector() {
2872
2885
  getNetwork2,
2873
2886
  switchNetwork,
2874
2887
  sendBitcoin2,
2888
+ connectModalOpen,
2875
2889
  openConnectModal,
2876
- requestDirectAccount,
2877
2890
  context,
2878
- disconnect
2891
+ requestDirectAccount,
2892
+ disconnect,
2893
+ getPublicKey
2879
2894
  ]);
2880
2895
  return hook;
2881
2896
  }
@@ -3844,7 +3859,6 @@ var ecc = __toESM(require("@bitcoinerlab/secp256k1"), 1);
3844
3859
  bitcoin.initEccLib(ecc);
3845
3860
  var NEAR_STORAGE_DEPOSIT_AMOUNT = "1250000000000000000000";
3846
3861
  var NBTC_STORAGE_DEPOSIT_AMOUNT = "3000";
3847
- var GAS_LIMIT = "50000000000000";
3848
3862
  var NEW_ACCOUNT_MIN_DEPOSIT_AMOUNT = "1000";
3849
3863
  function getBtcProvider() {
3850
3864
  if (typeof window === "undefined" || !window.btcContext) {
@@ -4068,12 +4082,12 @@ function executeBTCDepositAndAction(_0) {
4068
4082
  const debtAction = yield checkGasTokenDebt(csna, env, false);
4069
4083
  if (debtAction) {
4070
4084
  newActions.push(__spreadProps(__spreadValues({}, debtAction), {
4071
- gas: GAS_LIMIT
4085
+ gas: "30000000000000"
4072
4086
  }));
4073
4087
  }
4074
4088
  if (action) {
4075
4089
  newActions.push(__spreadProps(__spreadValues({}, action), {
4076
- gas: GAS_LIMIT
4090
+ gas: "100000000000000"
4077
4091
  }));
4078
4092
  }
4079
4093
  const storageDepositMsg = {};
@@ -4607,7 +4621,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
4607
4621
  });
4608
4622
  const context = window.btcContext.getContext();
4609
4623
  context.on("updatePublicKey", (btcPublicKey) => __async(this, null, function* () {
4610
- console.log("updatePublicKey");
4611
4624
  state_default.clear();
4612
4625
  console.log("updatePublicKey clear");
4613
4626
  try {
@@ -4906,7 +4919,7 @@ function getGroup(state) {
4906
4919
 
4907
4920
  // src/index.ts
4908
4921
  var getVersion = () => {
4909
- return "0.5.30-beta";
4922
+ return "0.5.32-beta";
4910
4923
  };
4911
4924
  if (typeof window !== "undefined") {
4912
4925
  window.__BTC_WALLET_VERSION = getVersion();