@b3dotfun/sdk 0.0.87-alpha.1 → 0.0.87
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 +0 -5
- package/dist/cjs/anyspend/react/components/AnySpend.js +49 -59
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +2 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +12 -17
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +0 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +5 -12
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/index.d.ts +0 -2
- package/dist/cjs/anyspend/react/components/index.js +1 -3
- package/dist/cjs/anyspend/react/hooks/index.d.ts +0 -1
- package/dist/cjs/anyspend/react/hooks/index.js +0 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +11 -35
- package/dist/cjs/anyspend/utils/format.js +5 -28
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -4
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +0 -5
- package/dist/esm/anyspend/react/components/AnySpend.js +49 -59
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +2 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +12 -17
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +0 -2
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +5 -12
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/index.d.ts +0 -2
- package/dist/esm/anyspend/react/components/index.js +0 -1
- package/dist/esm/anyspend/react/hooks/index.d.ts +0 -1
- package/dist/esm/anyspend/react/hooks/index.js +0 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +11 -35
- package/dist/esm/anyspend/utils/format.js +5 -28
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -4
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +0 -5
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +0 -2
- package/dist/types/anyspend/react/components/index.d.ts +0 -2
- package/dist/types/anyspend/react/hooks/index.d.ts +0 -1
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -4
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +45 -68
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +3 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +8 -26
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +8 -20
- package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
- package/src/anyspend/react/components/index.ts +0 -2
- package/src/anyspend/react/hooks/index.ts +0 -1
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +12 -37
- package/src/anyspend/utils/format.ts +5 -33
- package/src/global-account/react/stores/useModalStore.ts +0 -4
- package/src/styles/index.css +0 -2
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +0 -122
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +0 -190
- package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +0 -43
- package/dist/cjs/anyspend/react/components/QRDeposit.js +0 -146
- package/dist/cjs/anyspend/react/components/common/WarningText.d.ts +0 -32
- package/dist/cjs/anyspend/react/components/common/WarningText.js +0 -36
- package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.js +0 -6
- package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.js +0 -6
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +0 -24
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +0 -86
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +0 -122
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +0 -187
- package/dist/esm/anyspend/react/components/QRDeposit.d.ts +0 -43
- package/dist/esm/anyspend/react/components/QRDeposit.js +0 -143
- package/dist/esm/anyspend/react/components/common/WarningText.d.ts +0 -32
- package/dist/esm/anyspend/react/components/common/WarningText.js +0 -32
- package/dist/esm/anyspend/react/components/icons/CreditCardIcon.d.ts +0 -6
- package/dist/esm/anyspend/react/components/icons/CreditCardIcon.js +0 -2
- package/dist/esm/anyspend/react/components/icons/QrCodeIcon.d.ts +0 -6
- package/dist/esm/anyspend/react/components/icons/QrCodeIcon.js +0 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +0 -24
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +0 -83
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +0 -122
- package/dist/types/anyspend/react/components/QRDeposit.d.ts +0 -43
- package/dist/types/anyspend/react/components/common/WarningText.d.ts +0 -32
- package/dist/types/anyspend/react/components/icons/CreditCardIcon.d.ts +0 -6
- package/dist/types/anyspend/react/components/icons/QrCodeIcon.d.ts +0 -6
- package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +0 -24
- package/src/anyspend/react/components/AnySpendDeposit.tsx +0 -578
- package/src/anyspend/react/components/QRDeposit.tsx +0 -348
- package/src/anyspend/react/components/common/WarningText.tsx +0 -52
- package/src/anyspend/react/components/icons/CreditCardIcon.tsx +0 -25
- package/src/anyspend/react/components/icons/QrCodeIcon.tsx +0 -25
- package/src/anyspend/react/components/icons/credit-card.svg +0 -5
- package/src/anyspend/react/components/icons/qr-code.svg +0 -5
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +0 -110
|
@@ -90,7 +90,6 @@ const ANYSPEND_RECIPIENTS_KEY = "anyspend_recipients";
|
|
|
90
90
|
export function AnySpend(props: {
|
|
91
91
|
mode?: "page" | "modal";
|
|
92
92
|
defaultActiveTab?: "crypto" | "fiat";
|
|
93
|
-
sourceChainId?: number;
|
|
94
93
|
destinationTokenAddress?: string;
|
|
95
94
|
destinationTokenChainId?: number;
|
|
96
95
|
recipientAddress?: string;
|
|
@@ -103,10 +102,6 @@ export function AnySpend(props: {
|
|
|
103
102
|
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
104
103
|
onSuccess?: (txHash?: string) => void;
|
|
105
104
|
customUsdInputValues?: string[];
|
|
106
|
-
hideHeader?: boolean;
|
|
107
|
-
hideBottomNavigation?: boolean;
|
|
108
|
-
/** When true, disables URL parameter management for swap configuration */
|
|
109
|
-
disableUrlParamManagement?: boolean;
|
|
110
105
|
}) {
|
|
111
106
|
const fingerprintConfig = getFingerprintConfig();
|
|
112
107
|
|
|
@@ -118,7 +113,6 @@ export function AnySpend(props: {
|
|
|
118
113
|
}
|
|
119
114
|
|
|
120
115
|
function AnySpendInner({
|
|
121
|
-
sourceChainId,
|
|
122
116
|
destinationTokenAddress,
|
|
123
117
|
destinationTokenChainId,
|
|
124
118
|
mode = "modal",
|
|
@@ -129,11 +123,7 @@ function AnySpendInner({
|
|
|
129
123
|
onTokenSelect,
|
|
130
124
|
onSuccess,
|
|
131
125
|
customUsdInputValues,
|
|
132
|
-
hideHeader,
|
|
133
|
-
hideBottomNavigation = false,
|
|
134
|
-
disableUrlParamManagement = false,
|
|
135
126
|
}: {
|
|
136
|
-
sourceChainId?: number;
|
|
137
127
|
destinationTokenAddress?: string;
|
|
138
128
|
destinationTokenChainId?: number;
|
|
139
129
|
mode?: "page" | "modal";
|
|
@@ -144,9 +134,6 @@ function AnySpendInner({
|
|
|
144
134
|
onTokenSelect?: (token: components["schemas"]["Token"], event: { preventDefault: () => void }) => void;
|
|
145
135
|
onSuccess?: (txHash?: string) => void;
|
|
146
136
|
customUsdInputValues?: string[];
|
|
147
|
-
hideHeader?: boolean;
|
|
148
|
-
hideBottomNavigation?: boolean;
|
|
149
|
-
disableUrlParamManagement?: boolean;
|
|
150
137
|
}) {
|
|
151
138
|
const searchParams = useSearchParamsSSR();
|
|
152
139
|
const router = useRouter();
|
|
@@ -224,7 +211,7 @@ function AnySpendInner({
|
|
|
224
211
|
// const recipientInputRef = useRef<HTMLInputElement>(null);
|
|
225
212
|
|
|
226
213
|
// Get initial chain IDs from URL or defaults
|
|
227
|
-
const initialSrcChainId =
|
|
214
|
+
const initialSrcChainId = parseInt(searchParams.get("fromChainId") || "0") || mainnet.id;
|
|
228
215
|
const initialDstChainId =
|
|
229
216
|
parseInt(searchParams.get("toChainId") || "0") || (isBuyMode ? destinationTokenChainId : base.id);
|
|
230
217
|
|
|
@@ -336,8 +323,8 @@ function AnySpendInner({
|
|
|
336
323
|
|
|
337
324
|
// Load swap configuration from URL on initial render
|
|
338
325
|
useEffect(() => {
|
|
339
|
-
// Skip if we've already processed the URL
|
|
340
|
-
if (initialUrlProcessed.current || loadOrder
|
|
326
|
+
// Skip if we've already processed the URL or if we have an order to load
|
|
327
|
+
if (initialUrlProcessed.current || loadOrder) return;
|
|
341
328
|
|
|
342
329
|
try {
|
|
343
330
|
const tabParam = searchParams.get("tab");
|
|
@@ -370,7 +357,7 @@ function AnySpendInner({
|
|
|
370
357
|
|
|
371
358
|
// Mark that we've processed the initial URL
|
|
372
359
|
initialUrlProcessed.current = true;
|
|
373
|
-
}, [searchParams, loadOrder
|
|
360
|
+
}, [searchParams, loadOrder]);
|
|
374
361
|
|
|
375
362
|
// Update URL when swap configuration changes - but not on initial load
|
|
376
363
|
const updateSwapParamsInURL = useCallback(() => {
|
|
@@ -383,8 +370,7 @@ function AnySpendInner({
|
|
|
383
370
|
activePanel !== PanelView.MAIN ||
|
|
384
371
|
!initialUrlProcessed.current ||
|
|
385
372
|
searchParams.has("orderId") ||
|
|
386
|
-
mode === "modal"
|
|
387
|
-
disableUrlParamManagement
|
|
373
|
+
mode === "modal"
|
|
388
374
|
)
|
|
389
375
|
return;
|
|
390
376
|
|
|
@@ -455,7 +441,6 @@ function AnySpendInner({
|
|
|
455
441
|
dstAmount,
|
|
456
442
|
router,
|
|
457
443
|
srcAmountOnRamp,
|
|
458
|
-
disableUrlParamManagement,
|
|
459
444
|
]);
|
|
460
445
|
|
|
461
446
|
// Update URL when relevant state changes - but only after initial render
|
|
@@ -665,20 +650,20 @@ function AnySpendInner({
|
|
|
665
650
|
// setNewRecipientAddress("");
|
|
666
651
|
navigateToPanel(PanelView.ORDER_DETAILS, "forward");
|
|
667
652
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
console.log("Creating order - selectedCryptoPaymentMethod:", selectedCryptoPaymentMethod);
|
|
653
|
+
// Debug: Check payment method before setting URL
|
|
654
|
+
console.log("Creating order - selectedCryptoPaymentMethod:", selectedCryptoPaymentMethod);
|
|
671
655
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
656
|
+
// Add orderId and payment method to URL for persistence
|
|
657
|
+
const params = new URLSearchParams(searchParams.toString()); // Preserve existing params
|
|
658
|
+
params.set("orderId", orderId);
|
|
659
|
+
if (effectiveCryptoPaymentMethod !== CryptoPaymentMethodType.NONE) {
|
|
660
|
+
console.log("Setting cryptoPaymentMethod in URL:", effectiveCryptoPaymentMethod);
|
|
661
|
+
params.set("cryptoPaymentMethod", effectiveCryptoPaymentMethod);
|
|
662
|
+
} else {
|
|
663
|
+
console.log("Payment method is NONE, not setting in URL");
|
|
681
664
|
}
|
|
665
|
+
console.log("Final URL params:", params.toString());
|
|
666
|
+
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
682
667
|
},
|
|
683
668
|
onError: error => {
|
|
684
669
|
console.error(error);
|
|
@@ -693,13 +678,11 @@ function AnySpendInner({
|
|
|
693
678
|
setOrderId(orderId);
|
|
694
679
|
navigateToPanel(PanelView.ORDER_DETAILS, "forward");
|
|
695
680
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
702
|
-
}
|
|
681
|
+
// Add orderId and payment method to URL for persistence
|
|
682
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
683
|
+
params.set("orderId", orderId);
|
|
684
|
+
params.set("paymentMethod", "fiat");
|
|
685
|
+
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
703
686
|
},
|
|
704
687
|
onError: error => {
|
|
705
688
|
console.error(error);
|
|
@@ -848,13 +831,11 @@ function AnySpendInner({
|
|
|
848
831
|
type: "anySpendOrderHistory",
|
|
849
832
|
showBackButton: false,
|
|
850
833
|
});
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
857
|
-
}
|
|
834
|
+
// Remove orderId and paymentMethod from URL when going back to history
|
|
835
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
836
|
+
params.delete("orderId");
|
|
837
|
+
params.delete("paymentMethod");
|
|
838
|
+
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
858
839
|
};
|
|
859
840
|
|
|
860
841
|
// Handle crypto swap creation
|
|
@@ -971,25 +952,23 @@ function AnySpendInner({
|
|
|
971
952
|
|
|
972
953
|
// Update useEffect for URL parameter to not override loadOrder
|
|
973
954
|
useEffect(() => {
|
|
974
|
-
if (loadOrder
|
|
955
|
+
if (loadOrder) return; // Skip if we have a loadOrder
|
|
975
956
|
|
|
976
957
|
const orderIdParam = searchParams.get("orderId");
|
|
977
958
|
if (orderIdParam) {
|
|
978
959
|
setOrderId(orderIdParam);
|
|
979
960
|
setActivePanel(PanelView.ORDER_DETAILS);
|
|
980
961
|
}
|
|
981
|
-
}, [searchParams, loadOrder
|
|
962
|
+
}, [searchParams, loadOrder]);
|
|
982
963
|
|
|
983
964
|
const onSelectOrder = (selectedOrderId: string) => {
|
|
984
965
|
setOrderId(selectedOrderId);
|
|
985
966
|
navigateToPanel(PanelView.ORDER_DETAILS, "forward");
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
992
|
-
}
|
|
967
|
+
// Update URL with the new orderId and preserve existing parameters
|
|
968
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
969
|
+
params.set("orderId", selectedOrderId);
|
|
970
|
+
// Keep existing paymentMethod if present
|
|
971
|
+
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
993
972
|
};
|
|
994
973
|
|
|
995
974
|
// Save custom recipients to local storage when they change
|
|
@@ -1077,7 +1056,7 @@ function AnySpendInner({
|
|
|
1077
1056
|
<div className={"mx-auto flex w-[460px] max-w-full flex-col items-center gap-2 pt-5"}>
|
|
1078
1057
|
<div className={"flex w-full max-w-full flex-col items-center gap-2 px-5"}>
|
|
1079
1058
|
{/* Token Header - Show when in buy mode */}
|
|
1080
|
-
{isBuyMode &&
|
|
1059
|
+
{isBuyMode && (
|
|
1081
1060
|
<div className="mb-4 flex flex-col items-center gap-3 text-center">
|
|
1082
1061
|
{selectedDstToken.metadata?.logoURI && (
|
|
1083
1062
|
<div className="relative">
|
|
@@ -1283,7 +1262,7 @@ function AnySpendInner({
|
|
|
1283
1262
|
}
|
|
1284
1263
|
}}
|
|
1285
1264
|
>
|
|
1286
|
-
{mode !== "page" &&
|
|
1265
|
+
{mode !== "page" && <BottomNavigation />}
|
|
1287
1266
|
</TabsPrimitive>
|
|
1288
1267
|
</div>
|
|
1289
1268
|
</div>
|
|
@@ -1305,18 +1284,16 @@ function AnySpendInner({
|
|
|
1305
1284
|
onOrderCreated={orderId => {
|
|
1306
1285
|
setOrderId(orderId);
|
|
1307
1286
|
navigateToPanel(PanelView.ORDER_DETAILS, "forward");
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
params.set("paymentMethod", selectedCryptoPaymentMethod);
|
|
1317
|
-
}
|
|
1318
|
-
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
1287
|
+
// Add orderId and payment method to URL for persistence
|
|
1288
|
+
const params = new URLSearchParams(searchParams.toString()); // Preserve existing params
|
|
1289
|
+
params.set("orderId", orderId);
|
|
1290
|
+
// For fiat payments, the payment method is always fiat (but we use the active tab context)
|
|
1291
|
+
if (activeTab === "fiat") {
|
|
1292
|
+
params.set("paymentMethod", "fiat");
|
|
1293
|
+
} else if (selectedCryptoPaymentMethod !== CryptoPaymentMethodType.NONE) {
|
|
1294
|
+
params.set("paymentMethod", selectedCryptoPaymentMethod);
|
|
1319
1295
|
}
|
|
1296
|
+
router.push(`${window.location.pathname}?${params.toString()}`);
|
|
1320
1297
|
}}
|
|
1321
1298
|
onBack={navigateBack}
|
|
1322
1299
|
recipientEnsName={globalWallet?.ensName}
|
|
@@ -57,7 +57,7 @@ export interface AnySpendCustomExactInProps {
|
|
|
57
57
|
customUsdInputValues?: string[];
|
|
58
58
|
preferEoa?: boolean;
|
|
59
59
|
customExactInConfig?: CustomExactInConfig;
|
|
60
|
-
orderType?: "hype_duel" | "custom_exact_in"
|
|
60
|
+
orderType?: "hype_duel" | "custom_exact_in";
|
|
61
61
|
minDestinationAmount?: number;
|
|
62
62
|
header?: ({
|
|
63
63
|
anyspendPrice,
|
|
@@ -147,6 +147,7 @@ function AnySpendCustomExactInInner({
|
|
|
147
147
|
paymentType,
|
|
148
148
|
recipientAddress,
|
|
149
149
|
loadOrder,
|
|
150
|
+
isDepositMode: true,
|
|
150
151
|
onTransactionSuccess: onSuccess,
|
|
151
152
|
sourceTokenAddress,
|
|
152
153
|
sourceTokenChainId,
|
|
@@ -313,7 +314,7 @@ function AnySpendCustomExactInInner({
|
|
|
313
314
|
);
|
|
314
315
|
|
|
315
316
|
const mainView = (
|
|
316
|
-
<div className="
|
|
317
|
+
<div className="mx-auto flex w-[460px] max-w-full flex-col items-center gap-2">
|
|
317
318
|
{headerContent}
|
|
318
319
|
|
|
319
320
|
<div className="relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2">
|
|
@@ -90,7 +90,6 @@ function getOrderSuccessText({
|
|
|
90
90
|
let actionText = "";
|
|
91
91
|
switch (order.type) {
|
|
92
92
|
case "swap":
|
|
93
|
-
case "deposit_first":
|
|
94
93
|
actionText = `sent ${formattedActualDstAmount || "--"} ${dstToken.symbol}`;
|
|
95
94
|
return `Successfully ${actionText} to ${recipient}`;
|
|
96
95
|
case "mint_nft":
|
|
@@ -248,7 +247,6 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
248
247
|
const { data: walletClient } = useWalletClient();
|
|
249
248
|
const [txHash, setTxHash] = useState<`0x${string}` | undefined>();
|
|
250
249
|
const [showQRCode, setShowQRCode] = useState(false);
|
|
251
|
-
const [orderDetailsOpen, setOrderDetailsOpen] = useState(true);
|
|
252
250
|
const { isLoading: txLoading, isSuccess: txSuccess } = useWaitForTransactionReceipt({ hash: txHash });
|
|
253
251
|
|
|
254
252
|
const { switchChainAndExecuteWithEOA, switchChainAndExecute, isSwitchingOrExecuting } =
|
|
@@ -445,8 +443,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
445
443
|
order.type === "mint_nft" ||
|
|
446
444
|
order.type === "join_tournament" ||
|
|
447
445
|
order.type === "fund_tournament" ||
|
|
448
|
-
order.type === "custom"
|
|
449
|
-
order.type === "deposit_first"
|
|
446
|
+
order.type === "custom"
|
|
450
447
|
? "0"
|
|
451
448
|
: order.payload.expectedDstAmount.toString();
|
|
452
449
|
const formattedExpectedDstAmount = formatTokenAmount(BigInt(expectedDstAmount), dstToken.decimals);
|
|
@@ -468,8 +465,6 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
468
465
|
recipientName={recipientName}
|
|
469
466
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
470
467
|
points={points}
|
|
471
|
-
isOpen={orderDetailsOpen}
|
|
472
|
-
onOpenChange={setOrderDetailsOpen}
|
|
473
468
|
/>
|
|
474
469
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
475
470
|
<AccordionItem value="refund-details" className="order-details-refund-item">
|
|
@@ -549,8 +544,6 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
549
544
|
recipientName={recipientName}
|
|
550
545
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
551
546
|
points={points}
|
|
552
|
-
isOpen={orderDetailsOpen}
|
|
553
|
-
onOpenChange={setOrderDetailsOpen}
|
|
554
547
|
/>
|
|
555
548
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
556
549
|
<AccordionItem value="execute-details" className="order-details-execute-item">
|
|
@@ -584,7 +577,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
584
577
|
? relayTxs.map(relayTx => (
|
|
585
578
|
<TransactionDetails
|
|
586
579
|
key={relayTx.txHash}
|
|
587
|
-
title="Processed
|
|
580
|
+
title="Processed Transaction"
|
|
588
581
|
chainId={relayTx.chain}
|
|
589
582
|
tx={relayTx}
|
|
590
583
|
delay={0.5}
|
|
@@ -595,7 +588,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
595
588
|
|
|
596
589
|
<TransactionDetails
|
|
597
590
|
title={
|
|
598
|
-
order.type === "swap"
|
|
591
|
+
order.type === "swap"
|
|
599
592
|
? "Processed Swap"
|
|
600
593
|
: order.type === "mint_nft"
|
|
601
594
|
? "Minted NFT"
|
|
@@ -679,8 +672,6 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
679
672
|
recipientName={recipientName}
|
|
680
673
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
681
674
|
points={points}
|
|
682
|
-
isOpen={orderDetailsOpen}
|
|
683
|
-
onOpenChange={setOrderDetailsOpen}
|
|
684
675
|
/>
|
|
685
676
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
686
677
|
<AccordionItem value="more-details" className="order-details-more-item">
|
|
@@ -712,12 +703,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
712
703
|
: null}
|
|
713
704
|
{relayTxs.map(relayTx => (
|
|
714
705
|
<TransactionDetails
|
|
715
|
-
|
|
716
|
-
title={
|
|
717
|
-
relayTx.chain === order.srcChain
|
|
718
|
-
? `Process swap on ${getChainName(relayTx.chain)}`
|
|
719
|
-
: `Received on ${getChainName(relayTx.chain)}`
|
|
720
|
-
}
|
|
706
|
+
title="Processed Transaction"
|
|
721
707
|
chainId={relayTx.chain}
|
|
722
708
|
isProcessing={false}
|
|
723
709
|
tx={relayTx}
|
|
@@ -727,8 +713,8 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
727
713
|
{order.status === "executing" && (
|
|
728
714
|
<TransactionDetails
|
|
729
715
|
title={
|
|
730
|
-
order.type === "swap" || order.type === "x402_swap"
|
|
731
|
-
? "Processing
|
|
716
|
+
order.type === "swap" || order.type === "x402_swap"
|
|
717
|
+
? "Processing Swap"
|
|
732
718
|
: order.type === "mint_nft"
|
|
733
719
|
? "Minting NFT"
|
|
734
720
|
: order.type === "join_tournament"
|
|
@@ -818,8 +804,6 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
818
804
|
recipientName={recipientName}
|
|
819
805
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
820
806
|
points={points}
|
|
821
|
-
isOpen={orderDetailsOpen}
|
|
822
|
-
onOpenChange={setOrderDetailsOpen}
|
|
823
807
|
/>
|
|
824
808
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
825
809
|
<AccordionItem value="deposit-details" className="order-details-deposit-item">
|
|
@@ -858,8 +842,8 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
858
842
|
) : depositEnoughAmount ? (
|
|
859
843
|
<TransactionDetails
|
|
860
844
|
title={
|
|
861
|
-
order.type === "swap"
|
|
862
|
-
? "Processing
|
|
845
|
+
order.type === "swap"
|
|
846
|
+
? "Processing Swap"
|
|
863
847
|
: order.type === "mint_nft"
|
|
864
848
|
? "Minting NFT"
|
|
865
849
|
: order.type === "join_tournament"
|
|
@@ -1101,8 +1085,6 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
1101
1085
|
recipientName={recipientName}
|
|
1102
1086
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
1103
1087
|
points={points}
|
|
1104
|
-
isOpen={orderDetailsOpen}
|
|
1105
|
-
onOpenChange={setOrderDetailsOpen}
|
|
1106
1088
|
/>
|
|
1107
1089
|
)}
|
|
1108
1090
|
|
|
@@ -29,8 +29,6 @@ interface OrderDetailsCollapsibleProps {
|
|
|
29
29
|
showTotal?: boolean;
|
|
30
30
|
totalAmount?: string;
|
|
31
31
|
points?: number;
|
|
32
|
-
isOpen?: boolean;
|
|
33
|
-
onOpenChange?: (isOpen: boolean) => void;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
@@ -44,22 +42,15 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
|
44
42
|
showTotal = false,
|
|
45
43
|
totalAmount,
|
|
46
44
|
points,
|
|
47
|
-
isOpen,
|
|
48
|
-
onOpenChange,
|
|
49
45
|
}: OrderDetailsCollapsibleProps) {
|
|
50
|
-
const [
|
|
51
|
-
|
|
52
|
-
// Use controlled mode if isOpen is provided, otherwise use internal state
|
|
53
|
-
const showOrderDetails = isOpen !== undefined ? isOpen : internalOpen;
|
|
54
|
-
const setShowOrderDetails = onOpenChange || setInternalOpen;
|
|
46
|
+
const [showOrderDetails, setShowOrderDetails] = useState(true);
|
|
55
47
|
|
|
56
48
|
// Calculate expected amount if not provided
|
|
57
49
|
const expectedDstAmount =
|
|
58
50
|
order.type === "mint_nft" ||
|
|
59
51
|
order.type === "join_tournament" ||
|
|
60
52
|
order.type === "fund_tournament" ||
|
|
61
|
-
order.type === "custom"
|
|
62
|
-
order.type === "deposit_first"
|
|
53
|
+
order.type === "custom"
|
|
63
54
|
? "0"
|
|
64
55
|
: order.payload.expectedDstAmount.toString();
|
|
65
56
|
|
|
@@ -104,12 +95,9 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
|
104
95
|
<div className="order-details-divider divider w-full" />
|
|
105
96
|
|
|
106
97
|
{/* Expected Amount/Action Section */}
|
|
107
|
-
<div className="order-details-expected-section flex w-full items-
|
|
108
|
-
<div className="order-details-expected-label text-as-tertiarry
|
|
109
|
-
{order.type === "swap" ||
|
|
110
|
-
order.type === "deposit_first" ||
|
|
111
|
-
order.type === "mint_nft" ||
|
|
112
|
-
order.type === "hype_duel"
|
|
98
|
+
<div className="order-details-expected-section flex w-full items-center justify-between gap-2">
|
|
99
|
+
<div className="order-details-expected-label text-as-tertiarry">
|
|
100
|
+
{order.type === "swap" || order.type === "mint_nft" || order.type === "hype_duel"
|
|
113
101
|
? "Expected to receive"
|
|
114
102
|
: order.type === "join_tournament"
|
|
115
103
|
? "Join tournament"
|
|
@@ -122,9 +110,9 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
|
122
110
|
: ""}
|
|
123
111
|
</div>
|
|
124
112
|
|
|
125
|
-
<div className="order-details-expected-value flex
|
|
126
|
-
{order.type === "swap"
|
|
127
|
-
|
|
113
|
+
<div className="order-details-expected-value flex items-end gap-2">
|
|
114
|
+
{order.type === "swap" ? (
|
|
115
|
+
`~${finalFormattedExpectedDstAmount} ${dstToken.symbol}`
|
|
128
116
|
) : order.type === "mint_nft" ? (
|
|
129
117
|
<div className="order-details-nft-info flex items-center gap-2">
|
|
130
118
|
<img src={nft?.imageUrl} alt={nft?.name || "NFT"} className="order-details-nft-image h-5 w-5" />
|
|
@@ -13,7 +13,7 @@ export const OrderStatus = memo(function OrderStatus({
|
|
|
13
13
|
order: components["schemas"]["Order"];
|
|
14
14
|
selectedCryptoPaymentMethod?: CryptoPaymentMethodType;
|
|
15
15
|
}) {
|
|
16
|
-
const
|
|
16
|
+
const isComplete = order.status === "executed";
|
|
17
17
|
const { text, status: displayStatus, description } = getStatusDisplay(order);
|
|
18
18
|
const searchParams = useSearchParams();
|
|
19
19
|
const cryptoPaymentMethod = selectedCryptoPaymentMethod || searchParams.get("cryptoPaymentMethod");
|
|
@@ -51,7 +51,7 @@ export const OrderStatus = memo(function OrderStatus({
|
|
|
51
51
|
|
|
52
52
|
return (
|
|
53
53
|
<div className="flex items-center justify-center gap-2">
|
|
54
|
-
{
|
|
54
|
+
{isComplete ? (
|
|
55
55
|
<div className="flex flex-col items-center">
|
|
56
56
|
<div className={`bg-as-success-secondary relative flex h-10 w-10 items-center justify-center rounded-full`}>
|
|
57
57
|
<Check className="text-as-content-icon-success h-6 w-6" />
|
|
@@ -5,8 +5,6 @@ export { AnySpendBuySpin } from "./AnySpendBuySpin";
|
|
|
5
5
|
export { AnySpendCollectorClubPurchase } from "./AnySpendCollectorClubPurchase";
|
|
6
6
|
export { AnySpendCustom } from "./AnySpendCustom";
|
|
7
7
|
export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn";
|
|
8
|
-
export { AnySpendDeposit } from "./AnySpendDeposit";
|
|
9
|
-
export type { AnySpendDepositProps, ChainConfig, DepositContractConfig } from "./AnySpendDeposit";
|
|
10
8
|
export { AnySpendDepositHype, HYPE_TOKEN_DETAILS } from "./AnyspendDepositHype";
|
|
11
9
|
export * from "./AnySpendFingerprintWrapper";
|
|
12
10
|
export { AnySpendNFT } from "./AnySpendNFT";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from "./useAnyspendCreateOnrampOrder";
|
|
2
2
|
export * from "./useAnyspendCreateOrder";
|
|
3
|
-
export * from "./useCreateDepositFirstOrder";
|
|
4
3
|
export * from "./useAnyspendOrderAndTransactions";
|
|
5
4
|
export * from "./useAnyspendOrderHistory";
|
|
6
5
|
export * from "./useAnyspendQuote";
|
|
@@ -21,7 +21,6 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
21
21
|
import { parseUnits } from "viem";
|
|
22
22
|
import { base, mainnet } from "viem/chains";
|
|
23
23
|
import { components } from "../../types/api";
|
|
24
|
-
import { GetQuoteRequest } from "../../types/api_req_res";
|
|
25
24
|
import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod";
|
|
26
25
|
import { FiatPaymentMethod } from "../components/common/FiatPaymentMethod";
|
|
27
26
|
import { useAutoSelectCryptoPaymentMethod } from "./useAutoSelectCryptoPaymentMethod";
|
|
@@ -53,7 +52,7 @@ interface UseAnyspendFlowProps {
|
|
|
53
52
|
destinationTokenChainId?: number;
|
|
54
53
|
slippage?: number;
|
|
55
54
|
disableUrlParamManagement?: boolean;
|
|
56
|
-
orderType?: "hype_duel" | "custom_exact_in"
|
|
55
|
+
orderType?: "hype_duel" | "custom_exact_in";
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
// This hook serves for order hype_duel and custom_exact_in
|
|
@@ -61,6 +60,7 @@ export function useAnyspendFlow({
|
|
|
61
60
|
paymentType = "crypto",
|
|
62
61
|
recipientAddress,
|
|
63
62
|
loadOrder,
|
|
63
|
+
isDepositMode = false,
|
|
64
64
|
onOrderSuccess,
|
|
65
65
|
onTransactionSuccess,
|
|
66
66
|
sourceTokenAddress,
|
|
@@ -199,41 +199,16 @@ export function useAnyspendFlow({
|
|
|
199
199
|
// For fiat payments, always use USDC decimals (6) regardless of selectedSrcToken
|
|
200
200
|
const effectiveDecimals = paymentType === "fiat" ? USDC_BASE.decimals : selectedSrcToken.decimals;
|
|
201
201
|
const activeInputAmountInWei = parseUnits(srcAmount.replace(/,/g, ""), effectiveDecimals).toString();
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
if (orderType === "swap") {
|
|
215
|
-
return {
|
|
216
|
-
...baseParams,
|
|
217
|
-
type: "swap" as const,
|
|
218
|
-
tradeType: "EXACT_INPUT" as const,
|
|
219
|
-
amount: activeInputAmountInWei,
|
|
220
|
-
};
|
|
221
|
-
} else if (orderType === "hype_duel") {
|
|
222
|
-
return {
|
|
223
|
-
...baseParams,
|
|
224
|
-
type: "hype_duel" as const,
|
|
225
|
-
amount: activeInputAmountInWei,
|
|
226
|
-
};
|
|
227
|
-
} else {
|
|
228
|
-
return {
|
|
229
|
-
...baseParams,
|
|
230
|
-
type: "custom_exact_in" as const,
|
|
231
|
-
amount: activeInputAmountInWei,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
})();
|
|
235
|
-
|
|
236
|
-
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote(quoteRequest);
|
|
202
|
+
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote({
|
|
203
|
+
srcChain: paymentType === "fiat" ? base.id : selectedSrcChainId,
|
|
204
|
+
dstChain: isDepositMode ? base.id : selectedDstChainId, // For deposits, always Base; for swaps, use selected destination
|
|
205
|
+
srcTokenAddress: paymentType === "fiat" ? USDC_BASE.address : selectedSrcToken.address,
|
|
206
|
+
dstTokenAddress: selectedDstToken.address,
|
|
207
|
+
type: orderType,
|
|
208
|
+
amount: activeInputAmountInWei,
|
|
209
|
+
recipientAddress: effectiveRecipientAddress,
|
|
210
|
+
onrampVendor: paymentType === "fiat" ? getOnrampVendor(selectedFiatPaymentMethod) : undefined,
|
|
211
|
+
});
|
|
237
212
|
|
|
238
213
|
// Get geo options for fiat
|
|
239
214
|
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(
|
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
|
-
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
3
2
|
|
|
4
3
|
export const getStatusDisplay = (
|
|
5
4
|
order: components["schemas"]["Order"],
|
|
6
5
|
): { text: string; status: "processing" | "success" | "failure"; description?: string } => {
|
|
7
|
-
const srcToken = order.metadata?.srcToken;
|
|
8
|
-
const dstToken = order.metadata?.dstToken;
|
|
9
|
-
const formattedSrcAmount = srcToken ? formatTokenAmount(BigInt(order.srcAmount), srcToken.decimals) : undefined;
|
|
10
|
-
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
11
|
-
const formattedActualDstAmount =
|
|
12
|
-
actualDstAmount && dstToken ? formatTokenAmount(BigInt(actualDstAmount), dstToken.decimals) : undefined;
|
|
13
|
-
|
|
14
6
|
switch (order.status) {
|
|
15
|
-
case "scanning_deposit_transaction":
|
|
16
|
-
const depositText =
|
|
17
|
-
formattedSrcAmount && srcToken
|
|
18
|
-
? `Awaiting ${formattedSrcAmount} ${srcToken.symbol}`
|
|
19
|
-
: order.onrampMetadata
|
|
20
|
-
? "Awaiting Payment"
|
|
21
|
-
: "Awaiting Deposit";
|
|
7
|
+
case "scanning_deposit_transaction":
|
|
22
8
|
return {
|
|
23
|
-
text:
|
|
9
|
+
text: order.onrampMetadata ? "Awaiting Payment" : "Awaiting Deposit",
|
|
24
10
|
status: "processing",
|
|
25
11
|
};
|
|
26
|
-
}
|
|
27
12
|
case "waiting_stripe_payment":
|
|
28
13
|
return {
|
|
29
14
|
text: "Awaiting Payment",
|
|
@@ -49,18 +34,16 @@ export const getStatusDisplay = (
|
|
|
49
34
|
description: "It will take approximately one minute to complete.",
|
|
50
35
|
};
|
|
51
36
|
case "executed": {
|
|
52
|
-
const receivedText =
|
|
53
|
-
formattedActualDstAmount && dstToken ? `Received ${formattedActualDstAmount} ${dstToken.symbol}` : undefined;
|
|
54
37
|
const { text, description } =
|
|
55
38
|
order.type === "swap"
|
|
56
|
-
? { text:
|
|
39
|
+
? { text: "Swap Complete", description: "Your swap has been completed successfully." }
|
|
57
40
|
: order.type === "mint_nft"
|
|
58
41
|
? { text: "NFT Minted", description: "Your NFT has been minted" }
|
|
59
42
|
: order.type === "join_tournament"
|
|
60
43
|
? { text: "Tournament Joined", description: "You have joined the tournament" }
|
|
61
44
|
: order.type === "fund_tournament"
|
|
62
45
|
? { text: "Tournament Funded", description: "You have funded the tournament" }
|
|
63
|
-
: { text:
|
|
46
|
+
: { text: "Order Complete", description: "Your order has been completed" };
|
|
64
47
|
return { text, status: "success", description };
|
|
65
48
|
}
|
|
66
49
|
|
|
@@ -76,19 +59,8 @@ export const getStatusDisplay = (
|
|
|
76
59
|
description: "This order has failed. Please try again or contact support.",
|
|
77
60
|
};
|
|
78
61
|
|
|
79
|
-
case "quoting_after_deposit": {
|
|
80
|
-
return {
|
|
81
|
-
text: "Quoting After Deposit",
|
|
82
|
-
status: "processing",
|
|
83
|
-
description: "Getting quote for the order",
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
62
|
default:
|
|
88
|
-
|
|
89
|
-
text: order.status,
|
|
90
|
-
status: "processing",
|
|
91
|
-
};
|
|
63
|
+
throw new Error("Invalid order status");
|
|
92
64
|
}
|
|
93
65
|
};
|
|
94
66
|
|
|
@@ -151,10 +151,6 @@ export interface AnySpendModalProps extends BaseModalProps {
|
|
|
151
151
|
customUsdInputValues?: string[];
|
|
152
152
|
/** Client-provided reference ID for tracking orders */
|
|
153
153
|
clientReferenceId?: string;
|
|
154
|
-
/** Whether to hide the header */
|
|
155
|
-
hideHeader?: boolean;
|
|
156
|
-
/** When true, disables URL parameter management for swap configuration */
|
|
157
|
-
disableUrlParamManagement?: boolean;
|
|
158
154
|
}
|
|
159
155
|
|
|
160
156
|
/**
|