@b3dotfun/sdk 0.0.29 → 0.0.30-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/constants/index.d.ts +1 -0
- package/dist/cjs/anyspend/constants/index.js +2 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +17 -10
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +9 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +130 -41
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +6 -3
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +6 -4
- package/dist/cjs/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaySection.js +6 -4
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +34 -3
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/cjs/bondkit/abis/BondkitTokenABI.js +41 -9
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/cjs/bondkit/abis/BondkitTokenFactoryABI.js +0 -9
- package/dist/cjs/bondkit/constants.js +1 -1
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +28 -15
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/cjs/shared/constants/chains/supported.d.ts +4 -4
- package/dist/esm/anyspend/constants/index.d.ts +1 -0
- package/dist/esm/anyspend/constants/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +23 -24
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +19 -12
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +6 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +133 -44
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +7 -4
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +7 -5
- package/dist/esm/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaySection.js +7 -5
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +35 -4
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/esm/bondkit/abis/BondkitTokenABI.js +41 -9
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/esm/bondkit/abis/BondkitTokenFactoryABI.js +0 -9
- package/dist/esm/bondkit/constants.js +1 -1
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +28 -15
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/esm/shared/constants/chains/supported.d.ts +4 -4
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendBondKit.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnyspendDepositHype.d.ts +4 -2
- package/dist/types/anyspend/react/components/common/OrderStatus.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/bondkit/abis/BondkitTokenABI.d.ts +62 -17
- package/dist/types/bondkit/abis/BondkitTokenFactoryABI.d.ts +0 -25
- package/dist/types/global-account/react/hooks/useUnifiedChainSwitchAndExecute.d.ts +1 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -2
- package/dist/types/shared/constants/chains/b3Chain.d.ts +2 -2
- package/dist/types/shared/constants/chains/supported.d.ts +4 -4
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +2 -0
- package/src/anyspend/react/components/AnySpend.tsx +1 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +28 -28
- package/src/anyspend/react/components/AnySpendCustom.tsx +1 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +142 -130
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +9 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +289 -103
- package/src/anyspend/react/components/common/OrderDetails.tsx +7 -3
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +10 -4
- package/src/anyspend/react/components/common/OrderStatus.tsx +9 -2
- package/src/anyspend/react/components/common/PaySection.tsx +9 -7
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +41 -3
- package/src/bondkit/abis/BondkitTokenABI.ts +41 -9
- package/src/bondkit/abis/BondkitTokenFactoryABI.ts +0 -9
- package/src/bondkit/constants.ts +1 -1
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +26 -10
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +5 -1
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +1 -0
- package/src/global-account/react/stores/useModalStore.ts +4 -2
- package/dist/cjs/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/cjs/anyspend/abis/bondKit.js +0 -29
- package/dist/esm/anyspend/abis/bondKit.d.ts +0 -35
- package/dist/esm/anyspend/abis/bondKit.js +0 -26
- package/dist/types/anyspend/abis/bondKit.d.ts +0 -35
- package/src/anyspend/abis/bondKit.ts +0 -26
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B3_TOKEN } from "@b3dotfun/sdk/anyspend";
|
|
1
|
+
import { B3_TOKEN, DEPOSIT_HYPE_ACTION } from "@b3dotfun/sdk/anyspend";
|
|
2
2
|
import { Button, ShinyButton, StyleRoot, TransitionPanel } from "@b3dotfun/sdk/global-account/react";
|
|
3
3
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
4
4
|
import invariant from "invariant";
|
|
@@ -22,6 +22,8 @@ import { ESCROW_ABI } from "@b3dotfun/sdk/anyspend/abis/escrow";
|
|
|
22
22
|
import { ArrowDown } from "lucide-react";
|
|
23
23
|
import { PanelOnramp } from "./common/PanelOnramp";
|
|
24
24
|
|
|
25
|
+
const SLIPPAGE_PERCENT = 3;
|
|
26
|
+
|
|
25
27
|
function generateEncodedDataForDepositHype(amount: string, beneficiary: string): string {
|
|
26
28
|
invariant(BigInt(amount) > 0, "Amount must be greater than zero");
|
|
27
29
|
const encodedData = encodeFunctionData({
|
|
@@ -32,7 +34,7 @@ function generateEncodedDataForDepositHype(amount: string, beneficiary: string):
|
|
|
32
34
|
return encodedData;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
export
|
|
37
|
+
export interface AnySpendDepositHypeProps {
|
|
36
38
|
loadOrder?: string;
|
|
37
39
|
mode?: "modal" | "page";
|
|
38
40
|
recipientAddress: string;
|
|
@@ -41,7 +43,10 @@ export function AnySpendDepositHype(props: {
|
|
|
41
43
|
sourceTokenChainId?: number;
|
|
42
44
|
onSuccess?: () => void;
|
|
43
45
|
depositContractAddress?: string;
|
|
44
|
-
|
|
46
|
+
mainFooter?: React.ReactNode;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function AnySpendDepositHype(props: AnySpendDepositHypeProps) {
|
|
45
50
|
const fingerprintConfig = getFingerprintConfig();
|
|
46
51
|
|
|
47
52
|
return (
|
|
@@ -60,21 +65,14 @@ function AnySpendDepositHypeInner({
|
|
|
60
65
|
sourceTokenChainId,
|
|
61
66
|
onSuccess,
|
|
62
67
|
depositContractAddress,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
mode?: "modal" | "page";
|
|
66
|
-
recipientAddress: string;
|
|
67
|
-
paymentType?: "crypto" | "fiat";
|
|
68
|
-
sourceTokenAddress?: string;
|
|
69
|
-
sourceTokenChainId?: number;
|
|
70
|
-
onSuccess?: () => void;
|
|
71
|
-
depositContractAddress?: string;
|
|
72
|
-
}) {
|
|
68
|
+
mainFooter,
|
|
69
|
+
}: AnySpendDepositHypeProps) {
|
|
73
70
|
// Use shared flow hook
|
|
74
71
|
const {
|
|
75
72
|
activePanel,
|
|
76
73
|
setActivePanel,
|
|
77
74
|
orderId,
|
|
75
|
+
setOrderId,
|
|
78
76
|
oat,
|
|
79
77
|
selectedSrcChainId,
|
|
80
78
|
setSelectedSrcChainId,
|
|
@@ -111,6 +109,7 @@ function AnySpendDepositHypeInner({
|
|
|
111
109
|
onTransactionSuccess: onSuccess,
|
|
112
110
|
sourceTokenAddress,
|
|
113
111
|
sourceTokenChainId,
|
|
112
|
+
slippage: SLIPPAGE_PERCENT,
|
|
114
113
|
});
|
|
115
114
|
|
|
116
115
|
// Button state logic
|
|
@@ -185,6 +184,125 @@ function AnySpendDepositHypeInner({
|
|
|
185
184
|
}
|
|
186
185
|
};
|
|
187
186
|
|
|
187
|
+
const mainView = (
|
|
188
|
+
<div className="mx-auto flex w-[460px] max-w-full flex-col items-center gap-2">
|
|
189
|
+
{/* Header */}
|
|
190
|
+
<div className="mb-4 flex flex-col items-center gap-3 text-center">
|
|
191
|
+
<div>
|
|
192
|
+
<h1 className="text-as-primary text-xl font-bold">
|
|
193
|
+
{paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat"}
|
|
194
|
+
</h1>
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
<div className="relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2">
|
|
199
|
+
<div className="relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2">
|
|
200
|
+
{/* Send section */}
|
|
201
|
+
{paymentType === "crypto" ? (
|
|
202
|
+
<PaySection
|
|
203
|
+
paymentType="crypto"
|
|
204
|
+
selectedSrcChainId={selectedSrcChainId}
|
|
205
|
+
setSelectedSrcChainId={setSelectedSrcChainId}
|
|
206
|
+
selectedSrcToken={selectedSrcToken}
|
|
207
|
+
setSelectedSrcToken={setSelectedSrcToken}
|
|
208
|
+
srcAmount={srcAmount}
|
|
209
|
+
setSrcAmount={setSrcAmount}
|
|
210
|
+
setIsSrcInputDirty={setIsSrcInputDirty}
|
|
211
|
+
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
212
|
+
selectedFiatPaymentMethod={selectedFiatPaymentMethod}
|
|
213
|
+
onSelectCryptoPaymentMethod={() => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD)}
|
|
214
|
+
onSelectFiatPaymentMethod={() => setActivePanel(PanelView.FIAT_PAYMENT_METHOD)}
|
|
215
|
+
anyspendQuote={anyspendQuote}
|
|
216
|
+
/>
|
|
217
|
+
) : (
|
|
218
|
+
<motion.div
|
|
219
|
+
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
220
|
+
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
|
|
221
|
+
transition={{ duration: 0.3, delay: 0, ease: "easeInOut" }}
|
|
222
|
+
>
|
|
223
|
+
<PanelOnramp
|
|
224
|
+
srcAmountOnRamp={srcAmount}
|
|
225
|
+
setSrcAmountOnRamp={setSrcAmount}
|
|
226
|
+
selectedPaymentMethod={selectedFiatPaymentMethod}
|
|
227
|
+
setActivePanel={setActivePanel}
|
|
228
|
+
_recipientAddress={recipientAddress}
|
|
229
|
+
destinationToken={B3_TOKEN}
|
|
230
|
+
destinationChainId={base.id}
|
|
231
|
+
destinationAmount={dstAmount}
|
|
232
|
+
onDestinationTokenChange={() => {}}
|
|
233
|
+
onDestinationChainChange={() => {}}
|
|
234
|
+
fiatPaymentMethodIndex={PanelView.FIAT_PAYMENT_METHOD}
|
|
235
|
+
/>
|
|
236
|
+
</motion.div>
|
|
237
|
+
)}
|
|
238
|
+
|
|
239
|
+
{/* Reverse swap direction section */}
|
|
240
|
+
<div
|
|
241
|
+
className={cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden")}
|
|
242
|
+
>
|
|
243
|
+
<Button
|
|
244
|
+
variant="ghost"
|
|
245
|
+
className={cn(
|
|
246
|
+
"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",
|
|
247
|
+
)}
|
|
248
|
+
>
|
|
249
|
+
<div className="relative flex items-center justify-center transition-opacity">
|
|
250
|
+
<ArrowDown className="text-as-primary/50 h-5 w-5" />
|
|
251
|
+
</div>
|
|
252
|
+
</Button>
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
{/* Receive section - Hidden when fiat tab is active */}
|
|
256
|
+
{paymentType === "crypto" && (
|
|
257
|
+
<CryptoReceiveSection
|
|
258
|
+
isDepositMode={false}
|
|
259
|
+
isBuyMode={true}
|
|
260
|
+
selectedRecipientAddress={recipientAddress}
|
|
261
|
+
recipientName={recipientName || undefined}
|
|
262
|
+
onSelectRecipient={() => setActivePanel(PanelView.RECIPIENT_SELECTION)}
|
|
263
|
+
dstAmount={dstAmount}
|
|
264
|
+
dstToken={B3_TOKEN}
|
|
265
|
+
selectedDstChainId={base.id}
|
|
266
|
+
setSelectedDstChainId={() => {}}
|
|
267
|
+
setSelectedDstToken={() => {}}
|
|
268
|
+
onChangeDstAmount={value => {
|
|
269
|
+
setIsSrcInputDirty(false);
|
|
270
|
+
setSrcAmount(value);
|
|
271
|
+
}}
|
|
272
|
+
anyspendQuote={anyspendQuote}
|
|
273
|
+
/>
|
|
274
|
+
)}
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
|
|
278
|
+
{/* Error message section */}
|
|
279
|
+
<ErrorSection error={getAnyspendQuoteError} />
|
|
280
|
+
|
|
281
|
+
{/* Main button section */}
|
|
282
|
+
<motion.div
|
|
283
|
+
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
284
|
+
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
|
|
285
|
+
transition={{ duration: 0.3, delay: 0.2, ease: "easeInOut" }}
|
|
286
|
+
className={cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0")}
|
|
287
|
+
>
|
|
288
|
+
<ShinyButton
|
|
289
|
+
accentColor={"hsl(var(--as-brand))"}
|
|
290
|
+
disabled={btnInfo.disable}
|
|
291
|
+
onClick={onMainButtonClick}
|
|
292
|
+
className={cn(
|
|
293
|
+
"as-main-button relative w-full",
|
|
294
|
+
btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand",
|
|
295
|
+
)}
|
|
296
|
+
textClassName={cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white")}
|
|
297
|
+
>
|
|
298
|
+
{btnInfo.text}
|
|
299
|
+
</ShinyButton>
|
|
300
|
+
</motion.div>
|
|
301
|
+
|
|
302
|
+
{mainFooter ? mainFooter : null}
|
|
303
|
+
</div>
|
|
304
|
+
);
|
|
305
|
+
|
|
188
306
|
// Handle crypto order creation
|
|
189
307
|
const handleCryptoOrder = async () => {
|
|
190
308
|
try {
|
|
@@ -193,7 +311,12 @@ function AnySpendDepositHypeInner({
|
|
|
193
311
|
invariant(depositContractAddress, "Deposit contract address is not found");
|
|
194
312
|
|
|
195
313
|
const srcAmountBigInt = BigInt(activeInputAmountInWei);
|
|
196
|
-
|
|
314
|
+
// TODO: temp subtract 3% for slippage
|
|
315
|
+
const originalDepositAmountWei = anyspendQuote.data?.currencyOut?.amount || "0";
|
|
316
|
+
const depositAmountWei = (
|
|
317
|
+
(BigInt(originalDepositAmountWei) * BigInt(100 - SLIPPAGE_PERCENT)) /
|
|
318
|
+
BigInt(100)
|
|
319
|
+
).toString();
|
|
197
320
|
const encodedData = generateEncodedDataForDepositHype(depositAmountWei, selectedRecipientAddress);
|
|
198
321
|
|
|
199
322
|
createOrder({
|
|
@@ -209,7 +332,7 @@ function AnySpendDepositHypeInner({
|
|
|
209
332
|
amount: depositAmountWei,
|
|
210
333
|
data: encodedData,
|
|
211
334
|
to: depositContractAddress,
|
|
212
|
-
action:
|
|
335
|
+
action: DEPOSIT_HYPE_ACTION,
|
|
213
336
|
},
|
|
214
337
|
});
|
|
215
338
|
} catch (err: any) {
|
|
@@ -274,7 +397,7 @@ function AnySpendDepositHypeInner({
|
|
|
274
397
|
amount: depositAmountWei,
|
|
275
398
|
data: encodedData,
|
|
276
399
|
to: depositContractAddress,
|
|
277
|
-
action:
|
|
400
|
+
action: DEPOSIT_HYPE_ACTION,
|
|
278
401
|
},
|
|
279
402
|
});
|
|
280
403
|
} catch (err: any) {
|
|
@@ -289,7 +412,7 @@ function AnySpendDepositHypeInner({
|
|
|
289
412
|
<div className="relative flex flex-col gap-4">
|
|
290
413
|
{oat && (
|
|
291
414
|
<>
|
|
292
|
-
<OrderStatus order={oat.data.order} />
|
|
415
|
+
<OrderStatus order={oat.data.order} selectedCryptoPaymentMethod={selectedCryptoPaymentMethod} />
|
|
293
416
|
<OrderDetails
|
|
294
417
|
mode={mode}
|
|
295
418
|
order={oat.data.order}
|
|
@@ -299,6 +422,7 @@ function AnySpendDepositHypeInner({
|
|
|
299
422
|
refundTxs={oat.data.refundTxs}
|
|
300
423
|
cryptoPaymentMethod={paymentType === "fiat" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod}
|
|
301
424
|
onBack={() => {
|
|
425
|
+
setOrderId(undefined);
|
|
302
426
|
setActivePanel(PanelView.MAIN);
|
|
303
427
|
onSuccess?.();
|
|
304
428
|
}}
|
|
@@ -388,119 +512,7 @@ function AnySpendDepositHypeInner({
|
|
|
388
512
|
>
|
|
389
513
|
{[
|
|
390
514
|
<div key="main-view" className={cn(mode === "page" && "p-6")}>
|
|
391
|
-
|
|
392
|
-
{/* Header */}
|
|
393
|
-
<div className="mb-4 flex flex-col items-center gap-3 text-center">
|
|
394
|
-
<div>
|
|
395
|
-
<h1 className="text-as-primary text-xl font-bold">
|
|
396
|
-
{paymentType === "crypto" ? "Deposit Crypto" : "Fund with Fiat"}
|
|
397
|
-
</h1>
|
|
398
|
-
</div>
|
|
399
|
-
</div>
|
|
400
|
-
|
|
401
|
-
<div className="relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2">
|
|
402
|
-
<div className="relative flex w-full max-w-[calc(100vw-32px)] flex-col gap-2">
|
|
403
|
-
{/* Send section */}
|
|
404
|
-
{paymentType === "crypto" ? (
|
|
405
|
-
<PaySection
|
|
406
|
-
paymentType="crypto"
|
|
407
|
-
selectedSrcChainId={selectedSrcChainId}
|
|
408
|
-
setSelectedSrcChainId={setSelectedSrcChainId}
|
|
409
|
-
selectedSrcToken={selectedSrcToken}
|
|
410
|
-
setSelectedSrcToken={setSelectedSrcToken}
|
|
411
|
-
srcAmount={srcAmount}
|
|
412
|
-
setSrcAmount={setSrcAmount}
|
|
413
|
-
setIsSrcInputDirty={setIsSrcInputDirty}
|
|
414
|
-
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
415
|
-
selectedFiatPaymentMethod={selectedFiatPaymentMethod}
|
|
416
|
-
onSelectCryptoPaymentMethod={() => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD)}
|
|
417
|
-
onSelectFiatPaymentMethod={() => setActivePanel(PanelView.FIAT_PAYMENT_METHOD)}
|
|
418
|
-
anyspendQuote={anyspendQuote}
|
|
419
|
-
/>
|
|
420
|
-
) : (
|
|
421
|
-
<motion.div
|
|
422
|
-
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
423
|
-
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
|
|
424
|
-
transition={{ duration: 0.3, delay: 0, ease: "easeInOut" }}
|
|
425
|
-
>
|
|
426
|
-
<PanelOnramp
|
|
427
|
-
srcAmountOnRamp={srcAmount}
|
|
428
|
-
setSrcAmountOnRamp={setSrcAmount}
|
|
429
|
-
selectedPaymentMethod={selectedFiatPaymentMethod}
|
|
430
|
-
setActivePanel={setActivePanel}
|
|
431
|
-
_recipientAddress={recipientAddress}
|
|
432
|
-
destinationToken={B3_TOKEN}
|
|
433
|
-
destinationChainId={base.id}
|
|
434
|
-
destinationAmount={dstAmount}
|
|
435
|
-
onDestinationTokenChange={() => {}}
|
|
436
|
-
onDestinationChainChange={() => {}}
|
|
437
|
-
fiatPaymentMethodIndex={PanelView.FIAT_PAYMENT_METHOD}
|
|
438
|
-
/>
|
|
439
|
-
</motion.div>
|
|
440
|
-
)}
|
|
441
|
-
|
|
442
|
-
{/* Reverse swap direction section */}
|
|
443
|
-
<Button
|
|
444
|
-
variant="ghost"
|
|
445
|
-
className={cn(
|
|
446
|
-
"swap-direction-button border-as-stroke bg-as-surface-primary absolute left-1/2 top-[calc(50%+56px)] z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 cursor-default rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl",
|
|
447
|
-
paymentType === "fiat" && "hidden",
|
|
448
|
-
)}
|
|
449
|
-
>
|
|
450
|
-
<div className="relative flex items-center justify-center transition-opacity">
|
|
451
|
-
<ArrowDown className="text-as-primary/50 h-5 w-5" />
|
|
452
|
-
</div>
|
|
453
|
-
</Button>
|
|
454
|
-
|
|
455
|
-
{/* Receive section - Hidden when fiat tab is active */}
|
|
456
|
-
{paymentType === "crypto" && (
|
|
457
|
-
<CryptoReceiveSection
|
|
458
|
-
isDepositMode={false}
|
|
459
|
-
isBuyMode={true}
|
|
460
|
-
selectedRecipientAddress={recipientAddress}
|
|
461
|
-
recipientName={recipientName || undefined}
|
|
462
|
-
onSelectRecipient={() => setActivePanel(PanelView.RECIPIENT_SELECTION)}
|
|
463
|
-
dstAmount={dstAmount}
|
|
464
|
-
dstToken={B3_TOKEN}
|
|
465
|
-
selectedDstChainId={base.id}
|
|
466
|
-
setSelectedDstChainId={() => {}}
|
|
467
|
-
setSelectedDstToken={() => {}}
|
|
468
|
-
onChangeDstAmount={value => {
|
|
469
|
-
setIsSrcInputDirty(false);
|
|
470
|
-
setSrcAmount(value);
|
|
471
|
-
}}
|
|
472
|
-
anyspendQuote={anyspendQuote}
|
|
473
|
-
/>
|
|
474
|
-
)}
|
|
475
|
-
</div>
|
|
476
|
-
</div>
|
|
477
|
-
|
|
478
|
-
{/* Error message section */}
|
|
479
|
-
<ErrorSection error={getAnyspendQuoteError} />
|
|
480
|
-
|
|
481
|
-
{/* Main button section */}
|
|
482
|
-
<motion.div
|
|
483
|
-
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
484
|
-
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
|
|
485
|
-
transition={{ duration: 0.3, delay: 0.2, ease: "easeInOut" }}
|
|
486
|
-
className={cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0")}
|
|
487
|
-
>
|
|
488
|
-
<ShinyButton
|
|
489
|
-
accentColor={"hsl(var(--as-brand))"}
|
|
490
|
-
disabled={btnInfo.disable}
|
|
491
|
-
onClick={onMainButtonClick}
|
|
492
|
-
className={cn(
|
|
493
|
-
"as-main-button relative w-full",
|
|
494
|
-
btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand",
|
|
495
|
-
)}
|
|
496
|
-
textClassName={cn(
|
|
497
|
-
btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white",
|
|
498
|
-
)}
|
|
499
|
-
>
|
|
500
|
-
{btnInfo.text}
|
|
501
|
-
</ShinyButton>
|
|
502
|
-
</motion.div>
|
|
503
|
-
</div>
|
|
515
|
+
{mainView}
|
|
504
516
|
</div>,
|
|
505
517
|
<div key="crypto-payment-method-view" className={cn(mode === "page" && "p-6")}>
|
|
506
518
|
{cryptoPaymentMethodView}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
import { RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend";
|
|
4
4
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
5
5
|
import { ShinyButton, useProfile } from "@b3dotfun/sdk/global-account/react";
|
|
6
|
+
import centerTruncate from "@b3dotfun/sdk/shared/utils/centerTruncate";
|
|
6
7
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
7
8
|
import { motion } from "framer-motion";
|
|
8
9
|
import { ChevronRight, Loader2 } from "lucide-react";
|
|
10
|
+
import { useAccount } from "wagmi";
|
|
9
11
|
import { OrderDetailsCollapsible } from "./OrderDetailsCollapsible";
|
|
10
12
|
|
|
11
13
|
type Tournament = components["schemas"]["Tournament"];
|
|
@@ -33,6 +35,7 @@ export default function ConnectWalletPayment({
|
|
|
33
35
|
}: ConnectWalletPaymentProps) {
|
|
34
36
|
const profile = useProfile({ address: order.recipientAddress });
|
|
35
37
|
const recipientName = profile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
38
|
+
const { address: connectedAddress } = useAccount();
|
|
36
39
|
|
|
37
40
|
const srcToken = order.metadata.srcToken;
|
|
38
41
|
const dstToken = order.metadata.dstToken;
|
|
@@ -82,6 +85,12 @@ export default function ConnectWalletPayment({
|
|
|
82
85
|
</>
|
|
83
86
|
)}
|
|
84
87
|
</ShinyButton>
|
|
88
|
+
<span className="label-style text-as-primary/50 text-xs">
|
|
89
|
+
Connected to:{" "}
|
|
90
|
+
{order.srcChain === RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
91
|
+
? centerTruncate(phantomWalletAddress, 6)
|
|
92
|
+
: centerTruncate(connectedAddress || "")}
|
|
93
|
+
</span>
|
|
85
94
|
|
|
86
95
|
<div className="mt-4">
|
|
87
96
|
<OrderDetailsCollapsible
|