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/dist/index.js CHANGED
@@ -2390,6 +2390,14 @@ 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 initConnectorId = (0, import_react10.useCallback)(() => {
2394
+ const id = localStorage.getItem("current-connector-id");
2395
+ setConnectorId(id || "");
2396
+ }, []);
2397
+ const getConnector = (0, import_react10.useCallback)(() => {
2398
+ const connectorId2 = localStorage.getItem("current-connector-id");
2399
+ return connectors.find((item) => item.metadata.id === connectorId2);
2400
+ }, [connectorId, connectors]);
2393
2401
  const setAccountContract = (0, import_react10.useCallback)(
2394
2402
  (config) => {
2395
2403
  if (!checkBTCVersion(options.aaOptions.accountContracts, config.name, config.version)) {
@@ -2401,11 +2409,8 @@ var ConnectProvider = ({
2401
2409
  [options.aaOptions.accountContracts, _setAccountContract]
2402
2410
  );
2403
2411
  (0, import_react10.useEffect)(() => {
2404
- const id = localStorage.getItem("current-connector-id");
2405
- if (id) {
2406
- setConnectorId(id);
2407
- }
2408
- }, [autoConnect]);
2412
+ initConnectorId();
2413
+ }, [autoConnect, initConnectorId]);
2409
2414
  const evmSupportChainIds = (0, import_react10.useMemo)(() => {
2410
2415
  var _a2;
2411
2416
  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 +2420,15 @@ var ConnectProvider = ({
2415
2420
  chainIds = Array.from(new Set(chainIds || []));
2416
2421
  return chainIds;
2417
2422
  }, [options.aaOptions.accountContracts, accountContract]);
2418
- const connector = (0, import_react10.useMemo)(() => {
2419
- return connectors.find((item) => item.metadata.id === connectorId);
2420
- }, [connectorId, connectors]);
2423
+ const connector = (0, import_react10.useMemo)(() => getConnector(), [connectorId, connectors]);
2421
2424
  const getPublicKey = (0, import_react10.useCallback)(() => __async(void 0, null, function* () {
2422
- if (!connector) {
2425
+ const connector2 = getConnector();
2426
+ if (!connector2) {
2423
2427
  throw new Error("Wallet not connected!");
2424
2428
  }
2425
- const pubKey = yield connector.getPublicKey();
2429
+ const pubKey = yield connector2.getPublicKey();
2426
2430
  return pubKey;
2427
- }), [connector]);
2431
+ }), [getConnector]);
2428
2432
  const signMessage = (0, import_react10.useCallback)(
2429
2433
  (message) => __async(void 0, null, function* () {
2430
2434
  if (!connector) {
@@ -5045,7 +5049,7 @@ function getGroup(state) {
5045
5049
 
5046
5050
  // src/index.ts
5047
5051
  var getVersion = () => {
5048
- return "0.5.51-beta";
5052
+ return "0.5.52-beta";
5049
5053
  };
5050
5054
  if (typeof window !== "undefined") {
5051
5055
  window.__BTC_WALLET_VERSION = getVersion();