btc-wallet 0.5.100-beta → 0.6.0-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/dist/index.js CHANGED
@@ -2528,12 +2528,22 @@ var ConnectProvider = ({
2528
2528
  }, [options.aaOptions.accountContracts, accountContract]);
2529
2529
  const connector = (0, import_react10.useMemo)(() => getConnector(), [connectorId, connectors]);
2530
2530
  const getPublicKey = (0, import_react10.useCallback)(() => __async(void 0, null, function* () {
2531
+ var _a2;
2531
2532
  const connector2 = getConnector();
2532
2533
  if (!connector2) {
2533
2534
  throw new Error("Wallet not connected!");
2534
2535
  }
2535
- const pubKey = yield connector2.getPublicKey();
2536
- return pubKey;
2536
+ try {
2537
+ const pubKey = yield connector2.getPublicKey();
2538
+ return pubKey;
2539
+ } catch (error) {
2540
+ console.error("[BTC Wallet] getPublicKey error:", error);
2541
+ if ((_a2 = error.message) == null ? void 0 : _a2.includes("is not install")) {
2542
+ setConnectorId(void 0);
2543
+ setAccounts([]);
2544
+ }
2545
+ throw error;
2546
+ }
2537
2547
  }), [getConnector]);
2538
2548
  const signMessage2 = (0, import_react10.useCallback)(
2539
2549
  (message) => __async(void 0, null, function* () {
@@ -2556,11 +2566,21 @@ var ConnectProvider = ({
2556
2566
  [connector]
2557
2567
  );
2558
2568
  const getNetwork2 = (0, import_react10.useCallback)(() => __async(void 0, null, function* () {
2569
+ var _a2;
2559
2570
  if (!connector) {
2560
2571
  throw new Error("Wallet not connected!");
2561
2572
  }
2562
- const network = yield connector.getNetwork();
2563
- return network;
2573
+ try {
2574
+ const network = yield connector.getNetwork();
2575
+ return network;
2576
+ } catch (error) {
2577
+ console.error("[BTC Wallet] getNetwork error:", error);
2578
+ if ((_a2 = error.message) == null ? void 0 : _a2.includes("is not install")) {
2579
+ setConnectorId(void 0);
2580
+ setAccounts([]);
2581
+ }
2582
+ throw error;
2583
+ }
2564
2584
  }), [connector]);
2565
2585
  const switchNetwork = (0, import_react10.useCallback)(
2566
2586
  (network) => __async(void 0, null, function* () {
@@ -2594,26 +2614,50 @@ var ConnectProvider = ({
2594
2614
  }, [options, evmSupportChainIds, getPublicKey, signMessage2, accountContract]);
2595
2615
  const requestAccount = (0, import_react10.useCallback)(
2596
2616
  (connector2) => __async(void 0, null, function* () {
2597
- let accounts2 = yield connector2.getAccounts();
2598
- if (accounts2.length === 0 && autoConnect) {
2599
- accounts2 = yield connector2.requestAccounts();
2617
+ var _a2;
2618
+ try {
2619
+ let accounts2 = yield connector2.getAccounts();
2620
+ if (accounts2.length === 0 && autoConnect) {
2621
+ accounts2 = yield connector2.requestAccounts();
2622
+ }
2623
+ setAccounts(accounts2);
2624
+ } catch (error) {
2625
+ console.error("[BTC Wallet] requestAccount error:", error);
2626
+ if ((_a2 = error.message) == null ? void 0 : _a2.includes("is not install")) {
2627
+ setConnectorId(void 0);
2628
+ }
2629
+ setAccounts([]);
2630
+ throw error;
2600
2631
  }
2601
- setAccounts(accounts2);
2602
2632
  }),
2603
2633
  [autoConnect]
2604
2634
  );
2605
2635
  const requestDirectAccount = (0, import_react10.useCallback)((connector2) => __async(void 0, null, function* () {
2606
- let accounts2 = yield connector2.getAccounts();
2607
- if (accounts2.length === 0) {
2608
- accounts2 = yield connector2.requestAccounts();
2636
+ var _a2;
2637
+ try {
2638
+ let accounts2 = yield connector2.getAccounts();
2639
+ if (accounts2.length === 0) {
2640
+ accounts2 = yield connector2.requestAccounts();
2641
+ }
2642
+ setAccounts(accounts2);
2643
+ return accounts2;
2644
+ } catch (error) {
2645
+ console.error("[BTC Wallet] requestDirectAccount error:", error);
2646
+ if ((_a2 = error.message) == null ? void 0 : _a2.includes("is not install")) {
2647
+ setConnectorId(void 0);
2648
+ setAccounts([]);
2649
+ }
2650
+ throw error;
2609
2651
  }
2610
- setAccounts(accounts2);
2611
- return accounts2;
2612
2652
  }), []);
2613
2653
  (0, import_react10.useEffect)(() => {
2614
2654
  if (connector) {
2615
2655
  requestAccount(connector).catch((e) => {
2616
- console.error("get account error", e);
2656
+ var _a2;
2657
+ console.error("[BTC Wallet] requestAccount error:", e);
2658
+ if ((_a2 = e.message) == null ? void 0 : _a2.includes("is not install")) {
2659
+ setConnectorId(void 0);
2660
+ }
2617
2661
  setAccounts([]);
2618
2662
  });
2619
2663
  } else {
@@ -2924,6 +2968,13 @@ function useBtcWalletSelector() {
2924
2968
  eventCache.lastProcessedTime = now;
2925
2969
  getPublicKey().then((res) => {
2926
2970
  context.emit("updatePublicKey", res);
2971
+ }).catch((error) => {
2972
+ var _a;
2973
+ console.error("[BTC Wallet] getPublicKey failed in accountsChanged:", error);
2974
+ if ((_a = error.message) == null ? void 0 : _a.includes("is not install")) {
2975
+ disconnect == null ? void 0 : disconnect();
2976
+ context.emit("btcLogOut");
2977
+ }
2927
2978
  });
2928
2979
  };
2929
2980
  connector == null ? void 0 : connector.on("accountsChanged", handleAccountsChanged);
@@ -2952,7 +3003,6 @@ function useBtcWalletSelector() {
2952
3003
  );
2953
3004
  return account || null;
2954
3005
  } catch (error) {
2955
- console.error("btcLoginError", error);
2956
3006
  context.emit("btcLoginError");
2957
3007
  return null;
2958
3008
  }
@@ -5466,7 +5516,7 @@ function getGroup(state) {
5466
5516
 
5467
5517
  // src/index.ts
5468
5518
  var getVersion = () => {
5469
- return "0.5.100-beta";
5519
+ return "0.6.0-beta";
5470
5520
  };
5471
5521
  if (typeof window !== "undefined") {
5472
5522
  window.__BTC_WALLET_VERSION = getVersion();