@b3dotfun/sdk 0.1.65 → 0.1.66-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +7 -16
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +151 -22
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -50
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +4 -2
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendWorkflowTrigger.d.ts +31 -0
- package/dist/cjs/anyspend/react/components/AnySpendWorkflowTrigger.js +14 -0
- package/dist/cjs/anyspend/react/components/QRDeposit.js +5 -13
- package/dist/cjs/anyspend/react/components/ccShopAbi.d.ts +113 -0
- package/dist/cjs/anyspend/react/components/ccShopAbi.js +63 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +1 -3
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +3 -3
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +1 -4
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +3 -57
- package/dist/cjs/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/index.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/index.js +3 -1
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useOnOrderSuccess.d.ts +10 -0
- package/dist/cjs/anyspend/react/hooks/useOnOrderSuccess.js +27 -0
- package/dist/cjs/anyspend/services/anyspend.d.ts +2 -1
- package/dist/cjs/anyspend/services/anyspend.js +2 -1
- package/dist/cjs/anyspend/utils/chain.d.ts +1 -1
- package/dist/cjs/anyspend/utils/chain.js +72 -62
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +4 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +10 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +37 -1
- package/dist/cjs/global-account/react/stores/userStore.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +7 -16
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +6 -1
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +152 -23
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +4 -17
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +2 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +4 -2
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendWorkflowTrigger.d.ts +31 -0
- package/dist/esm/anyspend/react/components/AnySpendWorkflowTrigger.js +11 -0
- package/dist/esm/anyspend/react/components/QRDeposit.js +6 -14
- package/dist/esm/anyspend/react/components/ccShopAbi.d.ts +113 -0
- package/dist/esm/anyspend/react/components/ccShopAbi.js +60 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +1 -3
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +3 -3
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +1 -4
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +2 -56
- package/dist/esm/anyspend/react/components/common/PaySection.js +1 -1
- package/dist/esm/anyspend/react/components/index.d.ts +2 -0
- package/dist/esm/anyspend/react/components/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOnrampOrder.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -0
- package/dist/esm/anyspend/react/hooks/useOnOrderSuccess.d.ts +10 -0
- package/dist/esm/anyspend/react/hooks/useOnOrderSuccess.js +24 -0
- package/dist/esm/anyspend/services/anyspend.d.ts +2 -1
- package/dist/esm/anyspend/services/anyspend.js +2 -1
- package/dist/esm/anyspend/utils/chain.d.ts +1 -1
- package/dist/esm/anyspend/utils/chain.js +72 -62
- package/dist/esm/global-account/react/components/B3DynamicModal.js +4 -0
- package/dist/esm/global-account/react/hooks/useUserQuery.js +11 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +37 -1
- package/dist/esm/global-account/react/stores/userStore.js +1 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +6 -1
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +2 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendWorkflowTrigger.d.ts +31 -0
- package/dist/types/anyspend/react/components/ccShopAbi.d.ts +113 -0
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +1 -3
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +1 -4
- package/dist/types/anyspend/react/components/index.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendCreateOrder.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useOnOrderSuccess.d.ts +10 -0
- package/dist/types/anyspend/services/anyspend.d.ts +2 -1
- package/dist/types/anyspend/utils/chain.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +37 -1
- package/package.json +1 -1
- package/src/anyspend/README.md +14 -0
- package/src/anyspend/docs/checkout-sessions.md +228 -0
- package/src/anyspend/docs/components.md +26 -0
- package/src/anyspend/docs/examples.md +58 -0
- package/src/anyspend/docs/hooks.md +32 -0
- package/src/anyspend/llms.txt +185 -0
- package/src/anyspend/react/components/AnySpend.tsx +9 -17
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +206 -22
- package/src/anyspend/react/components/AnySpendCustom.tsx +3 -18
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +5 -1
- package/src/anyspend/react/components/AnySpendDeposit.tsx +5 -0
- package/src/anyspend/react/components/AnySpendWorkflowTrigger.tsx +73 -0
- package/src/anyspend/react/components/QRDeposit.tsx +19 -15
- package/src/anyspend/react/components/ccShopAbi.ts +64 -0
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +0 -5
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +1 -70
- package/src/anyspend/react/components/common/PaySection.tsx +0 -1
- package/src/anyspend/react/components/index.ts +2 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -0
- package/src/anyspend/react/hooks/useOnOrderSuccess.ts +36 -0
- package/src/anyspend/services/anyspend.ts +3 -0
- package/src/anyspend/utils/chain.ts +81 -65
- package/src/global-account/react/components/B3DynamicModal.tsx +4 -0
- package/src/global-account/react/hooks/useUserQuery.ts +12 -1
- package/src/global-account/react/stores/useModalStore.ts +39 -2
- package/src/global-account/react/stores/userStore.ts +1 -0
|
@@ -11,9 +11,10 @@ import { simpleHashChainToChainName } from "../../../shared/utils/simplehash.js"
|
|
|
11
11
|
import invariant from "invariant";
|
|
12
12
|
import { ChevronRight, ChevronRightCircle, Info, Loader2 } from "lucide-react";
|
|
13
13
|
import { motion } from "motion/react";
|
|
14
|
-
import
|
|
14
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
15
15
|
import { base } from "viem/chains";
|
|
16
16
|
import { useCryptoPaymentMethodState } from "../hooks/useCryptoPaymentMethodState.js";
|
|
17
|
+
import { useOnOrderSuccess } from "../hooks/useOnOrderSuccess.js";
|
|
17
18
|
import { useRecipientAddressState } from "../hooks/useRecipientAddressState.js";
|
|
18
19
|
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
19
20
|
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
@@ -126,8 +127,6 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
126
127
|
globalAddress: currentWallet.address,
|
|
127
128
|
});
|
|
128
129
|
const [orderId, setOrderId] = useState(loadOrder);
|
|
129
|
-
// Track if onSuccess has been called for the current order
|
|
130
|
-
const onSuccessCalled = React.useRef(false);
|
|
131
130
|
const [srcChainId, setSrcChainId] = useState(base.id);
|
|
132
131
|
// Get token list for token balance check
|
|
133
132
|
const chainName = useMemo(() => simpleHashChainToChainName(srcChainId), [srcChainId]);
|
|
@@ -265,20 +264,8 @@ function AnySpendCustomInner({ loadOrder, mode = "modal", activeTab: activeTabPr
|
|
|
265
264
|
}, [activeTab, srcFiatAmountForGeoCheck]);
|
|
266
265
|
// Get geo data and onramp options (use srcFiatAmountForGeoCheck to check availability regardless of activeTab)
|
|
267
266
|
const { geoData, isOnrampSupported, coinbaseAvailablePaymentMethods, stripeOnrampSupport, stripeWeb2Support } = useGeoOnrampOptions(srcFiatAmountForGeoCheck);
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
console.log("Calling onSuccess");
|
|
271
|
-
const relayTxs = oat?.data?.relayTxs;
|
|
272
|
-
const lastRelayTxHash = relayTxs?.[relayTxs.length - 1]?.txHash;
|
|
273
|
-
const txHash = oat?.data?.executeTx?.txHash || lastRelayTxHash;
|
|
274
|
-
onSuccess?.(txHash);
|
|
275
|
-
onSuccessCalled.current = true;
|
|
276
|
-
}
|
|
277
|
-
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, oat?.data?.relayTxs, onSuccess]);
|
|
278
|
-
// Reset flag when orderId changes
|
|
279
|
-
useEffect(() => {
|
|
280
|
-
onSuccessCalled.current = false;
|
|
281
|
-
}, [orderId]);
|
|
267
|
+
// Call onSuccess when order is executed
|
|
268
|
+
useOnOrderSuccess({ orderData: oat, orderId, onSuccess });
|
|
282
269
|
const { createOrder: createRegularOrder, isCreatingOrder: isCreatingRegularOrder } = useAnyspendCreateOrder({
|
|
283
270
|
onSuccess: data => {
|
|
284
271
|
setOrderId(data.data.id);
|
|
@@ -44,6 +44,8 @@ export interface AnySpendCustomExactInProps {
|
|
|
44
44
|
classes?: AnySpendCustomExactInClasses;
|
|
45
45
|
/** When true, allows direct transfer without swap if source and destination token/chain are the same */
|
|
46
46
|
allowDirectTransfer?: boolean;
|
|
47
|
+
/** Opaque metadata passed to the order for callbacks (e.g., workflow form data) */
|
|
48
|
+
callbackMetadata?: Record<string, unknown>;
|
|
47
49
|
}
|
|
48
50
|
export declare function AnySpendCustomExactIn(props: AnySpendCustomExactInProps): import("react/jsx-runtime").JSX.Element;
|
|
49
51
|
export {};
|
|
@@ -29,7 +29,7 @@ export function AnySpendCustomExactIn(props) {
|
|
|
29
29
|
const fingerprintConfig = getFingerprintConfig();
|
|
30
30
|
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomExactInInner, { ...props }) }));
|
|
31
31
|
}
|
|
32
|
-
function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, destinationTokenAmount, orderType = "custom_exact_in", minDestinationAmount, header, returnToHomeUrl, customRecipientLabel, returnHomeLabel, classes, allowDirectTransfer = false, }) {
|
|
32
|
+
function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddress, paymentType = "crypto", sourceTokenAddress, sourceTokenChainId, destinationToken, destinationChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, customExactInConfig, destinationTokenAmount, orderType = "custom_exact_in", minDestinationAmount, header, returnToHomeUrl, customRecipientLabel, returnHomeLabel, classes, allowDirectTransfer = false, callbackMetadata, }) {
|
|
33
33
|
const actionLabel = customExactInConfig?.action ?? "Custom Execution";
|
|
34
34
|
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
35
35
|
const DESTINATION_TOKEN_DETAILS = {
|
|
@@ -222,7 +222,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
222
222
|
};
|
|
223
223
|
const headerContent = header ? (header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote })) : (_jsx("div", { className: "mb-4 flex flex-col items-center gap-3 text-center", children: _jsxs("div", { children: [_jsx("h1", { className: "text-as-primary text-xl font-bold", children: actionLabel }), _jsx("p", { className: "text-as-secondary text-sm", children: "Pay from any token to execute a custom exact-in transaction." })] }) }));
|
|
224
224
|
const mainView = (_jsxs("div", { className: classes?.container ||
|
|
225
|
-
"anyspend-custom-exact-in-container mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [headerContent, _jsx("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, isSrcInputDirty: isSrcInputDirty, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect
|
|
225
|
+
"anyspend-custom-exact-in-container mx-auto flex w-[460px] max-w-full flex-col items-center gap-2", children: [headerContent, _jsx("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: _jsxs("div", { className: "relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2", children: [paymentType === "crypto" ? (_jsx(CryptoPaySection, { selectedSrcChainId: selectedSrcChainId, setSelectedSrcChainId: setSelectedSrcChainId, selectedSrcToken: selectedSrcToken, setSelectedSrcToken: setSelectedSrcToken, srcAmount: srcAmount, setSrcAmount: setSrcAmount, isSrcInputDirty: isSrcInputDirty, setIsSrcInputDirty: setIsSrcInputDirty, selectedCryptoPaymentMethod: effectiveCryptoPaymentMethod, onSelectCryptoPaymentMethod: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), anyspendQuote: anyspendQuote, onTokenSelect: onTokenSelect })) : (_jsx(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, children: _jsx(PanelOnramp, { srcAmountOnRamp: srcAmount, setSrcAmountOnRamp: setSrcAmount, selectedPaymentMethod: selectedFiatPaymentMethod, setActivePanel: setActivePanel, _recipientAddress: selectedRecipientOrDefault, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, dstTokenSymbol: DESTINATION_TOKEN_DETAILS.SYMBOL, hideDstToken: true, destinationAmount: dstAmount, onDestinationTokenChange: () => { }, onDestinationChainChange: () => { }, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, anyspendQuote: anyspendQuote, onShowPointsDetail: () => setActivePanel(PanelView.POINTS_DETAIL), onShowFeeDetail: () => setActivePanel(PanelView.FEE_DETAIL), customUsdInputValues: customUsdInputValues, customRecipientLabel: customRecipientLabel }) })), _jsx("div", { className: cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden"), children: _jsx(Button, { variant: "ghost", className: classes?.swapDirectionButton ||
|
|
226
226
|
"swap-direction-button border-as-stroke bg-as-surface-primary z-10 h-10 w-10 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", children: _jsx("div", { className: "relative flex items-center justify-center transition-opacity", children: _jsx(ArrowDown, { className: "text-as-primary/50 h-5 w-5" }) }) }) }), paymentType === "crypto" && (_jsx(CryptoReceiveSection, { isDepositMode: false, isBuyMode: false, effectiveRecipientAddress: selectedRecipientOrDefault, recipientName: recipientName || undefined, customRecipientLabel: customRecipientLabel, onSelectRecipient: () => setActivePanel(PanelView.RECIPIENT_SELECTION), dstAmount: isSrcInputDirty && !destinationTokenAmount ? dstAmount : dstAmountInput, dstToken: selectedDstToken, dstTokenSymbol: DESTINATION_TOKEN_DETAILS.SYMBOL, dstTokenLogoURI: DESTINATION_TOKEN_DETAILS.LOGO_URI, selectedDstChainId: selectedDstChainId, setSelectedDstChainId: () => { }, setSelectedDstToken: () => { }, isSrcInputDirty: isSrcInputDirty, onChangeDstAmount: value => {
|
|
227
227
|
setIsSrcInputDirty(false);
|
|
228
228
|
setDstAmountInput(value);
|
|
@@ -278,6 +278,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
278
278
|
? normalizeAddress(customExactInConfig.spenderAddress)
|
|
279
279
|
: undefined,
|
|
280
280
|
},
|
|
281
|
+
callbackMetadata,
|
|
281
282
|
});
|
|
282
283
|
}
|
|
283
284
|
else {
|
|
@@ -295,6 +296,7 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
295
296
|
expectedDstAmount: expectedDstAmountRaw,
|
|
296
297
|
creatorAddress: globalAddress,
|
|
297
298
|
payload,
|
|
299
|
+
callbackMetadata,
|
|
298
300
|
});
|
|
299
301
|
}
|
|
300
302
|
}
|
|
@@ -101,6 +101,8 @@ export interface AnySpendDepositProps {
|
|
|
101
101
|
allowDirectTransfer?: boolean;
|
|
102
102
|
/** Fixed destination token amount (in wei/smallest unit). When provided, user cannot change the amount. */
|
|
103
103
|
destinationTokenAmount?: string;
|
|
104
|
+
/** Opaque metadata passed to the order for callbacks (e.g., workflow form data) */
|
|
105
|
+
callbackMetadata?: Record<string, unknown>;
|
|
104
106
|
}
|
|
105
107
|
/**
|
|
106
108
|
* A flexible deposit component that wraps AnySpendCustomExactIn with optional chain selection.
|
|
@@ -137,4 +139,4 @@ export interface AnySpendDepositProps {
|
|
|
137
139
|
* onSuccess={(amount) => console.log(`Deposited ${amount}`)}
|
|
138
140
|
* />
|
|
139
141
|
*/
|
|
140
|
-
export declare function AnySpendDeposit({ loadOrder, mode, recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationTokenAddress, destinationTokenChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains, minPoolSize, topChainsCount, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, isCustomDeposit, classes, allowDirectTransfer, destinationTokenAmount, }: AnySpendDepositProps): import("react/jsx-runtime").JSX.Element | null;
|
|
142
|
+
export declare function AnySpendDeposit({ loadOrder, mode, recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationTokenAddress, destinationTokenChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains, minPoolSize, topChainsCount, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, isCustomDeposit, classes, allowDirectTransfer, destinationTokenAmount, callbackMetadata, }: AnySpendDepositProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -94,7 +94,7 @@ function ChainIcon({ chainId, className }) {
|
|
|
94
94
|
* onSuccess={(amount) => console.log(`Deposited ${amount}`)}
|
|
95
95
|
* />
|
|
96
96
|
*/
|
|
97
|
-
export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationTokenAddress, destinationTokenChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains = DEFAULT_SUPPORTED_CHAINS, minPoolSize = DEFAULT_MIN_POOL_SIZE, topChainsCount = 3, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, isCustomDeposit = false, classes, allowDirectTransfer = false, destinationTokenAmount, }) {
|
|
97
|
+
export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, paymentType: initialPaymentType, sourceTokenAddress, sourceTokenChainId: initialSourceChainId, destinationTokenAddress, destinationTokenChainId, onSuccess, onOpenCustomModal, mainFooter, onTokenSelect, customUsdInputValues, preferEoa, minDestinationAmount, header, orderType, depositContractConfig, showChainSelection, supportedChains = DEFAULT_SUPPORTED_CHAINS, minPoolSize = DEFAULT_MIN_POOL_SIZE, topChainsCount = 3, onClose, returnToHomeUrl, customRecipientLabel, returnHomeLabel, isCustomDeposit = false, classes, allowDirectTransfer = false, destinationTokenAmount, callbackMetadata, }) {
|
|
98
98
|
// Extract deposit-specific classes for convenience
|
|
99
99
|
const depositClasses = classes?.deposit;
|
|
100
100
|
const { connectedEOAWallet } = useAccountWallet();
|
|
@@ -206,5 +206,5 @@ export function AnySpendDeposit({ loadOrder, mode = "modal", recipientAddress, p
|
|
|
206
206
|
// Deposit view
|
|
207
207
|
return (_jsxs("div", { className: depositClasses?.form || "anyspend-deposit anyspend-deposit-form relative", children: [shouldShowChainSelection && (_jsxs("button", { onClick: handleBack, className: depositClasses?.backButton ||
|
|
208
208
|
"anyspend-deposit-back-button text-as-secondary hover:text-as-primary absolute left-4 top-4 z-10 flex items-center gap-1", children: [_jsx("svg", { className: depositClasses?.backIcon || "anyspend-deposit-back-icon h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }), _jsx("span", { className: depositClasses?.backText || "anyspend-deposit-back-text text-sm", children: "Back" })] })), onClose && (_jsx("button", { onClick: onClose, className: depositClasses?.closeButton ||
|
|
209
|
-
"anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: _jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), _jsx("div", { className: depositClasses?.formContent || cn("anyspend-deposit-form-content", shouldShowChainSelection && "pt-8"), children: isCustomDeposit ? (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, paymentType: paymentType, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: selectedChainId, destinationToken: destinationToken, destinationChainId: destinationTokenChainId, orderType: effectiveOrderType, minDestinationAmount: minDestinationAmount, header: header ?? defaultHeader, onSuccess: onSuccess, onOpenCustomModal: onOpenCustomModal, mainFooter: mainFooter, onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, preferEoa: preferEoa, customExactInConfig: depositContractConfig, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel, classes: classes?.customExactIn, allowDirectTransfer: allowDirectTransfer, destinationTokenAmount: destinationTokenAmount }, selectedChainId)) : (_jsx(AnySpend, { loadOrder: loadOrder, mode: mode, defaultActiveTab: paymentType, recipientAddress: recipientAddress, sourceChainId: selectedChainId, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, onSuccess: txHash => onSuccess?.(txHash ?? ""), onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, hideHeader: true, hideBottomNavigation: true, disableUrlParamManagement: true, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel, classes: classes?.anySpend, allowDirectTransfer: allowDirectTransfer, destinationTokenAmount: destinationTokenAmount }, selectedChainId)) }), _jsx(ChainWarningText, { chainId: destinationTokenChainId, classes: classes?.chainWarningText || { root: "px-4 pb-4" } })] }));
|
|
209
|
+
"anyspend-deposit-close-button text-as-secondary hover:text-as-primary absolute right-4 top-4 z-10", children: _jsx("svg", { className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })), _jsx("div", { className: depositClasses?.formContent || cn("anyspend-deposit-form-content", shouldShowChainSelection && "pt-8"), children: isCustomDeposit ? (_jsx(AnySpendCustomExactIn, { loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, paymentType: paymentType, sourceTokenAddress: sourceTokenAddress, sourceTokenChainId: selectedChainId, destinationToken: destinationToken, destinationChainId: destinationTokenChainId, orderType: effectiveOrderType, minDestinationAmount: minDestinationAmount, header: header ?? defaultHeader, onSuccess: onSuccess, onOpenCustomModal: onOpenCustomModal, mainFooter: mainFooter, onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, preferEoa: preferEoa, customExactInConfig: depositContractConfig, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel, classes: classes?.customExactIn, allowDirectTransfer: allowDirectTransfer, destinationTokenAmount: destinationTokenAmount, callbackMetadata: callbackMetadata }, selectedChainId)) : (_jsx(AnySpend, { loadOrder: loadOrder, mode: mode, defaultActiveTab: paymentType, recipientAddress: recipientAddress, sourceChainId: selectedChainId, destinationTokenAddress: destinationTokenAddress, destinationTokenChainId: destinationTokenChainId, onSuccess: txHash => onSuccess?.(txHash ?? ""), onTokenSelect: onTokenSelect, customUsdInputValues: customUsdInputValues, hideHeader: true, hideBottomNavigation: true, disableUrlParamManagement: true, returnToHomeUrl: returnToHomeUrl, customRecipientLabel: customRecipientLabel, returnHomeLabel: returnHomeLabel, classes: classes?.anySpend, allowDirectTransfer: allowDirectTransfer, destinationTokenAmount: destinationTokenAmount, callbackMetadata: callbackMetadata }, selectedChainId)) }), _jsx(ChainWarningText, { chainId: destinationTokenChainId, classes: classes?.chainWarningText || { root: "px-4 pb-4" } })] }));
|
|
210
210
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AnySpendAllClasses } from "./types/classes";
|
|
2
|
+
export interface AnySpendWorkflowTriggerProps {
|
|
3
|
+
/** Payment recipient address (hex) */
|
|
4
|
+
recipientAddress: string;
|
|
5
|
+
/** Destination chain ID */
|
|
6
|
+
chainId: number;
|
|
7
|
+
/** Destination token address */
|
|
8
|
+
tokenAddress: string;
|
|
9
|
+
/** Required payment amount in token base units (wei) */
|
|
10
|
+
amount: string;
|
|
11
|
+
/** Workflow ID to trigger */
|
|
12
|
+
workflowId: string;
|
|
13
|
+
/** Organization ID that owns the workflow */
|
|
14
|
+
orgId: string;
|
|
15
|
+
/** Optional callback metadata merged into the order */
|
|
16
|
+
callbackMetadata?: {
|
|
17
|
+
/** Passed as trigger result inputs — accessible via {{root.result.inputs.*}} */
|
|
18
|
+
inputs?: Record<string, unknown>;
|
|
19
|
+
} & Record<string, unknown>;
|
|
20
|
+
/** Callback when payment succeeds */
|
|
21
|
+
onSuccess?: (amount: string) => void;
|
|
22
|
+
/** Callback when modal is closed */
|
|
23
|
+
onClose?: () => void;
|
|
24
|
+
/** Display mode */
|
|
25
|
+
mode?: "modal" | "page";
|
|
26
|
+
/** Custom action label */
|
|
27
|
+
actionLabel?: string;
|
|
28
|
+
/** Custom class names */
|
|
29
|
+
classes?: AnySpendAllClasses;
|
|
30
|
+
}
|
|
31
|
+
export declare function AnySpendWorkflowTrigger({ recipientAddress, chainId, tokenAddress, amount, workflowId, orgId, callbackMetadata, onSuccess, onClose, mode, actionLabel, classes, }: AnySpendWorkflowTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { AnySpendDeposit } from "./AnySpendDeposit.js";
|
|
4
|
+
export function AnySpendWorkflowTrigger({ recipientAddress, chainId, tokenAddress, amount, workflowId, orgId, callbackMetadata, onSuccess, onClose, mode, actionLabel, classes, }) {
|
|
5
|
+
const metadata = useMemo(() => ({
|
|
6
|
+
workflowId,
|
|
7
|
+
orgId,
|
|
8
|
+
...callbackMetadata,
|
|
9
|
+
}), [workflowId, orgId, callbackMetadata]);
|
|
10
|
+
return (_jsx(AnySpendDeposit, { recipientAddress: recipientAddress, destinationTokenAddress: tokenAddress, destinationTokenChainId: chainId, destinationTokenAmount: amount, callbackMetadata: metadata, onSuccess: onSuccess, onClose: onClose, mode: mode, actionLabel: actionLabel, classes: classes, allowDirectTransfer: true }));
|
|
11
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ALL_CHAINS, getAvailableChainIds, isSameChainAndToken } from "../../../anyspend/index.js";
|
|
2
|
+
import { ALL_CHAINS, getAvailableChainIds, getPaymentUrl, isSameChainAndToken, ZERO_ADDRESS, } from "../../../anyspend/index.js";
|
|
3
3
|
import { Button, toast } from "../../../global-account/react/index.js";
|
|
4
4
|
import { cn } from "../../../shared/utils/cn.js";
|
|
5
5
|
import { TokenSelector } from "@relayprotocol/relay-kit-ui";
|
|
@@ -8,6 +8,7 @@ import { QRCodeSVG } from "qrcode.react";
|
|
|
8
8
|
import { useEffect, useRef, useState } from "react";
|
|
9
9
|
import { useAnyspendOrderAndTransactions } from "../hooks/useAnyspendOrderAndTransactions.js";
|
|
10
10
|
import { useCreateDepositFirstOrder } from "../hooks/useCreateDepositFirstOrder.js";
|
|
11
|
+
import { useOnOrderSuccess } from "../hooks/useOnOrderSuccess.js";
|
|
11
12
|
import { useWatchTransfer } from "../hooks/useWatchTransfer.js";
|
|
12
13
|
import { ChainTokenIcon } from "./common/ChainTokenIcon.js";
|
|
13
14
|
import { OrderDetails } from "./common/OrderDetails.js";
|
|
@@ -43,7 +44,6 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
|
|
|
43
44
|
const [orderId, setOrderId] = useState();
|
|
44
45
|
const [globalAddress, setGlobalAddress] = useState();
|
|
45
46
|
const orderCreatedRef = useRef(false);
|
|
46
|
-
const onSuccessCalled = useRef(false);
|
|
47
47
|
const [transferResult, setTransferResult] = useState(null);
|
|
48
48
|
// Source token/chain as state (can be changed by user)
|
|
49
49
|
const [sourceChainId, setSourceChainId] = useState(sourceChainIdProp ?? 8453);
|
|
@@ -125,19 +125,11 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
|
|
|
125
125
|
isPureTransfer,
|
|
126
126
|
]);
|
|
127
127
|
// Call onSuccess when order is executed
|
|
128
|
-
|
|
129
|
-
if (oat?.data?.order.status === "executed" && !onSuccessCalled.current) {
|
|
130
|
-
const txHash = oat?.data?.executeTx?.txHash;
|
|
131
|
-
onSuccess?.(txHash);
|
|
132
|
-
onSuccessCalled.current = true;
|
|
133
|
-
}
|
|
134
|
-
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, onSuccess]);
|
|
135
|
-
// Reset onSuccess flag when orderId changes
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
onSuccessCalled.current = false;
|
|
138
|
-
}, [orderId]);
|
|
128
|
+
useOnOrderSuccess({ orderData: oat, orderId, onSuccess });
|
|
139
129
|
// For pure transfers, always use recipient address; for orders, use global address
|
|
140
130
|
const displayAddress = isPureTransfer ? recipientAddress : globalAddress || recipientAddress;
|
|
131
|
+
// Generate EIP-681 payment URI for the QR code so wallets know which chain/token to use
|
|
132
|
+
const qrValue = getPaymentUrl(displayAddress, undefined, sourceToken.address === ZERO_ADDRESS ? "ETH" : sourceToken.address, sourceChainId, sourceToken.decimals);
|
|
141
133
|
const handleCopyAddress = async () => {
|
|
142
134
|
if (displayAddress) {
|
|
143
135
|
await navigator.clipboard.writeText(displayAddress);
|
|
@@ -170,7 +162,7 @@ export function QRDeposit({ mode = "modal", recipientAddress, sourceToken: sourc
|
|
|
170
162
|
}
|
|
171
163
|
return (_jsx("div", { className: classes?.container ||
|
|
172
164
|
cn("anyspend-container anyspend-qr-deposit font-inter bg-as-surface-primary mx-auto w-full max-w-[460px] p-6", mode === "page" && "border-as-border-secondary overflow-hidden rounded-2xl border shadow-xl"), children: _jsxs("div", { className: classes?.content || "anyspend-qr-deposit-content flex flex-col gap-4", children: [_jsxs("div", { className: classes?.header || "anyspend-qr-header flex items-center justify-between", children: [_jsx("button", { onClick: handleBack, className: classes?.backButton || "anyspend-qr-back-button text-as-secondary hover:text-as-primary", children: _jsx("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M15 19l-7-7 7-7" }) }) }), _jsx("h2", { className: classes?.title || "anyspend-qr-title text-as-primary text-base font-semibold", children: "Deposit" }), onClose ? (_jsx("button", { onClick: handleClose, className: classes?.closeButton || "anyspend-qr-close-button text-as-secondary hover:text-as-primary", children: _jsx("svg", { className: "h-5 w-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })) : (_jsx("div", { className: "w-5" }))] }), _jsxs("div", { className: classes?.tokenSelectorContainer || "anyspend-qr-token-selector flex flex-col gap-1.5", children: [_jsx("label", { className: classes?.tokenSelectorLabel || "anyspend-qr-token-label text-as-secondary text-sm", children: "Send" }), _jsx(TokenSelector, { chainIdsFilter: getAvailableChainIds("from"), context: "from", fromChainWalletVMSupported: true, isValidAddress: true, lockedChainIds: getAvailableChainIds("from"), multiWalletSupportEnabled: true, onAnalyticEvent: undefined, setToken: handleTokenSelect, supportedWalletVMs: ["evm"], token: undefined, trigger: _jsxs(Button, { variant: "outline", role: "combobox", className: classes?.tokenSelectorTrigger ||
|
|
173
|
-
"anyspend-qr-token-trigger border-as-stroke bg-as-surface-secondary flex h-auto w-full items-center justify-between gap-2 rounded-xl border px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center gap-2", children: [sourceToken.metadata?.logoURI ? (_jsx(ChainTokenIcon, { chainUrl: ALL_CHAINS[sourceChainId]?.logoUrl, tokenUrl: sourceToken.metadata.logoURI, className: "h-8 min-h-8 w-8 min-w-8" })) : (_jsx("div", { className: "h-8 w-8 rounded-full bg-gray-700" })), _jsxs("div", { className: "flex flex-col items-start gap-0", children: [_jsx("div", { className: "text-as-primary font-semibold", children: sourceToken.symbol }), _jsx("div", { className: "text-as-primary/70 text-xs", children: ALL_CHAINS[sourceChainId]?.name ?? "Unknown" })] })] }), _jsx(ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-70" })] }) })] }), _jsxs("div", { className: classes?.qrContent || "anyspend-qr-content border-as-stroke flex items-start gap-4 rounded-xl border p-4", children: [_jsxs("div", { className: classes?.qrCodeContainer || "anyspend-qr-code-container flex flex-col items-center gap-2", children: [_jsx("div", { className: classes?.qrCode || "anyspend-qr-code rounded-lg bg-white p-2", children: _jsx(QRCodeSVG, { value:
|
|
165
|
+
"anyspend-qr-token-trigger border-as-stroke bg-as-surface-secondary flex h-auto w-full items-center justify-between gap-2 rounded-xl border px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center gap-2", children: [sourceToken.metadata?.logoURI ? (_jsx(ChainTokenIcon, { chainUrl: ALL_CHAINS[sourceChainId]?.logoUrl, tokenUrl: sourceToken.metadata.logoURI, className: "h-8 min-h-8 w-8 min-w-8" })) : (_jsx("div", { className: "h-8 w-8 rounded-full bg-gray-700" })), _jsxs("div", { className: "flex flex-col items-start gap-0", children: [_jsx("div", { className: "text-as-primary font-semibold", children: sourceToken.symbol }), _jsx("div", { className: "text-as-primary/70 text-xs", children: ALL_CHAINS[sourceChainId]?.name ?? "Unknown" })] })] }), _jsx(ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-70" })] }) })] }), _jsxs("div", { className: classes?.qrContent || "anyspend-qr-content border-as-stroke flex items-start gap-4 rounded-xl border p-4", children: [_jsxs("div", { className: classes?.qrCodeContainer || "anyspend-qr-code-container flex flex-col items-center gap-2", children: [_jsx("div", { className: classes?.qrCode || "anyspend-qr-code rounded-lg bg-white p-2", children: _jsx(QRCodeSVG, { value: qrValue, size: 120, level: "M", marginSize: 0 }) }), _jsxs("span", { className: classes?.qrScanHint || "anyspend-qr-scan-hint text-as-secondary text-xs", children: ["SCAN WITH ", _jsx("span", { className: "inline-block", children: "\uD83E\uDD8A" })] })] }), _jsxs("div", { className: classes?.addressContainer || "anyspend-qr-address-container flex flex-1 flex-col gap-1", children: [_jsx("span", { className: classes?.addressLabel || "anyspend-qr-address-label text-as-secondary text-sm", children: "Deposit address:" }), _jsxs("div", { className: classes?.addressRow || "anyspend-qr-address-row flex items-start gap-1", children: [_jsx("span", { className: classes?.address || "anyspend-qr-address text-as-primary break-all font-mono text-sm leading-relaxed", children: displayAddress }), _jsx("button", { onClick: handleCopyAddress, className: classes?.addressCopyIcon ||
|
|
174
166
|
"anyspend-qr-copy-icon text-as-secondary hover:text-as-primary mt-0.5 shrink-0", children: copied ? _jsx(Check, { className: "h-4 w-4" }) : _jsx(Copy, { className: "h-4 w-4" }) })] })] })] }), _jsx(ChainWarningText, { chainId: destinationChainId }), _jsxs(WarningText, { children: ["Only send ", sourceToken.symbol, " on ", ALL_CHAINS[sourceChainId]?.name ?? "the specified chain", ". Other tokens will not be converted."] }), isPureTransfer && isWatchingTransfer && (_jsxs("div", { className: classes?.watchingIndicator ||
|
|
175
167
|
"anyspend-qr-watching flex items-center justify-center gap-2 rounded-lg bg-blue-500/10 p-3", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin text-blue-500" }), _jsx("span", { className: "text-sm text-blue-500", children: "Watching for incoming transfer..." })] })), _jsx("button", { onClick: handleCopyAddress, className: classes?.copyButton ||
|
|
176
168
|
"anyspend-qr-copy-button flex w-full items-center justify-center gap-2 rounded-xl bg-blue-500 py-3.5 font-medium text-white transition-all hover:bg-blue-600", children: "Copy deposit address" })] }) }));
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export declare const BUY_PACKS_FOR_ABI: {
|
|
2
|
+
readonly inputs: readonly [{
|
|
3
|
+
readonly internalType: "address";
|
|
4
|
+
readonly name: "user";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
}, {
|
|
7
|
+
readonly internalType: "uint256";
|
|
8
|
+
readonly name: "packId";
|
|
9
|
+
readonly type: "uint256";
|
|
10
|
+
}, {
|
|
11
|
+
readonly internalType: "uint256";
|
|
12
|
+
readonly name: "amount";
|
|
13
|
+
readonly type: "uint256";
|
|
14
|
+
}];
|
|
15
|
+
readonly name: "buyPacksFor";
|
|
16
|
+
readonly outputs: readonly [];
|
|
17
|
+
readonly stateMutability: "nonpayable";
|
|
18
|
+
readonly type: "function";
|
|
19
|
+
};
|
|
20
|
+
export declare const BUY_PACKS_FOR_WITH_DISCOUNT_ABI: {
|
|
21
|
+
readonly inputs: readonly [{
|
|
22
|
+
readonly internalType: "address";
|
|
23
|
+
readonly name: "user";
|
|
24
|
+
readonly type: "address";
|
|
25
|
+
}, {
|
|
26
|
+
readonly internalType: "uint256";
|
|
27
|
+
readonly name: "packId";
|
|
28
|
+
readonly type: "uint256";
|
|
29
|
+
}, {
|
|
30
|
+
readonly internalType: "uint256";
|
|
31
|
+
readonly name: "amount";
|
|
32
|
+
readonly type: "uint256";
|
|
33
|
+
}, {
|
|
34
|
+
readonly internalType: "string";
|
|
35
|
+
readonly name: "discountCode";
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
}];
|
|
38
|
+
readonly name: "buyPacksForWithDiscount";
|
|
39
|
+
readonly outputs: readonly [];
|
|
40
|
+
readonly stateMutability: "nonpayable";
|
|
41
|
+
readonly type: "function";
|
|
42
|
+
};
|
|
43
|
+
export declare const IS_DISCOUNT_CODE_VALID_FOR_PACK_ABI: {
|
|
44
|
+
readonly inputs: readonly [{
|
|
45
|
+
readonly internalType: "string";
|
|
46
|
+
readonly name: "code";
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
}, {
|
|
49
|
+
readonly internalType: "uint256";
|
|
50
|
+
readonly name: "packId";
|
|
51
|
+
readonly type: "uint256";
|
|
52
|
+
}];
|
|
53
|
+
readonly name: "isDiscountCodeValidForPack";
|
|
54
|
+
readonly outputs: readonly [{
|
|
55
|
+
readonly internalType: "bool";
|
|
56
|
+
readonly name: "isValid";
|
|
57
|
+
readonly type: "bool";
|
|
58
|
+
}, {
|
|
59
|
+
readonly internalType: "uint256";
|
|
60
|
+
readonly name: "discountAmount";
|
|
61
|
+
readonly type: "uint256";
|
|
62
|
+
}];
|
|
63
|
+
readonly stateMutability: "view";
|
|
64
|
+
readonly type: "function";
|
|
65
|
+
};
|
|
66
|
+
export declare const GET_DISCOUNT_CODE_ABI: {
|
|
67
|
+
readonly inputs: readonly [{
|
|
68
|
+
readonly internalType: "string";
|
|
69
|
+
readonly name: "code";
|
|
70
|
+
readonly type: "string";
|
|
71
|
+
}];
|
|
72
|
+
readonly name: "getDiscountCode";
|
|
73
|
+
readonly outputs: readonly [{
|
|
74
|
+
readonly components: readonly [{
|
|
75
|
+
readonly internalType: "uint256";
|
|
76
|
+
readonly name: "discountAmount";
|
|
77
|
+
readonly type: "uint256";
|
|
78
|
+
}, {
|
|
79
|
+
readonly internalType: "uint256";
|
|
80
|
+
readonly name: "expiresAt";
|
|
81
|
+
readonly type: "uint256";
|
|
82
|
+
}, {
|
|
83
|
+
readonly internalType: "bool";
|
|
84
|
+
readonly name: "used";
|
|
85
|
+
readonly type: "bool";
|
|
86
|
+
}, {
|
|
87
|
+
readonly internalType: "bool";
|
|
88
|
+
readonly name: "exists";
|
|
89
|
+
readonly type: "bool";
|
|
90
|
+
}, {
|
|
91
|
+
readonly internalType: "uint256";
|
|
92
|
+
readonly name: "maxUses";
|
|
93
|
+
readonly type: "uint256";
|
|
94
|
+
}, {
|
|
95
|
+
readonly internalType: "uint256";
|
|
96
|
+
readonly name: "usedCount";
|
|
97
|
+
readonly type: "uint256";
|
|
98
|
+
}, {
|
|
99
|
+
readonly internalType: "uint256";
|
|
100
|
+
readonly name: "packId";
|
|
101
|
+
readonly type: "uint256";
|
|
102
|
+
}, {
|
|
103
|
+
readonly internalType: "uint256";
|
|
104
|
+
readonly name: "minPurchaseAmount";
|
|
105
|
+
readonly type: "uint256";
|
|
106
|
+
}];
|
|
107
|
+
readonly internalType: "struct CCShop.DiscountCode";
|
|
108
|
+
readonly name: "";
|
|
109
|
+
readonly type: "tuple";
|
|
110
|
+
}];
|
|
111
|
+
readonly stateMutability: "view";
|
|
112
|
+
readonly type: "function";
|
|
113
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// CCShop contract ABI fragments used by AnySpendCollectorClubPurchase
|
|
2
|
+
export const BUY_PACKS_FOR_ABI = {
|
|
3
|
+
inputs: [
|
|
4
|
+
{ internalType: "address", name: "user", type: "address" },
|
|
5
|
+
{ internalType: "uint256", name: "packId", type: "uint256" },
|
|
6
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
7
|
+
],
|
|
8
|
+
name: "buyPacksFor",
|
|
9
|
+
outputs: [],
|
|
10
|
+
stateMutability: "nonpayable",
|
|
11
|
+
type: "function",
|
|
12
|
+
};
|
|
13
|
+
export const BUY_PACKS_FOR_WITH_DISCOUNT_ABI = {
|
|
14
|
+
inputs: [
|
|
15
|
+
{ internalType: "address", name: "user", type: "address" },
|
|
16
|
+
{ internalType: "uint256", name: "packId", type: "uint256" },
|
|
17
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
18
|
+
{ internalType: "string", name: "discountCode", type: "string" },
|
|
19
|
+
],
|
|
20
|
+
name: "buyPacksForWithDiscount",
|
|
21
|
+
outputs: [],
|
|
22
|
+
stateMutability: "nonpayable",
|
|
23
|
+
type: "function",
|
|
24
|
+
};
|
|
25
|
+
export const IS_DISCOUNT_CODE_VALID_FOR_PACK_ABI = {
|
|
26
|
+
inputs: [
|
|
27
|
+
{ internalType: "string", name: "code", type: "string" },
|
|
28
|
+
{ internalType: "uint256", name: "packId", type: "uint256" },
|
|
29
|
+
],
|
|
30
|
+
name: "isDiscountCodeValidForPack",
|
|
31
|
+
outputs: [
|
|
32
|
+
{ internalType: "bool", name: "isValid", type: "bool" },
|
|
33
|
+
{ internalType: "uint256", name: "discountAmount", type: "uint256" },
|
|
34
|
+
],
|
|
35
|
+
stateMutability: "view",
|
|
36
|
+
type: "function",
|
|
37
|
+
};
|
|
38
|
+
export const GET_DISCOUNT_CODE_ABI = {
|
|
39
|
+
inputs: [{ internalType: "string", name: "code", type: "string" }],
|
|
40
|
+
name: "getDiscountCode",
|
|
41
|
+
outputs: [
|
|
42
|
+
{
|
|
43
|
+
components: [
|
|
44
|
+
{ internalType: "uint256", name: "discountAmount", type: "uint256" },
|
|
45
|
+
{ internalType: "uint256", name: "expiresAt", type: "uint256" },
|
|
46
|
+
{ internalType: "bool", name: "used", type: "bool" },
|
|
47
|
+
{ internalType: "bool", name: "exists", type: "bool" },
|
|
48
|
+
{ internalType: "uint256", name: "maxUses", type: "uint256" },
|
|
49
|
+
{ internalType: "uint256", name: "usedCount", type: "uint256" },
|
|
50
|
+
{ internalType: "uint256", name: "packId", type: "uint256" },
|
|
51
|
+
{ internalType: "uint256", name: "minPurchaseAmount", type: "uint256" },
|
|
52
|
+
],
|
|
53
|
+
internalType: "struct CCShop.DiscountCode",
|
|
54
|
+
name: "",
|
|
55
|
+
type: "tuple",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
stateMutability: "view",
|
|
59
|
+
type: "function",
|
|
60
|
+
};
|
|
@@ -18,8 +18,6 @@ interface CryptoPaySectionProps {
|
|
|
18
18
|
}) => void;
|
|
19
19
|
onShowFeeDetail?: () => void;
|
|
20
20
|
classes?: CryptoPaySectionClasses;
|
|
21
|
-
/** When true, skip auto-setting max balance when token changes (used for fixed destination amount mode) */
|
|
22
|
-
skipAutoMaxOnTokenChange?: boolean;
|
|
23
21
|
}
|
|
24
|
-
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, classes,
|
|
22
|
+
export declare function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, classes, }: CryptoPaySectionProps): import("react/jsx-runtime").JSX.Element;
|
|
25
23
|
export {};
|
|
@@ -8,7 +8,7 @@ import { useConnectedWalletDisplay } from "../../hooks/useConnectedWalletDisplay
|
|
|
8
8
|
import { CryptoPaymentMethodDisplay } from "./CryptoPaymentMethodDisplay.js";
|
|
9
9
|
import { OrderTokenAmount } from "./OrderTokenAmount.js";
|
|
10
10
|
import { TokenBalance } from "./TokenBalance.js";
|
|
11
|
-
export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, classes,
|
|
11
|
+
export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, selectedSrcToken, setSelectedSrcToken, srcAmount, setSrcAmount, isSrcInputDirty, setIsSrcInputDirty, selectedCryptoPaymentMethod, onSelectCryptoPaymentMethod, anyspendQuote, onTokenSelect, onShowFeeDetail, classes, }) {
|
|
12
12
|
const { data: srcTokenMetadata } = useTokenData(selectedSrcToken?.chainId, selectedSrcToken?.address);
|
|
13
13
|
// Use custom hook to determine wallet address based on payment method
|
|
14
14
|
const { walletAddress } = useConnectedWalletDisplay(selectedCryptoPaymentMethod);
|
|
@@ -40,10 +40,10 @@ export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, se
|
|
|
40
40
|
}, [selectedSrcToken.address, selectedSrcToken.chainId]);
|
|
41
41
|
return (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: classes?.container ||
|
|
42
42
|
"pay-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: classes?.label || "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: ["Pay", !isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && (_jsx("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: _jsx(Info, { className: "h-4 w-4" }) }))] }), _jsx("button", { className: classes?.paymentMethodButton ||
|
|
43
|
-
"text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: _jsx(CryptoPaymentMethodDisplay, { paymentMethod: selectedCryptoPaymentMethod, connectedAddress: walletAddress, connectedName: connectedName }) })] }), _jsx("div", { className: classes?.inputContainer, children: _jsx(OrderTokenAmount, { address: walletAddress,
|
|
43
|
+
"text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: _jsx(CryptoPaymentMethodDisplay, { paymentMethod: selectedCryptoPaymentMethod, connectedAddress: walletAddress, connectedName: connectedName }) })] }), _jsx("div", { className: classes?.inputContainer, children: _jsx(OrderTokenAmount, { address: walletAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
44
44
|
setIsSrcInputDirty(true);
|
|
45
45
|
setSrcAmount(value);
|
|
46
|
-
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken, onTokenSelect: onTokenSelect
|
|
46
|
+
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken, onTokenSelect: onTokenSelect }) }), _jsxs("div", { className: classes?.balanceRow || "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: formatDisplayNumber(anyspendQuote?.data?.currencyIn?.amountUsd, {
|
|
47
47
|
style: "currency",
|
|
48
48
|
fallback: "",
|
|
49
49
|
}) }), _jsx(TokenBalance, { token: selectedSrcToken, walletAddress: walletAddress, onChangeInput: value => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../../anyspend/types/api";
|
|
2
|
-
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect,
|
|
2
|
+
export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect, canEditAmount, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, }: {
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
inputValue: string;
|
|
5
5
|
onChangeInput: (value: string) => void;
|
|
@@ -18,7 +18,4 @@ export declare function OrderTokenAmount({ disabled, inputValue, onChangeInput,
|
|
|
18
18
|
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
19
19
|
preventDefault: () => void;
|
|
20
20
|
}) => void;
|
|
21
|
-
walletAddress?: string | undefined;
|
|
22
|
-
/** When true, skip auto-setting max balance when token changes (used for fixed destination amount mode) */
|
|
23
|
-
skipAutoMaxOnTokenChange?: boolean;
|
|
24
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,63 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ChevronsUpDown } from "lucide-react";
|
|
4
|
-
import { useEffect, useRef } from "react";
|
|
5
4
|
import { NumericFormat } from "react-number-format";
|
|
6
|
-
import { formatUnits } from "viem";
|
|
7
5
|
import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID, getAvailableChainIds } from "../../../../anyspend/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import { isNativeToken } from "../../../../anyspend/utils/token.js";
|
|
10
|
-
import { Button, useTokenBalance } from "../../../../global-account/react/index.js";
|
|
6
|
+
import { Button } from "../../../../global-account/react/index.js";
|
|
11
7
|
import { cn } from "../../../../shared/utils/index.js";
|
|
12
8
|
import { TokenSelector } from "@relayprotocol/relay-kit-ui";
|
|
13
9
|
import { ChainTokenIcon } from "./ChainTokenIcon.js";
|
|
14
|
-
export function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect = false, canEditAmount = true, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect,
|
|
15
|
-
// Track previous token to detect changes
|
|
16
|
-
const prevTokenRef = useRef(token.address);
|
|
17
|
-
// Only get token balance when context is "from" (for setting max amount)
|
|
18
|
-
const { rawBalance } = useTokenBalance({
|
|
19
|
-
token,
|
|
20
|
-
address: context === "from" && walletAddress ? walletAddress : undefined,
|
|
21
|
-
});
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
// Only handle "from" context
|
|
24
|
-
if (context !== "from")
|
|
25
|
-
return;
|
|
26
|
-
// Skip auto-max when in fixed destination amount mode
|
|
27
|
-
if (skipAutoMaxOnTokenChange) {
|
|
28
|
-
prevTokenRef.current = token.address;
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
// Check if token changed or if this is the initial load with balance
|
|
32
|
-
const isTokenChanged = prevTokenRef.current !== token.address;
|
|
33
|
-
if (isTokenChanged && rawBalance) {
|
|
34
|
-
console.log(`Setting max balance - Token: ${token.address}, Changed: ${isTokenChanged}`);
|
|
35
|
-
// Calculate max amount with gas reserve for native tokens
|
|
36
|
-
let maxAmount;
|
|
37
|
-
if (isNativeToken(token.address)) {
|
|
38
|
-
const gasReserve = getNativeRequired(token.chainId);
|
|
39
|
-
// Ensure we don't go negative
|
|
40
|
-
maxAmount = rawBalance > gasReserve ? rawBalance - gasReserve : BigInt(0);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
// For ERC20 tokens, use full balance
|
|
44
|
-
maxAmount = rawBalance;
|
|
45
|
-
}
|
|
46
|
-
// Set the max amount as input value
|
|
47
|
-
onChangeInput(formatUnits(maxAmount, token.decimals));
|
|
48
|
-
// Update refs
|
|
49
|
-
prevTokenRef.current = token.address;
|
|
50
|
-
}
|
|
51
|
-
}, [
|
|
52
|
-
token.address,
|
|
53
|
-
token.chainId,
|
|
54
|
-
token.decimals,
|
|
55
|
-
chainId,
|
|
56
|
-
context,
|
|
57
|
-
onChangeInput,
|
|
58
|
-
rawBalance,
|
|
59
|
-
skipAutoMaxOnTokenChange,
|
|
60
|
-
]);
|
|
10
|
+
export function OrderTokenAmount({ disabled, inputValue, onChangeInput, context, address, chainId, setChainId, token, setToken, hideTokenSelect = false, canEditAmount = true, className, innerClassName, amountClassName, tokenSelectClassName, onTokenSelect, }) {
|
|
61
11
|
const handleTokenSelect = (newToken) => {
|
|
62
12
|
const token = {
|
|
63
13
|
address: newToken.address,
|
|
@@ -80,11 +30,7 @@ export function OrderTokenAmount({ disabled, inputValue, onChangeInput, context,
|
|
|
80
30
|
return; // Early return if callback prevented default behavior
|
|
81
31
|
}
|
|
82
32
|
}
|
|
83
|
-
// Mark that we're about to change tokens
|
|
84
|
-
prevTokenRef.current = "changing"; // Temporary value to force effect
|
|
85
|
-
// Set the chain ID first
|
|
86
33
|
setChainId(newToken.chainId);
|
|
87
|
-
// Then set the new token - the useEffect will handle setting the max balance
|
|
88
34
|
setToken(token);
|
|
89
35
|
};
|
|
90
36
|
return (_jsx("div", { className: cn("border-as-stroke flex w-full flex-col gap-2 rounded-xl", className), children: _jsxs("div", { className: cn("flex items-center justify-between gap-3", innerClassName), children: [!canEditAmount ? (_jsx("h2", { className: cn("text-3xl font-medium text-white", amountClassName), children: inputValue || "--" })) : (_jsx(NumericFormat, { decimalSeparator: ".", allowedDecimalSeparators: [","], thousandSeparator: true, inputMode: "decimal", autoComplete: "off", autoCorrect: "off", type: "text", placeholder: "0.00", minLength: 1, maxLength: 30, spellCheck: "false", className: cn("placeholder:text-as-primary/70 disabled:text-as-primary/70 text-as-primary w-full bg-transparent text-4xl font-semibold leading-[42px] outline-none sm:text-[30px]", amountClassName), pattern: "^[0-9]*[.,]?[0-9]*$", disabled: disabled, value: inputValue, allowNegative: false, onChange: e => onChangeInput(e.currentTarget.value) }, `input-${token.address}-${chainId}`)), !hideTokenSelect && (_jsx(TokenSelector, { address: address, chainIdsFilter: getAvailableChainIds(context), context: context, fromChainWalletVMSupported: true, isValidAddress: true, lockedChainIds: getAvailableChainIds(context), multiWalletSupportEnabled: true, onAnalyticEvent: undefined, popularChainIds: [1, 8453, RELAY_SOLANA_MAINNET_CHAIN_ID], setToken: handleTokenSelect, supportedWalletVMs: ["evm", "svm"], token: undefined, trigger: _jsxs(Button, { variant: "outline", role: "combobox", className: cn("token-selector-button bg-b3-react-background border-as-stroke flex h-auto w-fit shrink-0 items-center justify-center gap-2 rounded-xl border-2 px-2 py-1 pr-2 text-center", tokenSelectClassName), children: [token.metadata.logoURI ? (_jsx(ChainTokenIcon, { chainUrl: ALL_CHAINS[chainId].logoUrl, tokenUrl: token.metadata.logoURI, className: "h-8 min-h-8 w-8 min-w-8" })) : (_jsx("div", { className: "h-8 w-8 rounded-full bg-gray-700" })), _jsxs("div", { className: "flex flex-col items-start gap-0", children: [_jsx("div", { className: "text-as-primary font-semibold", children: token.symbol }), _jsx("div", { className: "text-as-primary/70 text-xs", children: ALL_CHAINS[chainId].name })] }), _jsx(ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-70" })] }) }, `selector-${context}-${token.address}-${chainId}`))] }) }, `${context}-${token.address}-${chainId}`));
|
|
@@ -39,7 +39,7 @@ export function CryptoPaySection({ selectedSrcChainId, setSelectedSrcChainId, se
|
|
|
39
39
|
useEffect(() => {
|
|
40
40
|
appliedSrcMetadataRef.current = false;
|
|
41
41
|
}, [selectedSrcToken.address, selectedSrcToken.chainId]);
|
|
42
|
-
return (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "pay-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [isConnected ? (_jsx("div", { className: "flex items-center gap-1", children: connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "") })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET ? (_jsxs(_Fragment, { children: ["Global Account", _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (_jsxs(_Fragment, { children: ["Transfer crypto", _jsx(ChevronRight, { className: "h-4 w-4" })] })) : (_jsxs(_Fragment, { children: ["Select payment method", _jsx(ChevronRight, { className: "h-4 w-4" })] })) })] }), _jsx(OrderTokenAmount, { address: connectedAddress,
|
|
42
|
+
return (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "pay-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-7 items-center text-sm", children: "Pay" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none", onClick: onSelectCryptoPaymentMethod, children: selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [isConnected ? (_jsx("div", { className: "flex items-center gap-1", children: connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "") })) : ("Connect wallet"), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET ? (_jsxs(_Fragment, { children: ["Global Account", _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (_jsxs(_Fragment, { children: ["Transfer crypto", _jsx(ChevronRight, { className: "h-4 w-4" })] })) : (_jsxs(_Fragment, { children: ["Select payment method", _jsx(ChevronRight, { className: "h-4 w-4" })] })) })] }), _jsx(OrderTokenAmount, { address: connectedAddress, context: "from", inputValue: srcAmount, onChangeInput: value => {
|
|
43
43
|
setIsSrcInputDirty(true);
|
|
44
44
|
setSrcAmount(value);
|
|
45
45
|
}, chainId: selectedSrcChainId, setChainId: setSelectedSrcChainId, token: selectedSrcToken, setToken: setSelectedSrcToken }), _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary/50 flex h-5 items-center text-sm", children: formatDisplayNumber(anyspendQuote?.data?.currencyIn?.amountUsd, {
|
|
@@ -8,6 +8,8 @@ export { AnySpendDeposit } from "./AnySpendDeposit";
|
|
|
8
8
|
export type { AnySpendDepositProps, ChainConfig, DepositContractConfig } from "./AnySpendDeposit";
|
|
9
9
|
export type { AnySpendAllClasses, AnySpendClasses, AnySpendCustomExactInClasses, AnySpendDepositClasses, CryptoPaymentMethodClasses, CryptoPaySectionClasses, CryptoReceiveSectionClasses, FiatPaymentMethodClasses, OrderDetailsClasses, PanelOnrampClasses, QRDepositClasses, RecipientSelectionClasses, } from "./types/classes";
|
|
10
10
|
export { AnySpendDepositHype, HYPE_TOKEN_DETAILS } from "./AnyspendDepositHype";
|
|
11
|
+
export { AnySpendWorkflowTrigger } from "./AnySpendWorkflowTrigger";
|
|
12
|
+
export type { AnySpendWorkflowTriggerProps } from "./AnySpendWorkflowTrigger";
|
|
11
13
|
export * from "./AnySpendFingerprintWrapper";
|
|
12
14
|
export { AnySpendNFT } from "./AnySpendNFT";
|
|
13
15
|
export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
|
|
@@ -7,6 +7,7 @@ export { AnySpendCustom } from "./AnySpendCustom.js";
|
|
|
7
7
|
export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn.js";
|
|
8
8
|
export { AnySpendDeposit } from "./AnySpendDeposit.js";
|
|
9
9
|
export { AnySpendDepositHype, HYPE_TOKEN_DETAILS } from "./AnyspendDepositHype.js";
|
|
10
|
+
export { AnySpendWorkflowTrigger } from "./AnySpendWorkflowTrigger.js";
|
|
10
11
|
export * from "./AnySpendFingerprintWrapper.js";
|
|
11
12
|
export { AnySpendNFT } from "./AnySpendNFT.js";
|
|
12
13
|
export { AnyspendSignatureMint } from "./AnyspendSignatureMint.js";
|
|
@@ -12,6 +12,7 @@ export * from "./useGasPrice";
|
|
|
12
12
|
export * from "./useGeoOnrampOptions";
|
|
13
13
|
export * from "./useGetGeo";
|
|
14
14
|
export * from "./useHyperliquidTransfer";
|
|
15
|
+
export * from "./useOnOrderSuccess";
|
|
15
16
|
export * from "./useRecipientAddressState";
|
|
16
17
|
export * from "./useSigMint";
|
|
17
18
|
export * from "./useStripeClientSecret";
|