btc-wallet 0.5.51-beta → 0.5.53-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
@@ -2390,6 +2390,17 @@ var ConnectProvider = ({
2390
2390
  name: ((_a = Object.keys(options.aaOptions.accountContracts)) == null ? void 0 : _a[0]) || "BTC",
2391
2391
  version: ((_c = options.aaOptions.accountContracts[((_b = Object.keys(options.aaOptions.accountContracts)) == null ? void 0 : _b[0]) || "BTC"]) == null ? void 0 : _c[0].version) || "1.0.0"
2392
2392
  });
2393
+ const getConnectorId = (0, import_react10.useCallback)(() => {
2394
+ if (typeof window === "undefined") {
2395
+ return "";
2396
+ }
2397
+ const id = localStorage.getItem("current-connector-id");
2398
+ return id != null ? id : "";
2399
+ }, []);
2400
+ const getConnector = (0, import_react10.useCallback)(() => {
2401
+ const connectorId2 = getConnectorId();
2402
+ return connectors.find((item) => item.metadata.id === connectorId2);
2403
+ }, [connectorId, connectors]);
2393
2404
  const setAccountContract = (0, import_react10.useCallback)(
2394
2405
  (config) => {
2395
2406
  if (!checkBTCVersion(options.aaOptions.accountContracts, config.name, config.version)) {
@@ -2401,11 +2412,11 @@ var ConnectProvider = ({
2401
2412
  [options.aaOptions.accountContracts, _setAccountContract]
2402
2413
  );
2403
2414
  (0, import_react10.useEffect)(() => {
2404
- const id = localStorage.getItem("current-connector-id");
2405
- if (id) {
2406
- setConnectorId(id);
2415
+ const connectorId2 = getConnectorId();
2416
+ if (connectorId2) {
2417
+ setConnectorId(connectorId2);
2407
2418
  }
2408
- }, [autoConnect]);
2419
+ }, [autoConnect, getConnectorId]);
2409
2420
  const evmSupportChainIds = (0, import_react10.useMemo)(() => {
2410
2421
  var _a2;
2411
2422
  let chainIds = (_a2 = options.aaOptions.accountContracts[accountContract.name]) == null ? void 0 : _a2.filter((item) => item.version === accountContract.version).map((item) => item.chainIds).reduce((a, b) => {
@@ -2415,16 +2426,15 @@ var ConnectProvider = ({
2415
2426
  chainIds = Array.from(new Set(chainIds || []));
2416
2427
  return chainIds;
2417
2428
  }, [options.aaOptions.accountContracts, accountContract]);
2418
- const connector = (0, import_react10.useMemo)(() => {
2419
- return connectors.find((item) => item.metadata.id === connectorId);
2420
- }, [connectorId, connectors]);
2429
+ const connector = (0, import_react10.useMemo)(() => getConnector(), [connectorId, connectors]);
2421
2430
  const getPublicKey = (0, import_react10.useCallback)(() => __async(void 0, null, function* () {
2422
- if (!connector) {
2431
+ const connector2 = getConnector();
2432
+ if (!connector2) {
2423
2433
  throw new Error("Wallet not connected!");
2424
2434
  }
2425
- const pubKey = yield connector.getPublicKey();
2435
+ const pubKey = yield connector2.getPublicKey();
2426
2436
  return pubKey;
2427
- }), [connector]);
2437
+ }), [getConnector]);
2428
2438
  const signMessage = (0, import_react10.useCallback)(
2429
2439
  (message) => __async(void 0, null, function* () {
2430
2440
  if (!connector) {
@@ -5045,7 +5055,7 @@ function getGroup(state) {
5045
5055
 
5046
5056
  // src/index.ts
5047
5057
  var getVersion = () => {
5048
- return "0.5.51-beta";
5058
+ return "0.5.53-beta";
5049
5059
  };
5050
5060
  if (typeof window !== "undefined") {
5051
5061
  window.__BTC_WALLET_VERSION = getVersion();