@b3dotfun/sdk 0.0.20 → 0.0.21-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/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/hooks/index.d.ts +1 -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/hooks/index.d.ts +1 -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/hooks/index.ts +1 -1
- 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,114 +1,62 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useAccountWallet } from "../../../../global-account/react/index.js";
|
|
4
|
+
import { thirdwebB3Mainnet } from "../../../../shared/constants/chains/b3Chain.js";
|
|
4
5
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
5
6
|
import { shortenAddress } from "../../../../shared/utils/formatAddress.js";
|
|
7
|
+
import { client } from "../../../../shared/utils/thirdweb.js";
|
|
6
8
|
import { ChevronLeft, ChevronRightCircle, Wallet, X } from "lucide-react";
|
|
7
|
-
import {
|
|
9
|
+
import { useState } from "react";
|
|
10
|
+
import { createPortal } from "react-dom";
|
|
8
11
|
import { toast } from "sonner";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
import { ConnectEmbed, lightTheme, useActiveWallet } from "thirdweb/react";
|
|
13
|
+
import { createWallet } from "thirdweb/wallets";
|
|
14
|
+
import { useDisconnect } from "wagmi";
|
|
15
|
+
export var CryptoPaymentMethodType;
|
|
16
|
+
(function (CryptoPaymentMethodType) {
|
|
17
|
+
CryptoPaymentMethodType["NONE"] = "none";
|
|
18
|
+
CryptoPaymentMethodType["CONNECT_WALLET"] = "connect_wallet";
|
|
19
|
+
CryptoPaymentMethodType["TRANSFER_CRYPTO"] = "transfer_crypto";
|
|
20
|
+
})(CryptoPaymentMethodType || (CryptoPaymentMethodType = {}));
|
|
17
21
|
export function CryptoPaymentMethod({ selectedPaymentMethod, setSelectedPaymentMethod, isCreatingOrder, onBack, onSelectPaymentMethod, }) {
|
|
18
|
-
const {
|
|
19
|
-
const
|
|
20
|
-
const { address: globalAddress, connectedEOAWallet, isActiveEOAWallet, wallet: globalWallet } = useAccountWallet();
|
|
22
|
+
const { wallet: globalWallet } = useAccountWallet();
|
|
23
|
+
const activeWallet = useActiveWallet();
|
|
21
24
|
const { disconnect } = useDisconnect();
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
toast.error(`Failed to connect wallet: ${connectError.message}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, [connectError, globalAddress, wagmiAccount.address, setSelectedPaymentMethod, onSelectPaymentMethod]);
|
|
66
|
-
return (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsxs("div", { className: cn("relative flex flex-col gap-10"), children: [_jsx("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsx("div", { className: "flex items-center justify-around gap-4", children: _jsx("div", { className: "flex-1 text-center", children: _jsx("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) }) }), _jsxs("div", { className: "flex flex-col gap-3", children: [!globalAddress ? (
|
|
67
|
-
// Not connected - show single connect button
|
|
68
|
-
_jsxs("button", { onClick: () => {
|
|
69
|
-
// Prevent connecting if already connecting or if there's already a connection
|
|
70
|
-
if (isConnecting)
|
|
71
|
-
return;
|
|
72
|
-
try {
|
|
73
|
-
// Check if wagmi already has a connection
|
|
74
|
-
if (wagmiAccount.isConnected && wagmiAccount.address) {
|
|
75
|
-
// Already connected via wagmi, just proceed with selection
|
|
76
|
-
console.log("Wagmi already connected, proceeding with selection");
|
|
77
|
-
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
78
|
-
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
// Check if global address exists (b3 account system)
|
|
82
|
-
if (globalAddress) {
|
|
83
|
-
// Already connected via global account, just proceed with selection
|
|
84
|
-
console.log("Global address already exists, proceeding with selection");
|
|
85
|
-
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
86
|
-
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
// Use the first available connector or a preferred one
|
|
90
|
-
const preferredConnector = connectors.find(c => c.name.toLowerCase().includes("metamask")) || connectors[0];
|
|
91
|
-
if (preferredConnector) {
|
|
92
|
-
connect({ connector: preferredConnector });
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
console.error("Connection error:", error);
|
|
97
|
-
toast.error("Failed to connect wallet. Please try again.");
|
|
98
|
-
}
|
|
99
|
-
}, disabled: isConnecting, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-50", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: _jsx(Wallet, { className: "h-4 w-4 text-blue-600" }) }), _jsxs("div", { className: "flex flex-col items-start text-left", children: [_jsx("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }), _jsx("p", { className: "text-as-primary/60 text-sm", children: "Connect your wallet to continue" })] })] }), isConnecting ? (_jsx("div", { className: "border-as-primary/20 border-t-as-primary h-5 w-5 animate-spin rounded-full border-2" })) : (_jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" }))] })) : (
|
|
100
|
-
// Connected - show wallet info
|
|
101
|
-
_jsx("div", { className: "bg-as-surface-primary border-as-border-secondary rounded-xl border", children: _jsxs("div", { className: "flex items-center justify-between p-4", children: [_jsxs("div", { className: "flex items-center gap-3", children: [globalWallet?.meta?.icon ? (_jsx("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "h-8 w-8 rounded-full" })) : (_jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-green-100", children: _jsx(Wallet, { className: "h-4 w-4 text-green-600" }) })), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-as-primary font-semibold", children: "Connected Wallet" }), _jsx("span", { className: "text-as-primary/60 text-sm", children: shortenAddress(globalAddress) })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { onClick: () => {
|
|
102
|
-
setSelectedPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
103
|
-
onSelectPaymentMethod(PaymentMethod.CONNECT_WALLET);
|
|
104
|
-
}, className: "bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors", children: "Use Wallet" }), _jsx("button", { onClick: () => {
|
|
105
|
-
disconnect();
|
|
106
|
-
toast.success("Wallet disconnected");
|
|
107
|
-
if (selectedPaymentMethod === PaymentMethod.CONNECT_WALLET) {
|
|
108
|
-
setSelectedPaymentMethod(PaymentMethod.NONE);
|
|
109
|
-
}
|
|
110
|
-
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: _jsx(X, { className: "h-4 w-4" }) })] })] }) })), _jsxs("button", { onClick: () => {
|
|
111
|
-
setSelectedPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
112
|
-
onSelectPaymentMethod(PaymentMethod.TRANSFER_CRYPTO);
|
|
113
|
-
}, disabled: isCreatingOrder, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsx("div", { className: "flex flex-col items-start text-left", children: _jsx("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] }) }));
|
|
25
|
+
const [showWalletModal, setShowWalletModal] = useState(false);
|
|
26
|
+
// Define available wallets for the modal
|
|
27
|
+
const availableWallets = [
|
|
28
|
+
createWallet("io.metamask"),
|
|
29
|
+
// createWallet("com.coinbase.wallet"),
|
|
30
|
+
createWallet("me.rainbow"),
|
|
31
|
+
createWallet("walletConnect"),
|
|
32
|
+
createWallet("io.rabby"),
|
|
33
|
+
createWallet("app.phantom"),
|
|
34
|
+
];
|
|
35
|
+
return (_jsxs("div", { className: "mx-auto h-fit w-[460px] max-w-full", children: [_jsxs("div", { className: cn("relative flex flex-col gap-10"), children: [_jsx("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary absolute flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsx("div", { className: "flex items-center justify-around gap-4", children: _jsx("div", { className: "flex-1 text-center", children: _jsx("h2", { className: "text-as-primary text-lg font-semibold", children: "Choose payment method" }) }) }), _jsxs("div", { className: "flex flex-col gap-3", children: [!activeWallet ? (
|
|
36
|
+
// Not connected - show single connect button
|
|
37
|
+
_jsxs("button", { onClick: () => setShowWalletModal(true), className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-blue-100", children: _jsx(Wallet, { className: "h-4 w-4 text-blue-600" }) }), _jsxs("div", { className: "flex flex-col items-start text-left", children: [_jsx("h4", { className: "text-as-primary font-semibold", children: "Connect wallet" }), _jsx("p", { className: "text-as-primary/60 text-sm", children: "Choose from multiple wallet options" })] })] }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })) : (
|
|
38
|
+
// Connected - show wallet info
|
|
39
|
+
_jsx("div", { className: "bg-as-surface-primary border-as-border-secondary rounded-xl border", children: _jsxs("div", { className: "flex items-center justify-between p-4", children: [_jsxs("div", { className: "flex items-center gap-3", children: [globalWallet?.meta?.icon ? (_jsx("img", { src: globalWallet.meta.icon, alt: "Connected Wallet", className: "h-8 w-8 rounded-full" })) : (_jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-green-100", children: _jsx(Wallet, { className: "h-4 w-4 text-green-600" }) })), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { className: "text-as-primary font-semibold", children: "Connected Wallet" }), _jsx("span", { className: "text-as-primary/60 text-sm", children: shortenAddress(activeWallet.getAccount()?.address || "") })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { onClick: () => {
|
|
40
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
41
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
42
|
+
}, className: "bg-as-brand hover:bg-as-brand/90 rounded-lg px-3 py-1.5 text-sm font-medium text-white transition-colors", children: "Use Wallet" }), _jsx("button", { onClick: async () => {
|
|
43
|
+
disconnect();
|
|
44
|
+
toast.success("Wallet disconnected");
|
|
45
|
+
if (selectedPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
|
|
46
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.NONE);
|
|
47
|
+
}
|
|
48
|
+
}, className: "text-as-primary/60 hover:text-as-primary/80 rounded-lg p-1.5 transition-colors", children: _jsx(X, { className: "h-4 w-4" }) })] })] }) })), _jsxs("button", { onClick: () => {
|
|
49
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
50
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.TRANSFER_CRYPTO);
|
|
51
|
+
}, disabled: isCreatingOrder, className: "bg-as-surface-primary border-as-border-secondary hover:border-as-secondary/80 group flex w-full items-center justify-between gap-4 rounded-xl border px-4 py-3.5 transition-all duration-200 hover:shadow-md", children: [_jsx("div", { className: "flex flex-col items-start text-left", children: _jsx("h4", { className: "text-as-primary font-semibold", children: "Transfer crypto" }) }), _jsx(ChevronRightCircle, { className: "text-as-primary/40 group-hover:text-as-primary/60 h-5 w-5 transition-colors" })] })] })] }), showWalletModal &&
|
|
52
|
+
createPortal(_jsx("div", { className: "pointer-events-auto fixed inset-0 z-[9999] flex items-center justify-center bg-black/50", children: _jsxs("div", { className: "max-h-[80vh] w-[400px] max-w-[90vw] overflow-auto rounded-xl bg-white p-6 dark:bg-gray-900", children: [_jsxs("div", { className: "mb-4 flex items-center justify-between", children: [_jsx("h3", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: "Connect Wallet" }), _jsx("button", { onClick: () => setShowWalletModal(false), className: "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200", children: _jsx(X, { className: "h-5 w-5" }) })] }), _jsx(ConnectEmbed, { client: client, chain: thirdwebB3Mainnet, wallets: availableWallets, showThirdwebBranding: false, theme: lightTheme(), onConnect: async (wallet) => {
|
|
53
|
+
console.log("Wallet connected:", wallet);
|
|
54
|
+
// setShowWalletModal(false);
|
|
55
|
+
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
56
|
+
onSelectPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
57
|
+
setShowWalletModal(false);
|
|
58
|
+
}, style: {
|
|
59
|
+
width: "100%",
|
|
60
|
+
minHeight: "300px",
|
|
61
|
+
} })] }) }), typeof window !== "undefined" ? document.getElementById("b3-root") || document.body : document.body)] }));
|
|
114
62
|
}
|
|
@@ -49,7 +49,7 @@ export function FiatPaymentMethodComponent({ selectedPaymentMethod, setSelectedP
|
|
|
49
49
|
id: FiatPaymentMethod.STRIPE,
|
|
50
50
|
name: "Stripe",
|
|
51
51
|
description: "Credit or debit card payment",
|
|
52
|
-
badge: stripeFee ? `$${stripeFee} fee` : "Standard Fee",
|
|
52
|
+
badge: stripeFee ? `$${Number(stripeFee).toFixed(2)} fee` : "Standard Fee",
|
|
53
53
|
badgeColor: "bg-yellow-100 text-yellow-800",
|
|
54
54
|
available: true,
|
|
55
55
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { components } from "../../../../anyspend/types/api";
|
|
2
|
-
import {
|
|
2
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
3
3
|
interface OrderDetailsProps {
|
|
4
4
|
isMainnet: boolean;
|
|
5
5
|
mode?: "modal" | "page";
|
|
@@ -8,7 +8,7 @@ interface OrderDetailsProps {
|
|
|
8
8
|
relayTx: components["schemas"]["RelayTx"] | null;
|
|
9
9
|
executeTx: components["schemas"]["ExecuteTx"] | null;
|
|
10
10
|
refundTxs: components["schemas"]["RefundTx"][] | null;
|
|
11
|
-
|
|
11
|
+
cryptoPaymentMethod?: CryptoPaymentMethodType;
|
|
12
12
|
onBack?: () => void;
|
|
13
13
|
}
|
|
14
14
|
export declare const OrderDetails: import("react").NamedExoticComponent<OrderDetailsProps>;
|
|
@@ -20,7 +20,7 @@ import { erc20Abi } from "viem";
|
|
|
20
20
|
import { b3 } from "viem/chains";
|
|
21
21
|
import { useWaitForTransactionReceipt, useWalletClient } from "wagmi";
|
|
22
22
|
import ConnectWalletPayment from "./ConnectWalletPayment.js";
|
|
23
|
-
import {
|
|
23
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod.js";
|
|
24
24
|
import { OrderDetailsCollapsible } from "./OrderDetailsCollapsible.js";
|
|
25
25
|
import PaymentVendorUI from "./PaymentVendorUI.js";
|
|
26
26
|
import { TransferCryptoDetails } from "./TransferCryptoDetails.js";
|
|
@@ -120,12 +120,12 @@ function roundTokenAmount(amount) {
|
|
|
120
120
|
const roundedDecimalPart = digits.join("");
|
|
121
121
|
return `${wholePart}.${roundedDecimalPart}`;
|
|
122
122
|
}
|
|
123
|
-
export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "modal", order, depositTxs, relayTx, executeTx, refundTxs,
|
|
123
|
+
export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "modal", order, depositTxs, relayTx, executeTx, refundTxs, cryptoPaymentMethod, onBack, }) {
|
|
124
124
|
const router = useRouter();
|
|
125
125
|
const searchParams = useSearchParams();
|
|
126
|
-
// Read payment method from URL parameters
|
|
127
|
-
const
|
|
128
|
-
const
|
|
126
|
+
// Read crypto payment method from URL parameters
|
|
127
|
+
const cryptoPaymentMethodFromUrl = searchParams.get("cryptoPaymentMethod");
|
|
128
|
+
const effectiveCryptoPaymentMethod = cryptoPaymentMethod || cryptoPaymentMethodFromUrl || CryptoPaymentMethodType.NONE;
|
|
129
129
|
const setB3ModalOpen = useModalStore((state) => state.setB3ModalOpen);
|
|
130
130
|
const srcToken = order.metadata.srcToken;
|
|
131
131
|
const dstToken = order.metadata.dstToken;
|
|
@@ -470,7 +470,7 @@ export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "moda
|
|
|
470
470
|
? `Waiting for payment`
|
|
471
471
|
: `Waiting for deposit ${formattedDepositDeficit} ${srcToken.symbol}`, chainId: order.srcChain, tx: null, isProcessing: true, delay: 0.5 }))] })] }));
|
|
472
472
|
}
|
|
473
|
-
return (_jsxs(_Fragment, { children: [statusDisplay === "processing" && (_jsx(_Fragment, { children: order.onrampMetadata ? (_jsx(PaymentVendorUI, { isMainnet: isMainnet, order: order, dstTokenSymbol: dstToken.symbol })) :
|
|
473
|
+
return (_jsxs(_Fragment, { children: [statusDisplay === "processing" && (_jsx(_Fragment, { children: order.onrampMetadata ? (_jsx(PaymentVendorUI, { isMainnet: isMainnet, order: order, dstTokenSymbol: dstToken.symbol })) : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (_jsx(ConnectWalletPayment, { order: order, onPayment: handlePayment, onCancel: handleBack, txLoading: txLoading, isSwitchingOrExecuting: isSwitchingOrExecuting, phantomWalletAddress: phantomWalletAddress, tournament: tournament, nft: nft })) : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (
|
|
474
474
|
// Transfer Crypto Payment Method - Show new card-based UI
|
|
475
475
|
_jsx(TransferCryptoDetails, { order: order, recipientName: recipientName, srcToken: srcToken, dstToken: dstToken, tournament: tournament, nft: nft, onBack: handleBack })) : (_jsxs("div", { className: "relative flex w-full flex-1 flex-col", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("span", { className: "text-as-primary/50", children: "Please send" }), _jsxs("div", { className: "flex w-full flex-wrap items-center gap-6 sm:justify-between sm:gap-0", children: [_jsx(CopyToClipboard, { text: roundedUpSrcAmount, onCopy: () => {
|
|
476
476
|
toast.success("Copied to clipboard");
|
|
@@ -482,11 +482,9 @@ export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "moda
|
|
|
482
482
|
? centerTruncate(phantomWalletAddress, 6)
|
|
483
483
|
: centerTruncate(account?.address || "", 6)] })] }), _jsxs("div", { className: "flex w-full flex-col items-center gap-2", children: [_jsxs(ShinyButton, { accentColor: colorMode === "dark" ? "#ffffff" : "#000000", className: "flex w-5/6 items-center gap-2 sm:px-0", onClick: () => setShowQRCode(true), children: [_jsx("span", { className: "pl-4 text-lg md:text-sm", children: "Pay from a different wallet" }), _jsx(ChevronRight, { className: "h-4 w-4" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletWalletConnect, { className: "h-5 w-5", variant: "branded" }), _jsx("span", { className: "label-style text-as-primary/30 text-xs", children: "& more" })] })] })] }) })) : (
|
|
484
484
|
// Default case - existing QR code flow
|
|
485
|
-
_jsx(motion.div, { initial: { opacity: 0, filter: "blur(10px)" }, animate: { opacity: 1, filter: "blur(0px)" }, transition: { duration: 0.5, ease: "easeInOut" }, className: "flex w-full items-center justify-evenly gap-4", children: _jsxs("div", { className: "mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress, order.srcChain), className: "max-w-[200px]" }), _jsxs("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [_jsx("span", { className: "label-style text-as-brand/70 text-sm", children: "Scan with" }), _jsxs(TextLoop, { interval: 3, children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }))] })) })), _jsxs("div", { className: "flex w-full items-center justify-center gap-1 text-sm", children: [_jsx("div", { className: "text-as-primary/30", children: "Time remaining:" }), _jsx("div", { className: "text-as-primary", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : (_jsx(TimeAgo, { date: new Date(order.expiredAt), live: true })) })] }), statusDisplay !== "processing" && (_jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })), _jsxs("button", { className: "flex w-full items-center justify-center gap-2", onClick: handleBack, children: [_jsx(RefreshCcw, { className: "ml-2 h-4 w-4" }), " Cancel and start over"] })] }));
|
|
485
|
+
_jsx(motion.div, { initial: { opacity: 0, filter: "blur(10px)" }, animate: { opacity: 1, filter: "blur(0px)" }, transition: { duration: 0.5, ease: "easeInOut" }, className: "flex w-full items-center justify-evenly gap-4", children: _jsxs("div", { className: "mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === RELAY_ETH_ADDRESS ? srcToken?.symbol || "ETH" : order.srcTokenAddress, order.srcChain, srcToken?.decimals), className: "max-w-[200px]" }), _jsxs("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [_jsx("span", { className: "label-style text-as-brand/70 text-sm", children: "Scan with" }), _jsxs(TextLoop, { interval: 3, children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }))] })) })), _jsxs("div", { className: "flex w-full items-center justify-center gap-1 text-sm", children: [_jsx("div", { className: "text-as-primary/30", children: "Time remaining:" }), _jsx("div", { className: "text-as-primary", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : (_jsx(TimeAgo, { date: new Date(order.expiredAt), live: true })) })] }), statusDisplay !== "processing" && (_jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })), _jsxs("button", { className: "flex w-full items-center justify-center gap-2", onClick: handleBack, children: [_jsx(RefreshCcw, { className: "ml-2 h-4 w-4" }), " Cancel and start over"] })] }));
|
|
486
486
|
});
|
|
487
487
|
function TransactionDetails({ title, chainId, tx, isProcessing, delay, }) {
|
|
488
|
-
return (_jsxs("div", { className: "relative flex w-full flex-1 items-center justify-between gap-4", children: [_jsxs("div", { className: "flex grow items-center gap-4", children: [_jsx(motion.div, { className: "bg-b3-react-background relative h-10 w-10 rounded-full", children: isProcessing ? (_jsx(motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeInOut", delay }, className: "absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full bg-black/70 shadow-lg backdrop-blur-sm", children: _jsx(Loader2, { className: "text-as-primary h-4 w-4 animate-spin" }) })) : (_jsx(motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeOut", delay }, className: "bg-as-brand/70 absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full border border-white/30 shadow-lg
|
|
489
|
-
boxShadow: "0 0 15px 5px rgba(138, 43, 226, 0.2)",
|
|
490
|
-
}, children: _jsx(CheckIcon, { className: "text-as-primary h-3 w-3" }) })) }), _jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, ease: "easeInOut", delay }, className: "shrink-0 text-base", children: isProcessing ? (_jsx(TextShimmer, { duration: 1, children: title })) : (_jsx("span", { className: "text-as-primary", children: title })) })] }), _jsx("div", { className: "flex flex-col gap-1", children: tx ? (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, ease: "easeInOut", delay: (delay || 0) + 0.3 }, className: "flex items-center gap-3", children: _jsx("a", { href: getExplorerTxUrl(chainId, tx.txHash), target: "_blank", children: _jsx("div", { className: "text-as-primary/30 font-mono text-xs", children: centerTruncate(tx?.txHash, 6) }) }) })) : null })] }));
|
|
488
|
+
return (_jsxs("div", { className: "relative flex w-full flex-1 items-center justify-between gap-4", children: [_jsxs("div", { className: "flex grow items-center gap-4", children: [_jsx(motion.div, { className: "bg-b3-react-background relative h-10 w-10 rounded-full", children: isProcessing ? (_jsx(motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeInOut", delay }, className: "absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full bg-black/70 shadow-lg backdrop-blur-sm", children: _jsx(Loader2, { className: "text-as-primary h-4 w-4 animate-spin" }) })) : (_jsx(motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeOut", delay }, className: "bg-as-brand/70 absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full border border-white/30 shadow-lg backdrop-blur-sm", children: _jsx(CheckIcon, { className: "text-as-primary h-3 w-3" }) })) }), _jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, ease: "easeInOut", delay }, className: "shrink-0 text-base", children: isProcessing ? (_jsx(TextShimmer, { duration: 1, children: title })) : (_jsx("span", { className: "text-as-primary", children: title })) })] }), _jsx("div", { className: "flex flex-col gap-1", children: tx ? (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration: 0.3, ease: "easeInOut", delay: (delay || 0) + 0.3 }, className: "flex items-center gap-3", children: _jsx("a", { href: getExplorerTxUrl(chainId, tx.txHash), target: "_blank", children: _jsx("div", { className: "text-as-primary/30 font-mono text-xs", children: centerTruncate(tx?.txHash, 6) }) }) })) : null })] }));
|
|
491
489
|
}
|
|
492
490
|
export const OrderDetailsLoadingView = (_jsxs("div", { className: "mx-auto flex w-[460px] max-w-full flex-col items-center gap-4", children: [_jsxs(Badge, { variant: "default", className: "hover:bg-b3-react-background flex items-center gap-3 border-white/20 bg-white/10 px-4 py-1 text-base transition-colors", children: [_jsx(Loader2, { className: "text-as-primary h-4 w-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 p-6 pb-3", children: [_jsx("div", { className: "h-[200px] w-[200px]" }), _jsx("div", { className: "mt-3 flex items-center justify-center gap-2", children: _jsx("div", { className: "h-5 w-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-background 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(Skeleton, { className: "h-10 w-full" })] }));
|
|
@@ -20,10 +20,10 @@ export const OrderStatus = memo(function OrderStatus({ order }) {
|
|
|
20
20
|
description: description,
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
|
-
if (order.status
|
|
23
|
+
if (["waiting_stripe_payment"].includes(order.status)) {
|
|
24
24
|
return _jsx(StepProgress, { steps: paymentSteps, currentStepIndex: 0 });
|
|
25
25
|
}
|
|
26
|
-
if (order.status
|
|
26
|
+
if (["relay", "sending_token_from_vault"].includes(order.status)) {
|
|
27
27
|
return _jsx(StepProgress, { steps: paymentSteps, currentStepIndex: 1 });
|
|
28
28
|
}
|
|
29
29
|
if (!isComplete && displayStatus !== "failure") {
|
|
@@ -81,9 +81,7 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
|
|
|
81
81
|
try {
|
|
82
82
|
const result = (await stripe.confirmPayment({
|
|
83
83
|
elements,
|
|
84
|
-
|
|
85
|
-
return_url: `${window.location.origin}/?orderId=${order.id}&waitingForDeposit=true&fromStripe=true`,
|
|
86
|
-
},
|
|
84
|
+
redirect: "if_required",
|
|
87
85
|
}));
|
|
88
86
|
if (result.error) {
|
|
89
87
|
// This point will only be reached if there is an immediate error.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface RecipientSelectionProps {
|
|
2
|
+
/**
|
|
3
|
+
* Initial recipient address value
|
|
4
|
+
*/
|
|
5
|
+
initialValue?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Placeholder text for the input field
|
|
8
|
+
*/
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Title text displayed in the header
|
|
12
|
+
*/
|
|
13
|
+
title?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Description text displayed below the title
|
|
16
|
+
*/
|
|
17
|
+
description?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Text for the confirm button
|
|
20
|
+
*/
|
|
21
|
+
confirmText?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Callback when back button is clicked
|
|
24
|
+
*/
|
|
25
|
+
onBack: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Callback when recipient address is confirmed
|
|
28
|
+
* @param address - The recipient address entered by the user
|
|
29
|
+
*/
|
|
30
|
+
onConfirm: (address: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the component should auto-focus the input
|
|
33
|
+
*/
|
|
34
|
+
autoFocus?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Custom validation function for the address
|
|
37
|
+
* @param address - The address to validate
|
|
38
|
+
* @returns true if valid, false otherwise
|
|
39
|
+
*/
|
|
40
|
+
validateAddress?: (address: string) => boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function RecipientSelection({ initialValue, placeholder, title, description, confirmText, onBack, onConfirm, autoFocus, validateAddress, }: RecipientSelectionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example usage of the RecipientSelection component
|
|
3
|
+
* This file demonstrates various ways to use the component with different props
|
|
4
|
+
*/
|
|
5
|
+
export declare function BasicRecipientSelection(): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function CustomRecipientSelection(): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function ENSRecipientSelection(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Example usage of the RecipientSelection component
|
|
4
|
+
* This file demonstrates various ways to use the component with different props
|
|
5
|
+
*/
|
|
6
|
+
import { isAddress } from "viem";
|
|
7
|
+
import { RecipientSelection } from "./RecipientSelection.js";
|
|
8
|
+
// Basic usage example
|
|
9
|
+
export function BasicRecipientSelection() {
|
|
10
|
+
return (_jsx(RecipientSelection, { onBack: () => console.log("Back clicked"), onConfirm: address => console.log("Address confirmed:", address) }));
|
|
11
|
+
}
|
|
12
|
+
// Custom styling and validation example
|
|
13
|
+
export function CustomRecipientSelection() {
|
|
14
|
+
const validateEthereumAddress = (address) => {
|
|
15
|
+
return isAddress(address);
|
|
16
|
+
};
|
|
17
|
+
return (_jsx(RecipientSelection, { initialValue: "0x...", placeholder: "Enter Ethereum address", title: "Send to Ethereum Address", description: "Enter a valid Ethereum address to send tokens", confirmText: "Confirm Ethereum Address", validateAddress: validateEthereumAddress, autoFocus: false, onBack: () => console.log("Going back"), onConfirm: address => console.log("Valid Ethereum address:", address) }));
|
|
18
|
+
}
|
|
19
|
+
// ENS-focused example
|
|
20
|
+
export function ENSRecipientSelection() {
|
|
21
|
+
return (_jsx(RecipientSelection, { placeholder: "Enter ENS name (e.g., vitalik.eth)", title: "Send to ENS Address", description: "Enter an ENS name or Ethereum address", confirmText: "Confirm ENS Address", onBack: () => console.log("Back to previous view"), onConfirm: address => console.log("ENS or address:", address) }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronLeft } from "lucide-react";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
export function RecipientSelection({ initialValue = "", placeholder = "Enter recipient address", title = "Add recipient address or ENS", description = "Swap and send tokens to another address", confirmText = "Confirm recipient address", onBack, onConfirm, autoFocus = true, validateAddress, }) {
|
|
6
|
+
const [recipientAddress, setRecipientAddress] = useState(initialValue);
|
|
7
|
+
// Update internal state when initialValue changes
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
setRecipientAddress(initialValue);
|
|
10
|
+
}, [initialValue]);
|
|
11
|
+
const handlePaste = async () => {
|
|
12
|
+
try {
|
|
13
|
+
const text = await navigator.clipboard.readText();
|
|
14
|
+
setRecipientAddress(text);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
console.error("Failed to read clipboard:", err);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const handleConfirm = () => {
|
|
21
|
+
if (recipientAddress && (!validateAddress || validateAddress(recipientAddress))) {
|
|
22
|
+
onConfirm(recipientAddress);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const handleKeyDown = (e) => {
|
|
26
|
+
if (e.key === "Enter" && recipientAddress) {
|
|
27
|
+
handleConfirm();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const isAddressValid = !validateAddress || !recipientAddress || validateAddress(recipientAddress);
|
|
31
|
+
const canConfirm = recipientAddress && isAddressValid;
|
|
32
|
+
return (_jsx("div", { className: "mx-auto w-[460px] max-w-full", children: _jsxs("div", { className: "flex flex-col gap-6", children: [_jsxs("div", { className: "flex justify-around", children: [_jsx("button", { onClick: onBack, className: "text-as-quaternary hover:text-as-primary flex h-8 w-8 items-center justify-center rounded-lg transition-colors", children: _jsx(ChevronLeft, { className: "h-6 w-6" }) }), _jsxs("div", { className: "flex-1 text-center", children: [_jsx("h2", { className: "text-as-primary text-lg font-semibold", children: title }), _jsx("p", { className: "text-as-primary/60 text-sm", children: description })] })] }), _jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "bg-as-surface-secondary border-as-border-secondary flex h-12 w-full overflow-hidden rounded-xl border", children: [_jsx("input", { type: "text", placeholder: placeholder, value: recipientAddress, onChange: e => setRecipientAddress(e.target.value), onKeyDown: handleKeyDown, className: "text-as-primary placeholder:text-as-primary/50 flex-1 bg-transparent px-4 text-base focus:outline-none", autoFocus: autoFocus }), _jsx("div", { className: "border-as-border-secondary border-l", children: _jsx("button", { onClick: handlePaste, className: "text-as-primary/70 hover:text-as-primary hover:bg-as-surface-primary h-full px-4 font-semibold transition-colors", children: "Paste" }) })] }), recipientAddress && !isAddressValid && (_jsx("div", { className: "text-as-red text-sm", children: "Please enter a valid address" })), _jsx("button", { onClick: handleConfirm, disabled: !canConfirm, className: "bg-as-brand hover:bg-as-brand/90 disabled:bg-as-on-surface-2 disabled:text-as-secondary h-12 w-full rounded-xl font-medium text-white transition-colors disabled:cursor-not-allowed", children: confirmText })] })] }) }));
|
|
33
|
+
}
|
|
@@ -66,5 +66,5 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({ order
|
|
|
66
66
|
transition: "stroke-dashoffset 1s linear",
|
|
67
67
|
} })] }), _jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: _jsx("span", { className: "text-as-primary text-[10px] font-semibold", children: formatTime(timeLeft) }) })] })] }), _jsxs("div", { className: "flex w-full flex-col gap-4", children: [_jsxs("div", { className: "flex items-center gap-4", children: [_jsxs("div", { className: "w-full", children: [_jsx("span", { className: "text-as-content-secondary text-sm font-medium", children: "Amount" }), _jsx("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: _jsx(CopyToClipboard, { text: roundedUpSrcAmount || "", onCopy: () => {
|
|
68
68
|
toast.success("Amount copied to clipboard");
|
|
69
|
-
}, children: _jsxs("div", { className: "flex cursor-pointer items-center justify-between gap-2", children: [_jsxs("strong", { className: "text-as-primary font-semibold", children: [roundedUpSrcAmount, " ", srcToken.symbol] }), _jsx(Copy, { className: "text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" })] }) }) })] }), _jsxs("div", { className: "w-full", children: [_jsx("span", { className: "text-as-content-secondary text-sm font-medium", children: "Chain" }), _jsx("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("img", { src: ALL_CHAINS[order.srcChain].logoUrl, alt: getChainName(order.srcChain), className: cn("h-6 rounded-full", order.srcChain === b3.id && "h-5 rounded-none") }), _jsx("span", { className: "text-as-primary text-sm font-semibold", children: getChainName(order.srcChain) })] }) })] })] }), _jsxs("div", { className: "border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border", children: [_jsx("div", { className: "border-as-border-primary h-full w-full border-r", children: _jsx("div", { className: "flex justify-center", children: _jsxs("div", { className: "bg-as-surface-secondary flex flex-col items-center rounded-lg p-6", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress, order.srcChain), className: "bg-as-surface-secondary max-h-48 max-w-48" }), _jsxs("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [_jsx("span", { className: "text-as-brand/70 text-sm font-medium", children: "SCAN WITH" }), _jsxs(TextLoop, { interval: 3, children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }) }), _jsxs("div", { className: "flex h-full w-full flex-col gap-2 p-6", children: [_jsx("span", { className: "text-as-content-secondary text-sm font-medium", children: "Deposit address:" }), _jsxs("div", { className: "flex h-full cursor-pointer flex-col items-stretch justify-between gap-4", onClick: handleCopyAddress, children: [_jsx("div", { className: "text-as-primary break-all font-mono text-sm font-semibold leading-relaxed", children: order.globalAddress }), _jsx("div", { className: "place-self-end", children: _jsx(Copy, { className: "group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" }) })] })] })] }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })] }), _jsx("div", { className: "flex flex-col gap-3", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "w-full py-3", onClick: handleCopyAddress, children: "Copy deposit address" }) })] }));
|
|
69
|
+
}, children: _jsxs("div", { className: "flex cursor-pointer items-center justify-between gap-2", children: [_jsxs("strong", { className: "text-as-primary font-semibold", children: [roundedUpSrcAmount, " ", srcToken.symbol] }), _jsx(Copy, { className: "text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" })] }) }) })] }), _jsxs("div", { className: "w-full", children: [_jsx("span", { className: "text-as-content-secondary text-sm font-medium", children: "Chain" }), _jsx("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("img", { src: ALL_CHAINS[order.srcChain].logoUrl, alt: getChainName(order.srcChain), className: cn("h-6 rounded-full", order.srcChain === b3.id && "h-5 rounded-none") }), _jsx("span", { className: "text-as-primary text-sm font-semibold", children: getChainName(order.srcChain) })] }) })] })] }), _jsxs("div", { className: "border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border", children: [_jsx("div", { className: "border-as-border-primary h-full w-full border-r", children: _jsx("div", { className: "flex justify-center", children: _jsxs("div", { className: "bg-as-surface-secondary flex flex-col items-center rounded-lg p-6", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress, order.srcChain, srcToken?.decimals), className: "bg-as-surface-secondary max-h-48 max-w-48" }), _jsxs("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [_jsx("span", { className: "text-as-brand/70 text-sm font-medium", children: "SCAN WITH" }), _jsxs(TextLoop, { interval: 3, children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }) }), _jsxs("div", { className: "flex h-full w-full flex-col gap-2 p-6", children: [_jsx("span", { className: "text-as-content-secondary text-sm font-medium", children: "Deposit address:" }), _jsxs("div", { className: "flex h-full cursor-pointer flex-col items-stretch justify-between gap-4", onClick: handleCopyAddress, children: [_jsx("div", { className: "text-as-primary break-all font-mono text-sm font-semibold leading-relaxed", children: order.globalAddress }), _jsx("div", { className: "place-self-end", children: _jsx(Copy, { className: "group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" }) })] })] })] }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })] }), _jsx("div", { className: "flex flex-col gap-3", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "w-full py-3", onClick: handleCopyAddress, children: "Copy deposit address" }) })] }));
|
|
70
70
|
});
|
|
@@ -16,6 +16,7 @@ export { OrderHistoryItem } from "./common/OrderHistoryItem";
|
|
|
16
16
|
export { OrderStatus } from "./common/OrderStatus";
|
|
17
17
|
export { OrderToken } from "./common/OrderToken";
|
|
18
18
|
export { OrderTokenAmount } from "./common/OrderTokenAmount";
|
|
19
|
+
export { RecipientSelection } from "./common/RecipientSelection";
|
|
19
20
|
export { StepProgress } from "./common/StepProgress";
|
|
20
21
|
export { TokenBalance } from "./common/TokenBalance";
|
|
21
22
|
export { TransferCryptoDetails } from "./common/TransferCryptoDetails";
|
|
@@ -18,6 +18,7 @@ export { OrderHistoryItem } from "./common/OrderHistoryItem.js";
|
|
|
18
18
|
export { OrderStatus } from "./common/OrderStatus.js";
|
|
19
19
|
export { OrderToken } from "./common/OrderToken.js";
|
|
20
20
|
export { OrderTokenAmount } from "./common/OrderTokenAmount.js";
|
|
21
|
+
export { RecipientSelection } from "./common/RecipientSelection.js";
|
|
21
22
|
export { StepProgress } from "./common/StepProgress.js";
|
|
22
23
|
export { TokenBalance } from "./common/TokenBalance.js";
|
|
23
24
|
export { TransferCryptoDetails } from "./common/TransferCryptoDetails.js";
|
|
@@ -5,6 +5,7 @@ export * from "./useAnyspendOrderHistory";
|
|
|
5
5
|
export * from "./useAnyspendQuote";
|
|
6
6
|
export * from "./useAnyspendTokens";
|
|
7
7
|
export * from "./useCoinbaseOnrampOptions";
|
|
8
|
+
export * from "./useConnectedUserProfile";
|
|
8
9
|
export * from "./useGeoOnrampOptions";
|
|
9
10
|
export * from "./useGetGeo";
|
|
10
11
|
export * from "./useSigMint";
|
|
@@ -5,6 +5,7 @@ export * from "./useAnyspendOrderHistory.js";
|
|
|
5
5
|
export * from "./useAnyspendQuote.js";
|
|
6
6
|
export * from "./useAnyspendTokens.js";
|
|
7
7
|
export * from "./useCoinbaseOnrampOptions.js";
|
|
8
|
+
export * from "./useConnectedUserProfile.js";
|
|
8
9
|
export * from "./useGeoOnrampOptions.js";
|
|
9
10
|
export * from "./useGetGeo.js";
|
|
10
11
|
export * from "./useSigMint.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook that provides connected user's address, profile, and cleaned display name
|
|
3
|
+
* Combines logic for getting connected address from either global account or thirdweb wallets
|
|
4
|
+
*/
|
|
5
|
+
export declare function useConnectedUserProfile(): {
|
|
6
|
+
address: string | undefined;
|
|
7
|
+
profile: import("@tanstack/react-query").UseQueryResult<import("../../../global-account/react").CombinedProfile, Error>;
|
|
8
|
+
name: string | null | undefined;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
isError: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useAccountWallet, useProfile } from "../../../global-account/react/index.js";
|
|
2
|
+
import { useConnectedWallets } from "thirdweb/react";
|
|
3
|
+
/**
|
|
4
|
+
* Hook that provides connected user's address, profile, and cleaned display name
|
|
5
|
+
* Combines logic for getting connected address from either global account or thirdweb wallets
|
|
6
|
+
*/
|
|
7
|
+
export function useConnectedUserProfile() {
|
|
8
|
+
const { address: globalAddress } = useAccountWallet();
|
|
9
|
+
const connectedWallets = useConnectedWallets();
|
|
10
|
+
// Get connected address from global account or first connected wallet
|
|
11
|
+
const connectedAddress = globalAddress || connectedWallets?.[0]?.getAccount()?.address;
|
|
12
|
+
// Fetch profile data for the connected address with cleaned name
|
|
13
|
+
const connectedProfile = useProfile({ address: connectedAddress });
|
|
14
|
+
return {
|
|
15
|
+
address: connectedAddress,
|
|
16
|
+
profile: connectedProfile,
|
|
17
|
+
name: connectedProfile.data?.name,
|
|
18
|
+
isLoading: connectedProfile.isLoading,
|
|
19
|
+
isError: connectedProfile.isError,
|
|
20
|
+
error: connectedProfile.error,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -16,13 +16,13 @@ export declare const useGenerateSigMintData: ({ recipientAddress, contractAddres
|
|
|
16
16
|
creator?: string | undefined;
|
|
17
17
|
signatureRequestBody?: {
|
|
18
18
|
currency?: string | undefined;
|
|
19
|
-
price?: string | undefined;
|
|
20
|
-
clonePrice?: string | undefined;
|
|
21
|
-
primarySaleRecipient?: string | undefined;
|
|
22
19
|
royaltyRecipient?: string | undefined;
|
|
23
20
|
royaltyBps?: number | undefined;
|
|
21
|
+
primarySaleRecipient?: string | undefined;
|
|
24
22
|
validityStartTimestamp?: number | undefined;
|
|
25
23
|
validityEndTimestamp?: number | undefined;
|
|
24
|
+
price?: string | undefined;
|
|
25
|
+
clonePrice?: string | undefined;
|
|
26
26
|
metadata: {
|
|
27
27
|
name?: string | undefined;
|
|
28
28
|
description?: string | undefined;
|
|
@@ -38,9 +38,9 @@ export declare const useGenerateSigMintData: ({ recipientAddress, contractAddres
|
|
|
38
38
|
maxSupply?: number | undefined;
|
|
39
39
|
conditions?: {
|
|
40
40
|
chainId: number;
|
|
41
|
-
tokenAddress: string;
|
|
42
41
|
conditionType: "user-owns-tokens";
|
|
43
42
|
isOnchain: boolean;
|
|
43
|
+
tokenAddress: string;
|
|
44
44
|
tokenAmount: string;
|
|
45
45
|
}[] | undefined;
|
|
46
46
|
isFreeMint?: boolean | undefined;
|
|
@@ -90,9 +90,9 @@ export declare const useSigMintCollection: ({ address, chainId }: FindByAddressP
|
|
|
90
90
|
description?: string | undefined;
|
|
91
91
|
name?: string | undefined;
|
|
92
92
|
image?: string | undefined;
|
|
93
|
+
attributes?: any;
|
|
93
94
|
externalLink?: string | undefined;
|
|
94
95
|
appUri?: string | undefined;
|
|
95
|
-
attributes?: any;
|
|
96
96
|
backgroundColor?: string | undefined;
|
|
97
97
|
promptImageUrl?: string | undefined;
|
|
98
98
|
};
|