@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.49-alpha.11",
3
+ "version": "0.0.49-alpha.13",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -374,7 +374,7 @@
374
374
  "react": "^18.0.0 || ^19.0.0",
375
375
  "react-dom": "^18.0.0 || ^19.0.0",
376
376
  "react-native-mmkv": "^3.2.0",
377
- "thirdweb": "5.108.9",
377
+ "thirdweb": "5.108.14",
378
378
  "three": "^0.175.0",
379
379
  "viem": "^2.28.1",
380
380
  "wagmi": "^2.14.15"
@@ -14,7 +14,7 @@ import {
14
14
  useDisconnect,
15
15
  useSetActiveWallet,
16
16
  } from "thirdweb/react";
17
- import { ecosystemWallet, Wallet } from "thirdweb/wallets";
17
+ import { Wallet, ecosystemWallet } from "thirdweb/wallets";
18
18
  import { preAuthenticate } from "thirdweb/wallets/in-app";
19
19
  import { useAccount, useConnect, useSwitchAccount } from "wagmi";
20
20
  import { useUserQuery } from "./useUserQuery";
@@ -45,6 +45,18 @@ export function useAuthentication(partnerId: string) {
45
45
  const { switchAccount } = useSwitchAccount();
46
46
  debug("@@activeWagmiAccount", activeWagmiAccount);
47
47
 
48
+ // Check localStorage version and clear if not found or mismatched
49
+ useEffect(() => {
50
+ if (typeof localStorage !== "undefined") {
51
+ const version = localStorage.getItem("version");
52
+ if (version !== "1") {
53
+ debug("@@localStorage:clearing due to version mismatch", { version });
54
+ localStorage.clear();
55
+ localStorage.setItem("version", "1");
56
+ }
57
+ }
58
+ }, []);
59
+
48
60
  const wallet = ecosystemWallet(ecosystemWalletId, {
49
61
  partnerId: partnerId,
50
62
  });
@@ -1,12 +1,14 @@
1
1
  import { useAuthStore } from "@b3dotfun/sdk/global-account/react";
2
2
  import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
3
- import { useEffect, useState } from "react";
3
+ import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
4
+ import { useEffect, useMemo, useState } from "react";
5
+ import { viemAdapter } from "thirdweb/adapters/viem";
4
6
  import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
5
7
  import { Wallet } from "thirdweb/wallets";
6
8
 
7
9
  const debug = debugB3React("useFirstEOA");
8
10
 
9
- export function useFirstEOA() {
11
+ export function useFirstEOA(chain?: { id: number; name: string; rpcUrls: { default: { http: string[] } } }) {
10
12
  const wallets = useConnectedWallets();
11
13
  const isConnected = useAuthStore(state => state.isConnected);
12
14
  const [firstEOA, setFirstEOA] = useState<Wallet | undefined>(undefined);
@@ -39,9 +41,25 @@ export function useFirstEOA() {
39
41
  autoSelectFirstEOAWallet();
40
42
  }, [isConnected, wallets]);
41
43
 
44
+ const walletClient = useMemo(() => {
45
+ if (!firstEOA) return undefined;
46
+ if (!chain) return undefined;
47
+ try {
48
+ const viemClientWallet = viemAdapter.wallet.toViem({
49
+ client,
50
+ chain: { id: chain.id, name: chain.name, rpc: chain.rpcUrls.default.http[0] },
51
+ wallet: firstEOA,
52
+ });
53
+ return viemClientWallet;
54
+ } catch (err) {
55
+ console.error("Error setting wallet client", err);
56
+ }
57
+ }, [firstEOA, chain]);
58
+
42
59
  return {
43
60
  account: firstEOA,
44
61
  address,
45
62
  info: walletInfo,
63
+ walletClient,
46
64
  };
47
65
  }