@b3dotfun/sdk 0.0.88-alpha.5 → 0.0.88-alpha.6
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/AnySpend.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +1 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +2 -3
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +12 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +23 -57
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +38 -35
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +14 -4
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +4 -11
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +18 -17
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +1 -2
- package/dist/cjs/global-account/react/components/ManageAccount/channels/DiscordChannel.js +6 -6
- package/dist/cjs/global-account/react/components/ManageAccount/channels/EmailChannel.js +7 -7
- package/dist/cjs/global-account/react/components/ManageAccount/channels/PhoneChannel.js +7 -7
- package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +5 -5
- package/dist/cjs/global-account/react/components/RequestPermissions/RequestPermissions.js +8 -9
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/cjs/global-account/react/components/StyleRoot.js +3 -3
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +1 -2
- package/dist/cjs/global-account/react/components/index.d.ts +1 -2
- package/dist/cjs/global-account/react/components/index.js +3 -6
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useAuth.js +1 -2
- package/dist/cjs/global-account/react/hooks/useClient.js +1 -1
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +1 -1
- package/dist/cjs/global-account/react/hooks/useNotifications.js +14 -14
- package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
- package/dist/cjs/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/cjs/global-account/react/hooks/useUser.js +20 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +9 -35
- package/dist/cjs/global-account/react/index.native.d.ts +0 -2
- package/dist/cjs/global-account/react/index.native.js +1 -5
- package/dist/cjs/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/cjs/global-account/react/stores/configStore.js +30 -0
- package/dist/cjs/global-account/react/stores/index.d.ts +1 -0
- package/dist/cjs/global-account/react/stores/index.js +3 -1
- package/dist/cjs/global-account/react/stores/userStore.d.ts +22 -0
- package/dist/cjs/global-account/react/stores/userStore.js +30 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +3 -4
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +2 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -4
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +10 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +22 -58
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +36 -36
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +14 -4
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +4 -11
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +18 -17
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +2 -3
- package/dist/esm/global-account/react/components/ManageAccount/channels/DiscordChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/EmailChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/PhoneChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +2 -2
- package/dist/esm/global-account/react/components/RequestPermissions/RequestPermissions.js +2 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- package/dist/esm/global-account/react/components/StyleRoot.js +3 -3
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -3
- package/dist/esm/global-account/react/components/index.d.ts +1 -2
- package/dist/esm/global-account/react/components/index.js +1 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAuth.js +2 -3
- package/dist/esm/global-account/react/hooks/useClient.js +2 -2
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -2
- package/dist/esm/global-account/react/hooks/useNotifications.js +2 -2
- package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
- package/dist/esm/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/esm/global-account/react/hooks/useUser.js +17 -0
- package/dist/esm/global-account/react/hooks/useUserQuery.js +1 -27
- package/dist/esm/global-account/react/index.native.d.ts +0 -2
- package/dist/esm/global-account/react/index.native.js +0 -2
- package/dist/esm/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/esm/global-account/react/stores/configStore.js +27 -0
- package/dist/esm/global-account/react/stores/index.d.ts +1 -0
- package/dist/esm/global-account/react/stores/index.js +1 -0
- package/dist/esm/global-account/react/stores/userStore.d.ts +22 -0
- package/dist/esm/global-account/react/stores/userStore.js +27 -0
- package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -18
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +5 -5
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +14 -4
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +10 -2
- package/dist/types/global-account/react/components/index.d.ts +1 -2
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/types/global-account/react/index.native.d.ts +0 -2
- package/dist/types/global-account/react/stores/configStore.d.ts +24 -0
- package/dist/types/global-account/react/stores/index.d.ts +1 -0
- package/dist/types/global-account/react/stores/userStore.d.ts +22 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +2 -2
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +3 -4
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +2 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -2
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +2 -2
- package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +2 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +3 -4
- package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +19 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +43 -54
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +32 -117
- package/src/global-account/react/components/B3Provider/useB3.ts +4 -13
- package/src/global-account/react/components/B3Provider/useB3Account.ts +6 -2
- package/src/global-account/react/components/B3Provider/useB3Config.ts +18 -31
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +2 -4
- package/src/global-account/react/components/ManageAccount/channels/DiscordChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/EmailChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/PhoneChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +2 -2
- package/src/global-account/react/components/RequestPermissions/RequestPermissions.tsx +4 -4
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/StyleRoot.tsx +3 -3
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -3
- package/src/global-account/react/components/index.ts +1 -2
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAuth.ts +2 -3
- package/src/global-account/react/hooks/useClient.ts +2 -2
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +2 -2
- package/src/global-account/react/hooks/useNotifications.ts +2 -2
- package/src/global-account/react/hooks/useTokenBalance.tsx +8 -7
- package/src/global-account/react/hooks/useUser.ts +20 -0
- package/src/global-account/react/hooks/useUserQuery.ts +1 -40
- package/src/global-account/react/index.native.ts +0 -2
- package/src/global-account/react/stores/configStore.ts +51 -0
- package/src/global-account/react/stores/index.ts +1 -0
- package/src/global-account/react/stores/userStore.ts +41 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/dist/cjs/global-account/react/components/B3Provider/types.js +0 -24
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/dist/esm/global-account/react/components/B3Provider/types.js +0 -21
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/src/global-account/react/components/B3Provider/types.ts +0 -50
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useB3ConfigStore = void 0;
|
|
4
|
+
const zustand_1 = require("zustand");
|
|
5
|
+
/**
|
|
6
|
+
* Default permissions configuration for B3 provider
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_PERMISSIONS = {
|
|
9
|
+
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
|
|
10
|
+
nativeTokenLimitPerTransaction: 0.1,
|
|
11
|
+
startDate: new Date(),
|
|
12
|
+
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Zustand store for B3 configuration
|
|
16
|
+
* NOT persisted - these are developer-set configuration values
|
|
17
|
+
*/
|
|
18
|
+
exports.useB3ConfigStore = (0, zustand_1.create)(set => ({
|
|
19
|
+
accountOverride: undefined,
|
|
20
|
+
automaticallySetFirstEoa: false,
|
|
21
|
+
environment: "development",
|
|
22
|
+
defaultPermissions: DEFAULT_PERMISSIONS,
|
|
23
|
+
theme: "light",
|
|
24
|
+
clientType: "rest",
|
|
25
|
+
partnerId: "",
|
|
26
|
+
stripePublishableKey: undefined,
|
|
27
|
+
createClientReferenceId: undefined,
|
|
28
|
+
enableTurnkey: false,
|
|
29
|
+
setConfig: config => set(state => ({ ...state, ...config })),
|
|
30
|
+
}));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useAuthStore } from "./useAuthStore";
|
|
2
|
+
export { useB3ConfigStore } from "./configStore";
|
|
2
3
|
export { useModalStore } from "./useModalStore";
|
|
3
4
|
export { useRecentAddressesStore } from "./useRecentAddressesStore";
|
|
4
5
|
export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useRecentAddressesStore = exports.useModalStore = exports.useAuthStore = void 0;
|
|
3
|
+
exports.useRecentAddressesStore = exports.useModalStore = exports.useB3ConfigStore = exports.useAuthStore = void 0;
|
|
4
4
|
var useAuthStore_1 = require("./useAuthStore");
|
|
5
5
|
Object.defineProperty(exports, "useAuthStore", { enumerable: true, get: function () { return useAuthStore_1.useAuthStore; } });
|
|
6
|
+
var configStore_1 = require("./configStore");
|
|
7
|
+
Object.defineProperty(exports, "useB3ConfigStore", { enumerable: true, get: function () { return configStore_1.useB3ConfigStore; } });
|
|
6
8
|
var useModalStore_1 = require("./useModalStore");
|
|
7
9
|
Object.defineProperty(exports, "useModalStore", { enumerable: true, get: function () { return useModalStore_1.useModalStore; } });
|
|
8
10
|
var useRecentAddressesStore_1 = require("./useRecentAddressesStore");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
+
interface UserStore {
|
|
3
|
+
user: Users | null;
|
|
4
|
+
setUser: (user: Users | undefined) => void;
|
|
5
|
+
clearUser: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Zustand store for managing user state
|
|
9
|
+
* Persists user data to localStorage
|
|
10
|
+
*/
|
|
11
|
+
export declare const useUserStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<UserStore>, "persist"> & {
|
|
12
|
+
persist: {
|
|
13
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>) => void;
|
|
14
|
+
clearStorage: () => void;
|
|
15
|
+
rehydrate: () => Promise<void> | void;
|
|
16
|
+
hasHydrated: () => boolean;
|
|
17
|
+
onHydrate: (fn: (state: UserStore) => void) => () => void;
|
|
18
|
+
onFinishHydration: (fn: (state: UserStore) => void) => () => void;
|
|
19
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<UserStore, UserStore>>;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useUserStore = void 0;
|
|
4
|
+
const debug_1 = require("../../../shared/utils/debug");
|
|
5
|
+
const zustand_1 = require("zustand");
|
|
6
|
+
const middleware_1 = require("zustand/middleware");
|
|
7
|
+
const debug = (0, debug_1.debugB3React)("useUserQuery");
|
|
8
|
+
/**
|
|
9
|
+
* Zustand store for managing user state
|
|
10
|
+
* Persists user data to localStorage
|
|
11
|
+
*/
|
|
12
|
+
exports.useUserStore = (0, zustand_1.create)()((0, middleware_1.persist)(set => ({
|
|
13
|
+
user: null,
|
|
14
|
+
setUser: (newUser) => {
|
|
15
|
+
const userToSave = newUser ?? null;
|
|
16
|
+
set({ user: userToSave });
|
|
17
|
+
debug("User updated", userToSave);
|
|
18
|
+
},
|
|
19
|
+
clearUser: () => {
|
|
20
|
+
set({ user: null });
|
|
21
|
+
debug("User cleared");
|
|
22
|
+
},
|
|
23
|
+
}), {
|
|
24
|
+
name: "b3-user",
|
|
25
|
+
onRehydrateStorage: () => (_, error) => {
|
|
26
|
+
if (error) {
|
|
27
|
+
console.warn("Failed to rehydrate user store:", error);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { eqci, getDefaultToken, getHyperliquidUSDCToken, HYPERLIQUID_CHAIN_ID, HYPERLIQUID_USDC_ADDRESS, USDC_BASE, ZERO_ADDRESS, } from "../../../anyspend/index.js";
|
|
4
4
|
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
|
-
import { Button, ShinyButton, StyleRoot, TabsPrimitive, toast, TransitionPanel, useAccountWallet,
|
|
5
|
+
import { Button, ShinyButton, StyleRoot, TabsPrimitive, toast, TransitionPanel, useAccountWallet, useB3Config, useModalStore, useProfile, useRouter, useSearchParamsSSR, useTokenBalanceDirect, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
|
|
6
6
|
import BottomNavigation from "../../../global-account/react/components/ManageAccount/BottomNavigation.js";
|
|
7
7
|
import { useAccountWalletImage } from "../../../global-account/react/hooks/useAccountWallet.js";
|
|
8
8
|
import { getThirdwebChain } from "../../../shared/constants/chains/supported.js";
|
|
@@ -53,7 +53,7 @@ export function AnySpend(props) {
|
|
|
53
53
|
function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, customUsdInputValues, hideHeader, hideBottomNavigation = false, disableUrlParamManagement = false, }) {
|
|
54
54
|
const searchParams = useSearchParamsSSR();
|
|
55
55
|
const router = useRouter();
|
|
56
|
-
const { partnerId } =
|
|
56
|
+
const { partnerId } = useB3Config();
|
|
57
57
|
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
58
58
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
59
59
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { ALL_CHAINS, getChainName, getErrorDisplay, getExplorerTxUrl, getPaymentUrl, getStatusDisplay, isNativeToken, RELAY_SOLANA_MAINNET_CHAIN_ID, ZERO_ADDRESS, } from "../../../../anyspend/index.js";
|
|
4
|
-
import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet,
|
|
4
|
+
import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet, useB3Config, useModalStore, useProfile, useUnifiedChainSwitchAndExecute, } from "../../../../global-account/react/index.js";
|
|
5
5
|
import { useRouter, useSearchParams } from "../../../../shared/react/hooks/index.js";
|
|
6
6
|
import { cn } from "../../../../shared/utils/index.js";
|
|
7
7
|
import centerTruncate from "../../../../shared/utils/centerTruncate.js";
|
|
@@ -135,7 +135,7 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
|
|
|
135
135
|
const router = useRouter();
|
|
136
136
|
const searchParams = useSearchParams();
|
|
137
137
|
// Get theme from B3Provider context
|
|
138
|
-
const { theme } =
|
|
138
|
+
const { theme } = useB3Config();
|
|
139
139
|
const colorMode = theme || "light";
|
|
140
140
|
// Read crypto payment method from URL parameters
|
|
141
141
|
const cryptoPaymentMethodFromUrl = searchParams.get("cryptoPaymentMethod");
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getStripePromise } from "../../../../shared/utils/payment.utils.js";
|
|
3
2
|
import { OrderDetailsCollapsible, useStripeClientSecret } from "../../../../anyspend/react/index.js";
|
|
4
|
-
import { ShinyButton,
|
|
3
|
+
import { ShinyButton, useB3Config, useModalStore, useProfile } from "../../../../global-account/react/index.js";
|
|
5
4
|
import { formatTokenAmount } from "../../../../shared/utils/number.js";
|
|
6
|
-
import { formatStripeAmount } from "../../../../shared/utils/payment.utils.js";
|
|
5
|
+
import { formatStripeAmount, getStripePromise } from "../../../../shared/utils/payment.utils.js";
|
|
7
6
|
import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
|
8
7
|
import { X } from "lucide-react";
|
|
9
8
|
import { useEffect, useState } from "react";
|
|
@@ -11,7 +10,7 @@ import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFin
|
|
|
11
10
|
import HowItWorks from "./HowItWorks.js";
|
|
12
11
|
import PaymentMethodIcons from "./PaymentMethodIcons.js";
|
|
13
12
|
export default function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaymentSuccess }) {
|
|
14
|
-
const { theme, stripePublishableKey } =
|
|
13
|
+
const { theme, stripePublishableKey } = useB3Config();
|
|
15
14
|
const fingerprintConfig = getFingerprintConfig();
|
|
16
15
|
const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = useStripeClientSecret(stripePaymentIntentId);
|
|
17
16
|
if (isLoadingStripeClientSecret) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { USDC_BASE } from "../../../anyspend/constants/index.js";
|
|
2
2
|
import { anyspendService } from "../../../anyspend/services/anyspend.js";
|
|
3
3
|
import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useB3Config } from "../../../global-account/react/index.js";
|
|
5
5
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
6
6
|
import { useMutation } from "@tanstack/react-query";
|
|
7
7
|
import { useMemo } from "react";
|
|
@@ -14,7 +14,7 @@ import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.j
|
|
|
14
14
|
*/
|
|
15
15
|
export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
16
16
|
// Get B3 context values
|
|
17
|
-
const { partnerId } =
|
|
17
|
+
const { partnerId } = useB3Config();
|
|
18
18
|
// Get validated client reference ID from B3 context
|
|
19
19
|
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
20
20
|
// Get fingerprint data
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { anyspendService } from "../../../anyspend/services/anyspend.js";
|
|
2
2
|
import { buildMetadata, buildPayload, normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useB3Config } from "../../../global-account/react/index.js";
|
|
4
4
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
5
5
|
import { useMutation } from "@tanstack/react-query";
|
|
6
6
|
import { useMemo } from "react";
|
|
@@ -12,7 +12,7 @@ import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.j
|
|
|
12
12
|
*/
|
|
13
13
|
export function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
14
14
|
// Get B3 context values
|
|
15
|
-
const { partnerId } =
|
|
15
|
+
const { partnerId } = useB3Config();
|
|
16
16
|
// Get validated client reference ID from B3 context
|
|
17
17
|
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
18
18
|
// Get fingerprint data
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { anyspendService } from "../../../anyspend/services/anyspend.js";
|
|
2
2
|
import { normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useB3Config } from "../../../global-account/react/index.js";
|
|
4
4
|
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
5
5
|
import { useMutation } from "@tanstack/react-query";
|
|
6
6
|
import { useMemo } from "react";
|
|
@@ -9,7 +9,7 @@ import { useMemo } from "react";
|
|
|
9
9
|
* This order type doesn't require srcAmount - the user deposits tokens after the order is created.
|
|
10
10
|
*/
|
|
11
11
|
export function useCreateDepositFirstOrder({ onSuccess, onError } = {}) {
|
|
12
|
-
const { partnerId } =
|
|
12
|
+
const { partnerId } = useB3Config();
|
|
13
13
|
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
14
14
|
const visitorData = fpData && {
|
|
15
15
|
requestId: fpData.requestId,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Validators } from "../../../anyspend/utils/validation.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useB3Config } from "../../../global-account/react/index.js";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
4
|
/**
|
|
5
5
|
* Hook that provides a validated client reference ID
|
|
6
6
|
* Gets the createClientReferenceId function from B3 context and validates the result
|
|
7
7
|
*/
|
|
8
8
|
export function useValidatedClientReferenceId() {
|
|
9
|
-
const { createClientReferenceId } =
|
|
9
|
+
const { createClientReferenceId } = useB3Config();
|
|
10
10
|
const createValidatedClientReferenceId = useCallback(async (params) => {
|
|
11
11
|
// If no function provided, return undefined
|
|
12
12
|
if (!createClientReferenceId) {
|
|
@@ -4,14 +4,13 @@ import { AnySpendDepositHype } from "../../../anyspend/react/components/Anyspend
|
|
|
4
4
|
import { AnySpendDepositUpside } from "../../../anyspend/react/components/AnySpendDepositUpside.js";
|
|
5
5
|
import { AnySpendStakeUpside } from "../../../anyspend/react/components/AnySpendStakeUpside.js";
|
|
6
6
|
import { AnySpendStakeUpsideExactIn } from "../../../anyspend/react/components/AnySpendStakeUpsideExactIn.js";
|
|
7
|
-
import { useGlobalAccount, useIsMobile, useModalStore } from "../../../global-account/react/index.js";
|
|
7
|
+
import { useB3Config, useGlobalAccount, useIsMobile, useModalStore } from "../../../global-account/react/index.js";
|
|
8
8
|
import { cn } from "../../../shared/utils/cn.js";
|
|
9
9
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
10
10
|
import { AnimatePresence, motion } from "framer-motion";
|
|
11
11
|
import { useEffect, useRef } from "react";
|
|
12
12
|
import { useSetActiveWallet } from "thirdweb/react";
|
|
13
13
|
import { AvatarEditor } from "./AvatarEditor/AvatarEditor.js";
|
|
14
|
-
import { useB3 } from "./B3Provider/useB3.js";
|
|
15
14
|
import { Deposit } from "./Deposit/Deposit.js";
|
|
16
15
|
import { LinkAccount } from "./LinkAccount/LinkAccount.js";
|
|
17
16
|
import { LinkNewAccount } from "./LinkAccount/LinkNewAccount.js";
|
|
@@ -20,8 +19,8 @@ import NotificationsContent from "./ManageAccount/NotificationsContent.js";
|
|
|
20
19
|
import { RequestPermissions } from "./RequestPermissions/RequestPermissions.js";
|
|
21
20
|
import { Send } from "./Send/Send.js";
|
|
22
21
|
import { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow.js";
|
|
23
|
-
import { TurnkeyAuthModal } from "./TurnkeyAuthModal.js";
|
|
24
22
|
import { ToastContainer, useToastContext } from "./Toast/index.js";
|
|
23
|
+
import { TurnkeyAuthModal } from "./TurnkeyAuthModal.js";
|
|
25
24
|
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "./ui/dialog.js";
|
|
26
25
|
import { Drawer, DrawerContent, DrawerDescription, DrawerTitle } from "./ui/drawer.js";
|
|
27
26
|
const debug = debugB3React("B3DynamicModal");
|
|
@@ -30,7 +29,7 @@ export function B3DynamicModal() {
|
|
|
30
29
|
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
31
30
|
const contentType = useModalStore(state => state.contentType);
|
|
32
31
|
const navigateBack = useModalStore(state => state.navigateBack);
|
|
33
|
-
const { theme } =
|
|
32
|
+
const { theme } = useB3Config();
|
|
34
33
|
const isMobile = useIsMobile();
|
|
35
34
|
const prevIsOpenRef = useRef(isOpen);
|
|
36
35
|
const { wallet } = useGlobalAccount();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useAuthentication } from "../../hooks/index.js";
|
|
2
|
+
import { useAutoSelectWallet } from "../../hooks/useAutoSelectWallet.js";
|
|
3
|
+
const AuthenticationProvider = ({ partnerId, automaticallySetFirstEoa, }) => {
|
|
4
|
+
useAuthentication(partnerId);
|
|
5
|
+
useAutoSelectWallet({
|
|
6
|
+
enabled: automaticallySetFirstEoa,
|
|
7
|
+
});
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
export default AuthenticationProvider;
|
|
@@ -5,15 +5,14 @@ import "@relayprotocol/relay-kit-ui/styles.css";
|
|
|
5
5
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
6
6
|
import { CreateConnectorFn } from "wagmi";
|
|
7
7
|
import { ClientType } from "../../../client-manager";
|
|
8
|
-
import { B3ContextType } from "./types";
|
|
9
8
|
/**
|
|
10
9
|
* Main B3Provider component
|
|
11
10
|
*/
|
|
12
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
|
|
11
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, defaultPermissions, }: {
|
|
13
12
|
theme: "light" | "dark";
|
|
14
13
|
children: React.ReactNode;
|
|
15
14
|
accountOverride?: Account;
|
|
16
|
-
environment
|
|
15
|
+
environment?: "development" | "production";
|
|
17
16
|
automaticallySetFirstEoa?: boolean;
|
|
18
17
|
simDuneApiKey?: string;
|
|
19
18
|
toaster?: {
|
|
@@ -30,20 +29,5 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
30
29
|
overrideDefaultConnectors?: boolean;
|
|
31
30
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
32
31
|
enableTurnkey?: boolean;
|
|
33
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
34
|
-
/**
|
|
35
|
-
* Inner provider component that provides the actual B3Context
|
|
36
|
-
*/
|
|
37
|
-
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
|
|
38
|
-
children: React.ReactNode;
|
|
39
|
-
accountOverride?: Account;
|
|
40
|
-
environment: B3ContextType["environment"];
|
|
41
32
|
defaultPermissions?: PermissionsConfig;
|
|
42
|
-
automaticallySetFirstEoa: boolean;
|
|
43
|
-
theme: "light" | "dark";
|
|
44
|
-
clientType?: ClientType;
|
|
45
|
-
partnerId: string;
|
|
46
|
-
stripePublishableKey?: string;
|
|
47
|
-
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
48
|
-
enableTurnkey?: boolean;
|
|
49
33
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { RelayKitProviderWrapper, TooltipProvider
|
|
3
|
-
import { useAutoSelectWallet } from "../../../../global-account/react/hooks/useAutoSelectWallet.js";
|
|
2
|
+
import { RelayKitProviderWrapper, TooltipProvider } from "../../../../global-account/react/index.js";
|
|
4
3
|
import { createWagmiConfig } from "../../../../global-account/react/utils/createWagmiConfig.js";
|
|
5
4
|
import { loadGA4Script } from "../../../../global-account/utils/analytics.js";
|
|
6
5
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
7
6
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
8
7
|
import { useEffect, useMemo } from "react";
|
|
9
|
-
import { ThirdwebProvider
|
|
8
|
+
import { ThirdwebProvider } from "thirdweb/react";
|
|
10
9
|
import { WagmiProvider } from "wagmi";
|
|
11
10
|
import { setClientType } from "../../../client-manager.js";
|
|
11
|
+
import { useB3ConfigStore } from "../../stores/configStore.js";
|
|
12
12
|
import { StyleRoot } from "../StyleRoot.js";
|
|
13
13
|
import { setToastContext, ToastProvider, useToastContext } from "../Toast/index.js";
|
|
14
|
+
import AuthenticationProvider from "./AuthenticationProvider.js";
|
|
14
15
|
import { LocalSDKProvider } from "./LocalSDKProvider.js";
|
|
15
|
-
import { B3Context } from "./types.js";
|
|
16
|
-
/**
|
|
17
|
-
* Default permissions configuration for B3 provider
|
|
18
|
-
*/
|
|
19
|
-
const DEFAULT_PERMISSIONS = {
|
|
20
|
-
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"], // Example contract
|
|
21
|
-
nativeTokenLimitPerTransaction: 0.1, // in ETH
|
|
22
|
-
startDate: new Date(),
|
|
23
|
-
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
24
|
-
};
|
|
25
16
|
// Create queryClient instance
|
|
26
17
|
const queryClient = new QueryClient();
|
|
27
18
|
/**
|
|
@@ -29,7 +20,23 @@ const queryClient = new QueryClient();
|
|
|
29
20
|
*/
|
|
30
21
|
export function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
|
|
31
22
|
// deprecated since v0.0.87
|
|
32
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, }) {
|
|
23
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, defaultPermissions, }) {
|
|
24
|
+
const setConfig = useB3ConfigStore(state => state.setConfig);
|
|
25
|
+
// Initialize config store on mount - props are static and never change
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
setConfig({
|
|
28
|
+
accountOverride,
|
|
29
|
+
environment: environment ?? "development",
|
|
30
|
+
automaticallySetFirstEoa: !!automaticallySetFirstEoa,
|
|
31
|
+
theme,
|
|
32
|
+
clientType,
|
|
33
|
+
partnerId,
|
|
34
|
+
stripePublishableKey,
|
|
35
|
+
createClientReferenceId,
|
|
36
|
+
enableTurnkey,
|
|
37
|
+
defaultPermissions,
|
|
38
|
+
});
|
|
39
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
33
40
|
// Initialize Google Analytics on mount
|
|
34
41
|
useEffect(() => {
|
|
35
42
|
loadGA4Script();
|
|
@@ -39,50 +46,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
39
46
|
setClientType(clientType);
|
|
40
47
|
}, [clientType]);
|
|
41
48
|
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
42
|
-
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children:
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Inner provider component that provides the actual B3Context
|
|
46
|
-
*/
|
|
47
|
-
export function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }) {
|
|
48
|
-
const activeAccount = useActiveAccount();
|
|
49
|
-
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
50
|
-
//const isConnected = useAuthStore(state => state.isConnected);
|
|
51
|
-
//const justCompletedLogin = useAuthStore(state => state.justCompletedLogin);
|
|
52
|
-
// Note: This fixes a bug where useAuthentication is no longer rendered on every page, as of this PR https://github.com/b3-fun/b3/pull/385/files#diff-3ef996931b8fc8e49021ba1b42ddaa97535214681610dc5fdacf63542e261af7
|
|
53
|
-
// The above PR removes useAuthentication from the overall B3Provider. useAuthentication should be everywhere the provider is, since it sets the overall auth state
|
|
54
|
-
// By just calling it manually, we fix that issue
|
|
55
|
-
// As a follow up, we should fix the SDK directly
|
|
56
|
-
useAuthentication(partnerId);
|
|
57
|
-
// Use given accountOverride or activeAccount from thirdweb
|
|
58
|
-
// WOJ: why if isAuthenticated is false, we don't use activeAccount, which should be undefined?
|
|
59
|
-
// skip isAuthenticated check ?
|
|
60
|
-
const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
61
|
-
// Wrapper to set active wallet via thirdweb
|
|
62
|
-
// Note: `wallet` in context is deprecated - use useActiveWallet() from thirdweb/react instead
|
|
63
|
-
// Auto-select first EOA wallet when enabled
|
|
64
|
-
useAutoSelectWallet({
|
|
65
|
-
enabled: automaticallySetFirstEoa,
|
|
66
|
-
});
|
|
67
|
-
return (_jsx(B3Context.Provider, { value: {
|
|
68
|
-
account: effectiveAccount,
|
|
69
|
-
// setWallet,
|
|
70
|
-
//wallet: undefined, // Deprecated: use useActiveWallet() from thirdweb/react instead
|
|
71
|
-
//user,
|
|
72
|
-
//setUser,
|
|
73
|
-
//refetchUser,
|
|
74
|
-
initialized: true,
|
|
75
|
-
ready: !!effectiveAccount,
|
|
76
|
-
automaticallySetFirstEoa,
|
|
77
|
-
environment,
|
|
78
|
-
defaultPermissions,
|
|
79
|
-
theme,
|
|
80
|
-
clientType,
|
|
81
|
-
partnerId: partnerId,
|
|
82
|
-
stripePublishableKey,
|
|
83
|
-
createClientReferenceId,
|
|
84
|
-
enableTurnkey,
|
|
85
|
-
}, children: children }));
|
|
49
|
+
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsxs(LocalSDKProvider, { onConnectCallback: onConnect, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] }), _jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }));
|
|
86
50
|
}
|
|
87
51
|
/**
|
|
88
52
|
* Component to connect the toast context to the global toast API
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
2
2
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
3
3
|
import { ClientType } from "../../../client-manager";
|
|
4
|
-
import { B3ContextType } from "./types";
|
|
5
4
|
/**
|
|
6
5
|
* Main B3Provider component
|
|
7
6
|
*/
|
|
8
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, }: {
|
|
7
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, defaultPermissions, }: {
|
|
9
8
|
theme: "light" | "dark";
|
|
10
9
|
children: React.ReactNode;
|
|
11
10
|
accountOverride?: Account;
|
|
12
|
-
environment
|
|
11
|
+
environment?: "development" | "production";
|
|
13
12
|
clientType?: ClientType;
|
|
14
13
|
partnerId: string;
|
|
15
14
|
rpcUrls?: Record<number, string>;
|
|
16
15
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
16
|
+
defaultPermissions?: PermissionsConfig;
|
|
17
17
|
}): import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
/**
|
|
19
|
-
* Inner provider component
|
|
19
|
+
* Inner provider component for native
|
|
20
20
|
*/
|
|
21
21
|
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, partnerId, rpcUrls, }: {
|
|
22
22
|
children: React.ReactNode;
|
|
23
23
|
accountOverride?: Account;
|
|
24
|
-
environment
|
|
24
|
+
environment?: "development" | "production";
|
|
25
25
|
defaultPermissions?: PermissionsConfig;
|
|
26
26
|
theme: "light" | "dark";
|
|
27
27
|
clientType?: ClientType;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { ThirdwebProvider } from "thirdweb/react";
|
|
4
5
|
import { WagmiProvider } from "wagmi";
|
|
6
|
+
import { useB3ConfigStore } from "../../stores/configStore.js";
|
|
5
7
|
import { createWagmiConfig } from "../../utils/createWagmiConfig.js";
|
|
8
|
+
import AuthenticationProvider from "./AuthenticationProvider.js";
|
|
6
9
|
import { LocalSDKProvider } from "./LocalSDKProvider.js";
|
|
7
|
-
import { B3Context } from "./types.js";
|
|
8
|
-
/**
|
|
9
|
-
* Default permissions configuration for B3 provider
|
|
10
|
-
*/
|
|
11
|
-
const DEFAULT_PERMISSIONS = {
|
|
12
|
-
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"], // Example contract
|
|
13
|
-
nativeTokenLimitPerTransaction: 0.1, // in ETH
|
|
14
|
-
startDate: new Date(),
|
|
15
|
-
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
16
|
-
};
|
|
17
10
|
// Create queryClient instance
|
|
18
11
|
const queryClient = new QueryClient();
|
|
19
12
|
/**
|
|
20
13
|
* Main B3Provider component
|
|
21
14
|
*/
|
|
22
|
-
export function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, onConnect, }) {
|
|
23
|
-
|
|
15
|
+
export function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, onConnect, defaultPermissions, }) {
|
|
16
|
+
const setConfig = useB3ConfigStore(state => state.setConfig);
|
|
17
|
+
// Initialize config store on mount - props are static and never change
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
setConfig({
|
|
20
|
+
accountOverride,
|
|
21
|
+
environment: environment ?? "development",
|
|
22
|
+
automaticallySetFirstEoa: false,
|
|
23
|
+
theme,
|
|
24
|
+
clientType,
|
|
25
|
+
partnerId,
|
|
26
|
+
defaultPermissions,
|
|
27
|
+
});
|
|
28
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
29
|
+
return (_jsx(ThirdwebProvider, { children: _jsxs(LocalSDKProvider, { onConnectCallback: onConnect, children: [children, _jsx(AuthenticationProvider, { partnerId: partnerId, automaticallySetFirstEoa: false })] }) }));
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
|
-
* Inner provider component
|
|
32
|
+
* Inner provider component for native
|
|
27
33
|
*/
|
|
28
|
-
export function InnerProvider({ children, accountOverride, environment, defaultPermissions
|
|
29
|
-
const
|
|
30
|
-
//const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
34
|
+
export function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
35
|
+
const setConfig = useB3ConfigStore(state => state.setConfig);
|
|
31
36
|
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
theme,
|
|
46
|
-
clientType,
|
|
47
|
-
partnerId,
|
|
48
|
-
//refetchUser,
|
|
49
|
-
}, children: children }) }) }));
|
|
37
|
+
// Initialize config store on mount - props are static and never change
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
setConfig({
|
|
40
|
+
accountOverride,
|
|
41
|
+
environment: environment ?? "development",
|
|
42
|
+
automaticallySetFirstEoa: false,
|
|
43
|
+
theme,
|
|
44
|
+
clientType,
|
|
45
|
+
partnerId,
|
|
46
|
+
defaultPermissions,
|
|
47
|
+
});
|
|
48
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
49
|
+
return (_jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: children }) }));
|
|
50
50
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hook to access the B3
|
|
3
|
-
* @
|
|
4
|
-
* @deprecated Use useB3Config or useB3Account instead
|
|
2
|
+
* Hook to access the B3 configuration
|
|
3
|
+
* @deprecated This is just an alias for useB3Config. Use useB3Config directly instead.
|
|
5
4
|
*/
|
|
6
|
-
export declare function useB3():
|
|
5
|
+
export declare function useB3(): {
|
|
6
|
+
automaticallySetFirstEoa: boolean;
|
|
7
|
+
environment: "development" | "production";
|
|
8
|
+
theme: "light" | "dark";
|
|
9
|
+
clientType: import("../../../client-manager").ClientType;
|
|
10
|
+
partnerId: string;
|
|
11
|
+
createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
|
|
12
|
+
enableTurnkey: boolean;
|
|
13
|
+
stripePublishableKey: string | undefined;
|
|
14
|
+
defaultPermissions: import("../../../types/permissions").PermissionsConfig;
|
|
15
|
+
accountOverride: import("thirdweb/wallets").Account | undefined;
|
|
16
|
+
};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { B3Context } from "./types.js";
|
|
1
|
+
import { useB3Config } from "./useB3Config.js";
|
|
3
2
|
/**
|
|
4
|
-
* Hook to access the B3
|
|
5
|
-
* @
|
|
6
|
-
* @deprecated Use useB3Config or useB3Account instead
|
|
3
|
+
* Hook to access the B3 configuration
|
|
4
|
+
* @deprecated This is just an alias for useB3Config. Use useB3Config directly instead.
|
|
7
5
|
*/
|
|
8
6
|
export function useB3() {
|
|
9
|
-
|
|
10
|
-
if (!context.initialized) {
|
|
11
|
-
throw new Error("useB3 must be used within a B3Provider");
|
|
12
|
-
}
|
|
13
|
-
// Return a stable reference
|
|
14
|
-
return useMemo(() => context, [context]);
|
|
7
|
+
return useB3Config();
|
|
15
8
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { useActiveAccount } from "thirdweb/react";
|
|
2
|
+
import { useAuthStore } from "../../stores/useAuthStore.js";
|
|
2
3
|
// Wrapper around useActiveAccount
|
|
3
4
|
export const useB3Account = () => {
|
|
4
|
-
const
|
|
5
|
-
|
|
5
|
+
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
6
|
+
const activeAccount = useActiveAccount();
|
|
7
|
+
const effectiveAccount = isAuthenticated ? activeAccount : undefined;
|
|
8
|
+
return effectiveAccount;
|
|
6
9
|
};
|