@b3dotfun/sdk 0.0.29 → 0.0.30-alpha.1
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 +2 -2
- 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/AnySpendBuySpin.js +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +2 -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 +124 -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/OrderTokenAmount.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.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/useB3BalanceFromAddresses.js +2 -1
- package/dist/cjs/global-account/react/hooks/useNativeBalance.js +2 -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/cjs/shared/constants/index.d.ts +1 -0
- package/dist/cjs/shared/constants/index.js +2 -1
- 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 +2 -2
- 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/AnySpendBuySpin.js +2 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +2 -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 +126 -43
- 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/OrderTokenAmount.js +1 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.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/useB3BalanceFromAddresses.js +2 -1
- package/dist/esm/global-account/react/hooks/useNativeBalance.js +2 -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/esm/shared/constants/index.d.ts +1 -0
- package/dist/esm/shared/constants/index.js +1 -0
- 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/components/common/PanelOnramp.d.ts +2 -1
- 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/dist/types/shared/constants/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +2 -0
- package/src/anyspend/react/components/AnySpend.tsx +2 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +28 -28
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +2 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +1 -1
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +2 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +143 -130
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +9 -0
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +243 -104
- 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/OrderTokenAmount.tsx +2 -2
- package/src/anyspend/react/components/common/PanelOnramp.tsx +3 -1
- package/src/anyspend/react/components/common/PaySection.tsx +10 -8
- 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/useB3BalanceFromAddresses.ts +2 -1
- package/src/global-account/react/hooks/useNativeBalance.tsx +2 -1
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +1 -0
- package/src/global-account/react/stores/useModalStore.ts +4 -2
- package/src/shared/constants/index.ts +2 -0
- 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,126 @@ 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
|
+
recipientSelectionPanelIndex={PanelView.RECIPIENT_SELECTION}
|
|
236
|
+
/>
|
|
237
|
+
</motion.div>
|
|
238
|
+
)}
|
|
239
|
+
|
|
240
|
+
{/* Reverse swap direction section */}
|
|
241
|
+
<div
|
|
242
|
+
className={cn("relative -my-1 flex h-0 items-center justify-center", paymentType === "fiat" && "hidden")}
|
|
243
|
+
>
|
|
244
|
+
<Button
|
|
245
|
+
variant="ghost"
|
|
246
|
+
className={cn(
|
|
247
|
+
"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",
|
|
248
|
+
)}
|
|
249
|
+
>
|
|
250
|
+
<div className="relative flex items-center justify-center transition-opacity">
|
|
251
|
+
<ArrowDown className="text-as-primary/50 h-5 w-5" />
|
|
252
|
+
</div>
|
|
253
|
+
</Button>
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
{/* Receive section - Hidden when fiat tab is active */}
|
|
257
|
+
{paymentType === "crypto" && (
|
|
258
|
+
<CryptoReceiveSection
|
|
259
|
+
isDepositMode={false}
|
|
260
|
+
isBuyMode={true}
|
|
261
|
+
selectedRecipientAddress={recipientAddress}
|
|
262
|
+
recipientName={recipientName || undefined}
|
|
263
|
+
onSelectRecipient={() => setActivePanel(PanelView.RECIPIENT_SELECTION)}
|
|
264
|
+
dstAmount={dstAmount}
|
|
265
|
+
dstToken={B3_TOKEN}
|
|
266
|
+
selectedDstChainId={base.id}
|
|
267
|
+
setSelectedDstChainId={() => {}}
|
|
268
|
+
setSelectedDstToken={() => {}}
|
|
269
|
+
onChangeDstAmount={value => {
|
|
270
|
+
setIsSrcInputDirty(false);
|
|
271
|
+
setSrcAmount(value);
|
|
272
|
+
}}
|
|
273
|
+
anyspendQuote={anyspendQuote}
|
|
274
|
+
/>
|
|
275
|
+
)}
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
|
|
279
|
+
{/* Error message section */}
|
|
280
|
+
<ErrorSection error={getAnyspendQuoteError} />
|
|
281
|
+
|
|
282
|
+
{/* Main button section */}
|
|
283
|
+
<motion.div
|
|
284
|
+
initial={{ opacity: 0, y: 20, filter: "blur(10px)" }}
|
|
285
|
+
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
|
|
286
|
+
transition={{ duration: 0.3, delay: 0.2, ease: "easeInOut" }}
|
|
287
|
+
className={cn("mt-4 flex w-full max-w-[460px] flex-col gap-2", getAnyspendQuoteError && "mt-0")}
|
|
288
|
+
>
|
|
289
|
+
<ShinyButton
|
|
290
|
+
accentColor={"hsl(var(--as-brand))"}
|
|
291
|
+
disabled={btnInfo.disable}
|
|
292
|
+
onClick={onMainButtonClick}
|
|
293
|
+
className={cn(
|
|
294
|
+
"as-main-button relative w-full",
|
|
295
|
+
btnInfo.error ? "!bg-as-red" : btnInfo.disable ? "!bg-as-on-surface-2" : "!bg-as-brand",
|
|
296
|
+
)}
|
|
297
|
+
textClassName={cn(btnInfo.error ? "text-white" : btnInfo.disable ? "text-as-secondary" : "text-white")}
|
|
298
|
+
>
|
|
299
|
+
{btnInfo.text}
|
|
300
|
+
</ShinyButton>
|
|
301
|
+
</motion.div>
|
|
302
|
+
|
|
303
|
+
{mainFooter ? mainFooter : null}
|
|
304
|
+
</div>
|
|
305
|
+
);
|
|
306
|
+
|
|
188
307
|
// Handle crypto order creation
|
|
189
308
|
const handleCryptoOrder = async () => {
|
|
190
309
|
try {
|
|
@@ -193,7 +312,12 @@ function AnySpendDepositHypeInner({
|
|
|
193
312
|
invariant(depositContractAddress, "Deposit contract address is not found");
|
|
194
313
|
|
|
195
314
|
const srcAmountBigInt = BigInt(activeInputAmountInWei);
|
|
196
|
-
|
|
315
|
+
// TODO: temp subtract 3% for slippage
|
|
316
|
+
const originalDepositAmountWei = anyspendQuote.data?.currencyOut?.amount || "0";
|
|
317
|
+
const depositAmountWei = (
|
|
318
|
+
(BigInt(originalDepositAmountWei) * BigInt(100 - SLIPPAGE_PERCENT)) /
|
|
319
|
+
BigInt(100)
|
|
320
|
+
).toString();
|
|
197
321
|
const encodedData = generateEncodedDataForDepositHype(depositAmountWei, selectedRecipientAddress);
|
|
198
322
|
|
|
199
323
|
createOrder({
|
|
@@ -209,7 +333,7 @@ function AnySpendDepositHypeInner({
|
|
|
209
333
|
amount: depositAmountWei,
|
|
210
334
|
data: encodedData,
|
|
211
335
|
to: depositContractAddress,
|
|
212
|
-
action:
|
|
336
|
+
action: DEPOSIT_HYPE_ACTION,
|
|
213
337
|
},
|
|
214
338
|
});
|
|
215
339
|
} catch (err: any) {
|
|
@@ -274,7 +398,7 @@ function AnySpendDepositHypeInner({
|
|
|
274
398
|
amount: depositAmountWei,
|
|
275
399
|
data: encodedData,
|
|
276
400
|
to: depositContractAddress,
|
|
277
|
-
action:
|
|
401
|
+
action: DEPOSIT_HYPE_ACTION,
|
|
278
402
|
},
|
|
279
403
|
});
|
|
280
404
|
} catch (err: any) {
|
|
@@ -289,7 +413,7 @@ function AnySpendDepositHypeInner({
|
|
|
289
413
|
<div className="relative flex flex-col gap-4">
|
|
290
414
|
{oat && (
|
|
291
415
|
<>
|
|
292
|
-
<OrderStatus order={oat.data.order} />
|
|
416
|
+
<OrderStatus order={oat.data.order} selectedCryptoPaymentMethod={selectedCryptoPaymentMethod} />
|
|
293
417
|
<OrderDetails
|
|
294
418
|
mode={mode}
|
|
295
419
|
order={oat.data.order}
|
|
@@ -299,6 +423,7 @@ function AnySpendDepositHypeInner({
|
|
|
299
423
|
refundTxs={oat.data.refundTxs}
|
|
300
424
|
cryptoPaymentMethod={paymentType === "fiat" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod}
|
|
301
425
|
onBack={() => {
|
|
426
|
+
setOrderId(undefined);
|
|
302
427
|
setActivePanel(PanelView.MAIN);
|
|
303
428
|
onSuccess?.();
|
|
304
429
|
}}
|
|
@@ -388,119 +513,7 @@ function AnySpendDepositHypeInner({
|
|
|
388
513
|
>
|
|
389
514
|
{[
|
|
390
515
|
<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>
|
|
516
|
+
{mainView}
|
|
504
517
|
</div>,
|
|
505
518
|
<div key="crypto-payment-method-view" className={cn(mode === "page" && "p-6")}>
|
|
506
519
|
{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
|