@b3dotfun/sdk 0.1.69-alpha.22 → 0.1.69-alpha.24
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.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +12 -4
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +7 -3
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +3 -3
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +6 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.d.ts +37 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.js +85 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +3 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +2 -2
- package/dist/cjs/global-account/react/components/index.d.ts +1 -0
- package/dist/cjs/global-account/react/components/index.js +5 -3
- package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useBetterAuth.js +5 -4
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +12 -4
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +7 -3
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +3 -3
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +6 -1
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.d.ts +37 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.js +82 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +3 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +2 -2
- package/dist/esm/global-account/react/components/index.d.ts +1 -0
- package/dist/esm/global-account/react/components/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useBetterAuth.js +5 -4
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +5 -1
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpside.d.ts +3 -1
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +6 -1
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.d.ts +37 -0
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +3 -1
- package/dist/types/global-account/react/components/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +24 -12
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +6 -0
- package/src/anyspend/react/components/AnySpendCustom.tsx +12 -2
- package/src/anyspend/react/components/AnySpendDeposit.tsx +38 -31
- package/src/anyspend/react/components/AnySpendNFT.tsx +4 -0
- package/src/anyspend/react/components/AnySpendStakeUpside.tsx +4 -0
- package/src/global-account/react/components/SignInWithB3/BetterAuthSignIn.tsx +7 -1
- package/src/global-account/react/components/SignInWithB3/BetterAuthVerifyEmail.tsx +155 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +8 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +4 -2
- package/src/global-account/react/components/index.ts +5 -0
- package/src/global-account/react/hooks/useBetterAuth.ts +5 -4
- package/src/global-account/react/stores/useModalStore.ts +4 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
2
|
import type { AnySpendContent, AnySpendSlots, AnySpendTheme } from "./types/customization";
|
|
3
|
-
export declare function AnySpendStakeUpside({ loadOrder, mode, beneficiaryAddress, stakeAmount, stakingContractAddress, token, onSuccess, activeTab, senderAddress, slots, content, theme, }: {
|
|
3
|
+
export declare function AnySpendStakeUpside({ loadOrder, mode, beneficiaryAddress, stakeAmount, stakingContractAddress, token, onSuccess, activeTab, senderAddress, slots, content, theme, showFiatOption, }: {
|
|
4
4
|
loadOrder?: string;
|
|
5
5
|
mode?: "modal" | "page";
|
|
6
6
|
beneficiaryAddress: string;
|
|
@@ -14,4 +14,6 @@ export declare function AnySpendStakeUpside({ loadOrder, mode, beneficiaryAddres
|
|
|
14
14
|
slots?: AnySpendSlots;
|
|
15
15
|
content?: AnySpendContent;
|
|
16
16
|
theme?: AnySpendTheme;
|
|
17
|
+
/** Whether to show the "Pay with fiat" tab. Defaults to true. */
|
|
18
|
+
showFiatOption?: boolean;
|
|
17
19
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,6 +10,11 @@ export interface BetterAuthSignInProps {
|
|
|
10
10
|
showEmail?: boolean;
|
|
11
11
|
/** URL to redirect to after password reset link is clicked. Token is appended as ?token=... */
|
|
12
12
|
passwordResetRedirectTo?: string;
|
|
13
|
+
/**
|
|
14
|
+
* URL Better Auth redirects to after server-side email verification. Render
|
|
15
|
+
* `BetterAuthVerifyEmail` at this route so the user gets a confirmation page.
|
|
16
|
+
*/
|
|
17
|
+
verifyEmailRedirectTo?: string;
|
|
13
18
|
/** Called after successful authentication */
|
|
14
19
|
onSuccess?: () => void;
|
|
15
20
|
/** Called on authentication error */
|
|
@@ -31,4 +36,4 @@ export interface BetterAuthSignInProps {
|
|
|
31
36
|
* />
|
|
32
37
|
* ```
|
|
33
38
|
*/
|
|
34
|
-
export declare function BetterAuthSignIn({ title, subtitle, socialProviders, showEmail, passwordResetRedirectTo, onSuccess, onError, className, }: BetterAuthSignInProps): import("react/jsx-runtime").JSX.Element | null;
|
|
39
|
+
export declare function BetterAuthSignIn({ title, subtitle, socialProviders, showEmail, passwordResetRedirectTo, verifyEmailRedirectTo, onSuccess, onError, className, }: BetterAuthSignInProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type BetterAuthVerifyEmailState = "success" | "expired" | "invalid" | "already-verified" | "error";
|
|
2
|
+
export interface BetterAuthVerifyEmailProps {
|
|
3
|
+
/**
|
|
4
|
+
* Error code from the callback URL's `?error=` query param. Pass `null` /
|
|
5
|
+
* `undefined` when the user landed here cleanly (successful verification).
|
|
6
|
+
* Better Auth appends this param when server-side verification fails.
|
|
7
|
+
*/
|
|
8
|
+
errorCode?: string | null;
|
|
9
|
+
/** Called when the user clicks the "Go to sign in" button. */
|
|
10
|
+
onGoToSignIn?: () => void;
|
|
11
|
+
/** Fallback href used when `onGoToSignIn` is not provided. Defaults to "/login". */
|
|
12
|
+
signInHref?: string;
|
|
13
|
+
/** Optional override for the success headline. */
|
|
14
|
+
successTitle?: string;
|
|
15
|
+
/** Optional override for the success body text. */
|
|
16
|
+
successMessage?: string;
|
|
17
|
+
/** Optional class name for the root container. */
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Standalone email-verification confirmation page. Render on the route you
|
|
22
|
+
* set as `callbackURL` when calling `betterAuthClient.sendVerificationEmail`
|
|
23
|
+
* (or the `verifyCallbackURL` arg on `useBetterAuth().signUpWithEmail`).
|
|
24
|
+
*
|
|
25
|
+
* Better Auth verifies the token server-side before redirecting here. This
|
|
26
|
+
* component only displays the outcome based on the `?error=` query param.
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const error = new URLSearchParams(window.location.search).get("error");
|
|
31
|
+
* <BetterAuthVerifyEmail
|
|
32
|
+
* errorCode={error}
|
|
33
|
+
* onGoToSignIn={() => router.push("/login")}
|
|
34
|
+
* />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function BetterAuthVerifyEmail({ errorCode, onGoToSignIn, signInHref, successTitle, successMessage, className, }: BetterAuthVerifyEmailProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,4 +3,4 @@ import { SignInWithB3ModalProps } from "@b3dotfun/sdk/global-account/react";
|
|
|
3
3
|
* Component that manages the authentication flow for Sign In With B3
|
|
4
4
|
* Handles different login providers, authentication steps, and session key management
|
|
5
5
|
*/
|
|
6
|
-
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled, verifyEmailRedirectTo, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
interface LoginStepBetterAuthProps {
|
|
2
2
|
onSuccess?: () => void;
|
|
3
3
|
onError?: (error: Error) => Promise<void>;
|
|
4
|
+
/** URL Better Auth redirects to after server-side email verification. */
|
|
5
|
+
verifyEmailRedirectTo?: string;
|
|
4
6
|
}
|
|
5
|
-
export declare function LoginStepBetterAuth({ onSuccess, onError }: LoginStepBetterAuthProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function LoginStepBetterAuth({ onSuccess, onError, verifyEmailRedirectTo }: LoginStepBetterAuthProps): import("react/jsx-runtime").JSX.Element;
|
|
6
8
|
export {};
|
|
@@ -8,6 +8,7 @@ export { useB3Config } from "./B3Provider/useB3Config";
|
|
|
8
8
|
export { StyleRoot } from "./StyleRoot";
|
|
9
9
|
export { BetterAuthResetPassword, type BetterAuthResetPasswordProps } from "./SignInWithB3/BetterAuthResetPassword";
|
|
10
10
|
export { BetterAuthSignIn, type BetterAuthSignInProps } from "./SignInWithB3/BetterAuthSignIn";
|
|
11
|
+
export { BetterAuthVerifyEmail, type BetterAuthVerifyEmailProps, type BetterAuthVerifyEmailState, } from "./SignInWithB3/BetterAuthVerifyEmail";
|
|
11
12
|
export { AuthButton } from "./SignInWithB3/components/AuthButton";
|
|
12
13
|
export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
13
14
|
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
@@ -13,7 +13,7 @@ export declare class EmailVerificationRequiredError extends Error {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function useBetterAuth(): {
|
|
15
15
|
signInWithEmail: (email: string, password: string) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
16
|
-
signUpWithEmail: (email: string, password: string, name: string) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
16
|
+
signUpWithEmail: (email: string, password: string, name: string, verifyCallbackURL?: string) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
17
17
|
signInWithSocial: (provider: BetterAuthSocialProvider) => Promise<void>;
|
|
18
18
|
requestPasswordReset: (email: string, redirectTo?: string) => Promise<{
|
|
19
19
|
data: {
|
|
@@ -41,6 +41,8 @@ export interface SignInWithB3ModalProps extends BaseModalProps {
|
|
|
41
41
|
source?: "signInWithB3Button" | "requestPermissions";
|
|
42
42
|
/** Whether to show the signers enabled modal */
|
|
43
43
|
signersEnabled?: boolean;
|
|
44
|
+
/** URL Better Auth redirects to after server-side email verification. */
|
|
45
|
+
verifyEmailRedirectTo?: string;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
48
|
* Props for the Request Permissions modal
|
|
@@ -609,6 +611,8 @@ export interface AnySpendDepositModalProps extends BaseModalProps {
|
|
|
609
611
|
actionLabel?: string;
|
|
610
612
|
/** Whether to show chain selection step. Defaults to true if sourceTokenChainId is not provided */
|
|
611
613
|
showChainSelection?: boolean;
|
|
614
|
+
/** Whether to show the "Fund with Fiat" option in the deposit options list. Defaults to true */
|
|
615
|
+
showFiatOption?: boolean;
|
|
612
616
|
/** Minimum pool size for filtering tokens (default: 1,000,000) */
|
|
613
617
|
minPoolSize?: number;
|
|
614
618
|
/** Custom title for chain selection step */
|
package/package.json
CHANGED
|
@@ -148,6 +148,8 @@ export function AnySpend(props: {
|
|
|
148
148
|
theme?: AnySpendTheme;
|
|
149
149
|
/** When true, shows a KYC gate before Stripe Web2 (credit card) payments. Default false. */
|
|
150
150
|
kycEnabled?: boolean;
|
|
151
|
+
/** Whether to show the "Pay with Fiat" tab. Defaults to true. When false, the fiat tab is hidden and activeTab is forced to "crypto". */
|
|
152
|
+
showFiatOption?: boolean;
|
|
151
153
|
}) {
|
|
152
154
|
const fingerprintConfig = getFingerprintConfig();
|
|
153
155
|
|
|
@@ -184,6 +186,7 @@ function AnySpendInner({
|
|
|
184
186
|
callbackMetadata,
|
|
185
187
|
senderAddress,
|
|
186
188
|
kycEnabled = false,
|
|
189
|
+
showFiatOption = true,
|
|
187
190
|
}: {
|
|
188
191
|
sourceChainId?: number;
|
|
189
192
|
destinationTokenAddress?: string;
|
|
@@ -211,6 +214,7 @@ function AnySpendInner({
|
|
|
211
214
|
content?: AnySpendContent;
|
|
212
215
|
theme?: AnySpendTheme;
|
|
213
216
|
kycEnabled?: boolean;
|
|
217
|
+
showFiatOption?: boolean;
|
|
214
218
|
}) {
|
|
215
219
|
const { slots, content } = useAnySpendCustomization();
|
|
216
220
|
const searchParams = useSearchParamsSSR();
|
|
@@ -253,6 +257,7 @@ function AnySpendInner({
|
|
|
253
257
|
const previousPanel = useRef<PanelView>(PanelView.MAIN);
|
|
254
258
|
|
|
255
259
|
const [activeTab, setActiveTab] = useState<"crypto" | "fiat">(() => {
|
|
260
|
+
if (!showFiatOption) return "crypto";
|
|
256
261
|
if (typeof window !== "undefined") {
|
|
257
262
|
const stored = sessionStorage.getItem("anyspend_active_tab") as "crypto" | "fiat" | null;
|
|
258
263
|
if (stored === "crypto" || stored === "fiat") return stored;
|
|
@@ -261,8 +266,13 @@ function AnySpendInner({
|
|
|
261
266
|
});
|
|
262
267
|
|
|
263
268
|
useEffect(() => {
|
|
269
|
+
if (!showFiatOption && activeTab === "fiat") setActiveTab("crypto");
|
|
270
|
+
}, [showFiatOption, activeTab]);
|
|
271
|
+
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
if (!showFiatOption) return;
|
|
264
274
|
sessionStorage.setItem("anyspend_active_tab", activeTab);
|
|
265
|
-
}, [activeTab]);
|
|
275
|
+
}, [activeTab, showFiatOption]);
|
|
266
276
|
|
|
267
277
|
const [orderId, setOrderId] = useState<string | undefined>(loadOrder);
|
|
268
278
|
const [directTransferTxHash, setDirectTransferTxHash] = useState<string | undefined>();
|
|
@@ -1312,17 +1322,19 @@ function AnySpendInner({
|
|
|
1312
1322
|
)}
|
|
1313
1323
|
|
|
1314
1324
|
{/* Tab section */}
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
setActiveTab
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1325
|
+
{showFiatOption && (
|
|
1326
|
+
<TabSection
|
|
1327
|
+
activeTab={activeTab}
|
|
1328
|
+
setActiveTab={tab => {
|
|
1329
|
+
setActiveTab(tab);
|
|
1330
|
+
// Reset payment methods when switching tabs
|
|
1331
|
+
resetPaymentMethods();
|
|
1332
|
+
setSelectedFiatPaymentMethod(FiatPaymentMethod.NONE);
|
|
1333
|
+
}}
|
|
1334
|
+
setSelectedCryptoPaymentMethod={setSelectedCryptoPaymentMethod}
|
|
1335
|
+
setSelectedFiatPaymentMethod={setSelectedFiatPaymentMethod}
|
|
1336
|
+
/>
|
|
1337
|
+
)}
|
|
1326
1338
|
|
|
1327
1339
|
<div className="relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2">
|
|
1328
1340
|
{/* Send section */}
|
|
@@ -119,6 +119,10 @@ export interface AnySpendCollectorClubPurchaseProps {
|
|
|
119
119
|
* Force fiat payment
|
|
120
120
|
*/
|
|
121
121
|
forceFiatPayment?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Whether to show the "Pay with fiat" tab. Defaults to true.
|
|
124
|
+
*/
|
|
125
|
+
showFiatOption?: boolean;
|
|
122
126
|
/**
|
|
123
127
|
* Optional discount code to apply to the purchase.
|
|
124
128
|
* When provided, validates on-chain and adjusts the price accordingly.
|
|
@@ -146,6 +150,7 @@ export function AnySpendCollectorClubPurchase({
|
|
|
146
150
|
vendingMachineId,
|
|
147
151
|
packType,
|
|
148
152
|
forceFiatPayment,
|
|
153
|
+
showFiatOption = true,
|
|
149
154
|
discountCode,
|
|
150
155
|
slots,
|
|
151
156
|
content,
|
|
@@ -398,6 +403,7 @@ export function AnySpendCollectorClubPurchase({
|
|
|
398
403
|
showRecipient={showRecipient}
|
|
399
404
|
srcFiatAmount={srcFiatAmount}
|
|
400
405
|
forceFiatPayment={forceFiatPayment}
|
|
406
|
+
showFiatOption={showFiatOption}
|
|
401
407
|
slots={slots}
|
|
402
408
|
content={content}
|
|
403
409
|
theme={theme}
|
|
@@ -178,6 +178,8 @@ export function AnySpendCustom(props: {
|
|
|
178
178
|
dstToken: components["schemas"]["Token"];
|
|
179
179
|
dstAmount: string;
|
|
180
180
|
forceFiatPayment?: boolean;
|
|
181
|
+
/** Whether to show the "Pay with fiat" tab. Defaults to true. When false, the fiat tab is hidden and activeTab is forced to "crypto". */
|
|
182
|
+
showFiatOption?: boolean;
|
|
181
183
|
contractAddress: string;
|
|
182
184
|
encodedData: string;
|
|
183
185
|
metadata: any;
|
|
@@ -232,6 +234,7 @@ function AnySpendCustomInner({
|
|
|
232
234
|
onShowPointsDetail,
|
|
233
235
|
srcFiatAmount: srcFiatAmountProps,
|
|
234
236
|
forceFiatPayment,
|
|
237
|
+
showFiatOption = true,
|
|
235
238
|
senderAddress,
|
|
236
239
|
}: {
|
|
237
240
|
loadOrder?: string;
|
|
@@ -258,6 +261,7 @@ function AnySpendCustomInner({
|
|
|
258
261
|
onShowPointsDetail?: () => void;
|
|
259
262
|
srcFiatAmount?: string;
|
|
260
263
|
forceFiatPayment?: boolean;
|
|
264
|
+
showFiatOption?: boolean;
|
|
261
265
|
senderAddress?: string;
|
|
262
266
|
slots?: AnySpendSlots;
|
|
263
267
|
content?: AnySpendContent;
|
|
@@ -271,7 +275,13 @@ function AnySpendCustomInner({
|
|
|
271
275
|
const [activePanel, setActivePanel] = useState<PanelView>(
|
|
272
276
|
loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER,
|
|
273
277
|
);
|
|
274
|
-
const [activeTab, setActiveTab] = useState<"crypto" | "fiat">(
|
|
278
|
+
const [activeTab, setActiveTab] = useState<"crypto" | "fiat">(
|
|
279
|
+
!showFiatOption ? "crypto" : forceFiatPayment ? "fiat" : activeTabProps,
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
useEffect(() => {
|
|
283
|
+
if (!showFiatOption && activeTab === "fiat") setActiveTab("crypto");
|
|
284
|
+
}, [showFiatOption, activeTab]);
|
|
275
285
|
|
|
276
286
|
// Payment method state with dual-state system (auto + explicit user selection)
|
|
277
287
|
// Note: AnySpendCustom doesn't use auto-selection, only explicit user selection
|
|
@@ -867,7 +877,7 @@ function AnySpendCustomInner({
|
|
|
867
877
|
onValueChange={value => setActiveTab(value as "crypto" | "fiat")}
|
|
868
878
|
className="bg-b3-react-background max-h-[60dvh] w-full overflow-y-auto p-5"
|
|
869
879
|
>
|
|
870
|
-
{!forceFiatPayment && (
|
|
880
|
+
{!forceFiatPayment && showFiatOption && (
|
|
871
881
|
<div className="w-full">
|
|
872
882
|
<div className="bg-as-surface-secondary relative mb-4 grid h-10 grid-cols-2 rounded-xl">
|
|
873
883
|
<div
|
|
@@ -95,6 +95,8 @@ export interface AnySpendDepositProps {
|
|
|
95
95
|
depositContractConfig?: DepositContractConfig;
|
|
96
96
|
/** Whether to show chain selection step. Defaults to true if sourceTokenChainId is not provided */
|
|
97
97
|
showChainSelection?: boolean;
|
|
98
|
+
/** Whether to show the "Fund with Fiat" option in the deposit options list. Defaults to true */
|
|
99
|
+
showFiatOption?: boolean;
|
|
98
100
|
/** Custom list of supported chains. If not provided, uses default chains */
|
|
99
101
|
supportedChains?: ChainConfig[];
|
|
100
102
|
/** Minimum pool size for filtering tokens (default: 1,000,000) */
|
|
@@ -248,6 +250,7 @@ export function AnySpendDeposit({
|
|
|
248
250
|
orderType,
|
|
249
251
|
depositContractConfig,
|
|
250
252
|
showChainSelection,
|
|
253
|
+
showFiatOption = true,
|
|
251
254
|
supportedChains = DEFAULT_SUPPORTED_CHAINS,
|
|
252
255
|
minPoolSize = DEFAULT_MIN_POOL_SIZE,
|
|
253
256
|
topChainsCount = 3,
|
|
@@ -585,39 +588,43 @@ export function AnySpendDeposit({
|
|
|
585
588
|
</button>
|
|
586
589
|
|
|
587
590
|
{/* Fund with Fiat */}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
<div
|
|
596
|
-
className={depositClasses?.optionContent || "anyspend-deposit-option-content flex items-center gap-3"}
|
|
591
|
+
{showFiatOption && (
|
|
592
|
+
<button
|
|
593
|
+
onClick={handleSelectFiat}
|
|
594
|
+
className={
|
|
595
|
+
depositClasses?.fiatButton ||
|
|
596
|
+
"anyspend-deposit-option-button anyspend-deposit-fiat-button border-border-primary hover:border-as-brand hover:bg-as-surface-secondary flex w-full items-center justify-between rounded-xl border p-4 text-left transition-all"
|
|
597
|
+
}
|
|
597
598
|
>
|
|
598
|
-
<
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
599
|
+
<div
|
|
600
|
+
className={depositClasses?.optionContent || "anyspend-deposit-option-content flex items-center gap-3"}
|
|
601
|
+
>
|
|
602
|
+
<CreditCardIcon className={depositClasses?.optionIcon || "anyspend-deposit-option-icon h-10 w-10"} />
|
|
603
|
+
<div className={depositClasses?.optionInfo || "anyspend-deposit-option-info"}>
|
|
604
|
+
<span
|
|
605
|
+
className={
|
|
606
|
+
depositClasses?.optionTitle || "anyspend-deposit-option-title text-as-primary font-medium"
|
|
607
|
+
}
|
|
608
|
+
>
|
|
609
|
+
Fund with Fiat
|
|
610
|
+
</span>
|
|
611
|
+
<p
|
|
612
|
+
className={
|
|
613
|
+
depositClasses?.optionDescription ||
|
|
614
|
+
"anyspend-deposit-option-description text-as-secondary text-xs"
|
|
615
|
+
}
|
|
616
|
+
>
|
|
617
|
+
Pay with card or bank transfer
|
|
618
|
+
</p>
|
|
619
|
+
</div>
|
|
615
620
|
</div>
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
+
<ChevronRight
|
|
622
|
+
className={
|
|
623
|
+
depositClasses?.optionChevron || "anyspend-deposit-option-chevron text-as-secondary h-5 w-5"
|
|
624
|
+
}
|
|
625
|
+
/>
|
|
626
|
+
</button>
|
|
627
|
+
)}
|
|
621
628
|
</div>
|
|
622
629
|
|
|
623
630
|
{/* Chain-specific warning */}
|
|
@@ -42,6 +42,7 @@ export function AnySpendNFT({
|
|
|
42
42
|
slots,
|
|
43
43
|
content,
|
|
44
44
|
theme,
|
|
45
|
+
showFiatOption = true,
|
|
45
46
|
}: {
|
|
46
47
|
loadOrder?: string;
|
|
47
48
|
mode?: "modal" | "page";
|
|
@@ -54,6 +55,8 @@ export function AnySpendNFT({
|
|
|
54
55
|
slots?: AnySpendSlots;
|
|
55
56
|
content?: AnySpendContent;
|
|
56
57
|
theme?: AnySpendTheme;
|
|
58
|
+
/** Whether to show the "Pay with fiat" tab. Defaults to true. */
|
|
59
|
+
showFiatOption?: boolean;
|
|
57
60
|
}) {
|
|
58
61
|
const [imageUrlWithFallback, setFallbackImageUrl] = useState<string | null>(nftContract.imageUrl);
|
|
59
62
|
const hasFetchedRef = useRef(false);
|
|
@@ -164,6 +167,7 @@ export function AnySpendNFT({
|
|
|
164
167
|
loadOrder={loadOrder}
|
|
165
168
|
mode={mode}
|
|
166
169
|
activeTab="fiat"
|
|
170
|
+
showFiatOption={showFiatOption}
|
|
167
171
|
recipientAddress={recipientAddress}
|
|
168
172
|
orderType={"mint_nft"}
|
|
169
173
|
dstChainId={nftContract.chainId}
|
|
@@ -30,6 +30,7 @@ export function AnySpendStakeUpside({
|
|
|
30
30
|
slots,
|
|
31
31
|
content,
|
|
32
32
|
theme,
|
|
33
|
+
showFiatOption = true,
|
|
33
34
|
}: {
|
|
34
35
|
loadOrder?: string;
|
|
35
36
|
mode?: "modal" | "page";
|
|
@@ -44,6 +45,8 @@ export function AnySpendStakeUpside({
|
|
|
44
45
|
slots?: AnySpendSlots;
|
|
45
46
|
content?: AnySpendContent;
|
|
46
47
|
theme?: AnySpendTheme;
|
|
48
|
+
/** Whether to show the "Pay with fiat" tab. Defaults to true. */
|
|
49
|
+
showFiatOption?: boolean;
|
|
47
50
|
}) {
|
|
48
51
|
const header = () => (
|
|
49
52
|
<>
|
|
@@ -90,6 +93,7 @@ export function AnySpendStakeUpside({
|
|
|
90
93
|
onSuccess={onSuccess}
|
|
91
94
|
showRecipient={true}
|
|
92
95
|
activeTab={activeTab}
|
|
96
|
+
showFiatOption={showFiatOption}
|
|
93
97
|
senderAddress={senderAddress}
|
|
94
98
|
slots={slots}
|
|
95
99
|
content={content}
|
|
@@ -33,6 +33,11 @@ export interface BetterAuthSignInProps {
|
|
|
33
33
|
showEmail?: boolean;
|
|
34
34
|
/** URL to redirect to after password reset link is clicked. Token is appended as ?token=... */
|
|
35
35
|
passwordResetRedirectTo?: string;
|
|
36
|
+
/**
|
|
37
|
+
* URL Better Auth redirects to after server-side email verification. Render
|
|
38
|
+
* `BetterAuthVerifyEmail` at this route so the user gets a confirmation page.
|
|
39
|
+
*/
|
|
40
|
+
verifyEmailRedirectTo?: string;
|
|
36
41
|
/** Called after successful authentication */
|
|
37
42
|
onSuccess?: () => void;
|
|
38
43
|
/** Called on authentication error */
|
|
@@ -61,6 +66,7 @@ export function BetterAuthSignIn({
|
|
|
61
66
|
socialProviders = DEFAULT_SOCIAL_PROVIDERS.map(p => p.id),
|
|
62
67
|
showEmail = true,
|
|
63
68
|
passwordResetRedirectTo,
|
|
69
|
+
verifyEmailRedirectTo,
|
|
64
70
|
onSuccess,
|
|
65
71
|
onError,
|
|
66
72
|
className,
|
|
@@ -153,7 +159,7 @@ export function BetterAuthSignIn({
|
|
|
153
159
|
setError(null);
|
|
154
160
|
|
|
155
161
|
if (mode === "sign-up") {
|
|
156
|
-
await signUpWithEmail(normalizedEmail, password, name.trim());
|
|
162
|
+
await signUpWithEmail(normalizedEmail, password, name.trim(), verifyEmailRedirectTo);
|
|
157
163
|
} else {
|
|
158
164
|
await signInWithEmail(normalizedEmail, password);
|
|
159
165
|
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Button } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
|
+
|
|
4
|
+
const debug = debugB3React("BetterAuthVerifyEmail");
|
|
5
|
+
|
|
6
|
+
export type BetterAuthVerifyEmailState = "success" | "expired" | "invalid" | "already-verified" | "error";
|
|
7
|
+
|
|
8
|
+
export interface BetterAuthVerifyEmailProps {
|
|
9
|
+
/**
|
|
10
|
+
* Error code from the callback URL's `?error=` query param. Pass `null` /
|
|
11
|
+
* `undefined` when the user landed here cleanly (successful verification).
|
|
12
|
+
* Better Auth appends this param when server-side verification fails.
|
|
13
|
+
*/
|
|
14
|
+
errorCode?: string | null;
|
|
15
|
+
/** Called when the user clicks the "Go to sign in" button. */
|
|
16
|
+
onGoToSignIn?: () => void;
|
|
17
|
+
/** Fallback href used when `onGoToSignIn` is not provided. Defaults to "/login". */
|
|
18
|
+
signInHref?: string;
|
|
19
|
+
/** Optional override for the success headline. */
|
|
20
|
+
successTitle?: string;
|
|
21
|
+
/** Optional override for the success body text. */
|
|
22
|
+
successMessage?: string;
|
|
23
|
+
/** Optional class name for the root container. */
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function classifyError(code: string | null | undefined): BetterAuthVerifyEmailState {
|
|
28
|
+
if (!code) return "success";
|
|
29
|
+
const normalized = code.toLowerCase();
|
|
30
|
+
|
|
31
|
+
// Exact matches for Better Auth's documented verification error codes.
|
|
32
|
+
if (normalized === "expired_token") return "expired";
|
|
33
|
+
if (normalized === "invalid_token") return "invalid";
|
|
34
|
+
if (normalized === "already_verified" || normalized === "email_already_verified") return "already-verified";
|
|
35
|
+
|
|
36
|
+
// Loose fallbacks for close variants. Order matters — check "already" before
|
|
37
|
+
// "verified" so `email_already_verified` maps to already-verified, not invalid.
|
|
38
|
+
if (normalized.includes("expired")) return "expired";
|
|
39
|
+
if (normalized.includes("already")) return "already-verified";
|
|
40
|
+
if (normalized.includes("invalid")) return "invalid";
|
|
41
|
+
return "error";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const COPY: Record<BetterAuthVerifyEmailState, { title: string; message: string }> = {
|
|
45
|
+
success: {
|
|
46
|
+
title: "Email verified",
|
|
47
|
+
message: "Your email is confirmed. You can now sign in to your account.",
|
|
48
|
+
},
|
|
49
|
+
expired: {
|
|
50
|
+
title: "Link expired",
|
|
51
|
+
message: "This verification link has expired. Request a new one from the sign-in page.",
|
|
52
|
+
},
|
|
53
|
+
invalid: {
|
|
54
|
+
title: "Invalid link",
|
|
55
|
+
message: "This verification link is invalid or has already been used. Try signing in or request a new link.",
|
|
56
|
+
},
|
|
57
|
+
"already-verified": {
|
|
58
|
+
title: "Already verified",
|
|
59
|
+
message: "Your email was already confirmed. You can sign in now.",
|
|
60
|
+
},
|
|
61
|
+
error: {
|
|
62
|
+
title: "Verification failed",
|
|
63
|
+
message: "We couldn't verify your email. Request a new link from the sign-in page.",
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Standalone email-verification confirmation page. Render on the route you
|
|
69
|
+
* set as `callbackURL` when calling `betterAuthClient.sendVerificationEmail`
|
|
70
|
+
* (or the `verifyCallbackURL` arg on `useBetterAuth().signUpWithEmail`).
|
|
71
|
+
*
|
|
72
|
+
* Better Auth verifies the token server-side before redirecting here. This
|
|
73
|
+
* component only displays the outcome based on the `?error=` query param.
|
|
74
|
+
*
|
|
75
|
+
* Usage:
|
|
76
|
+
* ```tsx
|
|
77
|
+
* const error = new URLSearchParams(window.location.search).get("error");
|
|
78
|
+
* <BetterAuthVerifyEmail
|
|
79
|
+
* errorCode={error}
|
|
80
|
+
* onGoToSignIn={() => router.push("/login")}
|
|
81
|
+
* />
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export function BetterAuthVerifyEmail({
|
|
85
|
+
errorCode,
|
|
86
|
+
onGoToSignIn,
|
|
87
|
+
signInHref = "/login",
|
|
88
|
+
successTitle,
|
|
89
|
+
successMessage,
|
|
90
|
+
className,
|
|
91
|
+
}: BetterAuthVerifyEmailProps) {
|
|
92
|
+
const state = classifyError(errorCode);
|
|
93
|
+
const isSuccess = state === "success" || state === "already-verified";
|
|
94
|
+
const copy = COPY[state];
|
|
95
|
+
const title = isSuccess && successTitle ? successTitle : copy.title;
|
|
96
|
+
const message = isSuccess && successMessage ? successMessage : copy.message;
|
|
97
|
+
|
|
98
|
+
debug("Rendering verify-email state", { state, errorCode });
|
|
99
|
+
|
|
100
|
+
const handleClick = () => {
|
|
101
|
+
if (onGoToSignIn) {
|
|
102
|
+
onGoToSignIn();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (typeof window !== "undefined") {
|
|
106
|
+
window.location.href = signInHref;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<div className={`w-full max-w-[400px] px-6 ${className || ""}`}>
|
|
112
|
+
<div className="space-y-6 text-center">
|
|
113
|
+
<div
|
|
114
|
+
className={`mx-auto flex h-12 w-12 items-center justify-center rounded-full ${
|
|
115
|
+
isSuccess ? "bg-green-100" : "bg-red-100"
|
|
116
|
+
}`}
|
|
117
|
+
>
|
|
118
|
+
{isSuccess ? (
|
|
119
|
+
<svg
|
|
120
|
+
className="h-6 w-6 text-green-600"
|
|
121
|
+
fill="none"
|
|
122
|
+
viewBox="0 0 24 24"
|
|
123
|
+
stroke="currentColor"
|
|
124
|
+
aria-hidden="true"
|
|
125
|
+
>
|
|
126
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
|
|
127
|
+
</svg>
|
|
128
|
+
) : (
|
|
129
|
+
<svg
|
|
130
|
+
className="h-6 w-6 text-red-600"
|
|
131
|
+
fill="none"
|
|
132
|
+
viewBox="0 0 24 24"
|
|
133
|
+
stroke="currentColor"
|
|
134
|
+
aria-hidden="true"
|
|
135
|
+
>
|
|
136
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
|
|
137
|
+
</svg>
|
|
138
|
+
)}
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<div>
|
|
142
|
+
<h1 className="text-[28px] font-semibold tracking-tight text-gray-900 dark:text-gray-100">{title}</h1>
|
|
143
|
+
<p className="mt-3 text-[15px] text-gray-500 dark:text-gray-400">{message}</p>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<Button
|
|
147
|
+
onClick={handleClick}
|
|
148
|
+
className="h-11 w-full bg-gray-900 text-[15px] font-medium text-white hover:bg-gray-800 dark:bg-white dark:text-gray-900 dark:hover:bg-gray-100"
|
|
149
|
+
>
|
|
150
|
+
{isSuccess ? "Go to sign in" : "Back to sign in"}
|
|
151
|
+
</Button>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
@@ -34,6 +34,7 @@ export function SignInWithB3Flow({
|
|
|
34
34
|
closeAfterLogin = false,
|
|
35
35
|
source = "signInWithB3Button",
|
|
36
36
|
signersEnabled = false,
|
|
37
|
+
verifyEmailRedirectTo,
|
|
37
38
|
}: SignInWithB3ModalProps) {
|
|
38
39
|
const { automaticallySetFirstEoa, authStrategy } = useB3Config();
|
|
39
40
|
// skipAutoConnect: this component intentionally logs out on mount to show a fresh login screen.
|
|
@@ -292,7 +293,13 @@ export function SignInWithB3Flow({
|
|
|
292
293
|
// Better Auth manages its own loading/verification states internally.
|
|
293
294
|
// Don't gate on isAuthenticating — it would unmount the component
|
|
294
295
|
// and lose verification state when setIsAuthenticating(false) fires.
|
|
295
|
-
content =
|
|
296
|
+
content = (
|
|
297
|
+
<LoginStepBetterAuth
|
|
298
|
+
onSuccess={() => handleLoginSuccess({} as Account)}
|
|
299
|
+
onError={onError}
|
|
300
|
+
verifyEmailRedirectTo={verifyEmailRedirectTo}
|
|
301
|
+
/>
|
|
302
|
+
);
|
|
296
303
|
} else if (!readyToShowLogin || isAuthenticating || isFetchingSigners) {
|
|
297
304
|
content = (
|
|
298
305
|
<LoginStepContainer partnerId={partnerId}>
|