@b3dotfun/sdk 0.0.88-alpha.6 → 0.0.88-alpha.7
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 +6 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +3 -3
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +4 -0
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +3 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +4 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +32 -4
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +3 -2
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +6 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +6 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +3 -3
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +2 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +4 -0
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +3 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +4 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +33 -5
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +3 -2
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +6 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +6 -0
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +4 -0
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +4 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +6 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +16 -0
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +13 -0
- package/src/anyspend/react/components/AnySpendDeposit.tsx +15 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +4 -0
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +5 -1
- package/src/anyspend/react/components/common/OrderDetails.tsx +52 -40
- package/src/anyspend/react/components/common/PanelOnramp.tsx +5 -1
- package/src/global-account/react/stores/useModalStore.ts +6 -0
|
@@ -65,6 +65,10 @@ interface OrderDetailsProps {
|
|
|
65
65
|
onBack?: () => void;
|
|
66
66
|
disableUrlParamManagement?: boolean; // When true, will not modify URL parameters
|
|
67
67
|
points?: number | undefined; // Points earned from the transaction
|
|
68
|
+
/** Custom URL to redirect to when clicking "Return to Home" on complete order screen */
|
|
69
|
+
returnToHomeUrl?: string;
|
|
70
|
+
/** Custom label for the return home button (overrides "Return to Home" / "Close") */
|
|
71
|
+
returnHomeLabel?: string;
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
// Add this helper function near the top or just above the component
|
|
@@ -217,6 +221,8 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
217
221
|
onBack,
|
|
218
222
|
disableUrlParamManagement = false,
|
|
219
223
|
points,
|
|
224
|
+
returnToHomeUrl,
|
|
225
|
+
returnHomeLabel,
|
|
220
226
|
}: OrderDetailsProps) {
|
|
221
227
|
const router = useRouter();
|
|
222
228
|
const searchParams = useSearchParams();
|
|
@@ -377,6 +383,49 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
377
383
|
onBack?.();
|
|
378
384
|
}, [cleanupUrlParams, onBack]);
|
|
379
385
|
|
|
386
|
+
// Handle "Return to Home" click - redirects to custom URL if provided
|
|
387
|
+
const handleReturnToHome = useCallback(() => {
|
|
388
|
+
if (returnToHomeUrl) {
|
|
389
|
+
// Validate URL to prevent Open Redirect / XSS attacks
|
|
390
|
+
try {
|
|
391
|
+
const url = new URL(returnToHomeUrl, window.location.origin);
|
|
392
|
+
// Only allow http/https protocols
|
|
393
|
+
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
394
|
+
window.location.href = url.href;
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
} catch {
|
|
398
|
+
// If URL parsing fails, check if it's a safe relative URL
|
|
399
|
+
if (returnToHomeUrl.startsWith("/") && !returnToHomeUrl.startsWith("//")) {
|
|
400
|
+
window.location.href = returnToHomeUrl;
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
// Fallback to handleBack if URL is not safe
|
|
405
|
+
handleBack();
|
|
406
|
+
} else {
|
|
407
|
+
handleBack();
|
|
408
|
+
}
|
|
409
|
+
}, [returnToHomeUrl, handleBack]);
|
|
410
|
+
|
|
411
|
+
// Reusable "Return to Home" / "Close" button
|
|
412
|
+
const returnHomeOrCloseButton = (
|
|
413
|
+
<button
|
|
414
|
+
className="order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white"
|
|
415
|
+
onClick={returnToHomeUrl ? handleReturnToHome : mode === "page" ? handleBack : handleCloseModal}
|
|
416
|
+
>
|
|
417
|
+
{returnHomeLabel ? (
|
|
418
|
+
returnHomeLabel
|
|
419
|
+
) : mode === "page" ? (
|
|
420
|
+
<>
|
|
421
|
+
Return to Home <Home className="ml-2 h-4 w-4" />
|
|
422
|
+
</>
|
|
423
|
+
) : (
|
|
424
|
+
"Close"
|
|
425
|
+
)}
|
|
426
|
+
</button>
|
|
427
|
+
);
|
|
428
|
+
|
|
380
429
|
useEffect(() => {
|
|
381
430
|
if (txSuccess) {
|
|
382
431
|
toast.success("Transaction successful! We are processing your order.", { duration: 10000 });
|
|
@@ -521,18 +570,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
521
570
|
</span>
|
|
522
571
|
</div>
|
|
523
572
|
)}
|
|
524
|
-
|
|
525
|
-
className="order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white"
|
|
526
|
-
onClick={mode === "page" ? handleBack : handleCloseModal}
|
|
527
|
-
>
|
|
528
|
-
{mode === "page" ? (
|
|
529
|
-
<>
|
|
530
|
-
Return to Home <Home className="ml-2 h-4 w-4" />
|
|
531
|
-
</>
|
|
532
|
-
) : (
|
|
533
|
-
"Close"
|
|
534
|
-
)}
|
|
535
|
-
</button>
|
|
573
|
+
{returnHomeOrCloseButton}
|
|
536
574
|
</>
|
|
537
575
|
);
|
|
538
576
|
}
|
|
@@ -649,20 +687,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
649
687
|
</ShinyButton>
|
|
650
688
|
)}
|
|
651
689
|
|
|
652
|
-
{order.status === "executed" &&
|
|
653
|
-
<button
|
|
654
|
-
className="order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white"
|
|
655
|
-
onClick={mode === "page" ? handleBack : handleCloseModal}
|
|
656
|
-
>
|
|
657
|
-
{mode === "page" ? (
|
|
658
|
-
<>
|
|
659
|
-
Return to Home <Home className="ml-2 h-4 w-4" />
|
|
660
|
-
</>
|
|
661
|
-
) : (
|
|
662
|
-
"Close"
|
|
663
|
-
)}
|
|
664
|
-
</button>
|
|
665
|
-
)}
|
|
690
|
+
{order.status === "executed" && returnHomeOrCloseButton}
|
|
666
691
|
</>
|
|
667
692
|
);
|
|
668
693
|
}
|
|
@@ -786,20 +811,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
786
811
|
</ShinyButton>
|
|
787
812
|
)}
|
|
788
813
|
|
|
789
|
-
{order.status === "executed" &&
|
|
790
|
-
<button
|
|
791
|
-
className="order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white"
|
|
792
|
-
onClick={mode === "page" ? handleBack : handleCloseModal}
|
|
793
|
-
>
|
|
794
|
-
{mode === "page" ? (
|
|
795
|
-
<>
|
|
796
|
-
Return to Home <Home className="ml-2 h-4 w-4" />
|
|
797
|
-
</>
|
|
798
|
-
) : (
|
|
799
|
-
"Close"
|
|
800
|
-
)}
|
|
801
|
-
</button>
|
|
802
|
-
)}
|
|
814
|
+
{order.status === "executed" && returnHomeOrCloseButton}
|
|
803
815
|
</>
|
|
804
816
|
);
|
|
805
817
|
}
|
|
@@ -33,6 +33,7 @@ export function PanelOnramp({
|
|
|
33
33
|
onShowPointsDetail,
|
|
34
34
|
onShowFeeDetail,
|
|
35
35
|
customUsdInputValues = ["5", "10", "20", "25"],
|
|
36
|
+
customRecipientLabel,
|
|
36
37
|
}: {
|
|
37
38
|
srcAmountOnRamp: string;
|
|
38
39
|
setSrcAmountOnRamp: (amount: string) => void;
|
|
@@ -52,6 +53,8 @@ export function PanelOnramp({
|
|
|
52
53
|
onShowPointsDetail?: () => void;
|
|
53
54
|
onShowFeeDetail?: () => void;
|
|
54
55
|
customUsdInputValues?: string[];
|
|
56
|
+
/** Custom label for recipient display (overrides recipientName) */
|
|
57
|
+
customRecipientLabel?: string;
|
|
55
58
|
}) {
|
|
56
59
|
// Helper function to get fees from anyspend quote
|
|
57
60
|
const getFeeFromApi = (paymentMethod: FiatPaymentMethod): number | null => {
|
|
@@ -228,7 +231,8 @@ export function PanelOnramp({
|
|
|
228
231
|
onClick={() => setActivePanel(recipientSelectionPanelIndex)} // Recipient selection panel
|
|
229
232
|
>
|
|
230
233
|
<span className="text-sm">
|
|
231
|
-
{
|
|
234
|
+
{customRecipientLabel ||
|
|
235
|
+
(recipientName ? formatUsername(recipientName) : formatAddress(_recipientAddress))}
|
|
232
236
|
</span>
|
|
233
237
|
<ChevronRight size={16} />
|
|
234
238
|
</button>
|
|
@@ -426,6 +426,12 @@ export interface AnySpendDepositHypeProps extends BaseModalProps {
|
|
|
426
426
|
customUsdInputValues?: string[];
|
|
427
427
|
/** prefer eoa wallet */
|
|
428
428
|
preferEoa?: boolean;
|
|
429
|
+
/** Custom URL to redirect to when clicking "Return to Home" on complete order screen */
|
|
430
|
+
returnToHomeUrl?: string;
|
|
431
|
+
/** Custom label for recipient display (e.g., "OBSN Telegram Bot") */
|
|
432
|
+
customRecipientLabel?: string;
|
|
433
|
+
/** Custom label for the return home button (overrides "Return to Home" / "Close") */
|
|
434
|
+
returnHomeLabel?: string;
|
|
429
435
|
}
|
|
430
436
|
|
|
431
437
|
export interface AvatarEditorModalProps extends BaseModalProps {
|