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/esm/index.js CHANGED
@@ -2320,6 +2320,17 @@ var ConnectProvider = ({
2320
2320
  name: ((_a = Object.keys(options.aaOptions.accountContracts)) == null ? void 0 : _a[0]) || "BTC",
2321
2321
  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"
2322
2322
  });
2323
+ const getConnectorId = useCallback7(() => {
2324
+ if (typeof window === "undefined") {
2325
+ return "";
2326
+ }
2327
+ const id = localStorage.getItem("current-connector-id");
2328
+ return id != null ? id : "";
2329
+ }, []);
2330
+ const getConnector = useCallback7(() => {
2331
+ const connectorId2 = getConnectorId();
2332
+ return connectors.find((item) => item.metadata.id === connectorId2);
2333
+ }, [connectorId, connectors]);
2323
2334
  const setAccountContract = useCallback7(
2324
2335
  (config) => {
2325
2336
  if (!checkBTCVersion(options.aaOptions.accountContracts, config.name, config.version)) {
@@ -2331,11 +2342,11 @@ var ConnectProvider = ({
2331
2342
  [options.aaOptions.accountContracts, _setAccountContract]
2332
2343
  );
2333
2344
  useEffect5(() => {
2334
- const id = localStorage.getItem("current-connector-id");
2335
- if (id) {
2336
- setConnectorId(id);
2345
+ const connectorId2 = getConnectorId();
2346
+ if (connectorId2) {
2347
+ setConnectorId(connectorId2);
2337
2348
  }
2338
- }, [autoConnect]);
2349
+ }, [autoConnect, getConnectorId]);
2339
2350
  const evmSupportChainIds = useMemo5(() => {
2340
2351
  var _a2;
2341
2352
  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) => {
@@ -2345,16 +2356,15 @@ var ConnectProvider = ({
2345
2356
  chainIds = Array.from(new Set(chainIds || []));
2346
2357
  return chainIds;
2347
2358
  }, [options.aaOptions.accountContracts, accountContract]);
2348
- const connector = useMemo5(() => {
2349
- return connectors.find((item) => item.metadata.id === connectorId);
2350
- }, [connectorId, connectors]);
2359
+ const connector = useMemo5(() => getConnector(), [connectorId, connectors]);
2351
2360
  const getPublicKey = useCallback7(() => __async(void 0, null, function* () {
2352
- if (!connector) {
2361
+ const connector2 = getConnector();
2362
+ if (!connector2) {
2353
2363
  throw new Error("Wallet not connected!");
2354
2364
  }
2355
- const pubKey = yield connector.getPublicKey();
2365
+ const pubKey = yield connector2.getPublicKey();
2356
2366
  return pubKey;
2357
- }), [connector]);
2367
+ }), [getConnector]);
2358
2368
  const signMessage = useCallback7(
2359
2369
  (message) => __async(void 0, null, function* () {
2360
2370
  if (!connector) {
@@ -4977,7 +4987,7 @@ function getGroup(state) {
4977
4987
 
4978
4988
  // src/index.ts
4979
4989
  var getVersion = () => {
4980
- return "0.5.51-beta";
4990
+ return "0.5.53-beta";
4981
4991
  };
4982
4992
  if (typeof window !== "undefined") {
4983
4993
  window.__BTC_WALLET_VERSION = getVersion();