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/esm/index.js CHANGED
@@ -2452,12 +2452,22 @@ var ConnectProvider = ({
2452
2452
  }, [options.aaOptions.accountContracts, accountContract]);
2453
2453
  const connector = useMemo5(() => getConnector(), [connectorId, connectors]);
2454
2454
  const getPublicKey = useCallback7(() => __async(void 0, null, function* () {
2455
+ var _a2;
2455
2456
  const connector2 = getConnector();
2456
2457
  if (!connector2) {
2457
2458
  throw new Error("Wallet not connected!");
2458
2459
  }
2459
- const pubKey = yield connector2.getPublicKey();
2460
- return pubKey;
2460
+ try {
2461
+ const pubKey = yield connector2.getPublicKey();
2462
+ return pubKey;
2463
+ } catch (error) {
2464
+ console.error("[BTC Wallet] getPublicKey error:", error);
2465
+ if ((_a2 = error.message) == null ? void 0 : _a2.includes("is not install")) {
2466
+ setConnectorId(void 0);
2467
+ setAccounts([]);
2468
+ }
2469
+ throw error;
2470
+ }
2461
2471
  }), [getConnector]);
2462
2472
  const signMessage2 = useCallback7(
2463
2473
  (message) => __async(void 0, null, function* () {
@@ -2480,11 +2490,21 @@ var ConnectProvider = ({
2480
2490
  [connector]
2481
2491
  );
2482
2492
  const getNetwork2 = useCallback7(() => __async(void 0, null, function* () {
2493
+ var _a2;
2483
2494
  if (!connector) {
2484
2495
  throw new Error("Wallet not connected!");
2485
2496
  }
2486
- const network = yield connector.getNetwork();
2487
- return network;
2497
+ try {
2498
+ const network = yield connector.getNetwork();
2499
+ return network;
2500
+ } catch (error) {
2501
+ console.error("[BTC Wallet] getNetwork error:", error);
2502
+ if ((_a2 = error.message) == null ? void 0 : _a2.includes("is not install")) {
2503
+ setConnectorId(void 0);
2504
+ setAccounts([]);
2505
+ }
2506
+ throw error;
2507
+ }
2488
2508
  }), [connector]);
2489
2509
  const switchNetwork = useCallback7(
2490
2510
  (network) => __async(void 0, null, function* () {
@@ -2518,26 +2538,50 @@ var ConnectProvider = ({
2518
2538
  }, [options, evmSupportChainIds, getPublicKey, signMessage2, accountContract]);
2519
2539
  const requestAccount = useCallback7(
2520
2540
  (connector2) => __async(void 0, null, function* () {
2521
- let accounts2 = yield connector2.getAccounts();
2522
- if (accounts2.length === 0 && autoConnect) {
2523
- accounts2 = yield connector2.requestAccounts();
2541
+ var _a2;
2542
+ try {
2543
+ let accounts2 = yield connector2.getAccounts();
2544
+ if (accounts2.length === 0 && autoConnect) {
2545
+ accounts2 = yield connector2.requestAccounts();
2546
+ }
2547
+ setAccounts(accounts2);
2548
+ } catch (error) {
2549
+ console.error("[BTC Wallet] requestAccount error:", error);
2550
+ if ((_a2 = error.message) == null ? void 0 : _a2.includes("is not install")) {
2551
+ setConnectorId(void 0);
2552
+ }
2553
+ setAccounts([]);
2554
+ throw error;
2524
2555
  }
2525
- setAccounts(accounts2);
2526
2556
  }),
2527
2557
  [autoConnect]
2528
2558
  );
2529
2559
  const requestDirectAccount = useCallback7((connector2) => __async(void 0, null, function* () {
2530
- let accounts2 = yield connector2.getAccounts();
2531
- if (accounts2.length === 0) {
2532
- accounts2 = yield connector2.requestAccounts();
2560
+ var _a2;
2561
+ try {
2562
+ let accounts2 = yield connector2.getAccounts();
2563
+ if (accounts2.length === 0) {
2564
+ accounts2 = yield connector2.requestAccounts();
2565
+ }
2566
+ setAccounts(accounts2);
2567
+ return accounts2;
2568
+ } catch (error) {
2569
+ console.error("[BTC Wallet] requestDirectAccount error:", error);
2570
+ if ((_a2 = error.message) == null ? void 0 : _a2.includes("is not install")) {
2571
+ setConnectorId(void 0);
2572
+ setAccounts([]);
2573
+ }
2574
+ throw error;
2533
2575
  }
2534
- setAccounts(accounts2);
2535
- return accounts2;
2536
2576
  }), []);
2537
2577
  useEffect5(() => {
2538
2578
  if (connector) {
2539
2579
  requestAccount(connector).catch((e) => {
2540
- console.error("get account error", e);
2580
+ var _a2;
2581
+ console.error("[BTC Wallet] requestAccount error:", e);
2582
+ if ((_a2 = e.message) == null ? void 0 : _a2.includes("is not install")) {
2583
+ setConnectorId(void 0);
2584
+ }
2541
2585
  setAccounts([]);
2542
2586
  });
2543
2587
  } else {
@@ -2848,6 +2892,13 @@ function useBtcWalletSelector() {
2848
2892
  eventCache.lastProcessedTime = now;
2849
2893
  getPublicKey().then((res) => {
2850
2894
  context.emit("updatePublicKey", res);
2895
+ }).catch((error) => {
2896
+ var _a;
2897
+ console.error("[BTC Wallet] getPublicKey failed in accountsChanged:", error);
2898
+ if ((_a = error.message) == null ? void 0 : _a.includes("is not install")) {
2899
+ disconnect == null ? void 0 : disconnect();
2900
+ context.emit("btcLogOut");
2901
+ }
2851
2902
  });
2852
2903
  };
2853
2904
  connector == null ? void 0 : connector.on("accountsChanged", handleAccountsChanged);
@@ -2876,7 +2927,6 @@ function useBtcWalletSelector() {
2876
2927
  );
2877
2928
  return account || null;
2878
2929
  } catch (error) {
2879
- console.error("btcLoginError", error);
2880
2930
  context.emit("btcLoginError");
2881
2931
  return null;
2882
2932
  }
@@ -5392,7 +5442,7 @@ function getGroup(state) {
5392
5442
 
5393
5443
  // src/index.ts
5394
5444
  var getVersion = () => {
5395
- return "0.5.100-beta";
5445
+ return "0.6.0-beta";
5396
5446
  };
5397
5447
  if (typeof window !== "undefined") {
5398
5448
  window.__BTC_WALLET_VERSION = getVersion();