@b3dotfun/sdk 0.0.20 → 0.0.21-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/README.md +28 -0
- package/dist/cjs/anyspend/index.native.d.ts +0 -2
- package/dist/cjs/anyspend/index.native.js +0 -4
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +3 -3
- package/dist/cjs/anyspend/react/components/AnySpend.js +43 -55
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +159 -84
- package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.js +2 -5
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +1 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +4 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +50 -102
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +7 -9
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +1 -3
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.d.ts +42 -0
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.example.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.example.js +27 -0
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +36 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -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/useConnectedUserProfile.d.ts +12 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.js +25 -0
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +5 -5
- package/dist/cjs/anyspend/react/index.d.ts +1 -1
- package/dist/cjs/anyspend/react/index.js +1 -1
- package/dist/cjs/anyspend/react/providers/index.d.ts +2 -0
- package/dist/cjs/anyspend/react/providers/index.js +18 -0
- package/dist/cjs/anyspend/types/api.d.ts +35 -56
- package/dist/cjs/anyspend/utils/chain.d.ts +1 -1
- package/dist/cjs/anyspend/utils/chain.js +122 -15
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +3 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +4 -1
- package/dist/cjs/global-account/react/hooks/useProfile.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/useProfile.js +9 -7
- package/dist/cjs/shared/constants/index.js +5 -3
- package/dist/cjs/shared/utils/formatUsername.d.ts +1 -1
- package/dist/cjs/shared/utils/formatUsername.js +3 -1
- package/dist/esm/anyspend/index.native.d.ts +0 -2
- package/dist/esm/anyspend/index.native.js +0 -4
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +3 -3
- package/dist/esm/anyspend/react/components/AnySpend.js +46 -58
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +163 -88
- package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.js +2 -5
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +1 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +4 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +52 -104
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +1 -1
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -10
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +1 -3
- package/dist/esm/anyspend/react/components/common/RecipientSelection.d.ts +42 -0
- package/dist/esm/anyspend/react/components/common/RecipientSelection.example.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/RecipientSelection.example.js +22 -0
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +33 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- 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/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.d.ts +12 -0
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.js +22 -0
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +5 -5
- package/dist/esm/anyspend/react/index.d.ts +1 -1
- package/dist/esm/anyspend/react/index.js +1 -1
- package/dist/esm/anyspend/react/providers/index.d.ts +2 -0
- package/dist/esm/anyspend/react/providers/index.js +2 -0
- package/dist/esm/anyspend/types/api.d.ts +35 -56
- package/dist/esm/anyspend/utils/chain.d.ts +1 -1
- package/dist/esm/anyspend/utils/chain.js +122 -15
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +4 -1
- package/dist/esm/global-account/react/hooks/useProfile.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/useProfile.js +9 -7
- package/dist/esm/shared/constants/index.js +5 -3
- package/dist/esm/shared/utils/formatUsername.d.ts +1 -1
- package/dist/esm/shared/utils/formatUsername.js +3 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/index.native.d.ts +0 -2
- package/dist/types/anyspend/react/components/AnySpend.d.ts +3 -3
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +1 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +4 -4
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -2
- package/dist/types/anyspend/react/components/common/RecipientSelection.d.ts +42 -0
- package/dist/types/anyspend/react/components/common/RecipientSelection.example.d.ts +7 -0
- package/dist/types/anyspend/react/components/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useConnectedUserProfile.d.ts +12 -0
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +5 -5
- package/dist/types/anyspend/react/index.d.ts +1 -1
- package/dist/types/anyspend/react/providers/index.d.ts +2 -0
- package/dist/types/anyspend/types/api.d.ts +35 -56
- package/dist/types/anyspend/utils/chain.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useProfile.d.ts +2 -1
- package/dist/types/shared/utils/formatUsername.d.ts +1 -1
- package/package.json +2 -2
- package/src/anyspend/index.native.ts +0 -6
- package/src/anyspend/react/components/AnySpend.tsx +110 -134
- package/src/anyspend/react/components/AnySpendCustom.tsx +488 -196
- package/src/anyspend/react/components/AnySpendFingerprintWrapper.tsx +4 -8
- package/src/anyspend/react/components/AnySpendNFT.tsx +1 -1
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +1 -1
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +76 -108
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +1 -1
- package/src/anyspend/react/components/common/OrderDetails.tsx +12 -13
- package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +1 -3
- package/src/anyspend/react/components/common/RecipientSelection.example.tsx +52 -0
- package/src/anyspend/react/components/common/RecipientSelection.tsx +146 -0
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +1 -0
- package/src/anyspend/react/components/index.ts +1 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useConnectedUserProfile.ts +26 -0
- package/src/anyspend/react/index.ts +1 -1
- package/src/anyspend/react/providers/index.ts +2 -0
- package/src/anyspend/types/api.ts +37 -58
- package/src/anyspend/utils/chain.ts +126 -18
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +2 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +4 -1
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -1
- package/src/global-account/react/hooks/index.ts +1 -1
- package/src/global-account/react/hooks/useAuthentication.ts +4 -2
- package/src/global-account/react/hooks/useProfile.ts +10 -5
- package/src/shared/constants/index.ts +5 -3
- package/src/shared/utils/formatUsername.ts +3 -2
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { eqci, getDefaultToken, roundUpUSDCBaseAmountToNearest } from "../../../anyspend/index.js";
|
|
3
3
|
import { RELAY_ETH_ADDRESS, USDC_BASE } from "../../../anyspend/constants/index.js";
|
|
4
|
-
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useAnyspendTokenList, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
|
-
import { Badge,
|
|
6
|
-
import { cn } from "../../../shared/utils/index.js";
|
|
7
|
-
import
|
|
4
|
+
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useAnyspendTokenList, useConnectedUserProfile, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
|
+
import { Badge, ShinyButton, Skeleton, StyleRoot, Tabs, TabsContent, TextShimmer, Tooltip, TooltipContent, TooltipTrigger, TransitionPanel, useAccountWallet, useHasMounted, useProfile, useRouter, useSearchParamsSSR, useTokenBalancesByChain, } from "../../../global-account/react/index.js";
|
|
6
|
+
import { cn, formatUsername } from "../../../shared/utils/index.js";
|
|
7
|
+
import { shortenAddress } from "../../../shared/utils/formatAddress.js";
|
|
8
8
|
import { formatTokenAmount, formatUnits } from "../../../shared/utils/number.js";
|
|
9
9
|
import { simpleHashChainToChainName } from "../../../shared/utils/simplehash.js";
|
|
10
10
|
import invariant from "invariant";
|
|
11
|
-
import { ChevronRightCircle, Loader2 } from "lucide-react";
|
|
11
|
+
import { ChevronRight, ChevronRightCircle, Loader2 } from "lucide-react";
|
|
12
12
|
import { motion } from "motion/react";
|
|
13
13
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
14
14
|
import { toast } from "sonner";
|
|
15
15
|
import { base, baseSepolia } from "viem/chains";
|
|
16
|
+
import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper.js";
|
|
17
|
+
import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod.js";
|
|
18
|
+
import { FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod.js";
|
|
16
19
|
import { OrderDetails } from "./common/OrderDetails.js";
|
|
17
20
|
import { OrderHistory } from "./common/OrderHistory.js";
|
|
18
21
|
import { OrderStatus as OrderStatusDisplay } from "./common/OrderStatus.js";
|
|
19
22
|
import { OrderToken } from "./common/OrderToken.js";
|
|
20
|
-
import {
|
|
23
|
+
import { RecipientSelection } from "./common/RecipientSelection.js";
|
|
21
24
|
var PanelView;
|
|
22
25
|
(function (PanelView) {
|
|
23
26
|
PanelView[PanelView["CONFIRM_ORDER"] = 0] = "CONFIRM_ORDER";
|
|
24
27
|
PanelView[PanelView["HISTORY"] = 1] = "HISTORY";
|
|
25
28
|
PanelView[PanelView["ORDER_DETAILS"] = 2] = "ORDER_DETAILS";
|
|
26
29
|
PanelView[PanelView["LOADING"] = 3] = "LOADING";
|
|
30
|
+
PanelView[PanelView["RECIPIENT_SELECTION"] = 4] = "RECIPIENT_SELECTION";
|
|
31
|
+
PanelView[PanelView["CRYPTO_PAYMENT_METHOD"] = 5] = "CRYPTO_PAYMENT_METHOD";
|
|
32
|
+
PanelView[PanelView["FIAT_PAYMENT_METHOD"] = 6] = "FIAT_PAYMENT_METHOD";
|
|
27
33
|
})(PanelView || (PanelView = {}));
|
|
28
34
|
function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChainId, dstToken, dstAmount, contractAddress, tokenId, contractType, encodedData, spenderAddress, }) {
|
|
29
35
|
switch (orderType) {
|
|
@@ -82,23 +88,25 @@ function generateGetRelayQuoteRequest({ orderType, srcChainId, srcToken, dstChai
|
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
|
-
export function AnySpendCustom(
|
|
91
|
+
export function AnySpendCustom(props) {
|
|
92
|
+
const fingerprintConfig = getFingerprintConfig();
|
|
93
|
+
return (_jsx(AnySpendFingerprintWrapper, { fingerprint: fingerprintConfig, children: _jsx(AnySpendCustomInner, { ...props }) }));
|
|
94
|
+
}
|
|
95
|
+
function AnySpendCustomInner({ isMainnet = true, loadOrder, mode = "modal", recipientAddress: recipientAddressProps, spenderAddress, orderType, dstChainId, dstToken, dstAmount, contractAddress, encodedData, metadata, header, onSuccess, showRecipient = true, }) {
|
|
86
96
|
const hasMounted = useHasMounted();
|
|
87
97
|
const searchParams = useSearchParamsSSR();
|
|
88
98
|
const router = useRouter();
|
|
89
99
|
const [activePanel, setActivePanel] = useState(loadOrder ? PanelView.ORDER_DETAILS : PanelView.CONFIRM_ORDER);
|
|
90
100
|
const [activeTab, setActiveTab] = useState("crypto");
|
|
101
|
+
// Add state for selected payment methods
|
|
102
|
+
const [selectedCryptoPaymentMethod, setSelectedCryptoPaymentMethod] = useState(CryptoPaymentMethodType.NONE);
|
|
103
|
+
const [selectedFiatPaymentMethod, setSelectedFiatPaymentMethod] = useState(FiatPaymentMethod.NONE);
|
|
91
104
|
// Get current user's wallet
|
|
92
105
|
const currentWallet = useAccountWallet();
|
|
93
|
-
// Add state for recipient modal
|
|
94
|
-
const [isRecipientModalOpen, setIsRecipientModalOpen] = useState(false);
|
|
95
106
|
// Add state for custom recipient
|
|
96
107
|
const [customRecipientAddress, setCustomRecipientAddress] = useState(recipientAddressProps);
|
|
97
108
|
// Update recipient logic to use custom recipient
|
|
98
109
|
const recipientAddress = customRecipientAddress || currentWallet.address;
|
|
99
|
-
const recipientPropsProfile = useProfile({ address: recipientAddress });
|
|
100
|
-
const recipientEnsName = recipientPropsProfile.data?.name?.replace(/\.b3\.fun/g, "");
|
|
101
|
-
const recipientImageUrl = recipientPropsProfile.data?.avatar || currentWallet.wallet.meta?.icon;
|
|
102
110
|
const [orderId, setOrderId] = useState(loadOrder);
|
|
103
111
|
const [srcChainId, setSrcChainId] = useState(isMainnet ? base.id : baseSepolia.id);
|
|
104
112
|
// Get token list for token balance check
|
|
@@ -210,7 +218,7 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
210
218
|
const formattedSrcAmount = srcAmount ? formatTokenAmount(srcAmount, srcToken.decimals, 6, false) : null;
|
|
211
219
|
const srcFiatAmount = useMemo(() => (activeTab === "fiat" && srcAmount ? formatUnits(srcAmount.toString(), USDC_BASE.decimals) : "0"), [activeTab, srcAmount]);
|
|
212
220
|
// Get geo data and onramp options (after quote is available)
|
|
213
|
-
const { geoData, isOnrampSupported } = useGeoOnrampOptions(isMainnet, srcFiatAmount);
|
|
221
|
+
const { geoData, isOnrampSupported, coinbaseAvailablePaymentMethods, isStripeOnrampSupported, stripeWeb2Support } = useGeoOnrampOptions(isMainnet, srcFiatAmount);
|
|
214
222
|
useEffect(() => {
|
|
215
223
|
if (oat?.data?.order.status === "executed") {
|
|
216
224
|
console.log("Calling onSuccess");
|
|
@@ -237,6 +245,9 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
237
245
|
},
|
|
238
246
|
});
|
|
239
247
|
const isCreatingOrder = isCreatingRegularOrder || isCreatingOnrampOrder;
|
|
248
|
+
const { address: connectedAddress, name: connectedName, profile: connectedProfile } = useConnectedUserProfile();
|
|
249
|
+
const recipientProfile = useProfile({ address: recipientAddress });
|
|
250
|
+
const recipientName = recipientProfile.data?.name;
|
|
240
251
|
const handleCreateOrder = async (recipientAddress, onramp) => {
|
|
241
252
|
try {
|
|
242
253
|
invariant(anyspendQuote, "Relay price is not found");
|
|
@@ -256,7 +267,7 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
256
267
|
? {
|
|
257
268
|
type: "erc1155",
|
|
258
269
|
contractAddress: metadata.nftContract.contractAddress,
|
|
259
|
-
tokenId: metadata.nftContract.tokenId,
|
|
270
|
+
tokenId: metadata.nftContract.tokenId ?? 0,
|
|
260
271
|
name: metadata.nftContract.name,
|
|
261
272
|
description: metadata.nftContract.description,
|
|
262
273
|
imageUrl: metadata.nftContract.imageUrl,
|
|
@@ -291,15 +302,18 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
291
302
|
: undefined,
|
|
292
303
|
};
|
|
293
304
|
if (onramp) {
|
|
294
|
-
|
|
295
|
-
invariant(
|
|
305
|
+
const effectiveSrcToken = activeTab === "fiat" ? USDC_BASE : srcToken;
|
|
306
|
+
invariant(effectiveSrcToken.address === USDC_BASE.address, "Selected src token is not USDC");
|
|
307
|
+
invariant((activeTab === "fiat" ? base.id : srcChainId) === base.id, "Selected src chain is not base");
|
|
308
|
+
// Get the current geo data from the hook
|
|
309
|
+
const currentGeoData = geoData;
|
|
296
310
|
void createOnrampOrder({
|
|
297
311
|
...createOrderParams,
|
|
298
312
|
srcFiatAmount: srcFiatAmount,
|
|
299
313
|
onramp: {
|
|
300
314
|
vendor: onramp.vendor,
|
|
301
315
|
paymentMethod: onramp.paymentMethod,
|
|
302
|
-
country:
|
|
316
|
+
country: currentGeoData?.country || "US",
|
|
303
317
|
redirectUrl: window.location.origin === "https://basement.fun"
|
|
304
318
|
? "https://basement.fun/deposit"
|
|
305
319
|
: window.location.origin,
|
|
@@ -318,22 +332,21 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
318
332
|
}
|
|
319
333
|
};
|
|
320
334
|
const handleConfirmOrder = async (onramp) => {
|
|
321
|
-
// if
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
//
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
// }
|
|
335
|
+
// Check if recipient is selected
|
|
336
|
+
if (!recipientAddress) {
|
|
337
|
+
setActivePanel(PanelView.RECIPIENT_SELECTION);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
// Check payment method selection for crypto tab
|
|
341
|
+
if (activeTab === "crypto" && selectedCryptoPaymentMethod === CryptoPaymentMethodType.NONE) {
|
|
342
|
+
setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
// Check payment method selection for fiat tab
|
|
346
|
+
if (activeTab === "fiat" && selectedFiatPaymentMethod === FiatPaymentMethod.NONE) {
|
|
347
|
+
setActivePanel(PanelView.FIAT_PAYMENT_METHOD);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
337
350
|
if (recipientAddress) {
|
|
338
351
|
try {
|
|
339
352
|
await handleCreateOrder(recipientAddress, onramp);
|
|
@@ -344,21 +357,63 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
344
357
|
}
|
|
345
358
|
}
|
|
346
359
|
};
|
|
360
|
+
// Handle fiat order creation
|
|
361
|
+
const handleFiatOrder = async (paymentMethod) => {
|
|
362
|
+
try {
|
|
363
|
+
invariant(anyspendQuote, "Relay price is not found");
|
|
364
|
+
invariant(recipientAddress, "Recipient address is not found");
|
|
365
|
+
if (!srcFiatAmount || parseFloat(srcFiatAmount) <= 0) {
|
|
366
|
+
toast.error("Please enter a valid amount");
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
// Determine vendor and payment method string based on selected payment method
|
|
370
|
+
let vendor;
|
|
371
|
+
let paymentMethodString = "";
|
|
372
|
+
if (paymentMethod === FiatPaymentMethod.COINBASE_PAY) {
|
|
373
|
+
if (coinbaseAvailablePaymentMethods.length === 0) {
|
|
374
|
+
toast.error("Coinbase Pay not available");
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
vendor = "coinbase";
|
|
378
|
+
paymentMethodString = coinbaseAvailablePaymentMethods[0]?.id || "";
|
|
379
|
+
}
|
|
380
|
+
else if (paymentMethod === FiatPaymentMethod.STRIPE) {
|
|
381
|
+
if (!isStripeOnrampSupported && (!stripeWeb2Support || !stripeWeb2Support.isSupport)) {
|
|
382
|
+
toast.error("Stripe not available");
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
vendor = stripeWeb2Support && stripeWeb2Support.isSupport ? "stripe-web2" : "stripe";
|
|
386
|
+
paymentMethodString = "";
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
toast.error("Please select a payment method");
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
await handleCreateOrder(recipientAddress, {
|
|
393
|
+
paymentMethod: paymentMethodString,
|
|
394
|
+
vendor: vendor,
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
catch (err) {
|
|
398
|
+
console.error(err);
|
|
399
|
+
toast.error("Failed to create order: " + err.message);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
347
402
|
const recipientSection = showRecipient ? (_jsxs(motion.div, { initial: false, animate: {
|
|
348
403
|
opacity: hasMounted ? 1 : 0,
|
|
349
404
|
y: hasMounted ? 0 : 20,
|
|
350
405
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
351
|
-
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "flex w-full items-center justify-between gap-4", children: [_jsx("div", { className: "text-
|
|
406
|
+
}, transition: { duration: 0.3, delay: 0.2, ease: "easeInOut" }, className: "flex w-full items-center justify-between gap-4", children: [_jsx("div", { className: "text-as-tertiarry text-sm", children: orderType === "swap"
|
|
352
407
|
? "Recipient"
|
|
353
408
|
: orderType === "mint_nft"
|
|
354
409
|
? "Receive NFT at"
|
|
355
410
|
: orderType === "join_tournament"
|
|
356
411
|
? "Join for"
|
|
357
|
-
: "Recipient" }),
|
|
412
|
+
: "Recipient" }), _jsxs("div", { className: "flex items-center gap-2", children: [recipientAddress ? (_jsx("button", { className: cn("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: _jsxs(_Fragment, { children: [recipientProfile && (_jsx("img", { src: recipientProfile.data?.avatar || "", alt: recipientProfile.data?.name || "", className: "bg-b3-react-foreground size-6 rounded-full object-cover opacity-100" })), _jsxs("div", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: [recipientName && _jsx("span", { children: formatUsername(recipientName) }), _jsx("span", { children: shortenAddress(recipientAddress) })] })] }) })) : (_jsx("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: () => setActivePanel(PanelView.RECIPIENT_SELECTION), children: _jsx("div", { className: "text-sm font-medium", children: "Select recipient" }) })), _jsx(ChevronRight, { className: "h-4 w-4" })] })] }, recipientAddress)) : null;
|
|
358
413
|
const historyView = (_jsx("div", { className: cn("mx-auto flex w-full max-w-2xl flex-col items-center p-5", mode === "modal" && "bg-b3-react-background"), children: _jsx(OrderHistory, { mode: mode, onBack: () => {
|
|
359
414
|
setActivePanel(PanelView.HISTORY);
|
|
360
415
|
}, onSelectOrder: onSelectOrder }) }));
|
|
361
|
-
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background"), children: [oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatusDisplay, { order: oat.data.order }), _jsx(OrderDetails, { isMainnet: isMainnet, mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, onBack: () => {
|
|
416
|
+
const orderDetailsView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background rounded-xl"), children: [oat && (_jsxs(_Fragment, { children: [_jsx(OrderStatusDisplay, { order: oat.data.order }), _jsx(OrderDetails, { isMainnet: isMainnet, mode: mode, order: oat.data.order, depositTxs: oat.data.depositTxs, relayTx: oat.data.relayTx, executeTx: oat.data.executeTx, refundTxs: oat.data.refundTxs, cryptoPaymentMethod: activeTab === "fiat" ? CryptoPaymentMethodType.NONE : selectedCryptoPaymentMethod, onBack: () => {
|
|
362
417
|
setOrderId(undefined);
|
|
363
418
|
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
364
419
|
// Remove orderId from URL when canceling
|
|
@@ -368,66 +423,86 @@ export function AnySpendCustom({ isMainnet = true, loadOrder, mode = "modal", re
|
|
|
368
423
|
} })] })), mode === "page" && _jsx("div", { className: "h-12" })] }));
|
|
369
424
|
const loadingView = (_jsxs("div", { className: cn("mx-auto flex w-full flex-col items-center gap-4 p-5", mode === "modal" && "bg-b3-react-background"), children: [_jsxs(Badge, { variant: "default", className: "bg-b3-react-muted/30 border-b3-react-border hover:bg-b3-react-muted/50 flex items-center gap-3 px-4 py-1 text-base transition-all", children: [_jsx(Loader2, { className: "text-b3-react-foreground size-4 animate-spin" }), _jsx(TextShimmer, { duration: 1, className: "font-sf-rounded text-base font-semibold", children: "Loading..." })] }), _jsxs("div", { className: "flex w-full flex-1 flex-col", children: [_jsxs("div", { className: "mb-4 flex flex-col gap-1", children: [_jsx(Skeleton, { className: "h-4 w-24" }), _jsxs("div", { className: "mt-2 flex items-center gap-2", children: [_jsx(Skeleton, { className: "h-8 w-48" }), _jsx(Skeleton, { className: "ml-4 h-8 w-32" })] }), _jsx(Skeleton, { className: "mt-4 h-8 w-24" })] }), _jsx(Skeleton, { className: "mb-4 h-12 w-full" }), _jsxs("div", { className: "flex w-full items-center justify-between gap-4", children: [_jsxs(Skeleton, { className: "rounded-lg bg-white/5 p-6 pb-3", children: [_jsx("div", { className: "size-[200px]" }), _jsx("div", { className: "mt-3 flex items-center justify-center gap-2", children: _jsx("div", { className: "size-5 rounded-full" }) })] }), _jsx("div", { className: "flex flex-1 flex-col gap-2", children: [1, 2, 3].map(i => (_jsx(Skeleton, { className: "h-10 w-full" }, i))) })] })] }), _jsxs("div", { className: "bg-b3-react-muted/30 mt-8 w-full rounded-lg p-4", children: [_jsx(Skeleton, { className: "mb-3 h-4 w-48" }), _jsxs("div", { className: "flex items-center gap-4", children: [_jsx(Skeleton, { className: "h-10 flex-1" }), _jsx(Skeleton, { className: "h-10 flex-1" })] })] }), _jsx("div", { className: "flex w-full flex-col gap-3", children: [1, 2, 3, 4, 5].map(i => (_jsxs("div", { className: "flex w-full justify-between", children: [_jsx(Skeleton, { className: "h-4 w-24" }), _jsx(Skeleton, { className: "h-4 w-32" })] }, i))) }), _jsx(Skeleton, { className: "h-10 w-full" }), mode === "page" && _jsx("div", { className: "h-12" })] }));
|
|
370
425
|
// Confirm order view.
|
|
371
|
-
const confirmOrderView = (_jsxs("div", { className: "relative mx-auto flex w-full flex-col items-center", children: [header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote }),
|
|
426
|
+
const confirmOrderView = (_jsxs("div", { className: "relative mx-auto flex w-full flex-col items-center", children: [header({ anyspendPrice: anyspendQuote, isLoadingAnyspendPrice: isLoadingAnyspendQuote }), _jsxs(Tabs, { value: activeTab, onValueChange: value => setActiveTab(value), className: "bg-b3-react-background max-h-[60dvh] w-full overflow-y-auto p-5", children: [_jsx("div", { className: "w-full", children: _jsxs("div", { className: "bg-as-surface-secondary relative mb-4 grid h-10 grid-cols-2 rounded-xl", children: [_jsx("div", { className: cn("bg-as-brand absolute bottom-0 left-0 top-0 z-0 rounded-xl transition-transform duration-100", "h-full w-1/2", activeTab === "fiat" ? "translate-x-full" : "translate-x-0"), style: { willChange: "transform" } }), _jsx("button", { className: cn("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "crypto" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
|
|
427
|
+
setActiveTab("crypto");
|
|
428
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
429
|
+
setSelectedFiatPaymentMethod(FiatPaymentMethod.NONE);
|
|
430
|
+
}, children: "Pay with crypto" }), isOnrampSupported ? (_jsx("button", { className: cn("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", activeTab === "fiat" ? "text-white" : "text-as-primary/70 hover:bg-as-on-surface-2 bg-transparent"), onClick: () => {
|
|
431
|
+
setActiveTab("fiat");
|
|
432
|
+
setSelectedCryptoPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
433
|
+
setSelectedFiatPaymentMethod(FiatPaymentMethod.NONE);
|
|
434
|
+
}, children: "Pay with fiat" })) : (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { className: cn("relative z-10 h-full w-full rounded-xl px-3 text-sm font-medium transition-colors duration-100", "text-as-primary/50 cursor-not-allowed bg-transparent"), disabled: true, children: "Pay with fiat" }) }), _jsx(TooltipContent, { children: _jsx("span", { className: "text-as-primary w-[140px]", children: "Fiat payments are not supported for this amount" }) })] }))] }) }), _jsx(TabsContent, { value: "crypto", children: _jsxs("div", { className: "mt-2 flex flex-col gap-6", children: [_jsxs("div", { className: "border-as-border-secondary bg-as-surface-secondary flex w-full flex-col gap-4 rounded-xl border p-4", children: [_jsxs(motion.div, { initial: false, animate: {
|
|
435
|
+
opacity: hasMounted ? 1 : 0,
|
|
436
|
+
y: hasMounted ? 0 : 20,
|
|
437
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
438
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry 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 hover:text-blue-700", onClick: () => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD), children: selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsxs(_Fragment, { children: [connectedAddress ? (_jsxs(_Fragment, { children: [connectedProfile?.data?.avatar && (_jsx("img", { src: connectedProfile.data?.avatar || "", alt: "Connected Wallet", className: "bg-as-primary h-6 w-6 rounded-full" })), _jsxs("span", { className: "text-as-tertiarry flex items-center gap-1", children: [connectedName && _jsx("span", { children: formatUsername(connectedName) }), _jsx("span", { children: shortenAddress(connectedAddress || "") })] })] })) : ("Connect wallet"), _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("div", { className: "divider w-full" }), recipientSection, _jsx("div", { className: "divider w-full" }), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs(motion.div, { initial: false, animate: {
|
|
439
|
+
opacity: hasMounted ? 1 : 0,
|
|
440
|
+
y: hasMounted ? 0 : 20,
|
|
441
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
442
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry text-sm", children: "Pay with" }), _jsx(OrderToken, { address: currentWallet?.wallet?.address, context: "from", chainId: srcChainId, setChainId: setSrcChainId, token: srcToken, setToken: token => {
|
|
443
|
+
setDirtySelectSrcToken(true);
|
|
444
|
+
setSrcToken(token);
|
|
445
|
+
}, requiredAmount: srcAmount || undefined })] }), _jsx("div", { className: "divider w-full" }), _jsxs(motion.div, { initial: false, animate: {
|
|
446
|
+
opacity: hasMounted ? 1 : 0,
|
|
447
|
+
y: hasMounted ? 0 : 20,
|
|
448
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
449
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("span", { className: "text-as-tertiarry text-sm", children: ["Total ", _jsx("span", { className: "text-as-tertiarry", children: "(with fee)" })] }), _jsxs("span", { className: "text-as-primary font-semibold", children: [formattedSrcAmount || "--", " ", srcToken.symbol] })] })] })] }), _jsx("div", { className: cn("flex w-full flex-col items-center justify-between gap-2"), children: _jsx(motion.div, { initial: false, animate: {
|
|
450
|
+
opacity: hasMounted ? 1 : 0,
|
|
451
|
+
y: hasMounted ? 0 : 20,
|
|
452
|
+
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
453
|
+
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => handleConfirmOrder(), className: "relative w-full", children: isCreatingOrder ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Creating order..." })] })) : isLoadingAnyspendQuote ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Loading quote..." })] })) : !recipientAddress ? ("Select recipient") : selectedCryptoPaymentMethod === CryptoPaymentMethodType.NONE ? ("Choose payment method") : anyspendQuote ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "Checkout" }), _jsx(ChevronRightCircle, { className: "absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-70" })] })) : ("No quote found") }) }) })] }) }), _jsx(TabsContent, { value: "fiat", children: _jsxs("div", { className: "mt-2 flex flex-col gap-6", children: [_jsxs("div", { className: "border-as-border-secondary bg-as-surface-secondary flex w-full flex-col gap-4 rounded-xl border p-4", children: [_jsxs(motion.div, { initial: false, animate: {
|
|
372
454
|
opacity: hasMounted ? 1 : 0,
|
|
373
455
|
y: hasMounted ? 0 : 20,
|
|
374
456
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
375
|
-
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "
|
|
376
|
-
setDirtySelectSrcToken(true);
|
|
377
|
-
setSrcToken(token);
|
|
378
|
-
}, requiredAmount: srcAmount || undefined })] }), _jsxs(motion.div, { initial: false, animate: {
|
|
457
|
+
}, transition: { duration: 0.3, delay: 0, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsx("div", { className: "text-as-tertiarry flex h-7 items-center text-sm", children: "Pay with" }), _jsx("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(PanelView.FIAT_PAYMENT_METHOD), children: selectedFiatPaymentMethod === FiatPaymentMethod.COINBASE_PAY ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-blue-600", children: _jsx("span", { className: "text-xs font-bold text-white", children: "C" }) }), "Coinbase Pay"] }), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : selectedFiatPaymentMethod === FiatPaymentMethod.STRIPE ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-blue-600", children: _jsx("span", { className: "text-xs font-bold text-white", children: "S" }) }), "Credit/Debit Card"] }), _jsx(ChevronRight, { className: "h-4 w-4" })] })) : (_jsxs(_Fragment, { children: ["Select payment method", _jsx(ChevronRight, { className: "h-4 w-4" })] })) })] }), _jsx("div", { className: "divider w-full" }), recipientSection, _jsx("div", { className: "divider w-full" }), _jsxs(motion.div, { initial: false, animate: {
|
|
379
458
|
opacity: hasMounted ? 1 : 0,
|
|
380
459
|
y: hasMounted ? 0 : 20,
|
|
381
460
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
382
|
-
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("span", { className: "
|
|
461
|
+
}, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "relative flex w-full items-center justify-between", children: [_jsxs("span", { className: "text-as-tertiarry text-sm", children: ["Total ", _jsx("span", { className: "text-as-tertiarry", children: "(USD)" })] }), _jsxs("span", { className: "text-as-primary text-xl font-semibold", children: ["$", srcFiatAmount || "0.00"] })] })] }), _jsx("div", { className: cn("flex w-full flex-col items-center justify-between gap-2"), children: _jsx(motion.div, { initial: false, animate: {
|
|
383
462
|
opacity: hasMounted ? 1 : 0,
|
|
384
463
|
y: hasMounted ? 0 : 20,
|
|
385
464
|
filter: hasMounted ? "blur(0px)" : "blur(10px)",
|
|
386
|
-
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
data: encodedData,
|
|
410
|
-
to: contractAddress,
|
|
411
|
-
spenderAddress: spenderAddress,
|
|
412
|
-
}
|
|
413
|
-
: undefined, recipientEnsName: recipientEnsName, recipientImageUrl: recipientImageUrl }) }) })] })] }));
|
|
465
|
+
}, transition: { duration: 0.3, delay: 0.3, ease: "easeInOut" }, className: "flex w-full flex-col gap-2", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", disabled: isCreatingOrder || isLoadingAnyspendQuote || !anyspendQuote, onClick: () => {
|
|
466
|
+
if (selectedFiatPaymentMethod !== FiatPaymentMethod.NONE) {
|
|
467
|
+
handleFiatOrder(selectedFiatPaymentMethod);
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
handleConfirmOrder();
|
|
471
|
+
}
|
|
472
|
+
}, className: "relative w-full", children: isCreatingOrder ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Creating order..." })] })) : isLoadingAnyspendQuote ? (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Loader2, { className: "size-4 animate-spin" }), _jsx("span", { children: "Loading quote..." })] })) : !recipientAddress ? ("Select recipient") : selectedFiatPaymentMethod === FiatPaymentMethod.NONE ? ("Select payment method") : anyspendQuote ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "Buy" }), _jsx(ChevronRightCircle, { className: "absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-70" })] })) : ("No quote found") }) }) })] }) })] })] }));
|
|
473
|
+
// Recipient selection view
|
|
474
|
+
const recipientSelectionView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(RecipientSelection, { initialValue: customRecipientAddress || "", title: "Add recipient address or ENS", description: "Send tokens to another address", onBack: () => setActivePanel(PanelView.CONFIRM_ORDER), onConfirm: address => {
|
|
475
|
+
setCustomRecipientAddress(address);
|
|
476
|
+
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
477
|
+
} }) }));
|
|
478
|
+
// Crypto payment method view
|
|
479
|
+
const cryptoPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(CryptoPaymentMethod, { globalAddress: currentWallet?.wallet?.address, globalWallet: currentWallet?.wallet, selectedPaymentMethod: selectedCryptoPaymentMethod, setSelectedPaymentMethod: setSelectedCryptoPaymentMethod, isCreatingOrder: isCreatingOrder, onBack: () => setActivePanel(PanelView.CONFIRM_ORDER), onSelectPaymentMethod: (method) => {
|
|
480
|
+
setSelectedCryptoPaymentMethod(method);
|
|
481
|
+
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
482
|
+
} }) }));
|
|
483
|
+
// Fiat payment method view
|
|
484
|
+
const fiatPaymentMethodView = (_jsx("div", { className: cn("bg-as-surface-primary mx-auto w-[460px] max-w-full rounded-xl p-4"), children: _jsx(FiatPaymentMethodComponent, { selectedPaymentMethod: selectedFiatPaymentMethod, setSelectedPaymentMethod: setSelectedFiatPaymentMethod, onBack: () => setActivePanel(PanelView.CONFIRM_ORDER), onSelectPaymentMethod: (method) => {
|
|
485
|
+
setSelectedFiatPaymentMethod(method);
|
|
486
|
+
setActivePanel(PanelView.CONFIRM_ORDER);
|
|
487
|
+
}, srcAmountOnRamp: srcFiatAmount, isMainnet: isMainnet }) }));
|
|
414
488
|
// Return the TransitionPanel with all views
|
|
415
|
-
return (
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
489
|
+
return (_jsx(StyleRoot, { children: _jsx(TransitionPanel, { activeIndex: orderId
|
|
490
|
+
? oat
|
|
491
|
+
? PanelView.ORDER_DETAILS
|
|
492
|
+
: PanelView.LOADING
|
|
493
|
+
: activePanel === PanelView.ORDER_DETAILS
|
|
494
|
+
? PanelView.CONFIRM_ORDER
|
|
495
|
+
: activePanel, className: cn("w-full"), variants: {
|
|
496
|
+
enter: { x: 300, opacity: 0 },
|
|
497
|
+
center: { x: 0, opacity: 1 },
|
|
498
|
+
exit: { x: -300, opacity: 0 },
|
|
499
|
+
}, transition: { type: "spring", stiffness: 300, damping: 30 }, children: [
|
|
500
|
+
_jsx("div", { className: "w-full", children: confirmOrderView }, "confirm-order-view"),
|
|
501
|
+
_jsx("div", { className: "w-full", children: historyView }, "history-view"),
|
|
502
|
+
_jsx("div", { className: "w-full", children: orderDetailsView }, "order-details-view"),
|
|
503
|
+
_jsx("div", { className: "w-full", children: loadingView }, "loading-view"),
|
|
504
|
+
_jsx("div", { className: "w-full", children: recipientSelectionView }, "recipient-selection-view"),
|
|
505
|
+
_jsx("div", { className: "w-full", children: cryptoPaymentMethodView }, "crypto-payment-method-view"),
|
|
506
|
+
_jsx("div", { className: "w-full", children: fiatPaymentMethodView }, "fiat-payment-method-view"),
|
|
507
|
+
] }) }));
|
|
433
508
|
}
|
|
@@ -13,5 +13,5 @@ interface AnySpendFingerprintWrapperProps {
|
|
|
13
13
|
* This prevents unnecessary fingerprinting of users who don't interact with AnySpend.
|
|
14
14
|
*/
|
|
15
15
|
export declare function AnySpendFingerprintWrapper({ children, fingerprint }: AnySpendFingerprintWrapperProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export declare function getFingerprintConfig(): FingerprintConfig
|
|
16
|
+
export declare function getFingerprintConfig(): FingerprintConfig;
|
|
17
17
|
export {};
|
|
@@ -22,14 +22,11 @@ export function AnySpendFingerprintWrapper({ children, fingerprint }) {
|
|
|
22
22
|
: undefined,
|
|
23
23
|
}, children: children }));
|
|
24
24
|
}
|
|
25
|
+
const defaultApiKey = "80EnsS6POsxPAR9xGxmN";
|
|
25
26
|
// Helper function to get fingerprint config from environment variables
|
|
26
27
|
export function getFingerprintConfig() {
|
|
27
|
-
const apiKey = process.env.NEXT_PUBLIC_FINGERPRINT_API_KEY;
|
|
28
|
-
if (!apiKey) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
28
|
return {
|
|
32
|
-
apiKey,
|
|
29
|
+
apiKey: process.env.NEXT_PUBLIC_FINGERPRINT_API_KEY || defaultApiKey,
|
|
33
30
|
endpoint: process.env.NEXT_PUBLIC_FINGERPRINT_ENDPOINT,
|
|
34
31
|
scriptUrlPattern: process.env.NEXT_PUBLIC_FINGERPRINT_SCRIPT_URL,
|
|
35
32
|
};
|
|
@@ -80,7 +80,7 @@ export function AnySpendNFT({ isMainnet = true, loadOrder, mode = "modal", recip
|
|
|
80
80
|
}
|
|
81
81
|
fetchContractMetadata();
|
|
82
82
|
}, [nftContract.contractAddress, nftContract.chainId, nftContract.imageUrl, nftContract.tokenId]);
|
|
83
|
-
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative size-[200px]", children: [_jsx("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), _jsxs(GlareCard, { className: "overflow-hidden", children: [imageUrlWithFallback && (_jsx("img", { src: imageUrlWithFallback, alt: nftContract.name, className: "size-full object-cover" })), _jsx("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), _jsx(DropdownMenu, { nftContract: nftContract })] }), _jsxs("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [_jsx("div", { className: "h-[100px] w-full" }), _jsxs("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [_jsx("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), _jsx("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? (_jsx(AnimatePresence, { mode: "wait", children: _jsx("div", { className: cn("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
83
|
+
const header = ({ anyspendPrice, isLoadingAnyspendPrice, }) => (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative size-[200px]", children: [_jsx("div", { className: "absolute inset-0 scale-95 bg-black/30 blur-md" }), _jsxs(GlareCard, { className: "overflow-hidden", children: [imageUrlWithFallback && (_jsx("img", { src: imageUrlWithFallback, alt: nftContract.name, className: "size-full object-cover" })), _jsx("div", { className: "absolute inset-0 rounded-xl border border-white/10" })] }), _jsx(DropdownMenu, { nftContract: nftContract })] }), _jsxs("div", { className: "from-b3-react-background to-as-on-surface-1 -mb-5 mt-[-100px] w-full rounded-t-lg bg-gradient-to-t", children: [_jsx("div", { className: "h-[100px] w-full" }), _jsxs("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: [_jsx("span", { className: "font-sf-rounded text-2xl font-semibold", children: nftContract.name }), _jsx("div", { className: "flex w-fit items-center gap-1", children: anyspendPrice ? (_jsx(AnimatePresence, { mode: "wait", children: _jsx("div", { className: cn("text-as-primary group flex items-center text-3xl font-semibold transition-all", {
|
|
84
84
|
"opacity-0": isLoadingAnyspendPrice,
|
|
85
85
|
}), children: formatDisplayNumber(anyspendPrice?.data?.currencyIn?.amountUsd, { style: "currency" }) }) })) : (_jsx("div", { className: "h-[36px] w-full" })) })] })] })] }));
|
|
86
86
|
return (_jsx(AnySpendCustom, { isMainnet: isMainnet, loadOrder: loadOrder, mode: mode, recipientAddress: recipientAddress, orderType: "mint_nft", dstChainId: nftContract.chainId, dstToken: nftContract.currency, dstAmount: nftContract.price, contractAddress: nftContract.contractAddress, encodedData: "0x", metadata: {
|
|
@@ -40,7 +40,7 @@ export default function ConnectWalletPayment({ order, onPayment, txLoading, isSw
|
|
|
40
40
|
if (!srcToken || !dstToken) {
|
|
41
41
|
return _jsx("div", { children: "Loading..." });
|
|
42
42
|
}
|
|
43
|
-
return (_jsxs("div", { className: "flex w-full flex-col items-center gap-6", children: [_jsx(StepProgress, { steps: steps, currentStepIndex: 1 }), _jsxs(motion.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.5 }, className: "flex w-full flex-col items-center gap-2", children: [_jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-5/6 items-center gap-2 sm:px-0", disabled: txLoading || isSwitchingOrExecuting, onClick: onPayment, children: txLoading ? (_jsxs(_Fragment, { children: ["Transaction Pending", _jsx(Loader2, { className: "ml-2 h-5 w-5 animate-spin" })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap pl-4 text-lg md:text-sm", children: order.srcChain === RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
43
|
+
return (_jsxs("div", { className: "flex w-full flex-col items-center gap-6", children: [_jsx(StepProgress, { steps: steps, currentStepIndex: 1 }), _jsxs(motion.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.5 }, className: "flex w-full flex-col items-center gap-2", children: [_jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "flex w-5/6 max-w-[400px] items-center gap-2 sm:px-0", disabled: txLoading || isSwitchingOrExecuting, onClick: onPayment, children: txLoading ? (_jsxs(_Fragment, { children: ["Transaction Pending", _jsx(Loader2, { className: "ml-2 h-5 w-5 animate-spin" })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "whitespace-nowrap pl-4 text-lg md:text-sm", children: order.srcChain === RELAY_SOLANA_MAINNET_CHAIN_ID && phantomWalletAddress
|
|
44
44
|
? "Pay from Phantom Wallet"
|
|
45
45
|
: "Pay from Connected Wallet" }), _jsx(ChevronRight, { className: "h-4 w-4" })] })) }), _jsx("div", { className: "mt-4", children: _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount }) })] })] }));
|
|
46
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum CryptoPaymentMethodType {
|
|
2
2
|
NONE = "none",
|
|
3
3
|
CONNECT_WALLET = "connect_wallet",
|
|
4
4
|
TRANSFER_CRYPTO = "transfer_crypto"
|
|
@@ -10,11 +10,11 @@ interface CryptoPaymentMethodProps {
|
|
|
10
10
|
icon?: string;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
selectedPaymentMethod:
|
|
14
|
-
setSelectedPaymentMethod: (method:
|
|
13
|
+
selectedPaymentMethod: CryptoPaymentMethodType;
|
|
14
|
+
setSelectedPaymentMethod: (method: CryptoPaymentMethodType) => void;
|
|
15
15
|
isCreatingOrder: boolean;
|
|
16
16
|
onBack: () => void;
|
|
17
|
-
onSelectPaymentMethod: (method:
|
|
17
|
+
onSelectPaymentMethod: (method: CryptoPaymentMethodType) => void;
|
|
18
18
|
}
|
|
19
19
|
export declare function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, }: CryptoPaymentMethodProps): import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
export {};
|