btc-wallet 0.5.51-beta → 0.5.52-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,14 @@ 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 initConnectorId = useCallback7(() => {
2324
+ const id = localStorage.getItem("current-connector-id");
2325
+ setConnectorId(id || "");
2326
+ }, []);
2327
+ const getConnector = useCallback7(() => {
2328
+ const connectorId2 = localStorage.getItem("current-connector-id");
2329
+ return connectors.find((item) => item.metadata.id === connectorId2);
2330
+ }, [connectorId, connectors]);
2323
2331
  const setAccountContract = useCallback7(
2324
2332
  (config) => {
2325
2333
  if (!checkBTCVersion(options.aaOptions.accountContracts, config.name, config.version)) {
@@ -2331,11 +2339,8 @@ var ConnectProvider = ({
2331
2339
  [options.aaOptions.accountContracts, _setAccountContract]
2332
2340
  );
2333
2341
  useEffect5(() => {
2334
- const id = localStorage.getItem("current-connector-id");
2335
- if (id) {
2336
- setConnectorId(id);
2337
- }
2338
- }, [autoConnect]);
2342
+ initConnectorId();
2343
+ }, [autoConnect, initConnectorId]);
2339
2344
  const evmSupportChainIds = useMemo5(() => {
2340
2345
  var _a2;
2341
2346
  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 +2350,15 @@ var ConnectProvider = ({
2345
2350
  chainIds = Array.from(new Set(chainIds || []));
2346
2351
  return chainIds;
2347
2352
  }, [options.aaOptions.accountContracts, accountContract]);
2348
- const connector = useMemo5(() => {
2349
- return connectors.find((item) => item.metadata.id === connectorId);
2350
- }, [connectorId, connectors]);
2353
+ const connector = useMemo5(() => getConnector(), [connectorId, connectors]);
2351
2354
  const getPublicKey = useCallback7(() => __async(void 0, null, function* () {
2352
- if (!connector) {
2355
+ const connector2 = getConnector();
2356
+ if (!connector2) {
2353
2357
  throw new Error("Wallet not connected!");
2354
2358
  }
2355
- const pubKey = yield connector.getPublicKey();
2359
+ const pubKey = yield connector2.getPublicKey();
2356
2360
  return pubKey;
2357
- }), [connector]);
2361
+ }), [getConnector]);
2358
2362
  const signMessage = useCallback7(
2359
2363
  (message) => __async(void 0, null, function* () {
2360
2364
  if (!connector) {
@@ -4977,7 +4981,7 @@ function getGroup(state) {
4977
4981
 
4978
4982
  // src/index.ts
4979
4983
  var getVersion = () => {
4980
- return "0.5.51-beta";
4984
+ return "0.5.52-beta";
4981
4985
  };
4982
4986
  if (typeof window !== "undefined") {
4983
4987
  window.__BTC_WALLET_VERSION = getVersion();