@b3dotfun/sdk 0.1.69-alpha.10 → 0.1.69-alpha.12
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/cjs/global-account/bsmnt.d.ts +0 -1
- package/dist/cjs/global-account/bsmnt.js +0 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +8 -12
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -9
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +5 -7
- package/dist/cjs/global-account/react/utils/index.d.ts +0 -1
- package/dist/cjs/global-account/react/utils/index.js +0 -1
- package/dist/cjs/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/cjs/wallet/react/components/ConnectWallet.js +467 -0
- package/dist/cjs/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/cjs/wallet/react/components/WalletProvider.js +20 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.js +22 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.js +63 -0
- package/dist/cjs/wallet/react/index.d.ts +5 -0
- package/dist/cjs/wallet/react/index.js +16 -0
- package/dist/cjs/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/cjs/wallet/utils/createWalletConfig.js +24 -0
- package/dist/esm/global-account/bsmnt.d.ts +0 -1
- package/dist/esm/global-account/bsmnt.js +0 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +3 -7
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -5
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +5 -7
- package/dist/esm/global-account/react/utils/index.d.ts +0 -1
- package/dist/esm/global-account/react/utils/index.js +0 -1
- package/dist/esm/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/esm/wallet/react/components/ConnectWallet.js +431 -0
- package/dist/esm/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/esm/wallet/react/components/WalletProvider.js +17 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.js +19 -0
- package/dist/esm/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/esm/wallet/react/hooks/useWalletState.js +60 -0
- package/dist/esm/wallet/react/index.d.ts +5 -0
- package/dist/esm/wallet/react/index.js +8 -0
- package/dist/esm/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/esm/wallet/utils/createWalletConfig.js +21 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/global-account/bsmnt.d.ts +0 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/types/global-account/react/utils/index.d.ts +0 -1
- package/dist/types/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/types/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/types/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/types/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/types/wallet/react/index.d.ts +5 -0
- package/dist/types/wallet/utils/createWalletConfig.d.ts +21 -0
- package/package.json +12 -6
- package/src/global-account/bsmnt.ts +0 -6
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +14 -20
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +41 -45
- package/src/global-account/react/utils/createWagmiConfig.tsx +6 -7
- package/src/global-account/react/utils/index.ts +0 -1
- package/src/wallet/__tests__/createWalletConfig.test.ts +39 -0
- package/src/wallet/react/components/ConnectWallet.tsx +665 -0
- package/src/wallet/react/components/WalletProvider.tsx +64 -0
- package/src/wallet/react/hooks/useWalletDisconnect.ts +22 -0
- package/src/wallet/react/hooks/useWalletState.ts +93 -0
- package/src/wallet/react/index.ts +10 -0
- package/src/wallet/utils/createWalletConfig.ts +39 -0
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -54
- package/dist/cjs/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/cjs/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/cjs/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/cjs/global-account/react/hooks/useRPMToken.js +0 -11
- package/dist/cjs/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/cjs/global-account/react/utils/updateAvatar.js +0 -54
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -51
- package/dist/esm/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/esm/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/esm/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/esm/global-account/react/hooks/useRPMToken.js +0 -8
- package/dist/esm/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/esm/global-account/react/utils/updateAvatar.js +0 -18
- package/dist/types/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/types/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/types/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/types/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/src/global-account/react/components/AvatarCreator/AvatarCreator.tsx +0 -90
- package/src/global-account/react/components/ProfileAvatar.tsx +0 -138
- package/src/global-account/react/hooks/useRPMToken.ts +0 -17
- package/src/global-account/react/utils/updateAvatar.ts +0 -21
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ConnectWalletProps {
|
|
2
|
+
/** Theme for the modal and button. Defaults to "light". */
|
|
3
|
+
theme?: "light" | "dark";
|
|
4
|
+
/** Label for the connect button. Defaults to "Connect Wallet". */
|
|
5
|
+
buttonLabel?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Drop-in wallet connection component styled to match the B3 design system.
|
|
9
|
+
* Uses inline styles — works in any app without tailwind configuration.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ConnectWallet({ theme: themeProp, buttonLabel }: ConnectWalletProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { type Config, type CreateConnectorFn } from "wagmi";
|
|
3
|
+
import type { Chain } from "viem";
|
|
4
|
+
export interface WalletProviderProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Chains to support. Defaults to SDK's supportedChains.
|
|
8
|
+
* Must be memoized or defined outside the component — inline arrays cause the
|
|
9
|
+
* wagmi config to rebuild on every render, losing wallet connection state.
|
|
10
|
+
*/
|
|
11
|
+
chains?: Chain[];
|
|
12
|
+
/**
|
|
13
|
+
* Wagmi connectors. Must be memoized or defined outside the component — inline
|
|
14
|
+
* arrays cause the wagmi config to rebuild on every render, losing wallet connection state.
|
|
15
|
+
*/
|
|
16
|
+
connectors?: CreateConnectorFn[];
|
|
17
|
+
/**
|
|
18
|
+
* Optional RPC URL overrides per chain ID.
|
|
19
|
+
* Must be memoized or defined outside the component — inline objects cause the
|
|
20
|
+
* wagmi config to rebuild on every render, losing wallet connection state.
|
|
21
|
+
*/
|
|
22
|
+
rpcUrls?: Record<number, string>;
|
|
23
|
+
/** Escape hatch: pass a fully custom wagmi config. Overrides chains/connectors/rpcUrls. */
|
|
24
|
+
wagmiConfig?: Config;
|
|
25
|
+
/** Provide your own QueryClient for React Query. Defaults to an internal instance. */
|
|
26
|
+
queryClient?: QueryClient;
|
|
27
|
+
/** Whether to auto-reconnect the last wallet on mount. Defaults to false. */
|
|
28
|
+
reconnectOnMount?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Standalone wallet connection provider.
|
|
32
|
+
* Wraps ThirdwebProvider, WagmiProvider, and QueryClientProvider.
|
|
33
|
+
* Use wagmi hooks (useAccount, useConnect, useDisconnect) directly inside.
|
|
34
|
+
*/
|
|
35
|
+
export declare function WalletProvider({ children, chains, connectors, rpcUrls, wagmiConfig: wagmiConfigProp, queryClient: queryClientProp, reconnectOnMount, }: WalletProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disconnect the current wallet via wagmi.
|
|
3
|
+
* Consumers should use this instead of wagmi's useDisconnect directly
|
|
4
|
+
* to ensure a consistent disconnect API across the wallet module.
|
|
5
|
+
*
|
|
6
|
+
* Note: this only disconnects the wagmi layer. When used inside B3Provider,
|
|
7
|
+
* the thirdweb auth session is managed separately by B3Provider's own logout
|
|
8
|
+
* flow (useAuthentication). ConnectWallet is intended for standalone
|
|
9
|
+
* WalletProvider usage where thirdweb auth is not involved.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useWalletDisconnect(): {
|
|
12
|
+
disconnect: () => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Chain } from "viem";
|
|
2
|
+
import type { Connector } from "wagmi";
|
|
3
|
+
export interface WalletConnector {
|
|
4
|
+
/** Display name of the wallet */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Unique identifier for this connector instance */
|
|
7
|
+
uid: string;
|
|
8
|
+
/** Whether the wallet extension/app is detected in the browser */
|
|
9
|
+
isInstalled: boolean;
|
|
10
|
+
/** Connect using this connector. Returns a promise that resolves on success or rejects on failure/rejection. */
|
|
11
|
+
connect: () => Promise<void>;
|
|
12
|
+
/** Raw wagmi connector for advanced use */
|
|
13
|
+
connector: Connector;
|
|
14
|
+
}
|
|
15
|
+
export interface WalletState {
|
|
16
|
+
/** Connected wallet address, or undefined if not connected */
|
|
17
|
+
address: string | undefined;
|
|
18
|
+
/** Whether a wallet is currently connected */
|
|
19
|
+
isConnected: boolean;
|
|
20
|
+
/** Current chain the wallet is connected to */
|
|
21
|
+
chain: Chain | undefined;
|
|
22
|
+
/** Whether a connection attempt is in progress */
|
|
23
|
+
isPending: boolean;
|
|
24
|
+
/** Available wallet connectors, deduplicated by name */
|
|
25
|
+
connectors: WalletConnector[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Unified wallet state from both thirdweb and wagmi layers.
|
|
29
|
+
* Provides available connectors with install status and connect functions.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useWalletState(): WalletState;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { WalletProvider, type WalletProviderProps } from "./components/WalletProvider";
|
|
2
|
+
export { createWalletConfig, type CreateWalletConfigOptions } from "../utils/createWalletConfig";
|
|
3
|
+
export { useWalletDisconnect } from "./hooks/useWalletDisconnect";
|
|
4
|
+
export { useWalletState, type WalletConnector, type WalletState } from "./hooks/useWalletState";
|
|
5
|
+
export { ConnectWallet, type ConnectWalletProps } from "./components/ConnectWallet";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CreateConnectorFn } from "wagmi";
|
|
2
|
+
import type { Chain } from "viem";
|
|
3
|
+
export interface CreateWalletConfigOptions {
|
|
4
|
+
/** Chains to support. Defaults to SDK's supportedChains. Must be non-empty. */
|
|
5
|
+
chains?: Chain[];
|
|
6
|
+
/**
|
|
7
|
+
* Wagmi connectors. Defaults to injected + Coinbase Wallet.
|
|
8
|
+
* Must be memoized if passed to WalletProvider — inline arrays
|
|
9
|
+
* will cause the config to rebuild on every render, losing wallet connection state.
|
|
10
|
+
*/
|
|
11
|
+
connectors?: CreateConnectorFn[];
|
|
12
|
+
/** Optional RPC URL overrides per chain ID. */
|
|
13
|
+
rpcUrls?: Record<number, string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a generic wagmi config with sensible defaults.
|
|
17
|
+
* No ecosystem wallet, no B3-specific concerns.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createWalletConfig(options?: CreateWalletConfigOptions): import("wagmi").Config<readonly [Chain, ...Chain[]], {
|
|
20
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
21
|
+
}, CreateConnectorFn[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.1.69-alpha.
|
|
3
|
+
"version": "0.1.69-alpha.12",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -205,6 +205,16 @@
|
|
|
205
205
|
"import": "./dist/esm/notifications/types/index.js",
|
|
206
206
|
"require": "./dist/cjs/notifications/types/index.js"
|
|
207
207
|
},
|
|
208
|
+
"./wallet/react": {
|
|
209
|
+
"types": "./dist/types/wallet/react/index.d.ts",
|
|
210
|
+
"import": "./dist/esm/wallet/react/index.js",
|
|
211
|
+
"require": "./dist/cjs/wallet/react/index.js"
|
|
212
|
+
},
|
|
213
|
+
"./wallet/utils/*": {
|
|
214
|
+
"types": "./dist/types/wallet/utils/*.d.ts",
|
|
215
|
+
"import": "./dist/esm/wallet/utils/*.js",
|
|
216
|
+
"require": "./dist/cjs/wallet/utils/*.js"
|
|
217
|
+
},
|
|
208
218
|
"./shared/utils": {
|
|
209
219
|
"types": "./dist/types/shared/utils/index.d.ts",
|
|
210
220
|
"import": "./dist/esm/shared/utils/index.js",
|
|
@@ -375,6 +385,7 @@
|
|
|
375
385
|
"thirdweb": "5.116.1",
|
|
376
386
|
"tsc-alias": "^1.8.16",
|
|
377
387
|
"tsc-watch": "^7.1.1",
|
|
388
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
378
389
|
"vitest": "^3.2.4"
|
|
379
390
|
},
|
|
380
391
|
"typesVersions": {
|
|
@@ -388,8 +399,6 @@
|
|
|
388
399
|
"@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
|
|
389
400
|
"@privy-io/react-auth": "^2.8.0",
|
|
390
401
|
"@react-three/postprocessing": "2.16.6",
|
|
391
|
-
"@readyplayerme/react-avatar-creator": "0.5.0",
|
|
392
|
-
"@readyplayerme/visage": "6.10.0",
|
|
393
402
|
"@tanstack/react-query": "5.55.0",
|
|
394
403
|
"@wagmi/core": "2.20.3",
|
|
395
404
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -404,9 +413,6 @@
|
|
|
404
413
|
"@react-three/postprocessing": {
|
|
405
414
|
"optional": true
|
|
406
415
|
},
|
|
407
|
-
"@readyplayerme/visage": {
|
|
408
|
-
"optional": true
|
|
409
|
-
},
|
|
410
416
|
"react-native-mmkv": {
|
|
411
417
|
"optional": true
|
|
412
418
|
},
|
|
@@ -73,12 +73,6 @@ export const resetSocket = () => {
|
|
|
73
73
|
// reset the socket connection
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export function extractAvatarIdFromUrl(url: string): string | null {
|
|
77
|
-
const regex = /https:\/\/models\.readyplayer\.me\/([a-f0-9]{24})\.[a-zA-Z0-9]+/;
|
|
78
|
-
const match = url.match(regex);
|
|
79
|
-
return match ? match[1] : null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
76
|
export const authenticateWithB3JWT = async (fullToken: string, params?: Record<string, any>) => {
|
|
83
77
|
// Do not authenticate if there is no token
|
|
84
78
|
if (!fullToken) {
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
2
|
-
import {
|
|
2
|
+
import { WalletProvider } from "@b3dotfun/sdk/wallet/react";
|
|
3
3
|
import { ThirdwebProvider } from "thirdweb/react";
|
|
4
4
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
5
5
|
|
|
6
6
|
import { ClientType } from "../../../client-manager";
|
|
7
7
|
|
|
8
8
|
import { useMemo } from "react";
|
|
9
|
-
import { WagmiProvider } from "wagmi";
|
|
10
9
|
import { createWagmiConfig } from "../../utils/createWagmiConfig";
|
|
11
10
|
import AuthenticationProvider from "./AuthenticationProvider";
|
|
12
11
|
import { B3ConfigProvider } from "./B3ConfigProvider";
|
|
13
12
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
14
13
|
|
|
15
|
-
// Create queryClient instance
|
|
16
|
-
const queryClient = new QueryClient();
|
|
17
|
-
|
|
18
14
|
/**
|
|
19
15
|
* Main B3Provider component
|
|
20
16
|
*/
|
|
@@ -86,20 +82,18 @@ export function InnerProvider({
|
|
|
86
82
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls }), [partnerId, rpcUrls]);
|
|
87
83
|
|
|
88
84
|
return (
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
</QueryClientProvider>
|
|
103
|
-
</WagmiProvider>
|
|
85
|
+
<WalletProvider wagmiConfig={wagmiConfig}>
|
|
86
|
+
<B3ConfigProvider
|
|
87
|
+
accountOverride={accountOverride}
|
|
88
|
+
environment={environment}
|
|
89
|
+
automaticallySetFirstEoa={false}
|
|
90
|
+
theme={theme}
|
|
91
|
+
clientType={clientType}
|
|
92
|
+
partnerId={partnerId}
|
|
93
|
+
defaultPermissions={defaultPermissions}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
</B3ConfigProvider>
|
|
97
|
+
</WalletProvider>
|
|
104
98
|
);
|
|
105
99
|
}
|
|
@@ -4,12 +4,12 @@ import { RelayKitProviderWrapper, TooltipProvider } from "@b3dotfun/sdk/global-a
|
|
|
4
4
|
import { createWagmiConfig } from "@b3dotfun/sdk/global-account/react/utils/createWagmiConfig";
|
|
5
5
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
6
6
|
import { loadGA4Script } from "@b3dotfun/sdk/global-account/utils/analytics";
|
|
7
|
+
import { WalletProvider } from "@b3dotfun/sdk/wallet/react";
|
|
7
8
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
8
|
-
import { QueryClient
|
|
9
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
9
10
|
import { useEffect, useMemo } from "react";
|
|
10
|
-
import { ThirdwebProvider } from "thirdweb/react";
|
|
11
11
|
import { Account, EIP1193, Wallet } from "thirdweb/wallets";
|
|
12
|
-
import { CreateConnectorFn
|
|
12
|
+
import { CreateConnectorFn } from "wagmi";
|
|
13
13
|
import { ClientType, setClientType } from "../../../client-manager";
|
|
14
14
|
import { StyleRoot } from "../StyleRoot";
|
|
15
15
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index";
|
|
@@ -17,9 +17,6 @@ import AuthenticationProvider from "./AuthenticationProvider";
|
|
|
17
17
|
import { B3ConfigProvider } from "./B3ConfigProvider";
|
|
18
18
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
19
19
|
|
|
20
|
-
// Create queryClient instance
|
|
21
|
-
const queryClient = new QueryClient();
|
|
22
|
-
|
|
23
20
|
/**
|
|
24
21
|
* Main B3Provider component
|
|
25
22
|
*/
|
|
@@ -44,6 +41,7 @@ export function B3Provider({
|
|
|
44
41
|
createClientReferenceId,
|
|
45
42
|
defaultPermissions,
|
|
46
43
|
disableBSMNTAuthentication = false,
|
|
44
|
+
queryClient,
|
|
47
45
|
}: {
|
|
48
46
|
theme: "light" | "dark";
|
|
49
47
|
children: React.ReactNode;
|
|
@@ -69,6 +67,8 @@ export function B3Provider({
|
|
|
69
67
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
70
68
|
defaultPermissions?: PermissionsConfig;
|
|
71
69
|
disableBSMNTAuthentication?: boolean;
|
|
70
|
+
/** Provide your own QueryClient for React Query. If omitted, WalletProvider creates one internally. */
|
|
71
|
+
queryClient?: QueryClient;
|
|
72
72
|
}) {
|
|
73
73
|
// Initialize Google Analytics on mount
|
|
74
74
|
useEffect(() => {
|
|
@@ -86,45 +86,41 @@ export function B3Provider({
|
|
|
86
86
|
);
|
|
87
87
|
|
|
88
88
|
return (
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
<
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
</TooltipProvider>
|
|
125
|
-
</QueryClientProvider>
|
|
126
|
-
</WagmiProvider>
|
|
127
|
-
</ThirdwebProvider>
|
|
89
|
+
<WalletProvider wagmiConfig={wagmiConfig} queryClient={queryClient}>
|
|
90
|
+
<TooltipProvider>
|
|
91
|
+
<ToastProvider>
|
|
92
|
+
<LocalSDKProvider
|
|
93
|
+
onConnectCallback={onConnect}
|
|
94
|
+
onLogoutCallback={onLogout}
|
|
95
|
+
disableBSMNTAuthentication={disableBSMNTAuthentication}
|
|
96
|
+
>
|
|
97
|
+
<B3ConfigProvider
|
|
98
|
+
accountOverride={accountOverride}
|
|
99
|
+
environment={environment}
|
|
100
|
+
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
101
|
+
theme={theme}
|
|
102
|
+
clientType={clientType}
|
|
103
|
+
partnerId={partnerId}
|
|
104
|
+
stripePublishableKey={stripePublishableKey}
|
|
105
|
+
createClientReferenceId={createClientReferenceId}
|
|
106
|
+
defaultPermissions={defaultPermissions}
|
|
107
|
+
>
|
|
108
|
+
<ToastContextConnector />
|
|
109
|
+
<RelayKitProviderWrapper simDuneApiKey={simDuneApiKey}>
|
|
110
|
+
{children}
|
|
111
|
+
{/* For the modal https://github.com/b3-fun/b3/blob/main/packages/sdk/src/global-account/react/components/ui/dialog.tsx#L46 */}
|
|
112
|
+
<StyleRoot id="b3-root" />
|
|
113
|
+
</RelayKitProviderWrapper>
|
|
114
|
+
<AuthenticationProvider
|
|
115
|
+
partnerId={partnerId}
|
|
116
|
+
automaticallySetFirstEoa={!!automaticallySetFirstEoa}
|
|
117
|
+
defaultEoaProvider={defaultEoaProvider}
|
|
118
|
+
/>
|
|
119
|
+
</B3ConfigProvider>
|
|
120
|
+
</LocalSDKProvider>
|
|
121
|
+
</ToastProvider>
|
|
122
|
+
</TooltipProvider>
|
|
123
|
+
</WalletProvider>
|
|
128
124
|
);
|
|
129
125
|
}
|
|
130
126
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { createWalletConfig } from "@b3dotfun/sdk/wallet/utils/createWalletConfig";
|
|
1
2
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
2
|
-
import { supportedChains } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
3
3
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
4
4
|
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
|
|
5
|
-
import {
|
|
6
|
-
import { createConfig, type CreateConnectorFn } from "wagmi";
|
|
5
|
+
import type { CreateConnectorFn } from "wagmi";
|
|
7
6
|
|
|
8
7
|
export interface CreateWagmiConfigOptions {
|
|
9
8
|
partnerId: string;
|
|
@@ -13,7 +12,8 @@ export interface CreateWagmiConfigOptions {
|
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
|
-
* Creates a wagmi config with
|
|
15
|
+
* Creates a wagmi config with the B3 ecosystem wallet connector.
|
|
16
|
+
* Delegates to createWalletConfig and adds the ecosystem connector on top.
|
|
17
17
|
* @param options.partnerId - Partner ID for the ecosystem wallet
|
|
18
18
|
* @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
19
19
|
* @param options.connectors - Additional connectors to include
|
|
@@ -32,9 +32,8 @@ export function createWagmiConfig(options: CreateWagmiConfigOptions) {
|
|
|
32
32
|
|
|
33
33
|
const finalConnectors = overrideDefaultConnectors ? connectors : [...defaultConnectors, ...connectors];
|
|
34
34
|
|
|
35
|
-
return
|
|
36
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
37
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])),
|
|
35
|
+
return createWalletConfig({
|
|
38
36
|
connectors: finalConnectors,
|
|
37
|
+
rpcUrls,
|
|
39
38
|
});
|
|
40
39
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { createWalletConfig } from "../utils/createWalletConfig";
|
|
3
|
+
import { base, optimism } from "viem/chains";
|
|
4
|
+
|
|
5
|
+
describe("createWalletConfig", () => {
|
|
6
|
+
it("should create a config with default chains when no options provided", () => {
|
|
7
|
+
const config = createWalletConfig();
|
|
8
|
+
// Should not throw — uses supportedChains as default
|
|
9
|
+
expect(config).toBeDefined();
|
|
10
|
+
expect(config.chains).toBeDefined();
|
|
11
|
+
expect(config.chains.length).toBeGreaterThan(0);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should create a config with custom chains", () => {
|
|
15
|
+
const config = createWalletConfig({ chains: [base, optimism] });
|
|
16
|
+
expect(config.chains).toHaveLength(2);
|
|
17
|
+
expect(config.chains[0].id).toBe(base.id);
|
|
18
|
+
expect(config.chains[1].id).toBe(optimism.id);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should throw if chains array is empty", () => {
|
|
22
|
+
expect(() => createWalletConfig({ chains: [] })).toThrow("createWalletConfig: at least one chain must be provided");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should accept custom RPC URLs", () => {
|
|
26
|
+
const config = createWalletConfig({
|
|
27
|
+
chains: [base],
|
|
28
|
+
rpcUrls: { [base.id]: "https://custom-rpc.example.com" },
|
|
29
|
+
});
|
|
30
|
+
expect(config).toBeDefined();
|
|
31
|
+
// Config is created without error; transport internals are opaque
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should accept connectors", () => {
|
|
35
|
+
// Pass an empty array (valid) — connector instantiation requires browser env
|
|
36
|
+
const config = createWalletConfig({ chains: [base], connectors: [] });
|
|
37
|
+
expect(config).toBeDefined();
|
|
38
|
+
});
|
|
39
|
+
});
|