@b3dotfun/sdk 0.1.69-alpha.1 → 0.1.69-alpha.10
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/AnySpendStakeB3.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +1 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -4
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/cjs/anyspend/react/components/checkout/FiatCheckoutPanel.js +1 -2
- package/dist/cjs/anyspend/react/components/checkout/KycGate.js +1 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +5 -0
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +37 -6
- package/dist/cjs/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/StepProgress.js +7 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +4 -6
- package/dist/cjs/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/cjs/anyspend/react/hooks/useKycStatus.js +11 -7
- package/dist/cjs/app.shared.js +9 -7
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SessionDurationContent.js +57 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/cjs/global-account/react/components/SignInWithB3/components/AuthButton.js +10 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +96 -15
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +15 -2
- package/dist/cjs/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/cjs/global-account/react/components/Toast/ToastContext.js +30 -7
- package/dist/cjs/global-account/react/hooks/useAuth.js +26 -15
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +23 -12
- package/dist/cjs/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +0 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +0 -18
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +0 -17
- package/dist/cjs/shared/utils/session-duration.d.ts +15 -0
- package/dist/cjs/shared/utils/session-duration.js +69 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutPaymentPanel.js +2 -4
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +5 -3
- package/dist/esm/anyspend/react/components/checkout/FiatCheckoutPanel.js +2 -3
- package/dist/esm/anyspend/react/components/checkout/KycGate.js +2 -3
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +6 -1
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +34 -3
- package/dist/esm/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/StepProgress.js +4 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +5 -7
- package/dist/esm/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/esm/anyspend/react/hooks/useKycStatus.js +9 -5
- package/dist/esm/app.shared.js +9 -7
- package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/esm/global-account/react/components/ManageAccount/SessionDurationContent.js +52 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +12 -29
- package/dist/esm/global-account/react/components/SignInWithB3/components/AuthButton.js +11 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +100 -19
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +14 -1
- package/dist/esm/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/esm/global-account/react/components/Toast/ToastContext.js +30 -7
- package/dist/esm/global-account/react/hooks/useAuth.js +28 -17
- package/dist/esm/global-account/react/hooks/useAuthentication.js +24 -13
- package/dist/esm/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/esm/global-account/react/hooks/useTWAuth.js +0 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +0 -18
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +0 -16
- package/dist/esm/shared/utils/session-duration.d.ts +15 -0
- package/dist/esm/shared/utils/session-duration.js +64 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/checkout/CheckoutSuccess.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/StepProgress.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useKycStatus.d.ts +3 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/ManageAccount/SessionDurationContent.d.ts +5 -0
- package/dist/types/global-account/react/components/SignInWithB3/utils/signInUtils.d.ts +5 -3
- package/dist/types/global-account/react/components/Toast/ToastContext.d.ts +3 -0
- package/dist/types/global-account/react/hooks/useConnect.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +8 -8
- package/dist/types/global-account/react/stores/useModalStore.d.ts +10 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +0 -18
- package/dist/types/shared/utils/session-duration.d.ts +15 -0
- package/package.json +2 -1
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -2
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +2 -2
- package/src/anyspend/react/components/checkout/CheckoutPaymentPanel.tsx +2 -4
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +13 -3
- package/src/anyspend/react/components/checkout/FiatCheckoutPanel.tsx +9 -3
- package/src/anyspend/react/components/checkout/KycGate.tsx +8 -3
- package/src/anyspend/react/components/common/OrderDetails.tsx +8 -0
- package/src/anyspend/react/components/common/OrderStatus.tsx +38 -3
- package/src/anyspend/react/components/common/StepProgress.tsx +15 -5
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +5 -7
- package/src/anyspend/react/hooks/useKycStatus.ts +8 -5
- package/src/app.shared.ts +9 -8
- package/src/global-account/react/components/B3DynamicModal.tsx +5 -2
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +2 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +7 -1
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
- package/src/global-account/react/components/ManageAccount/SessionDurationContent.tsx +107 -0
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +28 -30
- package/src/global-account/react/components/SignInWithB3/components/AuthButton.tsx +21 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +207 -54
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +19 -3
- package/src/global-account/react/components/Toast/ToastContext.tsx +39 -7
- package/src/global-account/react/hooks/useAuth.ts +28 -17
- package/src/global-account/react/hooks/useAuthentication.ts +24 -13
- package/src/global-account/react/hooks/useConnect.tsx +2 -2
- package/src/global-account/react/hooks/useTWAuth.tsx +0 -1
- package/src/global-account/react/stores/useModalStore.ts +11 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +0 -18
- package/src/shared/utils/session-duration.ts +64 -0
- package/src/types/torph.d.ts +4 -0
|
@@ -7451,8 +7451,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7451
7451
|
[x: `bool[${string}]`]: undefined;
|
|
7452
7452
|
[x: `bytes[${string}]`]: undefined;
|
|
7453
7453
|
[x: `bytes1[${string}]`]: undefined;
|
|
7454
|
-
[x: `
|
|
7454
|
+
[x: `bytes7[${string}]`]: undefined;
|
|
7455
|
+
[x: `bytes14[${string}]`]: undefined;
|
|
7455
7456
|
[x: `bytes30[${string}]`]: undefined;
|
|
7457
|
+
[x: `bytes5[${string}]`]: undefined;
|
|
7456
7458
|
[x: `bytes18[${string}]`]: undefined;
|
|
7457
7459
|
[x: `bytes6[${string}]`]: undefined;
|
|
7458
7460
|
[x: `bytes9[${string}]`]: undefined;
|
|
@@ -7460,12 +7462,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7460
7462
|
[x: `bytes10[${string}]`]: undefined;
|
|
7461
7463
|
[x: `bytes2[${string}]`]: undefined;
|
|
7462
7464
|
[x: `bytes3[${string}]`]: undefined;
|
|
7463
|
-
[x: `
|
|
7464
|
-
[x: `bytes7[${string}]`]: undefined;
|
|
7465
|
+
[x: `bytes4[${string}]`]: undefined;
|
|
7465
7466
|
[x: `bytes11[${string}]`]: undefined;
|
|
7466
7467
|
[x: `bytes12[${string}]`]: undefined;
|
|
7467
7468
|
[x: `bytes13[${string}]`]: undefined;
|
|
7468
|
-
[x: `bytes14[${string}]`]: undefined;
|
|
7469
7469
|
[x: `bytes15[${string}]`]: undefined;
|
|
7470
7470
|
[x: `bytes16[${string}]`]: undefined;
|
|
7471
7471
|
[x: `bytes17[${string}]`]: undefined;
|
|
@@ -7553,8 +7553,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7553
7553
|
bool?: undefined;
|
|
7554
7554
|
bytes?: undefined;
|
|
7555
7555
|
bytes1?: undefined;
|
|
7556
|
-
|
|
7556
|
+
bytes7?: undefined;
|
|
7557
|
+
bytes14?: undefined;
|
|
7557
7558
|
bytes30?: undefined;
|
|
7559
|
+
bytes5?: undefined;
|
|
7558
7560
|
bytes18?: undefined;
|
|
7559
7561
|
bytes6?: undefined;
|
|
7560
7562
|
bytes9?: undefined;
|
|
@@ -7562,12 +7564,10 @@ export declare function useFirstEOA(chain?: {
|
|
|
7562
7564
|
bytes10?: undefined;
|
|
7563
7565
|
bytes2?: undefined;
|
|
7564
7566
|
bytes3?: undefined;
|
|
7565
|
-
|
|
7566
|
-
bytes7?: undefined;
|
|
7567
|
+
bytes4?: undefined;
|
|
7567
7568
|
bytes11?: undefined;
|
|
7568
7569
|
bytes12?: undefined;
|
|
7569
7570
|
bytes13?: undefined;
|
|
7570
|
-
bytes14?: undefined;
|
|
7571
7571
|
bytes15?: undefined;
|
|
7572
7572
|
bytes16?: undefined;
|
|
7573
7573
|
bytes17?: undefined;
|
|
@@ -16,7 +16,6 @@ const useSearchParamsSSR_1 = require("./useSearchParamsSSR");
|
|
|
16
16
|
* @deprecated Use useAuth() instead
|
|
17
17
|
*/
|
|
18
18
|
function useTWAuth() {
|
|
19
|
-
console.warn("useTWAuth is deprecated. Please migrate to useAuth() for authentication.");
|
|
20
19
|
const referralCode = (0, useSearchParamsSSR_1.useSearchParam)("referralCode");
|
|
21
20
|
const authenticate = (0, react_1.useCallback)(async (wallet, partnerId) => {
|
|
22
21
|
if (!wallet || !wallet?.getAuthToken?.())
|
|
@@ -425,6 +425,15 @@ export interface SendModalProps extends BaseModalProps {
|
|
|
425
425
|
/** Callback function called when send is successful */
|
|
426
426
|
onSuccess?: (txHash?: string) => void;
|
|
427
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Props for the Session Duration modal
|
|
430
|
+
* Allows users to configure how long they stay signed in
|
|
431
|
+
*/
|
|
432
|
+
export interface SessionDurationModalProps extends BaseModalProps {
|
|
433
|
+
type: "sessionDuration";
|
|
434
|
+
partnerId: string;
|
|
435
|
+
chain: Chain;
|
|
436
|
+
}
|
|
428
437
|
/**
|
|
429
438
|
* Props for the Notifications modal
|
|
430
439
|
* Allows users to manage notification settings and channels
|
|
@@ -626,7 +635,7 @@ export interface AnySpendDepositModalProps extends BaseModalProps {
|
|
|
626
635
|
/**
|
|
627
636
|
* Union type of all possible modal content types
|
|
628
637
|
*/
|
|
629
|
-
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | LinkNewAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | DepositModalProps | SendModalProps | NotificationsModalProps | AnySpendCollectorClubPurchaseProps | AnySpendDepositModalProps | AnySpendWorkflowTriggerModalProps | AnySpendCheckoutTriggerModalProps;
|
|
638
|
+
export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | LinkNewAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | DepositModalProps | SendModalProps | NotificationsModalProps | SessionDurationModalProps | AnySpendCollectorClubPurchaseProps | AnySpendDepositModalProps | AnySpendWorkflowTriggerModalProps | AnySpendCheckoutTriggerModalProps;
|
|
630
639
|
/**
|
|
631
640
|
* State interface for the modal store
|
|
632
641
|
*/
|
|
@@ -25,21 +25,3 @@ export declare function createWagmiConfig(options: CreateWagmiConfigOptions): im
|
|
|
25
25
|
}, {
|
|
26
26
|
"thirdweb:lastChainId": number;
|
|
27
27
|
}>)[]>;
|
|
28
|
-
/**
|
|
29
|
-
* Returns a cached wagmi config for the given partnerId.
|
|
30
|
-
* Use this instead of calling createWagmiConfig() directly inside React components or hooks
|
|
31
|
-
* to avoid registering duplicate EventEmitter listeners on every render.
|
|
32
|
-
*/
|
|
33
|
-
export declare function getCachedWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
|
|
34
|
-
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
35
|
-
}, (CreateConnectorFn | CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
|
|
36
|
-
connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
|
|
37
|
-
accounts: withCapabilities extends true ? readonly {
|
|
38
|
-
address: `0x${string}`;
|
|
39
|
-
capabilities: Record<string, unknown>;
|
|
40
|
-
}[] : readonly `0x${string}`[];
|
|
41
|
-
chainId: number;
|
|
42
|
-
}>;
|
|
43
|
-
}, {
|
|
44
|
-
"thirdweb:lastChainId": number;
|
|
45
|
-
}>)[]>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWagmiConfig = createWagmiConfig;
|
|
4
|
-
exports.getCachedWagmiConfig = getCachedWagmiConfig;
|
|
5
4
|
const constants_1 = require("../../../shared/constants");
|
|
6
5
|
const supported_1 = require("../../../shared/constants/chains/supported");
|
|
7
6
|
const thirdweb_1 = require("../../../shared/utils/thirdweb");
|
|
@@ -31,19 +30,3 @@ function createWagmiConfig(options) {
|
|
|
31
30
|
connectors: finalConnectors,
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
|
-
/** Module-level cache — wagmi configs must not be recreated on every render. */
|
|
35
|
-
const wagmiConfigCache = new Map();
|
|
36
|
-
/**
|
|
37
|
-
* Returns a cached wagmi config for the given partnerId.
|
|
38
|
-
* Use this instead of calling createWagmiConfig() directly inside React components or hooks
|
|
39
|
-
* to avoid registering duplicate EventEmitter listeners on every render.
|
|
40
|
-
*/
|
|
41
|
-
function getCachedWagmiConfig(options) {
|
|
42
|
-
const key = options.partnerId;
|
|
43
|
-
let config = wagmiConfigCache.get(key);
|
|
44
|
-
if (!config) {
|
|
45
|
-
config = createWagmiConfig(options);
|
|
46
|
-
wagmiConfigCache.set(key, config);
|
|
47
|
-
}
|
|
48
|
-
return config;
|
|
49
|
-
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const SESSION_DURATION_OPTIONS: readonly [0, 1, 7, 14, 30];
|
|
2
|
+
export type SessionDurationDays = (typeof SESSION_DURATION_OPTIONS)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Read session duration for a specific partner.
|
|
5
|
+
*
|
|
6
|
+
* preferences shape: { [partnerId]: { sessionDuration: number }, sessionDuration?: number }
|
|
7
|
+
*
|
|
8
|
+
* Priority: user.preferences[partnerId].sessionDuration
|
|
9
|
+
* → user.preferences.sessionDuration (global fallback)
|
|
10
|
+
* → localStorage (per-partner) → localStorage (global) → default 7d
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSessionDurationDays(userPreferences?: Record<string, any>, partnerId?: string): SessionDurationDays;
|
|
13
|
+
export declare const SESSION_DURATION_LABELS: Record<SessionDurationDays, string>;
|
|
14
|
+
/** Cache the preference locally so it's available immediately on next login */
|
|
15
|
+
export declare function setSessionDurationDays(days: SessionDurationDays, partnerId?: string): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SESSION_DURATION_LABELS = exports.SESSION_DURATION_OPTIONS = void 0;
|
|
4
|
+
exports.getSessionDurationDays = getSessionDurationDays;
|
|
5
|
+
exports.setSessionDurationDays = setSessionDurationDays;
|
|
6
|
+
const STORAGE_KEY_PREFIX = "b3-session-duration";
|
|
7
|
+
const DEFAULT_DAYS = 7;
|
|
8
|
+
// 0 = session cookie (expires when browser closes)
|
|
9
|
+
exports.SESSION_DURATION_OPTIONS = [0, 1, 7, 14, 30];
|
|
10
|
+
function storageKey(partnerId) {
|
|
11
|
+
return partnerId ? `${STORAGE_KEY_PREFIX}_${partnerId}` : STORAGE_KEY_PREFIX;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Read session duration for a specific partner.
|
|
15
|
+
*
|
|
16
|
+
* preferences shape: { [partnerId]: { sessionDuration: number }, sessionDuration?: number }
|
|
17
|
+
*
|
|
18
|
+
* Priority: user.preferences[partnerId].sessionDuration
|
|
19
|
+
* → user.preferences.sessionDuration (global fallback)
|
|
20
|
+
* → localStorage (per-partner) → localStorage (global) → default 7d
|
|
21
|
+
*/
|
|
22
|
+
function getSessionDurationDays(userPreferences, partnerId) {
|
|
23
|
+
if (userPreferences) {
|
|
24
|
+
if (partnerId) {
|
|
25
|
+
const v = userPreferences[partnerId]?.sessionDuration;
|
|
26
|
+
if (exports.SESSION_DURATION_OPTIONS.includes(v))
|
|
27
|
+
return v;
|
|
28
|
+
}
|
|
29
|
+
const v = userPreferences["sessionDuration"];
|
|
30
|
+
if (exports.SESSION_DURATION_OPTIONS.includes(v))
|
|
31
|
+
return v;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
if (partnerId) {
|
|
35
|
+
const stored = localStorage.getItem(storageKey(partnerId));
|
|
36
|
+
if (stored !== null) {
|
|
37
|
+
const parsed = Number(stored);
|
|
38
|
+
if (exports.SESSION_DURATION_OPTIONS.includes(parsed))
|
|
39
|
+
return parsed;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const stored = localStorage.getItem(STORAGE_KEY_PREFIX);
|
|
43
|
+
if (stored !== null) {
|
|
44
|
+
const parsed = Number(stored);
|
|
45
|
+
if (exports.SESSION_DURATION_OPTIONS.includes(parsed))
|
|
46
|
+
return parsed;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// localStorage unavailable (e.g. SSR)
|
|
51
|
+
}
|
|
52
|
+
return DEFAULT_DAYS;
|
|
53
|
+
}
|
|
54
|
+
exports.SESSION_DURATION_LABELS = {
|
|
55
|
+
0: "Session only",
|
|
56
|
+
1: "1 day",
|
|
57
|
+
7: "7 days",
|
|
58
|
+
14: "14 days",
|
|
59
|
+
30: "30 days",
|
|
60
|
+
};
|
|
61
|
+
/** Cache the preference locally so it's available immediately on next login */
|
|
62
|
+
function setSessionDurationDays(days, partnerId) {
|
|
63
|
+
try {
|
|
64
|
+
localStorage.setItem(storageKey(partnerId), String(days));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// ignore
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { ABI_ERC20_STAKING, B3_TOKEN, eqci } from "../../../anyspend/index.js";
|
|
2
|
+
import { ABI_ERC20_STAKING, B3_TOKEN, eqci, getExplorerTxUrl } from "../../../anyspend/index.js";
|
|
3
3
|
import { Button, GlareCardRounded, Input, StyleRoot, TextLoop, toast, useHasMounted, useModalStore, useSimBalance, useUnifiedChainSwitchAndExecute, } from "../../../global-account/react/index.js";
|
|
4
4
|
import { PUBLIC_BASE_RPC_URL } from "../../../shared/constants/index.js";
|
|
5
5
|
import { formatTokenAmount } from "../../../shared/utils/number.js";
|
|
@@ -262,7 +262,7 @@ export function AnySpendStakeB3({ loadOrder, mode = "modal", recipientAddress, s
|
|
|
262
262
|
opacity: hasMounted ? 1 : 0,
|
|
263
263
|
y: hasMounted ? 0 : 20,
|
|
264
264
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
265
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href:
|
|
265
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href: getExplorerTxUrl(base.id, stakingTxHash), target: "_blank", rel: "noopener noreferrer", className: "text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors", children: "View transaction" }) }), _jsx(Button, { onClick: () => {
|
|
266
266
|
setB3ModalOpen(false);
|
|
267
267
|
onSuccess?.();
|
|
268
268
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { ABI_ERC20_STAKING, B3_TOKEN, eqci } from "../../../anyspend/index.js";
|
|
2
|
+
import { ABI_ERC20_STAKING, B3_TOKEN, eqci, getExplorerTxUrl } from "../../../anyspend/index.js";
|
|
3
3
|
import { normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
4
4
|
import { Button, GlareCardRounded, Input, StyleRoot, TextLoop, toast, useHasMounted, useModalStore, useSimBalance, useUnifiedChainSwitchAndExecute, } from "../../../global-account/react/index.js";
|
|
5
5
|
import { PUBLIC_BASE_RPC_URL } from "../../../shared/constants/index.js";
|
|
@@ -275,7 +275,7 @@ export function AnySpendStakeB3ExactIn({ loadOrder, mode = "modal", sourceTokenA
|
|
|
275
275
|
opacity: hasMounted ? 1 : 0,
|
|
276
276
|
y: hasMounted ? 0 : 20,
|
|
277
277
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
278
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href:
|
|
278
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "bg-b3-react-background w-full p-6", children: [_jsx("div", { className: "mb-6", children: _jsx("a", { href: getExplorerTxUrl(base.id, stakingTxHash), target: "_blank", rel: "noopener noreferrer", className: "text-as-primary/70 hover:text-as-primary block break-all text-center font-mono text-sm underline transition-colors", children: "View transaction" }) }), _jsx(Button, { onClick: () => {
|
|
279
279
|
setB3ModalOpen(false);
|
|
280
280
|
onSuccess?.(formatTokenAmount(BigInt(userStakeAmount), 18) ?? "");
|
|
281
281
|
}, className: "bg-as-brand hover:bg-as-brand/90 text-as-primary h-14 w-full rounded-xl text-lg font-medium", children: "Done" })] })] }) }));
|
|
@@ -53,9 +53,7 @@ export function CheckoutPaymentPanel({ recipientAddress, destinationTokenAddress
|
|
|
53
53
|
if (activeOrderId) {
|
|
54
54
|
return (_jsx(CheckoutOrderStatus, { orderId: activeOrderId, themeColor: themeColor, returnUrl: returnUrl, returnLabel: returnLabel, onSuccess: onSuccess, onError: onError, onRetry: handleRetry, showPoints: showPoints, showOrderId: showOrderId, classes: classes }));
|
|
55
55
|
}
|
|
56
|
-
const accordionButtonClass = (active) => cn("anyspend-payment-method-btn flex w-full items-center gap-3 px-4 py-4 text-left transition-colors", active
|
|
57
|
-
|
|
58
|
-
: "bg-white hover:bg-gray-50 dark:bg-neutral-900 dark:hover:bg-neutral-800", classes?.paymentMethodButton);
|
|
59
|
-
const expandedPanelClass = cn("anyspend-payment-method-panel border-t border-gray-100 bg-white px-4 py-4 dark:border-neutral-800 dark:bg-neutral-900");
|
|
56
|
+
const accordionButtonClass = (active) => cn("anyspend-payment-method-btn flex w-full items-center gap-3 px-4 py-4 text-left transition-colors", !active && "hover:bg-gray-50 dark:hover:bg-neutral-800", classes?.paymentMethodButton);
|
|
57
|
+
const expandedPanelClass = cn("anyspend-payment-method-panel border-t border-gray-100 px-4 py-4 dark:border-neutral-800");
|
|
60
58
|
return (_jsxs("div", { className: cn("anyspend-payment-panel flex flex-col gap-5", classes?.paymentPanel), children: [_jsx("h2", { className: cn("anyspend-payment-title text-lg font-semibold text-gray-900 dark:text-gray-100", classes?.paymentTitle), children: "Payment" }), !isFormValid && (_jsx("p", { className: "text-sm text-amber-600 dark:text-amber-400", children: "Please complete the required fields above before proceeding to payment." })), _jsxs("div", { className: cn("anyspend-payment-methods divide-y divide-gray-200 overflow-hidden rounded-xl border border-gray-200 dark:divide-neutral-700 dark:border-neutral-700", !isFormValid && "pointer-events-none opacity-50", classes?.paymentMethodSelector), children: [_jsxs("div", { className: "anyspend-method-crypto", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "crypto" ? null : "crypto"), className: accordionButtonClass(paymentMethod === "crypto"), children: [_jsx(RadioCircle, { selected: paymentMethod === "crypto", themeColor: themeColor }), _jsx(Wallet, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Pay with crypto" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "crypto" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(CryptoPayPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, buttonText: buttonText, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes, senderAddress: senderAddress }) }) }, "crypto-panel")) })] }), _jsxs("div", { className: "anyspend-method-card", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "card" ? null : "card"), className: accordionButtonClass(paymentMethod === "card"), children: [_jsx(RadioCircle, { selected: paymentMethod === "card", themeColor: themeColor }), _jsx(CreditCard, { className: "h-5 w-5 text-gray-700 dark:text-gray-300" }), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Credit or debit card" }), _jsxs("div", { className: "ml-auto flex items-center gap-1", children: [_jsx(VisaLogo, {}), _jsx(MastercardLogo, {}), _jsx(AmexLogo, {})] })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "card" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(FiatCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes, feeOnTop: feeOnTop, kycEnabled: kycEnabled }) }) }, "card-panel")) })] }), _jsxs("div", { className: "anyspend-method-coinbase", children: [_jsxs("button", { onClick: () => setPaymentMethod(paymentMethod === "coinbase" ? null : "coinbase"), className: accordionButtonClass(paymentMethod === "coinbase"), children: [_jsx(RadioCircle, { selected: paymentMethod === "coinbase", themeColor: themeColor }), _jsx(CoinbaseLogo, {}), _jsx("span", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Coinbase Pay" })] }), _jsx(AnimatePresence, { initial: false, children: paymentMethod === "coinbase" && (_jsx(motion.div, { initial: { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: { height: 0, opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { overflow: "hidden" }, children: _jsx("div", { className: expandedPanelClass, children: _jsx(CoinbaseCheckoutPanel, { recipientAddress: recipientAddress, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, totalAmount: totalAmount, themeColor: themeColor, onOrderCreated: handleOrderCreated, onError: onError, callbackMetadata: callbackMetadata, classes: classes }) }) }, "coinbase-panel")) })] })] })] }));
|
|
61
59
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
2
2
|
interface CheckoutSuccessProps {
|
|
3
3
|
txHash?: string;
|
|
4
|
+
dstChainId?: number;
|
|
4
5
|
orderId?: string;
|
|
5
6
|
returnUrl?: string;
|
|
6
7
|
returnLabel?: string;
|
|
7
8
|
classes?: AnySpendCheckoutClasses;
|
|
8
9
|
}
|
|
9
|
-
export declare function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function CheckoutSuccess({ txHash, dstChainId, orderId, returnUrl, returnLabel, classes, }: CheckoutSuccessProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { getExplorerTxUrl } from "../../../../anyspend/index.js";
|
|
4
|
+
import { b3 } from "viem/chains";
|
|
3
5
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
6
|
import { ExternalLink } from "lucide-react";
|
|
5
7
|
import { motion } from "motion/react";
|
|
6
8
|
import { useAnySpendCustomization } from "../context/AnySpendCustomizationContext.js";
|
|
7
9
|
import { AnimatedCheckmark } from "../icons/AnimatedCheckmark.js";
|
|
8
|
-
export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, classes }) {
|
|
10
|
+
export function CheckoutSuccess({ txHash, dstChainId, orderId, returnUrl, returnLabel, classes, }) {
|
|
9
11
|
const { content, slots } = useAnySpendCustomization();
|
|
10
12
|
if (slots.successScreen) {
|
|
11
13
|
return (_jsx(_Fragment, { children: slots.successScreen({
|
|
@@ -15,7 +17,7 @@ export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, class
|
|
|
15
17
|
: "Your payment has been processed successfully.",
|
|
16
18
|
txHash,
|
|
17
19
|
orderId,
|
|
18
|
-
explorerUrl: txHash ?
|
|
20
|
+
explorerUrl: txHash ? getExplorerTxUrl(dstChainId ?? b3.id, txHash) : undefined,
|
|
19
21
|
onDone: () => {
|
|
20
22
|
if (returnUrl)
|
|
21
23
|
window.location.href = returnUrl;
|
|
@@ -24,5 +26,5 @@ export function CheckoutSuccess({ txHash, orderId, returnUrl, returnLabel, class
|
|
|
24
26
|
returnLabel: content.returnButtonLabel || returnLabel,
|
|
25
27
|
}) }));
|
|
26
28
|
}
|
|
27
|
-
return (_jsxs("div", { className: cn("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [_jsx("div", { className: "anyspend-success-icon mb-4", children: _jsx(AnimatedCheckmark, { className: "h-16 w-16" }) }), _jsx(motion.h2, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.0, ease: "easeOut" }, className: "anyspend-success-title text-xl font-semibold text-gray-900 dark:text-gray-100", children: content.successTitle || "Payment Successful" }), _jsx(motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.15, ease: "easeOut" }, className: "anyspend-success-description mt-2 text-sm text-gray-500 dark:text-gray-400", children: content.successDescription || "Your payment has been processed successfully." }), txHash && (_jsxs(motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href:
|
|
29
|
+
return (_jsxs("div", { className: cn("anyspend-checkout-success flex flex-col items-center py-8 text-center", classes?.successPanel), children: [_jsx("div", { className: "anyspend-success-icon mb-4", children: _jsx(AnimatedCheckmark, { className: "h-16 w-16" }) }), _jsx(motion.h2, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.0, ease: "easeOut" }, className: "anyspend-success-title text-xl font-semibold text-gray-900 dark:text-gray-100", children: content.successTitle || "Payment Successful" }), _jsx(motion.p, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 1.15, ease: "easeOut" }, className: "anyspend-success-description mt-2 text-sm text-gray-500 dark:text-gray-400", children: content.successDescription || "Your payment has been processed successfully." }), txHash && (_jsxs(motion.a, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, href: getExplorerTxUrl(dstChainId ?? b3.id, txHash), target: "_blank", rel: "noopener noreferrer", className: "anyspend-success-tx-link mt-4 flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400", children: ["View Transaction", _jsx(ExternalLink, { className: "h-3.5 w-3.5" })] })), !txHash && orderId && (_jsxs(motion.p, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, delay: 0.5, ease: "easeOut" }, className: "anyspend-success-order-id mt-4 text-xs text-gray-400 dark:text-gray-500", children: ["Order ID: ", orderId] })), returnUrl && (_jsx(motion.a, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.3, delay: 0.6, ease: "easeOut" }, href: returnUrl, className: cn("anyspend-success-return-btn mt-6 inline-flex rounded-xl px-6 py-3 text-sm font-medium transition-colors", classes?.returnButton), style: { backgroundColor: "#111827", color: "#fff" }, children: content.returnButtonLabel || returnLabel || "Return to Store" }))] }));
|
|
28
30
|
}
|
|
@@ -5,19 +5,18 @@ import { USDC_BASE } from "../../../../anyspend/constants/index.js";
|
|
|
5
5
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
6
6
|
import { formatUnits } from "../../../../shared/utils/number.js";
|
|
7
7
|
import { getStripePromise } from "../../../../shared/utils/payment.utils.js";
|
|
8
|
-
import { ShinyButton, TextShimmer, useB3Config, useModalStore, useTokenData } from "../../../../global-account/react/index.js";
|
|
8
|
+
import { ShinyButton, TextShimmer, useAccountWallet, useB3Config, useModalStore, useTokenData, } from "../../../../global-account/react/index.js";
|
|
9
9
|
import { thirdwebB3Chain } from "../../../../shared/constants/chains/b3Chain.js";
|
|
10
10
|
import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
|
11
11
|
import { Loader2, Lock, Wallet } from "lucide-react";
|
|
12
12
|
import { AnimatePresence, motion } from "motion/react";
|
|
13
13
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
14
|
-
import { useAccount } from "wagmi";
|
|
15
14
|
import { KycGate } from "./KycGate.js";
|
|
16
15
|
export function FiatCheckoutPanel({ recipientAddress, destinationTokenAddress, destinationTokenChainId, totalAmount, themeColor, onSuccess, onOrderCreated, onError, callbackMetadata, classes, feeOnTop, kycEnabled = false, }) {
|
|
17
16
|
// Stable refs for callback props to avoid re-triggering effects
|
|
18
17
|
const onErrorRef = useRef(onError);
|
|
19
18
|
onErrorRef.current = onError;
|
|
20
|
-
const { address } =
|
|
19
|
+
const { address } = useAccountWallet();
|
|
21
20
|
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
22
21
|
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
23
22
|
const { data: tokenData } = useTokenData(destinationTokenChainId, destinationTokenAddress);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
|
-
import { ShinyButton, TextShimmer, useB3Config, useModalStore } from "../../../../global-account/react/index.js";
|
|
4
|
+
import { ShinyButton, TextShimmer, useAccountWallet, useB3Config, useModalStore, } from "../../../../global-account/react/index.js";
|
|
5
5
|
import { thirdwebB3Chain } from "../../../../shared/constants/chains/b3Chain.js";
|
|
6
6
|
import { Loader2, ShieldCheck, AlertTriangle, Clock, Wallet } from "lucide-react";
|
|
7
7
|
import { AnimatePresence, motion } from "motion/react";
|
|
8
8
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
9
|
-
import { useAccount } from "wagmi";
|
|
10
9
|
import { useCreateKycInquiry, useKycStatus, useVerifyKyc, useWalletAuthHeaders } from "../../hooks/useKycStatus.js";
|
|
11
10
|
export function KycGate({ themeColor, classes, enabled = false, onStatusResolved }) {
|
|
12
|
-
const { address } =
|
|
11
|
+
const { address } = useAccountWallet();
|
|
13
12
|
const { partnerId } = useB3Config();
|
|
14
13
|
// Gate the status fetch behind explicit user consent so the wallet
|
|
15
14
|
// signature prompt doesn't fire automatically on tab open.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } 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, useB3Config, useModalStore, useProfile, useUnifiedChainSwitchAndExecute, } from "../../../../global-account/react/index.js";
|
|
4
|
+
import { Badge, Button, CopyToClipboard, ShinyButton, Skeleton, TextLoop, TextShimmer, useAccountWallet, useB3Config, useModalStore, useProfile, useToastContext, 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";
|
|
@@ -134,6 +134,11 @@ function roundTokenAmount(amount) {
|
|
|
134
134
|
export const OrderDetails = memo(function OrderDetails({ mode = "modal", order, depositTxs, relayTxs, executeTx, refundTxs, cryptoPaymentMethod, selectedCryptoPaymentMethod, onPaymentMethodChange, onBack, disableUrlParamManagement = false, points, returnToHomeUrl, returnHomeLabel, classes, }) {
|
|
135
135
|
const router = useRouter();
|
|
136
136
|
const searchParams = useSearchParams();
|
|
137
|
+
const { setHeaderMode } = useToastContext();
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
setHeaderMode(true);
|
|
140
|
+
return () => setHeaderMode(false);
|
|
141
|
+
}, [setHeaderMode]);
|
|
137
142
|
// Get theme from B3Provider context
|
|
138
143
|
const { theme } = useB3Config();
|
|
139
144
|
const colorMode = theme || "light";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { getStatusDisplay } from "../../../../anyspend/index.js";
|
|
3
3
|
import { useSearchParams } from "../../../../shared/react/index.js";
|
|
4
|
-
import { Clock, Loader2, RotateCcw, X } from "lucide-react";
|
|
4
|
+
import { AlertCircle, AlertTriangle, CheckCircle, Clock, Info, Loader2, RotateCcw, X } from "lucide-react";
|
|
5
|
+
import { useToastContext } from "../../../../global-account/react/index.js";
|
|
5
6
|
import { memo, useEffect, useRef } from "react";
|
|
6
7
|
import { useAnySpendCustomization } from "../context/AnySpendCustomizationContext.js";
|
|
7
8
|
import { AnimatedCheckmark } from "../icons/AnimatedCheckmark.js";
|
|
@@ -14,6 +15,19 @@ function getStepIndex(status) {
|
|
|
14
15
|
return 1;
|
|
15
16
|
return -1;
|
|
16
17
|
}
|
|
18
|
+
function getToastIcon(type) {
|
|
19
|
+
const iconClass = "h-5 w-5";
|
|
20
|
+
switch (type) {
|
|
21
|
+
case "success":
|
|
22
|
+
return _jsx(CheckCircle, { className: `${iconClass} text-green-500` });
|
|
23
|
+
case "error":
|
|
24
|
+
return _jsx(AlertCircle, { className: `${iconClass} text-red-500` });
|
|
25
|
+
case "info":
|
|
26
|
+
return _jsx(Info, { className: `${iconClass} text-blue-500` });
|
|
27
|
+
case "warning":
|
|
28
|
+
return _jsx(AlertTriangle, { className: `${iconClass} text-amber-500` });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
17
31
|
export const OrderStatus = memo(function OrderStatus({ order, selectedCryptoPaymentMethod, }) {
|
|
18
32
|
const { text: defaultText, description: defaultDescription } = getStatusDisplay(order);
|
|
19
33
|
const { content, slots } = useAnySpendCustomization();
|
|
@@ -58,9 +72,26 @@ export const OrderStatus = memo(function OrderStatus({ order, selectedCryptoPaym
|
|
|
58
72
|
if (content.processingDescription)
|
|
59
73
|
description = content.processingDescription;
|
|
60
74
|
}
|
|
75
|
+
const { latestToast } = useToastContext();
|
|
76
|
+
// Override subtitle with toast notification when present (title stays unchanged)
|
|
77
|
+
let notificationIcon = undefined;
|
|
78
|
+
if (latestToast && currentStepIndex >= 0) {
|
|
79
|
+
description = latestToast.message;
|
|
80
|
+
notificationIcon = getToastIcon(latestToast.type);
|
|
81
|
+
}
|
|
61
82
|
const paymentSteps = [
|
|
62
|
-
{
|
|
63
|
-
|
|
83
|
+
{
|
|
84
|
+
id: 1,
|
|
85
|
+
title: text,
|
|
86
|
+
description: typeof description === "string" ? description : defaultDescription || "",
|
|
87
|
+
icon: notificationIcon,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 2,
|
|
91
|
+
title: text,
|
|
92
|
+
description: typeof description === "string" ? description : defaultDescription || "",
|
|
93
|
+
icon: notificationIcon,
|
|
94
|
+
},
|
|
64
95
|
];
|
|
65
96
|
if (currentStepIndex === 0) {
|
|
66
97
|
if (!(order.status === "scanning_deposit_transaction" && cryptoPaymentMethod === "transfer_crypto")) {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
3
4
|
import { motion } from "framer-motion";
|
|
5
|
+
import { TextMorph } from "torph/react";
|
|
4
6
|
import { AnimatedCheckmark } from "../icons/AnimatedCheckmark.js";
|
|
5
7
|
export function StepProgress({ steps, currentStepIndex, className = "", animateCompletedSteps = true, }) {
|
|
6
8
|
const currentStep = steps[currentStepIndex];
|
|
7
|
-
return (_jsxs("div", { className: `flex w-full flex-col items-center gap-4 ${className}`, children: [_jsx("div", { className: "flex items-center gap-2", children: steps.map((_, index) => (_jsxs(
|
|
9
|
+
return (_jsxs("div", { className: `flex w-full flex-col items-center gap-4 ${className}`, children: [_jsx("div", { className: "flex items-center gap-2", children: steps.map((_, index) => (_jsxs(React.Fragment, { children: [_jsx("div", { className: "flex items-center", children: index < currentStepIndex ? (
|
|
8
10
|
// Completed step - checkmark replaces the whole circle
|
|
9
11
|
_jsx(motion.div, { initial: { scale: 0.8, opacity: 0 }, animate: { scale: 1, opacity: 1 }, transition: { delay: index * 0.2 }, children: _jsx(AnimatedCheckmark, { className: "h-10 w-10", strokeWidth: 2.5, static: !animateCompletedSteps }) })) : (_jsx(motion.div, { initial: { scale: 0.8, opacity: 0 }, animate: { scale: 1, opacity: 1 }, transition: { delay: index * 0.2 }, className: `border-as-border-secondary relative flex h-10 w-10 items-center justify-center rounded-full border-[3px]`, children: index === currentStepIndex ? (
|
|
10
12
|
// Current step - show spinning border and step number
|
|
11
13
|
_jsxs(_Fragment, { children: [_jsx("div", { className: "border-t-as-primary absolute -inset-0.5 animate-spin rounded-full border-[3px] border-transparent" }), _jsx("span", { className: "text-as-primary font-semibold", children: index + 1 })] })) : (
|
|
12
14
|
// Future step - show step number with disabled styling
|
|
13
|
-
_jsx("span", { className: "text-as-content-disabled font-semibold", children: index + 1 })) })) }
|
|
15
|
+
_jsx("span", { className: "text-as-content-disabled font-semibold", children: index + 1 })) })) }), index < steps.length - 1 && (_jsx("div", { className: "flex w-8 items-center justify-center gap-1", children: Array.from({ length: 6 }).map((_, dotIndex) => (_jsx("div", { className: "bg-as-primary/30 h-[2px] w-[2px] rounded-full" }, dotIndex))) }))] }, index))) }), currentStep && (_jsxs(motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.3 }, className: "text-center", children: [_jsx("h2", { className: "text-as-primary text-xl font-semibold", children: _jsx(TextMorph, { children: currentStep.title }) }), currentStep.description && (_jsxs("p", { className: "text-as-tertiary mt-1 flex items-center justify-center gap-1.5 text-sm", children: [currentStep.icon, _jsx(TextMorph, { children: currentStep.description })] }))] }))] }));
|
|
14
16
|
}
|
|
@@ -7,8 +7,7 @@ import { useMutation } from "@tanstack/react-query";
|
|
|
7
7
|
import { useMemo } from "react";
|
|
8
8
|
import { parseUnits } from "viem";
|
|
9
9
|
import { base } from "viem/chains";
|
|
10
|
-
import {
|
|
11
|
-
import { getCachedWalletHeaders } from "./useKycStatus.js";
|
|
10
|
+
import { getCachedWalletHeaders, useWalletAuthHeaders } from "./useKycStatus.js";
|
|
12
11
|
import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.js";
|
|
13
12
|
/**
|
|
14
13
|
* Hook for creating onramp orders in the Anyspend protocol
|
|
@@ -17,7 +16,7 @@ import { useValidatedClientReferenceId } from "./useValidatedClientReferenceId.j
|
|
|
17
16
|
export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
18
17
|
// Get B3 context values
|
|
19
18
|
const { partnerId } = useB3Config();
|
|
20
|
-
const { address } =
|
|
19
|
+
const { address, getHeaders: getWalletAuthHeaders } = useWalletAuthHeaders();
|
|
21
20
|
// Get validated client reference ID from B3 context
|
|
22
21
|
const createValidatedClientReferenceId = useValidatedClientReferenceId();
|
|
23
22
|
// Get fingerprint data
|
|
@@ -41,12 +40,11 @@ export function useAnyspendCreateOnrampOrder({ onSuccess, onError } = {}) {
|
|
|
41
40
|
const srcAmountOnRampInWei = parseUnits(srcFiatAmount, USDC_BASE.decimals);
|
|
42
41
|
// For card payments, include wallet auth headers so the backend can verify
|
|
43
42
|
// KYC by the signing wallet address (may differ from the B3 JWT address).
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
// KycGate pre-caches the headers in the "Continue to Verify" user-gesture.
|
|
43
|
+
// First try cached headers (from KycGate), then sign on-the-fly.
|
|
44
|
+
// The user is already clicking "Continue"/"Pay" so signing here is acceptable.
|
|
47
45
|
let kycWalletHeaders;
|
|
48
46
|
if (onramp.vendor === "stripe-web2" && address) {
|
|
49
|
-
kycWalletHeaders = getCachedWalletHeaders(address);
|
|
47
|
+
kycWalletHeaders = getCachedWalletHeaders(address) || (await getWalletAuthHeaders());
|
|
50
48
|
}
|
|
51
49
|
return await anyspendService.createOrder({
|
|
52
50
|
recipientAddress: normalizeAddress(recipientAddress),
|
|
@@ -24,10 +24,12 @@ interface KycVerifyResponse {
|
|
|
24
24
|
export declare function getCachedWalletHeaders(address: string): Record<string, string> | undefined;
|
|
25
25
|
/**
|
|
26
26
|
* Returns a function that builds the wallet-signature auth headers.
|
|
27
|
+
* Uses useAccountWallet (thirdweb) instead of wagmi so signing works
|
|
28
|
+
* for all wallet types (social login, EOA, smart wallet, etc.).
|
|
27
29
|
* Caches signatures for 4 minutes (server allows 5-minute window).
|
|
28
30
|
*/
|
|
29
31
|
export declare function useWalletAuthHeaders(): {
|
|
30
|
-
address:
|
|
32
|
+
address: string | undefined;
|
|
31
33
|
getHeaders: () => Promise<Record<string, string>>;
|
|
32
34
|
};
|
|
33
35
|
export declare function useKycStatus(enabled?: boolean): {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ANYSPEND_MAINNET_BASE_URL } from "../../../anyspend/constants/index.js";
|
|
3
|
+
import { useAccountWallet } from "../../../global-account/react/index.js";
|
|
3
4
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
4
5
|
import { useCallback } from "react";
|
|
5
|
-
import { useAccount, useSignMessage } from "wagmi";
|
|
6
6
|
function buildWalletAuthMessage(walletAddress, timestamp) {
|
|
7
7
|
return `AnySpend wants to verify your identity for card payments.\n\nThis signature does not trigger a blockchain transaction or cost any gas.\n\nWallet: ${walletAddress.toLowerCase()}\nNonce: ${timestamp}`;
|
|
8
8
|
}
|
|
@@ -20,21 +20,25 @@ export function getCachedWalletHeaders(address) {
|
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Returns a function that builds the wallet-signature auth headers.
|
|
23
|
+
* Uses useAccountWallet (thirdweb) instead of wagmi so signing works
|
|
24
|
+
* for all wallet types (social login, EOA, smart wallet, etc.).
|
|
23
25
|
* Caches signatures for 4 minutes (server allows 5-minute window).
|
|
24
26
|
*/
|
|
25
27
|
export function useWalletAuthHeaders() {
|
|
26
|
-
const { address } =
|
|
27
|
-
const
|
|
28
|
+
const { address, wallet } = useAccountWallet();
|
|
29
|
+
const signMessage = wallet.signMessage;
|
|
28
30
|
const getHeaders = useCallback(async () => {
|
|
29
31
|
if (!address)
|
|
30
32
|
throw new Error("No wallet connected");
|
|
33
|
+
if (!signMessage)
|
|
34
|
+
throw new Error("Wallet does not support message signing");
|
|
31
35
|
const walletAddress = address.toLowerCase();
|
|
32
36
|
const cached = headerCache.get(walletAddress);
|
|
33
37
|
if (cached && Date.now() < cached.expiresAt)
|
|
34
38
|
return cached.headers;
|
|
35
39
|
const timestamp = Math.floor(Date.now() / 1000);
|
|
36
40
|
const message = buildWalletAuthMessage(walletAddress, timestamp);
|
|
37
|
-
const signature = await
|
|
41
|
+
const signature = await signMessage({ message });
|
|
38
42
|
const headers = {
|
|
39
43
|
"X-Wallet-Address": walletAddress,
|
|
40
44
|
"X-Wallet-Signature": signature,
|
|
@@ -43,7 +47,7 @@ export function useWalletAuthHeaders() {
|
|
|
43
47
|
// Cache for 4 minutes so repeated fetches don't re-prompt the user
|
|
44
48
|
headerCache.set(walletAddress, { headers, expiresAt: Date.now() + 4 * 60 * 1000 });
|
|
45
49
|
return headers;
|
|
46
|
-
}, [address,
|
|
50
|
+
}, [address, signMessage]);
|
|
47
51
|
return { address, getHeaders };
|
|
48
52
|
}
|
|
49
53
|
export function useKycStatus(enabled = true) {
|