@b3dotfun/sdk 0.0.49-alpha.11 → 0.0.49-alpha.13

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.
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useFirstEOA = useFirstEOA;
4
4
  const react_1 = require("../../../global-account/react");
5
5
  const debug_1 = require("../../../shared/utils/debug");
6
+ const thirdweb_1 = require("../../../shared/utils/thirdweb");
6
7
  const react_2 = require("react");
8
+ const viem_1 = require("thirdweb/adapters/viem");
7
9
  const react_3 = require("thirdweb/react");
8
10
  const debug = (0, debug_1.debugB3React)("useFirstEOA");
9
- function useFirstEOA() {
11
+ function useFirstEOA(chain) {
10
12
  const wallets = (0, react_3.useConnectedWallets)();
11
13
  const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
12
14
  const [firstEOA, setFirstEOA] = (0, react_2.useState)(undefined);
@@ -33,9 +35,27 @@ function useFirstEOA() {
33
35
  };
34
36
  autoSelectFirstEOAWallet();
35
37
  }, [isConnected, wallets]);
38
+ const walletClient = (0, react_2.useMemo)(() => {
39
+ if (!firstEOA)
40
+ return undefined;
41
+ if (!chain)
42
+ return undefined;
43
+ try {
44
+ const viemClientWallet = viem_1.viemAdapter.wallet.toViem({
45
+ client: thirdweb_1.client,
46
+ chain: { id: chain.id, name: chain.name, rpc: chain.rpcUrls.default.http[0] },
47
+ wallet: firstEOA,
48
+ });
49
+ return viemClientWallet;
50
+ }
51
+ catch (err) {
52
+ console.error("Error setting wallet client", err);
53
+ }
54
+ }, [firstEOA, chain]);
36
55
  return {
37
56
  account: firstEOA,
38
57
  address,
39
58
  info: walletInfo,
59
+ walletClient,
40
60
  };
41
61
  }
@@ -35,6 +35,17 @@ export function useAuthentication(partnerId) {
35
35
  const activeWagmiAccount = useAccount();
36
36
  const { switchAccount } = useSwitchAccount();
37
37
  debug("@@activeWagmiAccount", activeWagmiAccount);
38
+ // Check localStorage version and clear if not found or mismatched
39
+ useEffect(() => {
40
+ if (typeof localStorage !== "undefined") {
41
+ const version = localStorage.getItem("version");
42
+ if (version !== "1") {
43
+ debug("@@localStorage:clearing due to version mismatch", { version });
44
+ localStorage.clear();
45
+ localStorage.setItem("version", "1");
46
+ }
47
+ }
48
+ }, []);
38
49
  const wallet = ecosystemWallet(ecosystemWalletId, {
39
50
  partnerId: partnerId,
40
51
  });