@b3dotfun/sdk 0.1.69-alpha.11 → 0.1.69-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/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +5 -1
- 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/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/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +5 -1
- 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/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/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -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/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 -1
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +6 -0
- 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/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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWalletState = useWalletState;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const wagmi_1 = require("wagmi");
|
|
6
|
+
/**
|
|
7
|
+
* Unified wallet state from both thirdweb and wagmi layers.
|
|
8
|
+
* Provides available connectors with install status and connect functions.
|
|
9
|
+
*/
|
|
10
|
+
function useWalletState() {
|
|
11
|
+
const { address, isConnected, chain } = (0, wagmi_1.useAccount)();
|
|
12
|
+
const { connectAsync, isPending } = (0, wagmi_1.useConnect)();
|
|
13
|
+
const wagmiConnectors = (0, wagmi_1.useConnectors)();
|
|
14
|
+
// Ref to avoid connectAsync in useMemo deps — wagmi returns a new reference on state
|
|
15
|
+
// changes, which would recreate the connectors array on every render.
|
|
16
|
+
const connectAsyncRef = (0, react_1.useRef)(connectAsync);
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
18
|
+
connectAsyncRef.current = connectAsync;
|
|
19
|
+
});
|
|
20
|
+
const connectors = (0, react_1.useMemo)(() => {
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
const mapped = wagmiConnectors
|
|
23
|
+
.filter(c => {
|
|
24
|
+
// Hide generic "Injected" — it duplicates the actual wallet (MetaMask, Rabby, etc.)
|
|
25
|
+
if (c.name === "Injected")
|
|
26
|
+
return false;
|
|
27
|
+
if (seen.has(c.name))
|
|
28
|
+
return false;
|
|
29
|
+
seen.add(c.name);
|
|
30
|
+
return true;
|
|
31
|
+
})
|
|
32
|
+
.map(connector => ({
|
|
33
|
+
name: connector.name,
|
|
34
|
+
uid: connector.uid,
|
|
35
|
+
isInstalled: isConnectorInstalled(connector),
|
|
36
|
+
connect: async () => {
|
|
37
|
+
await connectAsyncRef.current({ connector });
|
|
38
|
+
},
|
|
39
|
+
connector,
|
|
40
|
+
}));
|
|
41
|
+
// Sort: installed connectors first
|
|
42
|
+
return mapped.sort((a, b) => (a.isInstalled === b.isInstalled ? 0 : a.isInstalled ? -1 : 1));
|
|
43
|
+
}, [wagmiConnectors]);
|
|
44
|
+
return { address, isConnected, chain, isPending, connectors };
|
|
45
|
+
}
|
|
46
|
+
/** Check if a wallet connector's provider is available in the browser. */
|
|
47
|
+
function isConnectorInstalled(connector) {
|
|
48
|
+
// WalletConnect is always "available" (uses QR code, no extension needed)
|
|
49
|
+
if (connector.id === "walletConnect")
|
|
50
|
+
return true;
|
|
51
|
+
// For injected connectors, check if any provider exists. This may report
|
|
52
|
+
// false positives (e.g., Rabby shows as installed when only MetaMask is)
|
|
53
|
+
// because multiple injected connectors share window.ethereum. This is
|
|
54
|
+
// intentional — we surface all options and let the wallet handle conflicts.
|
|
55
|
+
if (connector.type === "injected") {
|
|
56
|
+
return typeof window !== "undefined" && !!window.ethereum;
|
|
57
|
+
}
|
|
58
|
+
// Coinbase Wallet SDK works without extension (has mobile/QR fallback)
|
|
59
|
+
if (connector.id === "coinbaseWalletSDK")
|
|
60
|
+
return true;
|
|
61
|
+
// Default: assume available (better UX than hiding connectors)
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
@@ -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,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectWallet = exports.useWalletState = exports.useWalletDisconnect = exports.createWalletConfig = exports.WalletProvider = void 0;
|
|
4
|
+
// Provider
|
|
5
|
+
var WalletProvider_1 = require("./components/WalletProvider");
|
|
6
|
+
Object.defineProperty(exports, "WalletProvider", { enumerable: true, get: function () { return WalletProvider_1.WalletProvider; } });
|
|
7
|
+
var createWalletConfig_1 = require("../utils/createWalletConfig");
|
|
8
|
+
Object.defineProperty(exports, "createWalletConfig", { enumerable: true, get: function () { return createWalletConfig_1.createWalletConfig; } });
|
|
9
|
+
// Hooks
|
|
10
|
+
var useWalletDisconnect_1 = require("./hooks/useWalletDisconnect");
|
|
11
|
+
Object.defineProperty(exports, "useWalletDisconnect", { enumerable: true, get: function () { return useWalletDisconnect_1.useWalletDisconnect; } });
|
|
12
|
+
var useWalletState_1 = require("./hooks/useWalletState");
|
|
13
|
+
Object.defineProperty(exports, "useWalletState", { enumerable: true, get: function () { return useWalletState_1.useWalletState; } });
|
|
14
|
+
// Components
|
|
15
|
+
var ConnectWallet_1 = require("./components/ConnectWallet");
|
|
16
|
+
Object.defineProperty(exports, "ConnectWallet", { enumerable: true, get: function () { return ConnectWallet_1.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[]>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWalletConfig = createWalletConfig;
|
|
4
|
+
const supported_1 = require("../../shared/constants/chains/supported");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const wagmi_1 = require("wagmi");
|
|
7
|
+
const connectors_1 = require("wagmi/connectors");
|
|
8
|
+
/** Default connectors: injected (MetaMask, Rabby, Brave, etc.) + Coinbase Wallet. */
|
|
9
|
+
const DEFAULT_CONNECTORS = [(0, connectors_1.injected)(), (0, connectors_1.coinbaseWallet)({ appName: "B3" })];
|
|
10
|
+
/**
|
|
11
|
+
* Creates a generic wagmi config with sensible defaults.
|
|
12
|
+
* No ecosystem wallet, no B3-specific concerns.
|
|
13
|
+
*/
|
|
14
|
+
function createWalletConfig(options = {}) {
|
|
15
|
+
const { chains = supported_1.supportedChains, connectors = DEFAULT_CONNECTORS, rpcUrls } = options;
|
|
16
|
+
if (chains.length === 0) {
|
|
17
|
+
throw new Error("createWalletConfig: at least one chain must be provided");
|
|
18
|
+
}
|
|
19
|
+
return (0, wagmi_1.createConfig)({
|
|
20
|
+
chains: [chains[0], ...chains.slice(1)],
|
|
21
|
+
transports: Object.fromEntries(chains.map(chain => [chain.id, (0, viem_1.http)(rpcUrls?.[chain.id])])),
|
|
22
|
+
connectors,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -121,5 +121,7 @@ export interface AnySpendCheckoutProps {
|
|
|
121
121
|
feeOnTop?: boolean;
|
|
122
122
|
/** When true, identity verification (KYC) is required before card payment. Defaults to false. */
|
|
123
123
|
kycEnabled?: boolean;
|
|
124
|
+
/** Extra metadata included under the 'callbackMetadata' key in the order's callbackMetadata (e.g. workflowId, orgId from checkout session) */
|
|
125
|
+
callbackMetadata?: Record<string, unknown>;
|
|
124
126
|
}
|
|
125
|
-
export declare function AnySpendCheckout({ mode, recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText, checkoutSessionId, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, showPoints, showOrderId, shipping: shippingProp, tax, discount: discountProp, summaryLines, formSchema, formComponent, onFormSubmit, shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp, enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount, variablePricing, feeOnTop, kycEnabled, }: AnySpendCheckoutProps): import("react/jsx-runtime").JSX.Element;
|
|
127
|
+
export declare function AnySpendCheckout({ mode, recipientAddress, destinationTokenAddress, destinationTokenChainId, items, totalAmount: totalAmountOverride, organizationName, organizationLogo, themeColor, buttonText, checkoutSessionId, onSuccess, onError, returnUrl, returnLabel, classes, footer, defaultPaymentMethod, senderAddress, slots, content, theme, showPoints, showOrderId, shipping: shippingProp, tax, discount: discountProp, summaryLines, formSchema, formComponent, onFormSubmit, shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp, enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount, variablePricing, feeOnTop, kycEnabled, callbackMetadata: callbackMetadataProp, }: AnySpendCheckoutProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -21,7 +21,7 @@ shippingOptions, collectShippingAddress, onShippingChange: onShippingChangeProp,
|
|
|
21
21
|
// New discount props
|
|
22
22
|
enableDiscountCode, onDiscountApplied: onDiscountAppliedProp, validateDiscount,
|
|
23
23
|
// Variable pricing
|
|
24
|
-
variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
24
|
+
variablePricing, feeOnTop, kycEnabled = false, callbackMetadata: callbackMetadataProp, }) {
|
|
25
25
|
// ===== Variable pricing state =====
|
|
26
26
|
const [variablePricingAmount, setVariablePricingAmount] = useState("0");
|
|
27
27
|
const isVariablePricingActive = variablePricing?.enabled === true;
|
|
@@ -173,8 +173,12 @@ variablePricing, feeOnTop, kycEnabled = false, }) {
|
|
|
173
173
|
if (isVariablePricingActive && variablePricingAmount !== "0") {
|
|
174
174
|
meta.variablePricingAmount = variablePricingAmount;
|
|
175
175
|
}
|
|
176
|
+
// Namespace caller-supplied metadata to avoid collisions with internal keys
|
|
177
|
+
if (callbackMetadataProp)
|
|
178
|
+
meta.callbackMetadata = callbackMetadataProp;
|
|
176
179
|
return Object.keys(meta).length > 0 ? meta : undefined;
|
|
177
180
|
}, [
|
|
181
|
+
callbackMetadataProp,
|
|
178
182
|
formData,
|
|
179
183
|
selectedShipping,
|
|
180
184
|
shippingAddress,
|
|
@@ -2,13 +2,14 @@ import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAny
|
|
|
2
2
|
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
3
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
4
4
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
5
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
5
6
|
import { Account, EIP1193, Wallet } from "thirdweb/wallets";
|
|
6
7
|
import { CreateConnectorFn } from "wagmi";
|
|
7
8
|
import { ClientType } from "../../../client-manager";
|
|
8
9
|
/**
|
|
9
10
|
* Main B3Provider component
|
|
10
11
|
*/
|
|
11
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication, }: {
|
|
12
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication, queryClient, }: {
|
|
12
13
|
theme: "light" | "dark";
|
|
13
14
|
children: React.ReactNode;
|
|
14
15
|
accountOverride?: Account;
|
|
@@ -33,4 +34,6 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
33
34
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
34
35
|
defaultPermissions?: PermissionsConfig;
|
|
35
36
|
disableBSMNTAuthentication?: boolean;
|
|
37
|
+
/** Provide your own QueryClient for React Query. If omitted, WalletProvider creates one internally. */
|
|
38
|
+
queryClient?: QueryClient;
|
|
36
39
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,25 +2,21 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { RelayKitProviderWrapper, TooltipProvider } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { createWagmiConfig } from "../../../../global-account/react/utils/createWagmiConfig.js";
|
|
4
4
|
import { loadGA4Script } from "../../../../global-account/utils/analytics.js";
|
|
5
|
+
import { WalletProvider } from "../../../../wallet/react/index.js";
|
|
5
6
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
6
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
7
7
|
import { useEffect, useMemo } from "react";
|
|
8
|
-
import { ThirdwebProvider } from "thirdweb/react";
|
|
9
|
-
import { WagmiProvider } from "wagmi";
|
|
10
8
|
import { setClientType } from "../../../client-manager.js";
|
|
11
9
|
import { StyleRoot } from "../StyleRoot.js";
|
|
12
10
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index.js";
|
|
13
11
|
import AuthenticationProvider from "./AuthenticationProvider.js";
|
|
14
12
|
import { B3ConfigProvider } from "./B3ConfigProvider.js";
|
|
15
13
|
import { LocalSDKProvider } from "./LocalSDKProvider.js";
|
|
16
|
-
// Create queryClient instance
|
|
17
|
-
const queryClient = new QueryClient();
|
|
18
14
|
/**
|
|
19
15
|
* Main B3Provider component
|
|
20
16
|
*/
|
|
21
17
|
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, defaultEoaProvider, simDuneApiKey,
|
|
22
18
|
// deprecated since v0.0.87
|
|
23
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication = false, }) {
|
|
19
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, defaultPermissions, disableBSMNTAuthentication = false, queryClient, }) {
|
|
24
20
|
// Initialize Google Analytics on mount
|
|
25
21
|
useEffect(() => {
|
|
26
22
|
loadGA4Script();
|
|
@@ -30,7 +26,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
30
26
|
setClientType(clientType);
|
|
31
27
|
}, [clientType]);
|
|
32
28
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
33
|
-
return (_jsx(
|
|
29
|
+
return (_jsx(WalletProvider, { wagmiConfig: wagmiConfig, queryClient: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, disableBSMNTAuthentication: disableBSMNTAuthentication, children: _jsxs(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, defaultPermissions: defaultPermissions, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), _jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa, defaultEoaProvider: defaultEoaProvider })] }) }) }) }) }));
|
|
34
30
|
}
|
|
35
31
|
/**
|
|
36
32
|
* Component to connect the toast context to the global toast API
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { WalletProvider } from "../../../../wallet/react/index.js";
|
|
3
3
|
import { ThirdwebProvider } from "thirdweb/react";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import { WagmiProvider } from "wagmi";
|
|
6
5
|
import { createWagmiConfig } from "../../utils/createWagmiConfig.js";
|
|
7
6
|
import AuthenticationProvider from "./AuthenticationProvider.js";
|
|
8
7
|
import { B3ConfigProvider } from "./B3ConfigProvider.js";
|
|
9
8
|
import { LocalSDKProvider } from "./LocalSDKProvider.js";
|
|
10
|
-
// Create queryClient instance
|
|
11
|
-
const queryClient = new QueryClient();
|
|
12
9
|
/**
|
|
13
10
|
* Main B3Provider component
|
|
14
11
|
*/
|
|
@@ -20,5 +17,5 @@ export function B3Provider({ theme = "light", children, accountOverride, environ
|
|
|
20
17
|
*/
|
|
21
18
|
export function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
22
19
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls }), [partnerId, rpcUrls]);
|
|
23
|
-
return (_jsx(
|
|
20
|
+
return (_jsx(WalletProvider, { wagmiConfig: wagmiConfig, children: _jsx(B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: false, theme: theme, clientType: clientType, partnerId: partnerId, defaultPermissions: defaultPermissions, children: children }) }));
|
|
24
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CreateConnectorFn } from "wagmi";
|
|
2
2
|
export interface CreateWagmiConfigOptions {
|
|
3
3
|
partnerId: string;
|
|
4
4
|
rpcUrls?: Record<number, string>;
|
|
@@ -6,7 +6,8 @@ export interface CreateWagmiConfigOptions {
|
|
|
6
6
|
overrideDefaultConnectors?: boolean;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Creates a wagmi config with
|
|
9
|
+
* Creates a wagmi config with the B3 ecosystem wallet connector.
|
|
10
|
+
* Delegates to createWalletConfig and adds the ecosystem connector on top.
|
|
10
11
|
* @param options.partnerId - Partner ID for the ecosystem wallet
|
|
11
12
|
* @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
12
13
|
* @param options.connectors - Additional connectors to include
|
|
@@ -14,14 +15,4 @@ export interface CreateWagmiConfigOptions {
|
|
|
14
15
|
*/
|
|
15
16
|
export declare function createWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
|
|
16
17
|
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
17
|
-
},
|
|
18
|
-
connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
|
|
19
|
-
accounts: withCapabilities extends true ? readonly {
|
|
20
|
-
address: `0x${string}`;
|
|
21
|
-
capabilities: Record<string, unknown>;
|
|
22
|
-
}[] : readonly `0x${string}`[];
|
|
23
|
-
chainId: number;
|
|
24
|
-
}>;
|
|
25
|
-
}, {
|
|
26
|
-
"thirdweb:lastChainId": number;
|
|
27
|
-
}>)[]>;
|
|
18
|
+
}, CreateConnectorFn[]>;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { createWalletConfig } from "../../../wallet/utils/createWalletConfig.js";
|
|
1
2
|
import { ecosystemWalletId } from "../../../shared/constants/index.js";
|
|
2
|
-
import { supportedChains } from "../../../shared/constants/chains/supported.js";
|
|
3
3
|
import { client } from "../../../shared/utils/thirdweb.js";
|
|
4
4
|
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
|
|
5
|
-
import { http } from "viem";
|
|
6
|
-
import { createConfig } from "wagmi";
|
|
7
5
|
/**
|
|
8
|
-
* Creates a wagmi config with
|
|
6
|
+
* Creates a wagmi config with the B3 ecosystem wallet connector.
|
|
7
|
+
* Delegates to createWalletConfig and adds the ecosystem connector on top.
|
|
9
8
|
* @param options.partnerId - Partner ID for the ecosystem wallet
|
|
10
9
|
* @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
11
10
|
* @param options.connectors - Additional connectors to include
|
|
@@ -21,9 +20,8 @@ export function createWagmiConfig(options) {
|
|
|
21
20
|
}),
|
|
22
21
|
];
|
|
23
22
|
const finalConnectors = overrideDefaultConnectors ? connectors : [...defaultConnectors, ...connectors];
|
|
24
|
-
return
|
|
25
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
26
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])),
|
|
23
|
+
return createWalletConfig({
|
|
27
24
|
connectors: finalConnectors,
|
|
25
|
+
rpcUrls,
|
|
28
26
|
});
|
|
29
27
|
}
|
|
@@ -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;
|