@b3dotfun/sdk 0.1.0 → 0.1.1-test.0
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/GasIndicator.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/common/GasIndicator.js +6 -16
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +1 -1
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +15 -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/anyspend/react/providers/AnyspendProvider.js +1 -2
- package/dist/cjs/global-account/react/components/AccountAssets/AccountAssets.js +7 -3
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +1 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -15
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +57 -35
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +36 -39
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +27 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.js +24 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +3 -14
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +10 -4
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +2 -5
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +17 -18
- package/dist/cjs/global-account/react/components/ManageAccount/NFTContent.js +2 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +2 -1
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/DiscordChannel.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/EmailChannel.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/PhoneChannel.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/cjs/global-account/react/components/RequestPermissions/RequestPermissions.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -2
- 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 +2 -2
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -1
- package/dist/cjs/global-account/react/components/index.d.ts +2 -1
- package/dist/cjs/global-account/react/components/index.js +6 -3
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/index.js +5 -3
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuth.js +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -1
- 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 +1 -1
- package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +7 -0
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +43 -11
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.js +190 -0
- package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +1 -1
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +7 -6
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +39 -64
- package/dist/cjs/global-account/react/index.native.d.ts +2 -0
- package/dist/cjs/global-account/react/index.native.js +5 -1
- package/dist/cjs/global-account/react/stores/index.d.ts +0 -1
- package/dist/cjs/global-account/react/stores/index.js +1 -3
- package/dist/cjs/global-account/react/utils/simdune.d.ts +7 -0
- package/dist/cjs/global-account/react/utils/simdune.js +21 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -2
- package/dist/esm/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/esm/anyspend/react/components/common/GasIndicator.js +7 -17
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +16 -5
- 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/anyspend/react/providers/AnyspendProvider.js +1 -2
- package/dist/esm/global-account/react/components/AccountAssets/AccountAssets.js +7 -3
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +2 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +2 -16
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +58 -34
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +37 -37
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +27 -0
- package/dist/esm/global-account/react/components/B3Provider/types.js +21 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +3 -14
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +10 -4
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +2 -5
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +17 -18
- package/dist/esm/global-account/react/components/ManageAccount/NFTContent.js +3 -3
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +3 -2
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- 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 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +15 -4
- 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 +2 -2
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +3 -2
- package/dist/esm/global-account/react/components/index.d.ts +2 -1
- package/dist/esm/global-account/react/components/index.js +2 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/index.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuth.js +3 -3
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -1
- 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/useSimBalance.d.ts +7 -0
- package/dist/esm/global-account/react/hooks/useSimBalance.js +42 -11
- package/dist/esm/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
- package/dist/esm/global-account/react/hooks/useSimCollectibles.js +187 -0
- package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +2 -2
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +7 -6
- package/dist/esm/global-account/react/hooks/useUserQuery.js +37 -63
- package/dist/esm/global-account/react/index.native.d.ts +2 -0
- package/dist/esm/global-account/react/index.native.js +2 -0
- package/dist/esm/global-account/react/stores/index.d.ts +0 -1
- package/dist/esm/global-account/react/stores/index.js +0 -1
- package/dist/esm/global-account/react/utils/simdune.d.ts +7 -0
- package/dist/esm/global-account/react/utils/simdune.js +17 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +27 -0
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +3 -14
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
- package/dist/types/global-account/react/components/index.d.ts +2 -1
- package/dist/types/global-account/react/hooks/index.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useAuth.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useSimBalance.d.ts +7 -0
- package/dist/types/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +7 -6
- package/dist/types/global-account/react/index.native.d.ts +2 -0
- package/dist/types/global-account/react/stores/index.d.ts +0 -1
- package/dist/types/global-account/react/utils/simdune.d.ts +7 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +2 -2
- package/src/anyspend/react/components/common/GasIndicator.tsx +11 -30
- package/src/anyspend/react/components/common/OrderDetails.tsx +2 -2
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +2 -2
- package/src/anyspend/react/components/common/TokenBalance.tsx +17 -5
- 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/anyspend/react/providers/AnyspendProvider.tsx +2 -5
- package/src/global-account/react/components/AccountAssets/AccountAssets.tsx +25 -13
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +2 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +2 -18
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +57 -46
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +117 -44
- package/src/global-account/react/components/B3Provider/types.ts +50 -0
- package/src/global-account/react/components/B3Provider/useB3.ts +12 -4
- package/src/global-account/react/components/B3Provider/useB3Account.ts +2 -6
- package/src/global-account/react/components/B3Provider/useB3Config.ts +31 -18
- package/src/global-account/react/components/ManageAccount/NFTContent.tsx +4 -4
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +4 -2
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +2 -2
- 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 +2 -2
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +15 -4
- 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 +2 -2
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +3 -2
- package/src/global-account/react/components/index.ts +2 -1
- package/src/global-account/react/hooks/index.ts +2 -2
- package/src/global-account/react/hooks/useAuth.ts +3 -3
- package/src/global-account/react/hooks/useAuthentication.ts +1 -1
- 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/useSimBalance.ts +49 -12
- package/src/global-account/react/hooks/useSimCollectibles.ts +238 -0
- package/src/global-account/react/hooks/useTokenBalance.tsx +7 -8
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +2 -2
- package/src/global-account/react/hooks/useUserQuery.ts +51 -64
- package/src/global-account/react/index.native.ts +2 -0
- package/src/global-account/react/stores/index.ts +0 -1
- package/src/global-account/react/utils/simdune.ts +20 -0
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +0 -12
- package/dist/cjs/global-account/react/hooks/useUser.d.ts +0 -60
- package/dist/cjs/global-account/react/hooks/useUser.js +0 -20
- package/dist/cjs/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/cjs/global-account/react/stores/configStore.js +0 -30
- package/dist/cjs/global-account/react/stores/userStore.d.ts +0 -22
- package/dist/cjs/global-account/react/stores/userStore.js +0 -30
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +0 -10
- package/dist/esm/global-account/react/hooks/useUser.d.ts +0 -60
- package/dist/esm/global-account/react/hooks/useUser.js +0 -17
- package/dist/esm/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/esm/global-account/react/stores/configStore.js +0 -27
- package/dist/esm/global-account/react/stores/userStore.d.ts +0 -22
- package/dist/esm/global-account/react/stores/userStore.js +0 -27
- package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
- package/dist/types/global-account/react/hooks/useUser.d.ts +0 -60
- package/dist/types/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/types/global-account/react/stores/userStore.d.ts +0 -22
- package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +0 -19
- package/src/global-account/react/hooks/useUser.ts +0 -20
- package/src/global-account/react/stores/configStore.ts +0 -51
- package/src/global-account/react/stores/userStore.ts +0 -41
|
@@ -61,7 +61,7 @@ function AnySpend(props) {
|
|
|
61
61
|
function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationTokenChainId, mode = "modal", defaultActiveTab = "crypto", loadOrder, hideTransactionHistoryButton, recipientAddress: recipientAddressFromProps, onTokenSelect, onSuccess, customUsdInputValues, hideHeader, hideBottomNavigation = false, disableUrlParamManagement = false, returnToHomeUrl, customRecipientLabel, returnHomeLabel, }) {
|
|
62
62
|
const searchParams = (0, react_2.useSearchParamsSSR)();
|
|
63
63
|
const router = (0, react_2.useRouter)();
|
|
64
|
-
const { partnerId } = (0, react_2.
|
|
64
|
+
const { partnerId } = (0, react_2.useB3)();
|
|
65
65
|
const setB3ModalContentType = (0, react_2.useModalStore)(state => state.setB3ModalContentType);
|
|
66
66
|
// Determine if we're in "buy mode" based on whether destination token props are provided
|
|
67
67
|
const isBuyMode = !!(destinationTokenAddress && destinationTokenChainId);
|
|
@@ -3,4 +3,4 @@ export interface GasIndicatorProps {
|
|
|
3
3
|
gasPrice: GasPriceData;
|
|
4
4
|
className?: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function GasIndicator({ gasPrice, className }: GasIndicatorProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function GasIndicator({ gasPrice, className }: GasIndicatorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -5,21 +5,7 @@ exports.GasIndicator = GasIndicator;
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
7
7
|
const react_1 = require("motion/react");
|
|
8
|
-
|
|
9
|
-
low: "Low",
|
|
10
|
-
normal: "Normal",
|
|
11
|
-
elevated: "Elevated",
|
|
12
|
-
high: "High",
|
|
13
|
-
spike: "Spike",
|
|
14
|
-
};
|
|
15
|
-
const LEVEL_STYLES = {
|
|
16
|
-
low: "bg-green-500/20 text-green-500",
|
|
17
|
-
normal: "bg-as-surface-tertiary text-as-secondary",
|
|
18
|
-
elevated: "bg-yellow-500/20 text-yellow-600",
|
|
19
|
-
high: "bg-orange-500/20 text-orange-500",
|
|
20
|
-
spike: "bg-red-500/20 text-red-500",
|
|
21
|
-
};
|
|
22
|
-
function formatGasPrice(gweiString) {
|
|
8
|
+
function formatGwei(gweiString) {
|
|
23
9
|
const gwei = parseFloat(gweiString);
|
|
24
10
|
if (gwei < 0.001)
|
|
25
11
|
return "<0.001";
|
|
@@ -30,5 +16,9 @@ function formatGasPrice(gweiString) {
|
|
|
30
16
|
return gwei.toFixed(1);
|
|
31
17
|
}
|
|
32
18
|
function GasIndicator({ gasPrice, className }) {
|
|
33
|
-
|
|
19
|
+
// Only show when gas is high or spike
|
|
20
|
+
if (!["high", "spike"].includes(gasPrice.level)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.2 }, className: (0, cn_1.cn)("flex flex-col gap-1 rounded-lg bg-orange-500/10 px-3 py-2", className), children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-xs font-medium text-orange-500", children: "Gas is high - transaction may fail or cost more" }), (0, jsx_runtime_1.jsxs)("span", { className: "text-xs font-medium text-orange-500", children: [formatGwei(gasPrice.gasPriceGwei), " Gwei"] })] }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-secondary text-xs", children: "Consider swapping later for better rates" })] }));
|
|
34
24
|
}
|
|
@@ -141,7 +141,7 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ mode = "modal",
|
|
|
141
141
|
const router = (0, hooks_1.useRouter)();
|
|
142
142
|
const searchParams = (0, hooks_1.useSearchParams)();
|
|
143
143
|
// Get theme from B3Provider context
|
|
144
|
-
const { theme } = (0, react_1.
|
|
144
|
+
const { theme } = (0, react_1.useB3)();
|
|
145
145
|
const colorMode = theme || "light";
|
|
146
146
|
// Read crypto payment method from URL parameters
|
|
147
147
|
const cryptoPaymentMethodFromUrl = searchParams.get("cryptoPaymentMethod");
|
|
@@ -16,7 +16,7 @@ const AnySpendFingerprintWrapper_1 = require("../AnySpendFingerprintWrapper");
|
|
|
16
16
|
const HowItWorks_1 = __importDefault(require("./HowItWorks"));
|
|
17
17
|
const PaymentMethodIcons_1 = __importDefault(require("./PaymentMethodIcons"));
|
|
18
18
|
function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaymentSuccess }) {
|
|
19
|
-
const { theme, stripePublishableKey } = (0, react_2.
|
|
19
|
+
const { theme, stripePublishableKey } = (0, react_2.useB3)();
|
|
20
20
|
const fingerprintConfig = (0, AnySpendFingerprintWrapper_1.getFingerprintConfig)();
|
|
21
21
|
const { clientSecret, isLoadingStripeClientSecret, stripeClientSecretError } = (0, react_1.useStripeClientSecret)(stripePaymentIntentId);
|
|
22
22
|
if (isLoadingStripeClientSecret) {
|
|
@@ -5,12 +5,23 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const chain_1 = require("../../../../anyspend/utils/chain");
|
|
6
6
|
const token_1 = require("../../../../anyspend/utils/token");
|
|
7
7
|
const react_1 = require("../../../../global-account/react");
|
|
8
|
+
const number_1 = require("../../../../shared/utils/number");
|
|
9
|
+
const react_2 = require("react");
|
|
8
10
|
const viem_1 = require("viem");
|
|
9
11
|
function TokenBalance({ token, walletAddress, onChangeInput, }) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const tokenAddress = (0, token_1.isNativeToken)(token.address) ? "native" : token.address;
|
|
13
|
+
const { data, isLoading } = (0, react_1.useSimTokenBalance)(walletAddress, tokenAddress, token.chainId);
|
|
14
|
+
const { rawBalance, formattedBalance } = (0, react_2.useMemo)(() => {
|
|
15
|
+
const balance = data?.balances?.[0];
|
|
16
|
+
if (!balance?.amount) {
|
|
17
|
+
return { rawBalance: null, formattedBalance: "0" };
|
|
18
|
+
}
|
|
19
|
+
const raw = BigInt(balance.amount);
|
|
20
|
+
return {
|
|
21
|
+
rawBalance: raw,
|
|
22
|
+
formattedBalance: (0, number_1.formatTokenAmount)(raw, balance.decimals),
|
|
23
|
+
};
|
|
24
|
+
}, [data]);
|
|
14
25
|
const handlePercentageClick = (percentage) => {
|
|
15
26
|
if (!rawBalance)
|
|
16
27
|
return;
|
|
@@ -17,7 +17,7 @@ const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId
|
|
|
17
17
|
*/
|
|
18
18
|
function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
19
19
|
// Get B3 context values
|
|
20
|
-
const { partnerId } = (0, react_1.
|
|
20
|
+
const { partnerId } = (0, react_1.useB3)();
|
|
21
21
|
// Get validated client reference ID from B3 context
|
|
22
22
|
const createValidatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
|
|
23
23
|
// Get fingerprint data
|
|
@@ -15,7 +15,7 @@ const useValidatedClientReferenceId_1 = require("./useValidatedClientReferenceId
|
|
|
15
15
|
*/
|
|
16
16
|
function useAnyspendCreateOrder({ onSuccess, onError } = {}) {
|
|
17
17
|
// Get B3 context values
|
|
18
|
-
const { partnerId } = (0, react_1.
|
|
18
|
+
const { partnerId } = (0, react_1.useB3)();
|
|
19
19
|
// Get validated client reference ID from B3 context
|
|
20
20
|
const createValidatedClientReferenceId = (0, useValidatedClientReferenceId_1.useValidatedClientReferenceId)();
|
|
21
21
|
// Get fingerprint data
|
|
@@ -12,7 +12,7 @@ const react_2 = require("react");
|
|
|
12
12
|
* This order type doesn't require srcAmount - the user deposits tokens after the order is created.
|
|
13
13
|
*/
|
|
14
14
|
function useCreateDepositFirstOrder({ onSuccess, onError } = {}) {
|
|
15
|
-
const { partnerId } = (0, react_1.
|
|
15
|
+
const { partnerId } = (0, react_1.useB3)();
|
|
16
16
|
const { data: fpData } = (0, fingerprintjs_pro_react_1.useVisitorData)({ extendedResult: true }, { immediate: true });
|
|
17
17
|
const visitorData = fpData && {
|
|
18
18
|
requestId: fpData.requestId,
|
|
@@ -9,7 +9,7 @@ const react_2 = require("react");
|
|
|
9
9
|
* Gets the createClientReferenceId function from B3 context and validates the result
|
|
10
10
|
*/
|
|
11
11
|
function useValidatedClientReferenceId() {
|
|
12
|
-
const { createClientReferenceId } = (0, react_1.
|
|
12
|
+
const { createClientReferenceId } = (0, react_1.useB3)();
|
|
13
13
|
const createValidatedClientReferenceId = (0, react_2.useCallback)(async (params) => {
|
|
14
14
|
// If no function provided, return undefined
|
|
15
15
|
if (!createClientReferenceId) {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.AnyspendProvider = void 0;
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("../../../global-account/react");
|
|
7
6
|
const FeatureFlagsContext_1 = require("../contexts/FeatureFlagsContext");
|
|
8
7
|
const StripeRedirectHandler_1 = require("./StripeRedirectHandler");
|
|
9
8
|
/**
|
|
@@ -30,6 +29,6 @@ const StripeRedirectHandler_1 = require("./StripeRedirectHandler");
|
|
|
30
29
|
* ```
|
|
31
30
|
*/
|
|
32
31
|
const AnyspendProvider = function AnyspendProvider({ children, featureFlags }) {
|
|
33
|
-
return ((0, jsx_runtime_1.
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)(FeatureFlagsContext_1.FeatureFlagsProvider, { featureFlags: featureFlags, children: [(0, jsx_runtime_1.jsx)(StripeRedirectHandler_1.StripeRedirectHandler, {}), children] }));
|
|
34
33
|
};
|
|
35
34
|
exports.AnyspendProvider = AnyspendProvider;
|
|
@@ -21,6 +21,10 @@ function AccountAssets({ nfts, isLoading }) {
|
|
|
21
21
|
}, {});
|
|
22
22
|
const collections = Object.values(groupedNFTs || {});
|
|
23
23
|
const [expandedCollections, setExpandedCollections] = (0, react_1.useState)(() => new Set(collections.map(c => c.collection_id)));
|
|
24
|
+
const [failedImages, setFailedImages] = (0, react_1.useState)(() => new Set());
|
|
25
|
+
const handleImageError = (imageId) => {
|
|
26
|
+
setFailedImages(prev => new Set(prev).add(imageId));
|
|
27
|
+
};
|
|
24
28
|
if (isLoading) {
|
|
25
29
|
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-3", children: [...Array(2)].map((_, i) => ((0, jsx_runtime_1.jsxs)("div", { className: "animate-pulse", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-muted mb-3 h-6 w-48 rounded" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-muted h-[98px] w-[98px] shrink-0 rounded-lg" }), (0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-muted h-[98px] w-[98px] shrink-0 rounded-lg" })] })] }, i))) }));
|
|
26
30
|
}
|
|
@@ -39,11 +43,11 @@ function AccountAssets({ nfts, isLoading }) {
|
|
|
39
43
|
return next;
|
|
40
44
|
});
|
|
41
45
|
};
|
|
42
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-3
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-3", children: collections.map(collection => {
|
|
43
47
|
const isExpanded = expandedCollections.has(collection.collection_id);
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-3", children: [(0, jsx_runtime_1.jsxs)("button", { onClick: () => toggleCollection(collection.collection_id), className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1", children: [collection.collection_image && ((0, jsx_runtime_1.jsx)("img", { src: collection.collection_image, alt: collection.collection_name, className: "h-5 w-5 shrink-0 rounded object-cover" })), (0, jsx_runtime_1.jsxs)("p", { className: "font-neue-montreal-medium text-[14px] text-[#3f3f46]", children: [collection.collection_name, " (", collection.nfts.length, ")"] })] }), (0, jsx_runtime_1.jsx)("svg", { className: `h-[18px] w-[18px] shrink-0 transition-transform ${isExpanded ? "rotate-180" : ""}`, viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M4.5 6.75L9 11.25L13.5 6.75", stroke: "#51525C", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })] }), isExpanded && ((0, jsx_runtime_1.jsx)("div", { className: "flex gap-3 overflow-x-auto", children: collection.nfts.map(nft => ((0, jsx_runtime_1.jsx)("div", { className: "relative h-[98px] w-[98px] shrink-0 overflow-hidden rounded-lg", children: (0, jsx_runtime_1.jsx)("img", { src: nft.previews?.image_medium_url ||
|
|
48
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-3", children: [(0, jsx_runtime_1.jsxs)("button", { onClick: () => toggleCollection(collection.collection_id), className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1", children: [collection.collection_image && !failedImages.has(`collection-${collection.collection_id}`) && ((0, jsx_runtime_1.jsx)("img", { src: collection.collection_image, alt: collection.collection_name, className: "h-5 w-5 shrink-0 rounded object-cover", onError: () => handleImageError(`collection-${collection.collection_id}`) })), (0, jsx_runtime_1.jsxs)("p", { className: "font-neue-montreal-medium text-[14px] text-[#3f3f46]", children: [collection.collection_name, " (", collection.nfts.length, ")"] })] }), (0, jsx_runtime_1.jsx)("svg", { className: `h-[18px] w-[18px] shrink-0 transition-transform ${isExpanded ? "rotate-180" : ""}`, viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M4.5 6.75L9 11.25L13.5 6.75", stroke: "#51525C", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })] }), isExpanded && ((0, jsx_runtime_1.jsx)("div", { className: "flex gap-3 overflow-x-auto", children: collection.nfts.map(nft => ((0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-muted relative h-[98px] w-[98px] shrink-0 overflow-hidden rounded-lg", children: !failedImages.has(nft.nft_id) && ((0, jsx_runtime_1.jsx)("img", { src: nft.previews?.image_medium_url ||
|
|
45
49
|
nft.extra_metadata?.image_original_url ||
|
|
46
50
|
nft.collection?.image_url ||
|
|
47
|
-
"", alt: nft.name || "NFT", className: "h-full w-full object-cover" }) }, nft.nft_id))) }))] }, collection.collection_id));
|
|
51
|
+
"", alt: nft.name || "NFT", className: "h-full w-full object-cover", onError: () => handleImageError(nft.nft_id) })) }, nft.nft_id))) }))] }, collection.collection_id));
|
|
48
52
|
}) }));
|
|
49
53
|
}
|
|
@@ -43,7 +43,7 @@ function AvatarEditor({ onSetAvatar, className }) {
|
|
|
43
43
|
const [zoom, setZoom] = (0, react_2.useState)(1);
|
|
44
44
|
const [croppedAreaPixels, setCroppedAreaPixels] = (0, react_2.useState)(null);
|
|
45
45
|
const fileInputRef = (0, react_2.useRef)(null);
|
|
46
|
-
const { partnerId } = (0, react_1.
|
|
46
|
+
const { partnerId } = (0, react_1.useB3)();
|
|
47
47
|
const { user, setUser } = (0, react_1.useAuthentication)(partnerId);
|
|
48
48
|
const setB3ModalContentType = (0, stores_1.useModalStore)(state => state.setB3ModalContentType);
|
|
49
49
|
const contentType = (0, stores_1.useModalStore)(state => state.contentType);
|
|
@@ -14,8 +14,6 @@ const react_2 = require("../../../global-account/react");
|
|
|
14
14
|
const cn_1 = require("../../../shared/utils/cn");
|
|
15
15
|
const debug_1 = require("../../../shared/utils/debug");
|
|
16
16
|
const framer_motion_1 = require("framer-motion");
|
|
17
|
-
const react_3 = require("react");
|
|
18
|
-
const react_4 = require("thirdweb/react");
|
|
19
17
|
const AvatarEditor_1 = require("./AvatarEditor/AvatarEditor");
|
|
20
18
|
const Deposit_1 = require("./Deposit/Deposit");
|
|
21
19
|
const LinkAccount_1 = require("./LinkAccount/LinkAccount");
|
|
@@ -35,21 +33,9 @@ function B3DynamicModal() {
|
|
|
35
33
|
const setB3ModalOpen = (0, react_2.useModalStore)(state => state.setB3ModalOpen);
|
|
36
34
|
const contentType = (0, react_2.useModalStore)(state => state.contentType);
|
|
37
35
|
const navigateBack = (0, react_2.useModalStore)(state => state.navigateBack);
|
|
38
|
-
const { theme } = (0, react_2.
|
|
36
|
+
const { theme } = (0, react_2.useB3)();
|
|
39
37
|
const isMobile = (0, react_2.useIsMobile)();
|
|
40
|
-
const prevIsOpenRef = (0, react_3.useRef)(isOpen);
|
|
41
|
-
const { wallet } = (0, react_2.useGlobalAccount)();
|
|
42
|
-
const setActiveWallet = (0, react_4.useSetActiveWallet)();
|
|
43
38
|
const { toasts, removeToast } = (0, index_1.useToastContext)();
|
|
44
|
-
// anyspend cleanup global account chnages by setting account back
|
|
45
|
-
(0, react_3.useEffect)(() => {
|
|
46
|
-
if (prevIsOpenRef.current && !isOpen) {
|
|
47
|
-
if (wallet) {
|
|
48
|
-
setActiveWallet(wallet);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
prevIsOpenRef.current = isOpen;
|
|
52
|
-
}, [isOpen, wallet, setActiveWallet]);
|
|
53
39
|
// Define arrays for different modal type groups
|
|
54
40
|
const fullWidthTypes = [
|
|
55
41
|
"anySpend",
|
|
@@ -5,14 +5,15 @@ 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";
|
|
8
9
|
/**
|
|
9
10
|
* Main B3Provider component
|
|
10
11
|
*/
|
|
11
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey,
|
|
12
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
|
|
12
13
|
theme: "light" | "dark";
|
|
13
14
|
children: React.ReactNode;
|
|
14
15
|
accountOverride?: Account;
|
|
15
|
-
environment
|
|
16
|
+
environment: B3ContextType["environment"];
|
|
16
17
|
automaticallySetFirstEoa?: boolean;
|
|
17
18
|
simDuneApiKey?: string;
|
|
18
19
|
toaster?: {
|
|
@@ -29,5 +30,20 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
29
30
|
overrideDefaultConnectors?: boolean;
|
|
30
31
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
31
32
|
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"];
|
|
32
41
|
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;
|
|
33
49
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.B3Provider = B3Provider;
|
|
4
|
+
exports.InnerProvider = InnerProvider;
|
|
7
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
6
|
const react_1 = require("../../../../global-account/react");
|
|
7
|
+
const useAutoSelectWallet_1 = require("../../../../global-account/react/hooks/useAutoSelectWallet");
|
|
9
8
|
const createWagmiConfig_1 = require("../../../../global-account/react/utils/createWagmiConfig");
|
|
10
9
|
const analytics_1 = require("../../../../global-account/utils/analytics");
|
|
11
10
|
require("@relayprotocol/relay-kit-ui/styles.css");
|
|
@@ -14,11 +13,19 @@ const react_2 = require("react");
|
|
|
14
13
|
const react_3 = require("thirdweb/react");
|
|
15
14
|
const wagmi_1 = require("wagmi");
|
|
16
15
|
const client_manager_1 = require("../../../client-manager");
|
|
17
|
-
const configStore_1 = require("../../stores/configStore");
|
|
18
16
|
const StyleRoot_1 = require("../StyleRoot");
|
|
19
17
|
const index_1 = require("../Toast/index");
|
|
20
|
-
const AuthenticationProvider_1 = __importDefault(require("./AuthenticationProvider"));
|
|
21
18
|
const LocalSDKProvider_1 = require("./LocalSDKProvider");
|
|
19
|
+
const types_1 = require("./types");
|
|
20
|
+
/**
|
|
21
|
+
* Default permissions configuration for B3 provider
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_PERMISSIONS = {
|
|
24
|
+
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"], // Example contract
|
|
25
|
+
nativeTokenLimitPerTransaction: 0.1, // in ETH
|
|
26
|
+
startDate: new Date(),
|
|
27
|
+
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
28
|
+
};
|
|
22
29
|
// Create queryClient instance
|
|
23
30
|
const queryClient = new react_query_1.QueryClient();
|
|
24
31
|
/**
|
|
@@ -26,35 +33,7 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
26
33
|
*/
|
|
27
34
|
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
|
|
28
35
|
// deprecated since v0.0.87
|
|
29
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false,
|
|
30
|
-
const setConfig = (0, configStore_1.useB3ConfigStore)(state => state.setConfig);
|
|
31
|
-
// Initialize config store on mount
|
|
32
|
-
(0, react_2.useEffect)(() => {
|
|
33
|
-
setConfig({
|
|
34
|
-
accountOverride,
|
|
35
|
-
environment: environment ?? "development",
|
|
36
|
-
automaticallySetFirstEoa: !!automaticallySetFirstEoa,
|
|
37
|
-
theme,
|
|
38
|
-
clientType,
|
|
39
|
-
partnerId,
|
|
40
|
-
stripePublishableKey,
|
|
41
|
-
createClientReferenceId,
|
|
42
|
-
enableTurnkey,
|
|
43
|
-
defaultPermissions,
|
|
44
|
-
});
|
|
45
|
-
}, [
|
|
46
|
-
accountOverride,
|
|
47
|
-
environment,
|
|
48
|
-
automaticallySetFirstEoa,
|
|
49
|
-
theme,
|
|
50
|
-
clientType,
|
|
51
|
-
partnerId,
|
|
52
|
-
stripePublishableKey,
|
|
53
|
-
createClientReferenceId,
|
|
54
|
-
enableTurnkey,
|
|
55
|
-
defaultPermissions,
|
|
56
|
-
setConfig,
|
|
57
|
-
]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
36
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, }) {
|
|
58
37
|
// Initialize Google Analytics on mount
|
|
59
38
|
(0, react_2.useEffect)(() => {
|
|
60
39
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -64,7 +43,50 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
64
43
|
(0, client_manager_1.setClientType)(clientType);
|
|
65
44
|
}, [clientType]);
|
|
66
45
|
const wagmiConfig = (0, react_2.useMemo)(() => (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
67
|
-
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(index_1.ToastProvider, { children: (0, jsx_runtime_1.
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(index_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsxs)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, children: [(0, jsx_runtime_1.jsx)(ToastContextConnector, {}), (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" })] })] }) }) }) }) }) }) }));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Inner provider component that provides the actual B3Context
|
|
50
|
+
*/
|
|
51
|
+
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }) {
|
|
52
|
+
const activeAccount = (0, react_3.useActiveAccount)();
|
|
53
|
+
const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
|
|
54
|
+
//const isConnected = useAuthStore(state => state.isConnected);
|
|
55
|
+
//const justCompletedLogin = useAuthStore(state => state.justCompletedLogin);
|
|
56
|
+
// 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
|
|
57
|
+
// The above PR removes useAuthentication from the overall B3Provider. useAuthentication should be everywhere the provider is, since it sets the overall auth state
|
|
58
|
+
// By just calling it manually, we fix that issue
|
|
59
|
+
// As a follow up, we should fix the SDK directly
|
|
60
|
+
(0, react_1.useAuthentication)(partnerId);
|
|
61
|
+
// Use given accountOverride or activeAccount from thirdweb
|
|
62
|
+
// WOJ: why if isAuthenticated is false, we don't use activeAccount, which should be undefined?
|
|
63
|
+
// skip isAuthenticated check ?
|
|
64
|
+
const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
65
|
+
// Wrapper to set active wallet via thirdweb
|
|
66
|
+
// Note: `wallet` in context is deprecated - use useActiveWallet() from thirdweb/react instead
|
|
67
|
+
// Auto-select first EOA wallet when enabled
|
|
68
|
+
(0, useAutoSelectWallet_1.useAutoSelectWallet)({
|
|
69
|
+
enabled: automaticallySetFirstEoa,
|
|
70
|
+
});
|
|
71
|
+
return ((0, jsx_runtime_1.jsx)(types_1.B3Context.Provider, { value: {
|
|
72
|
+
account: effectiveAccount,
|
|
73
|
+
// setWallet,
|
|
74
|
+
//wallet: undefined, // Deprecated: use useActiveWallet() from thirdweb/react instead
|
|
75
|
+
//user,
|
|
76
|
+
//setUser,
|
|
77
|
+
//refetchUser,
|
|
78
|
+
initialized: true,
|
|
79
|
+
ready: !!effectiveAccount,
|
|
80
|
+
automaticallySetFirstEoa,
|
|
81
|
+
environment,
|
|
82
|
+
defaultPermissions,
|
|
83
|
+
theme,
|
|
84
|
+
clientType,
|
|
85
|
+
partnerId: partnerId,
|
|
86
|
+
stripePublishableKey,
|
|
87
|
+
createClientReferenceId,
|
|
88
|
+
enableTurnkey,
|
|
89
|
+
}, children: children }));
|
|
68
90
|
}
|
|
69
91
|
/**
|
|
70
92
|
* 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";
|
|
4
5
|
/**
|
|
5
|
-
* Main B3Provider component
|
|
6
|
+
* Main B3Provider component for React Native
|
|
6
7
|
*/
|
|
7
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect,
|
|
8
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, }: {
|
|
8
9
|
theme: "light" | "dark";
|
|
9
10
|
children: React.ReactNode;
|
|
10
11
|
accountOverride?: Account;
|
|
11
|
-
environment
|
|
12
|
+
environment: B3ContextType["environment"];
|
|
12
13
|
clientType?: ClientType;
|
|
13
14
|
partnerId: string;
|
|
14
15
|
rpcUrls?: Record<number, string>;
|
|
15
16
|
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 that provides the actual B3Context
|
|
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: B3ContextType["environment"];
|
|
25
25
|
defaultPermissions?: PermissionsConfig;
|
|
26
26
|
theme: "light" | "dark";
|
|
27
27
|
clientType?: ClientType;
|
|
@@ -1,57 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.B3Provider = B3Provider;
|
|
7
4
|
exports.InnerProvider = InnerProvider;
|
|
8
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
6
|
const react_query_1 = require("@tanstack/react-query");
|
|
10
|
-
const react_1 = require("react");
|
|
11
|
-
const react_2 = require("thirdweb/react");
|
|
7
|
+
const react_1 = require("thirdweb/react");
|
|
12
8
|
const wagmi_1 = require("wagmi");
|
|
13
|
-
const configStore_1 = require("../../stores/configStore");
|
|
14
9
|
const createWagmiConfig_1 = require("../../utils/createWagmiConfig");
|
|
15
|
-
const AuthenticationProvider_1 = __importDefault(require("./AuthenticationProvider"));
|
|
16
10
|
const LocalSDKProvider_1 = require("./LocalSDKProvider");
|
|
11
|
+
const types_1 = require("./types");
|
|
12
|
+
/**
|
|
13
|
+
* Default permissions configuration for B3 provider
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_PERMISSIONS = {
|
|
16
|
+
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"], // Example contract
|
|
17
|
+
nativeTokenLimitPerTransaction: 0.1, // in ETH
|
|
18
|
+
startDate: new Date(),
|
|
19
|
+
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
20
|
+
};
|
|
17
21
|
// Create queryClient instance
|
|
18
22
|
const queryClient = new react_query_1.QueryClient();
|
|
19
23
|
/**
|
|
20
|
-
* Main B3Provider component
|
|
24
|
+
* Main B3Provider component for React Native
|
|
21
25
|
*/
|
|
22
|
-
function B3Provider({ theme
|
|
23
|
-
|
|
24
|
-
// Initialize config store on mount - props are static and never change
|
|
25
|
-
(0, react_1.useEffect)(() => {
|
|
26
|
-
setConfig({
|
|
27
|
-
accountOverride,
|
|
28
|
-
environment: environment ?? "development",
|
|
29
|
-
automaticallySetFirstEoa: false,
|
|
30
|
-
theme,
|
|
31
|
-
clientType,
|
|
32
|
-
partnerId,
|
|
33
|
-
defaultPermissions,
|
|
34
|
-
});
|
|
35
|
-
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
36
|
-
return ((0, jsx_runtime_1.jsx)(react_2.ThirdwebProvider, { children: (0, jsx_runtime_1.jsxs)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: [children, (0, jsx_runtime_1.jsx)(AuthenticationProvider_1.default, { partnerId: partnerId, automaticallySetFirstEoa: false })] }) }));
|
|
26
|
+
function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, }) {
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(react_1.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, clientType: clientType, partnerId: partnerId, rpcUrls: rpcUrls, children: children }) }) }));
|
|
37
28
|
}
|
|
38
29
|
/**
|
|
39
|
-
* Inner provider component
|
|
30
|
+
* Inner provider component that provides the actual B3Context
|
|
40
31
|
*/
|
|
41
|
-
function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
42
|
-
const
|
|
32
|
+
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
33
|
+
const activeAccount = (0, react_1.useActiveAccount)();
|
|
34
|
+
//const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
43
35
|
const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls });
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
// Use given accountOverride or activeAccount from thirdweb
|
|
37
|
+
const effectiveAccount = accountOverride || activeAccount;
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(types_1.B3Context.Provider, { value: {
|
|
39
|
+
//account: effectiveAccount,
|
|
40
|
+
automaticallySetFirstEoa: false,
|
|
41
|
+
//setWallet: () => {},
|
|
42
|
+
wallet: undefined,
|
|
43
|
+
//user,
|
|
44
|
+
//setUser,
|
|
45
|
+
initialized: true,
|
|
46
|
+
ready: !!effectiveAccount,
|
|
47
|
+
environment,
|
|
48
|
+
defaultPermissions,
|
|
49
|
+
theme,
|
|
50
|
+
clientType,
|
|
51
|
+
partnerId,
|
|
52
|
+
//refetchUser,
|
|
53
|
+
}, children: children }) }) }));
|
|
57
54
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
+
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
4
|
+
import { Account, Wallet } from "thirdweb/wallets";
|
|
5
|
+
import { ClientType } from "../../../client-manager";
|
|
6
|
+
/**
|
|
7
|
+
* Context type for B3Provider
|
|
8
|
+
*/
|
|
9
|
+
export interface B3ContextType {
|
|
10
|
+
account?: Account;
|
|
11
|
+
automaticallySetFirstEoa: boolean;
|
|
12
|
+
wallet?: Wallet;
|
|
13
|
+
initialized: boolean;
|
|
14
|
+
ready: boolean;
|
|
15
|
+
environment?: "development" | "production";
|
|
16
|
+
defaultPermissions?: PermissionsConfig;
|
|
17
|
+
theme: "light" | "dark";
|
|
18
|
+
clientType: ClientType;
|
|
19
|
+
partnerId: string;
|
|
20
|
+
stripePublishableKey?: string;
|
|
21
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
22
|
+
enableTurnkey?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Context for B3 provider
|
|
26
|
+
*/
|
|
27
|
+
export declare const B3Context: import("react").Context<B3ContextType>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.B3Context = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Context for B3 provider
|
|
7
|
+
*/
|
|
8
|
+
exports.B3Context = (0, react_1.createContext)({
|
|
9
|
+
account: undefined,
|
|
10
|
+
automaticallySetFirstEoa: false,
|
|
11
|
+
//user: undefined,
|
|
12
|
+
//setWallet: () => {},
|
|
13
|
+
wallet: undefined,
|
|
14
|
+
//setUser: () => {},
|
|
15
|
+
//refetchUser: async () => {},
|
|
16
|
+
initialized: false,
|
|
17
|
+
ready: false,
|
|
18
|
+
environment: "development",
|
|
19
|
+
theme: "light",
|
|
20
|
+
clientType: "rest",
|
|
21
|
+
partnerId: "",
|
|
22
|
+
createClientReferenceId: undefined,
|
|
23
|
+
enableTurnkey: false,
|
|
24
|
+
});
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hook to access the B3
|
|
3
|
-
* @
|
|
2
|
+
* Hook to access the B3 context
|
|
3
|
+
* @throws Error if used outside a B3Provider
|
|
4
4
|
*/
|
|
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
|
-
};
|
|
5
|
+
export declare function useB3(): import("./types").B3ContextType;
|