@b3dotfun/sdk 0.0.65 → 0.0.66
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.js +38 -24
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +22 -9
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +44 -13
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/AnySpendDepositUpside.js +41 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +14 -251
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +2 -10
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/index.js +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +5 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +16 -10
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +7 -5
- package/dist/cjs/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +13 -9
- package/dist/cjs/anyspend/react/hooks/useCryptoPaymentMethodState.d.ts +42 -0
- package/dist/cjs/anyspend/react/hooks/useCryptoPaymentMethodState.js +51 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +6 -14
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +21 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +38 -24
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +22 -9
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +3 -1
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +44 -13
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.d.ts +11 -0
- package/dist/esm/anyspend/react/components/AnySpendDepositUpside.js +38 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +15 -249
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +2 -10
- package/dist/esm/anyspend/react/components/index.d.ts +1 -0
- package/dist/esm/anyspend/react/components/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +5 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +16 -10
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +7 -5
- package/dist/esm/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.js +13 -9
- package/dist/esm/anyspend/react/hooks/useCryptoPaymentMethodState.d.ts +42 -0
- package/dist/esm/anyspend/react/hooks/useCryptoPaymentMethodState.js +48 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +3 -0
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +6 -14
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +21 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +3 -1
- package/dist/types/anyspend/react/components/AnySpendDepositUpside.d.ts +11 -0
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +1 -1
- package/dist/types/anyspend/react/components/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +5 -1
- package/dist/types/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.d.ts +7 -5
- package/dist/types/anyspend/react/hooks/useCryptoPaymentMethodState.d.ts +42 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +21 -1
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +50 -29
- package/src/anyspend/react/components/AnySpendCustom.tsx +28 -15
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +54 -13
- package/src/anyspend/react/components/AnySpendDepositUpside.tsx +81 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +36 -526
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +2 -13
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +24 -12
- package/src/anyspend/react/hooks/useAutoSelectCryptoPaymentMethod.ts +20 -12
- package/src/anyspend/react/hooks/useCryptoPaymentMethodState.ts +71 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +3 -0
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +6 -12
- package/src/global-account/react/stores/useModalStore.ts +22 -0
- package/src/styles/index.css +8 -0
|
@@ -1,28 +1,7 @@
|
|
|
1
1
|
import { B3_TOKEN } from "@b3dotfun/sdk/anyspend";
|
|
2
2
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
|
-
import { Button, ShinyButton, StyleRoot, TransitionPanel, useAccountWallet } from "@b3dotfun/sdk/global-account/react";
|
|
4
|
-
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
5
|
-
import invariant from "invariant";
|
|
6
|
-
import { motion } from "motion/react";
|
|
7
|
-
import { useEffect, useMemo, useRef } from "react";
|
|
8
|
-
import { toast } from "sonner";
|
|
9
|
-
import { useSetActiveWallet } from "thirdweb/react";
|
|
10
3
|
import { base } from "viem/chains";
|
|
11
|
-
import {
|
|
12
|
-
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper";
|
|
13
|
-
import { CryptoPaySection } from "./common/CryptoPaySection";
|
|
14
|
-
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod";
|
|
15
|
-
import { CryptoReceiveSection } from "./common/CryptoReceiveSection";
|
|
16
|
-
import { FeeDetailPanel } from "./common/FeeDetailPanel";
|
|
17
|
-
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod";
|
|
18
|
-
import { OrderDetails } from "./common/OrderDetails";
|
|
19
|
-
import { PointsDetailPanel } from "./common/PointsDetailPanel";
|
|
20
|
-
import { RecipientSelection } from "./common/RecipientSelection";
|
|
21
|
-
|
|
22
|
-
import { ArrowDown, Loader2 } from "lucide-react";
|
|
23
|
-
import { PanelOnramp } from "./common/PanelOnramp";
|
|
24
|
-
|
|
25
|
-
const SLIPPAGE_PERCENT = 3;
|
|
4
|
+
import { AnySpendCustomExactIn } from "./AnySpendCustomExactIn";
|
|
26
5
|
|
|
27
6
|
export const HYPE_TOKEN_DETAILS = {
|
|
28
7
|
SYMBOL: "HYPE",
|
|
@@ -47,17 +26,7 @@ export interface AnySpendDepositHypeProps {
|
|
|
47
26
|
preferEoa?: boolean;
|
|
48
27
|
}
|
|
49
28
|
|
|
50
|
-
export function AnySpendDepositHype(
|
|
51
|
-
const fingerprintConfig = getFingerprintConfig();
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<AnySpendFingerprintWrapper fingerprint={fingerprintConfig}>
|
|
55
|
-
<AnySpendDepositHypeInner {...props} />
|
|
56
|
-
</AnySpendFingerprintWrapper>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function AnySpendDepositHypeInner({
|
|
29
|
+
export function AnySpendDepositHype({
|
|
61
30
|
loadOrder,
|
|
62
31
|
mode = "modal",
|
|
63
32
|
recipientAddress,
|
|
@@ -70,505 +39,46 @@ function AnySpendDepositHypeInner({
|
|
|
70
39
|
customUsdInputValues,
|
|
71
40
|
preferEoa,
|
|
72
41
|
}: AnySpendDepositHypeProps) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
setSelectedSrcChainId,
|
|
82
|
-
selectedSrcToken,
|
|
83
|
-
setSelectedSrcToken,
|
|
84
|
-
srcAmount,
|
|
85
|
-
setSrcAmount,
|
|
86
|
-
dstAmount,
|
|
87
|
-
isSrcInputDirty,
|
|
88
|
-
setIsSrcInputDirty,
|
|
89
|
-
selectedCryptoPaymentMethod,
|
|
90
|
-
setSelectedCryptoPaymentMethod,
|
|
91
|
-
selectedFiatPaymentMethod,
|
|
92
|
-
setSelectedFiatPaymentMethod,
|
|
93
|
-
selectedRecipientAddress,
|
|
94
|
-
setSelectedRecipientAddress,
|
|
95
|
-
recipientName,
|
|
96
|
-
globalAddress,
|
|
97
|
-
anyspendQuote,
|
|
98
|
-
isLoadingAnyspendQuote,
|
|
99
|
-
activeInputAmountInWei,
|
|
100
|
-
geoData,
|
|
101
|
-
coinbaseAvailablePaymentMethods,
|
|
102
|
-
stripeWeb2Support,
|
|
103
|
-
createOrder,
|
|
104
|
-
isCreatingOrder,
|
|
105
|
-
createOnrampOrder,
|
|
106
|
-
isCreatingOnrampOrder,
|
|
107
|
-
} = useAnyspendFlow({
|
|
108
|
-
paymentType,
|
|
109
|
-
recipientAddress,
|
|
110
|
-
loadOrder,
|
|
111
|
-
isDepositMode: true,
|
|
112
|
-
onTransactionSuccess: onSuccess,
|
|
113
|
-
sourceTokenAddress,
|
|
114
|
-
sourceTokenChainId,
|
|
115
|
-
slippage: SLIPPAGE_PERCENT,
|
|
116
|
-
disableUrlParamManagement: true,
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const { connectedEOAWallet: connectedEOAWallet } = useAccountWallet();
|
|
120
|
-
const setActiveWallet = useSetActiveWallet();
|
|
121
|
-
const appliedPreferEoa = useRef(false);
|
|
122
|
-
|
|
123
|
-
useEffect(() => {
|
|
124
|
-
if (preferEoa && !appliedPreferEoa.current) {
|
|
125
|
-
if (connectedEOAWallet) {
|
|
126
|
-
appliedPreferEoa.current = true;
|
|
127
|
-
setActiveWallet(connectedEOAWallet);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}, [preferEoa, connectedEOAWallet, setActiveWallet]);
|
|
131
|
-
|
|
132
|
-
// Button state logic
|
|
133
|
-
const btnInfo: { text: string; disable: boolean; error: boolean; loading: boolean } = useMemo(() => {
|
|
134
|
-
if (activeInputAmountInWei === "0") return { text: "Enter an amount", disable: true, error: false, loading: false };
|
|
135
|
-
if (isLoadingAnyspendQuote) return { text: "Loading quote...", disable: true, error: false, loading: true };
|
|
136
|
-
if (isCreatingOrder || isCreatingOnrampOrder)
|
|
137
|
-
return { text: "Creating order...", disable: true, error: false, loading: true };
|
|
138
|
-
if (!selectedRecipientAddress) return { text: "Select recipient", disable: false, error: false, loading: false };
|
|
139
|
-
if (!anyspendQuote || !anyspendQuote.success)
|
|
140
|
-
return { text: "Get quote error", disable: true, error: true, loading: false };
|
|
141
|
-
if (!dstAmount) return { text: "No quote available", disable: true, error: true, loading: false };
|
|
142
|
-
|
|
143
|
-
// Check minimum deposit amount (10 HYPE)
|
|
144
|
-
// Use the raw amount from the quote instead of the formatted display string
|
|
145
|
-
if (anyspendQuote.data?.currencyOut?.amount && anyspendQuote.data.currencyOut.currency?.decimals) {
|
|
146
|
-
const rawAmountInWei = anyspendQuote.data.currencyOut.amount;
|
|
147
|
-
const decimals = anyspendQuote.data.currencyOut.currency.decimals;
|
|
148
|
-
const actualAmount = parseFloat(rawAmountInWei) / Math.pow(10, decimals);
|
|
149
|
-
|
|
150
|
-
if (actualAmount < 10) {
|
|
151
|
-
return { text: "Minimum 10 HYPE deposit", disable: true, error: true, loading: false };
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (paymentType === "crypto") {
|
|
156
|
-
if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
|
|
157
|
-
return { text: "Choose payment method", disable: false, error: false, loading: false };
|
|
158
|
-
}
|
|
159
|
-
return { text: "Continue to deposit", disable: false, error: false, loading: false };
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (paymentType === "fiat") {
|
|
163
|
-
if (selectedFiatPaymentMethod === FiatPaymentMethod.NONE) {
|
|
164
|
-
return { text: "Select payment method", disable: false, error: false, loading: false };
|
|
165
|
-
}
|
|
166
|
-
return { text: "Buy", disable: false, error: false, loading: false };
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return { text: "Continue to deposit", disable: false, error: false, loading: false };
|
|
170
|
-
}, [
|
|
171
|
-
activeInputAmountInWei,
|
|
172
|
-
isLoadingAnyspendQuote,
|
|
173
|
-
isCreatingOrder,
|
|
174
|
-
isCreatingOnrampOrder,
|
|
175
|
-
selectedRecipientAddress,
|
|
176
|
-
anyspendQuote,
|
|
177
|
-
dstAmount,
|
|
178
|
-
paymentType,
|
|
179
|
-
selectedCryptoPaymentMethod,
|
|
180
|
-
selectedFiatPaymentMethod,
|
|
181
|
-
]);
|
|
182
|
-
|
|
183
|
-
const onMainButtonClick = async () => {
|
|
184
|
-
if (btnInfo.disable) return;
|
|
185
|
-
|
|
186
|
-
if (!selectedRecipientAddress) {
|
|
187
|
-
setActivePanel(PanelView.RECIPIENT_SELECTION);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (paymentType === "crypto") {
|
|
192
|
-
if (selectedCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
|
|
193
|
-
setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
await handleCryptoOrder();
|
|
197
|
-
} else if (paymentType === "fiat") {
|
|
198
|
-
if (selectedFiatPaymentMethod === FiatPaymentMethod.NONE) {
|
|
199
|
-
setActivePanel(PanelView.FIAT_PAYMENT_METHOD);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
await handleFiatOrder();
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const mainView = (
|
|
207
|
-
<div className="mx-auto flex w-[460px] max-w-full flex-col items-center gap-2">
|
|
208
|
-
{/* Header */}
|
|
209
|
-
<div className="mb-4 flex flex-col items-center gap-3 text-center">
|
|
210
|
-
<div>
|
|
211
|
-
<h1 className="text-as-primary text-xl font-bold">
|
|
212
|
-
{paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat"}
|
|
213
|
-
</h1>
|
|
214
|
-
</div>
|
|
215
|
-
</div>
|
|
216
|
-
|
|
217
|
-
<div className="relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2">
|
|
218
|
-
<div className="relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2">
|
|
219
|
-
{/* Send section */}
|
|
220
|
-
{paymentType === "crypto" ? (
|
|
221
|
-
<CryptoPaySection
|
|
222
|
-
selectedSrcChainId={selectedSrcChainId}
|
|
223
|
-
setSelectedSrcChainId={setSelectedSrcChainId}
|
|
224
|
-
selectedSrcToken={selectedSrcToken}
|
|
225
|
-
setSelectedSrcToken={setSelectedSrcToken}
|
|
226
|
-
srcAmount={srcAmount}
|
|
227
|
-
setSrcAmount={setSrcAmount}
|
|
228
|
-
isSrcInputDirty={isSrcInputDirty}
|
|
229
|
-
setIsSrcInputDirty={setIsSrcInputDirty}
|
|
230
|
-
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
231
|
-
onSelectCryptoPaymentMethod={() => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD)}
|
|
232
|
-
anyspendQuote={anyspendQuote}
|
|
233
|
-
onTokenSelect={onTokenSelect}
|
|
234
|
-
/>
|
|
235
|
-
) : (
|
|
236
|
-
<motion.div
|
|
237
|
-
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
238
|
-
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
|
|
239
|
-
transition={{ duration: 0.3, delay: 0, ease: "easeInOut" }}
|
|
240
|
-
>
|
|
241
|
-
<PanelOnramp
|
|
242
|
-
srcAmountOnRamp={srcAmount}
|
|
243
|
-
setSrcAmountOnRamp={setSrcAmount}
|
|
244
|
-
selectedPaymentMethod={selectedFiatPaymentMethod}
|
|
245
|
-
setActivePanel={setActivePanel}
|
|
246
|
-
_recipientAddress={recipientAddress}
|
|
247
|
-
destinationToken={B3_TOKEN}
|
|
248
|
-
destinationChainId={base.id}
|
|
249
|
-
dstTokenSymbol={HYPE_TOKEN_DETAILS.SYMBOL}
|
|
250
|
-
hideDstToken
|
|
251
|
-
destinationAmount={dstAmount}
|
|
252
|
-
onDestinationTokenChange={() => {}}
|
|
253
|
-
onDestinationChainChange={() => {}}
|
|
254
|
-
fiatPaymentMethodIndex={PanelView.FIAT_PAYMENT_METHOD}
|
|
255
|
-
recipientSelectionPanelIndex={PanelView.RECIPIENT_SELECTION}
|
|
256
|
-
anyspendQuote={anyspendQuote}
|
|
257
|
-
onShowPointsDetail={() => setActivePanel(PanelView.POINTS_DETAIL)}
|
|
258
|
-
onShowFeeDetail={() => setActivePanel(PanelView.FEE_DETAIL)}
|
|
259
|
-
customUsdInputValues={customUsdInputValues}
|
|
260
|
-
/>
|
|
261
|
-
</motion.div>
|
|
262
|
-
)}
|
|
263
|
-
|
|
264
|
-
{/* Reverse swap direction section */}
|
|
265
|
-
<div
|
|
266
|
-
className={cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden")}
|
|
267
|
-
>
|
|
268
|
-
<Button
|
|
269
|
-
variant="ghost"
|
|
270
|
-
className={cn(
|
|
271
|
-
"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",
|
|
272
|
-
)}
|
|
273
|
-
>
|
|
274
|
-
<div className="relative flex items-center justify-center transition-opacity">
|
|
275
|
-
<ArrowDown className="text-as-primary/50 h-5 w-5" />
|
|
276
|
-
</div>
|
|
277
|
-
</Button>
|
|
278
|
-
</div>
|
|
279
|
-
|
|
280
|
-
{/* Receive section - Hidden when fiat tab is active */}
|
|
281
|
-
{paymentType === "crypto" && (
|
|
282
|
-
<CryptoReceiveSection
|
|
283
|
-
isDepositMode={false}
|
|
284
|
-
isBuyMode={true}
|
|
285
|
-
selectedRecipientAddress={selectedRecipientAddress}
|
|
286
|
-
recipientName={recipientName || undefined}
|
|
287
|
-
onSelectRecipient={() => setActivePanel(PanelView.RECIPIENT_SELECTION)}
|
|
288
|
-
setRecipientAddress={setSelectedRecipientAddress}
|
|
289
|
-
recipientAddressFromProps={recipientAddress}
|
|
290
|
-
globalAddress={globalAddress}
|
|
291
|
-
dstAmount={dstAmount}
|
|
292
|
-
dstToken={B3_TOKEN}
|
|
293
|
-
dstTokenSymbol={HYPE_TOKEN_DETAILS.SYMBOL}
|
|
294
|
-
dstTokenLogoURI={HYPE_TOKEN_DETAILS.LOGO_URI}
|
|
295
|
-
selectedDstChainId={base.id}
|
|
296
|
-
setSelectedDstChainId={() => {}}
|
|
297
|
-
setSelectedDstToken={() => {}}
|
|
298
|
-
isSrcInputDirty={isSrcInputDirty}
|
|
299
|
-
onChangeDstAmount={value => {
|
|
300
|
-
setIsSrcInputDirty(false);
|
|
301
|
-
setSrcAmount(value);
|
|
302
|
-
}}
|
|
303
|
-
anyspendQuote={anyspendQuote}
|
|
304
|
-
onShowPointsDetail={() => setActivePanel(PanelView.POINTS_DETAIL)}
|
|
305
|
-
onShowFeeDetail={() => setActivePanel(PanelView.FEE_DETAIL)}
|
|
306
|
-
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
307
|
-
/>
|
|
308
|
-
)}
|
|
309
|
-
</div>
|
|
42
|
+
if (!recipientAddress) return null;
|
|
43
|
+
|
|
44
|
+
const header = () => (
|
|
45
|
+
<div className="mb-4 flex flex-col items-center gap-3 text-center">
|
|
46
|
+
<div>
|
|
47
|
+
<h1 className="text-as-primary text-xl font-bold">
|
|
48
|
+
{paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat"}
|
|
49
|
+
</h1>
|
|
310
50
|
</div>
|
|
311
|
-
|
|
312
|
-
{/* Main button section */}
|
|
313
|
-
<motion.div
|
|
314
|
-
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
315
|
-
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
|
|
316
|
-
transition={{ duration: 0.3, delay: 0.2, ease: "easeInOut" }}
|
|
317
|
-
className={cn("mt-4 flex w-full max-w-[460px] flex-col gap-2")}
|
|
318
|
-
>
|
|
319
|
-
<ShinyButton
|
|
320
|
-
accentColor={"hsl(var(--as-brand))"}
|
|
321
|
-
disabled={btnInfo.disable}
|
|
322
|
-
onClick={onMainButtonClick}
|
|
323
|
-
className={cn(
|
|
324
|
-
"as-main-button relative w-full",
|
|
325
|
-
btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand",
|
|
326
|
-
)}
|
|
327
|
-
textClassName={cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white")}
|
|
328
|
-
>
|
|
329
|
-
<div className="flex items-center justify-center gap-2">
|
|
330
|
-
{btnInfo.loading && <Loader2 className="h-4 w-4 animate-spin" />}
|
|
331
|
-
{btnInfo.text}
|
|
332
|
-
</div>
|
|
333
|
-
</ShinyButton>
|
|
334
|
-
</motion.div>
|
|
335
|
-
|
|
336
|
-
{mainFooter ? mainFooter : null}
|
|
337
51
|
</div>
|
|
338
52
|
);
|
|
339
53
|
|
|
340
|
-
//
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
recipientAddress: selectedRecipientAddress,
|
|
349
|
-
orderType: "hype_duel",
|
|
350
|
-
srcChain: selectedSrcChainId,
|
|
351
|
-
dstChain: base.id,
|
|
352
|
-
srcToken: selectedSrcToken,
|
|
353
|
-
dstToken: B3_TOKEN,
|
|
354
|
-
srcAmount: srcAmountBigInt.toString(),
|
|
355
|
-
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
356
|
-
creatorAddress: globalAddress,
|
|
357
|
-
});
|
|
358
|
-
} catch (err: any) {
|
|
359
|
-
console.error(err);
|
|
360
|
-
toast.error("Failed to create order: " + err.message);
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
// Handle fiat order creation
|
|
365
|
-
const handleFiatOrder = async () => {
|
|
366
|
-
try {
|
|
367
|
-
invariant(anyspendQuote, "Relay price is not found");
|
|
368
|
-
invariant(selectedRecipientAddress, "Recipient address is not found");
|
|
369
|
-
|
|
370
|
-
if (!srcAmount || parseFloat(srcAmount) <= 0) {
|
|
371
|
-
toast.error("Please enter a valid amount");
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// Determine vendor and payment method string
|
|
376
|
-
let vendor: "coinbase" | "stripe" | "stripe-web2";
|
|
377
|
-
let paymentMethodString = "";
|
|
378
|
-
|
|
379
|
-
if (selectedFiatPaymentMethod === FiatPaymentMethod.COINBASE_PAY) {
|
|
380
|
-
if (coinbaseAvailablePaymentMethods.length === 0) {
|
|
381
|
-
toast.error("Coinbase Pay not available");
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
vendor = "coinbase";
|
|
385
|
-
paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || "";
|
|
386
|
-
} else if (selectedFiatPaymentMethod === FiatPaymentMethod.STRIPE) {
|
|
387
|
-
if (!stripeWeb2Support || !stripeWeb2Support.isSupport) {
|
|
388
|
-
toast.error("Stripe not available");
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
vendor = "stripe-web2";
|
|
392
|
-
paymentMethodString = "";
|
|
393
|
-
} else {
|
|
394
|
-
toast.error("Please select a payment method");
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
createOnrampOrder({
|
|
399
|
-
recipientAddress: selectedRecipientAddress,
|
|
400
|
-
orderType: "hype_duel",
|
|
401
|
-
dstChain: base.id,
|
|
402
|
-
dstToken: B3_TOKEN,
|
|
403
|
-
srcFiatAmount: srcAmount,
|
|
404
|
-
onramp: {
|
|
405
|
-
vendor: vendor,
|
|
406
|
-
paymentMethod: paymentMethodString,
|
|
407
|
-
country: geoData?.country || "US",
|
|
408
|
-
redirectUrl: window.location.origin,
|
|
409
|
-
},
|
|
410
|
-
expectedDstAmount: anyspendQuote?.data?.currencyOut?.amount?.toString() || "0",
|
|
411
|
-
creatorAddress: globalAddress,
|
|
412
|
-
});
|
|
413
|
-
} catch (err: any) {
|
|
414
|
-
console.error(err);
|
|
415
|
-
toast.error("Failed to create order: " + err.message);
|
|
416
|
-
}
|
|
54
|
+
// Create a modified B3_TOKEN with HYPE branding
|
|
55
|
+
const hypeToken: components["schemas"]["Token"] = {
|
|
56
|
+
...B3_TOKEN,
|
|
57
|
+
symbol: HYPE_TOKEN_DETAILS.SYMBOL,
|
|
58
|
+
metadata: {
|
|
59
|
+
...B3_TOKEN.metadata,
|
|
60
|
+
logoURI: HYPE_TOKEN_DETAILS.LOGO_URI,
|
|
61
|
+
},
|
|
417
62
|
};
|
|
418
63
|
|
|
419
|
-
// Order details view
|
|
420
|
-
const orderDetailsView = (
|
|
421
|
-
<div className={"mx-auto w-[460px] max-w-full"}>
|
|
422
|
-
<div className="relative flex flex-col gap-4">
|
|
423
|
-
{oat && (
|
|
424
|
-
<OrderDetails
|
|
425
|
-
mode={mode}
|
|
426
|
-
order={oat.data.order}
|
|
427
|
-
depositTxs={oat.data.depositTxs}
|
|
428
|
-
relayTxs={oat.data.relayTxs}
|
|
429
|
-
executeTx={oat.data.executeTx}
|
|
430
|
-
refundTxs={oat.data.refundTxs}
|
|
431
|
-
cryptoPaymentMethod={paymentType === "fiat" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod}
|
|
432
|
-
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
433
|
-
onPaymentMethodChange={setSelectedCryptoPaymentMethod}
|
|
434
|
-
onBack={() => {
|
|
435
|
-
setOrderId(undefined);
|
|
436
|
-
setActivePanel(PanelView.MAIN);
|
|
437
|
-
}}
|
|
438
|
-
disableUrlParamManagement
|
|
439
|
-
points={oat.data.points || undefined}
|
|
440
|
-
/>
|
|
441
|
-
)}
|
|
442
|
-
</div>
|
|
443
|
-
</div>
|
|
444
|
-
);
|
|
445
|
-
|
|
446
|
-
// Loading view
|
|
447
|
-
const loadingView = (
|
|
448
|
-
<div className="mx-auto flex w-full flex-col items-center gap-4 p-5">
|
|
449
|
-
<div className="text-as-primary">Loading order details...</div>
|
|
450
|
-
</div>
|
|
451
|
-
);
|
|
452
|
-
|
|
453
|
-
// Panel views
|
|
454
|
-
const recipientSelectionView = (
|
|
455
|
-
<RecipientSelection
|
|
456
|
-
initialValue={selectedRecipientAddress || ""}
|
|
457
|
-
onBack={() => setActivePanel(PanelView.MAIN)}
|
|
458
|
-
onConfirm={address => {
|
|
459
|
-
setSelectedRecipientAddress(address);
|
|
460
|
-
setActivePanel(PanelView.MAIN);
|
|
461
|
-
}}
|
|
462
|
-
/>
|
|
463
|
-
);
|
|
464
|
-
|
|
465
|
-
const cryptoPaymentMethodView = (
|
|
466
|
-
<CryptoPaymentMethod
|
|
467
|
-
globalAddress={globalAddress}
|
|
468
|
-
globalWallet={undefined}
|
|
469
|
-
selectedPaymentMethod={selectedCryptoPaymentMethod}
|
|
470
|
-
setSelectedPaymentMethod={setSelectedCryptoPaymentMethod}
|
|
471
|
-
isCreatingOrder={isCreatingOrder}
|
|
472
|
-
onBack={() => setActivePanel(PanelView.MAIN)}
|
|
473
|
-
onSelectPaymentMethod={(method: CryptoPaymentMethodType) => {
|
|
474
|
-
setSelectedCryptoPaymentMethod(method);
|
|
475
|
-
setActivePanel(PanelView.MAIN);
|
|
476
|
-
}}
|
|
477
|
-
/>
|
|
478
|
-
);
|
|
479
|
-
|
|
480
|
-
const fiatPaymentMethodView = (
|
|
481
|
-
<FiatPaymentMethodComponent
|
|
482
|
-
selectedPaymentMethod={selectedFiatPaymentMethod}
|
|
483
|
-
setSelectedPaymentMethod={setSelectedFiatPaymentMethod}
|
|
484
|
-
onBack={() => setActivePanel(PanelView.MAIN)}
|
|
485
|
-
onSelectPaymentMethod={(method: FiatPaymentMethod) => {
|
|
486
|
-
setSelectedFiatPaymentMethod(method);
|
|
487
|
-
setActivePanel(PanelView.MAIN);
|
|
488
|
-
}}
|
|
489
|
-
srcAmountOnRamp={srcAmount}
|
|
490
|
-
/>
|
|
491
|
-
);
|
|
492
|
-
|
|
493
|
-
const pointsDetailView = (
|
|
494
|
-
<PointsDetailPanel
|
|
495
|
-
pointsAmount={anyspendQuote?.data?.pointsAmount || 0}
|
|
496
|
-
onBack={() => setActivePanel(PanelView.MAIN)}
|
|
497
|
-
/>
|
|
498
|
-
);
|
|
499
|
-
|
|
500
|
-
const feeDetailView = anyspendQuote?.data?.fee ? (
|
|
501
|
-
<FeeDetailPanel
|
|
502
|
-
fee={anyspendQuote.data.fee}
|
|
503
|
-
transactionAmountUsd={
|
|
504
|
-
paymentType === "fiat"
|
|
505
|
-
? parseFloat(srcAmount)
|
|
506
|
-
: anyspendQuote.data.currencyIn?.amountUsd
|
|
507
|
-
? Number(anyspendQuote.data.currencyIn.amountUsd)
|
|
508
|
-
: undefined
|
|
509
|
-
}
|
|
510
|
-
onBack={() => setActivePanel(PanelView.MAIN)}
|
|
511
|
-
/>
|
|
512
|
-
) : null;
|
|
513
|
-
|
|
514
|
-
// If showing token selection, render with panel transitions
|
|
515
64
|
return (
|
|
516
|
-
<
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
className={cn("rounded-2xl", {
|
|
535
|
-
"mt-0": mode === "modal",
|
|
536
|
-
})}
|
|
537
|
-
variants={{
|
|
538
|
-
enter: { x: 300, opacity: 0 },
|
|
539
|
-
center: { x: 0, opacity: 1 },
|
|
540
|
-
exit: { x: -300, opacity: 0 },
|
|
541
|
-
}}
|
|
542
|
-
transition={{ type: "spring", stiffness: 300, damping: 30 }}
|
|
543
|
-
>
|
|
544
|
-
{[
|
|
545
|
-
<div key="main-view" className={cn(mode === "page" && "p-6")}>
|
|
546
|
-
{mainView}
|
|
547
|
-
</div>,
|
|
548
|
-
<div key="crypto-payment-method-view" className={cn(mode === "page" && "p-6")}>
|
|
549
|
-
{cryptoPaymentMethodView}
|
|
550
|
-
</div>,
|
|
551
|
-
<div key="fiat-payment-method-view" className={cn(mode === "page" && "p-6")}>
|
|
552
|
-
{fiatPaymentMethodView}
|
|
553
|
-
</div>,
|
|
554
|
-
<div key="recipient-selection-view" className={cn(mode === "page" && "p-6")}>
|
|
555
|
-
{recipientSelectionView}
|
|
556
|
-
</div>,
|
|
557
|
-
<div key="order-details-view" className={cn(mode === "page" && "p-6")}>
|
|
558
|
-
{orderDetailsView}
|
|
559
|
-
</div>,
|
|
560
|
-
<div key="loading-view" className={cn(mode === "page" && "p-6")}>
|
|
561
|
-
{loadingView}
|
|
562
|
-
</div>,
|
|
563
|
-
<div key="points-detail-view" className={cn(mode === "page" && "p-6")}>
|
|
564
|
-
{pointsDetailView}
|
|
565
|
-
</div>,
|
|
566
|
-
<div key="fee-detail-view" className={cn(mode === "page" && "p-6")}>
|
|
567
|
-
{feeDetailView}
|
|
568
|
-
</div>,
|
|
569
|
-
]}
|
|
570
|
-
</TransitionPanel>
|
|
571
|
-
</div>
|
|
572
|
-
</StyleRoot>
|
|
65
|
+
<AnySpendCustomExactIn
|
|
66
|
+
loadOrder={loadOrder}
|
|
67
|
+
mode={mode}
|
|
68
|
+
recipientAddress={recipientAddress}
|
|
69
|
+
paymentType={paymentType}
|
|
70
|
+
sourceTokenAddress={sourceTokenAddress}
|
|
71
|
+
sourceTokenChainId={sourceTokenChainId}
|
|
72
|
+
destinationToken={hypeToken}
|
|
73
|
+
destinationChainId={base.id}
|
|
74
|
+
orderType="hype_duel"
|
|
75
|
+
minDestinationAmount={10}
|
|
76
|
+
header={header}
|
|
77
|
+
onSuccess={onSuccess}
|
|
78
|
+
mainFooter={mainFooter}
|
|
79
|
+
onTokenSelect={onTokenSelect}
|
|
80
|
+
customUsdInputValues={customUsdInputValues}
|
|
81
|
+
preferEoa={preferEoa}
|
|
82
|
+
/>
|
|
573
83
|
);
|
|
574
84
|
}
|
|
@@ -53,8 +53,6 @@ export function OrderTokenAmount({
|
|
|
53
53
|
}) {
|
|
54
54
|
// Track previous token to detect changes
|
|
55
55
|
const prevTokenRef = useRef<string>(token.address);
|
|
56
|
-
// Track if initial balance has been set
|
|
57
|
-
const initialBalanceSetRef = useRef(false);
|
|
58
56
|
|
|
59
57
|
// Only get token balance when context is "from" (for setting max amount)
|
|
60
58
|
const { rawBalance } = useTokenBalance({
|
|
@@ -62,23 +60,15 @@ export function OrderTokenAmount({
|
|
|
62
60
|
address: context === "from" && walletAddress ? walletAddress : undefined,
|
|
63
61
|
});
|
|
64
62
|
|
|
65
|
-
// Reset balance ref when token address or chain changes
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
initialBalanceSetRef.current = false;
|
|
68
|
-
}, [token.address, token.chainId]);
|
|
69
|
-
|
|
70
63
|
useEffect(() => {
|
|
71
64
|
// Only handle "from" context
|
|
72
65
|
if (context !== "from") return;
|
|
73
66
|
|
|
74
67
|
// Check if token changed or if this is the initial load with balance
|
|
75
68
|
const isTokenChanged = prevTokenRef.current !== token.address;
|
|
76
|
-
const isInitialLoad = !initialBalanceSetRef.current && rawBalance;
|
|
77
69
|
|
|
78
|
-
if (
|
|
79
|
-
console.log(
|
|
80
|
-
`Setting max balance - Token: ${token.address}, Changed: ${isTokenChanged}, Initial: ${isInitialLoad}`,
|
|
81
|
-
);
|
|
70
|
+
if (isTokenChanged && rawBalance) {
|
|
71
|
+
console.log(`Setting max balance - Token: ${token.address}, Changed: ${isTokenChanged}`);
|
|
82
72
|
|
|
83
73
|
// Calculate max amount with gas reserve for native tokens
|
|
84
74
|
let maxAmount: bigint;
|
|
@@ -97,7 +87,6 @@ export function OrderTokenAmount({
|
|
|
97
87
|
|
|
98
88
|
// Update refs
|
|
99
89
|
prevTokenRef.current = token.address;
|
|
100
|
-
initialBalanceSetRef.current = true;
|
|
101
90
|
}
|
|
102
91
|
}, [token.address, token.chainId, token.decimals, chainId, context, onChangeInput, rawBalance]);
|
|
103
92
|
|
|
@@ -4,6 +4,7 @@ export { AnySpendBondKit } from "./AnySpendBondKit";
|
|
|
4
4
|
export { AnySpendBuySpin } from "./AnySpendBuySpin";
|
|
5
5
|
export { AnySpendCustom } from "./AnySpendCustom";
|
|
6
6
|
export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn";
|
|
7
|
+
export { AnySpendDepositHype, HYPE_TOKEN_DETAILS } from "./AnyspendDepositHype";
|
|
7
8
|
export * from "./AnySpendFingerprintWrapper";
|
|
8
9
|
export { AnySpendNFT } from "./AnySpendNFT";
|
|
9
10
|
export { AnyspendSignatureMint } from "./AnyspendSignatureMint";
|