0xtrails 0.2.4 → 0.2.6
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/aave.d.ts +8 -0
- package/dist/aave.d.ts.map +1 -1
- package/dist/abortController.d.ts +8 -0
- package/dist/abortController.d.ts.map +1 -0
- package/dist/{ccip-BlV1Mry3.js → ccip-Xjh9d1gb.js} +7 -7
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/estimate.d.ts +52 -0
- package/dist/estimate.d.ts.map +1 -1
- package/dist/fees.d.ts +19 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/{index-BNWCIGfQ.js → index-BnhdZ8Ho.js} +76406 -75798
- package/dist/index.js +726 -520
- package/dist/intents.d.ts +40 -0
- package/dist/intents.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts +3 -3
- package/dist/metaTxnMonitor.d.ts.map +1 -1
- package/dist/metaTxns.d.ts +3 -3
- package/dist/metaTxns.d.ts.map +1 -1
- package/dist/morpho.d.ts +8 -0
- package/dist/morpho.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +19 -75
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/queryParams.d.ts.map +1 -1
- package/dist/relayer.d.ts +6 -6
- package/dist/relayer.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +2 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -2
- package/dist/transactions.d.ts.map +1 -1
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts +4 -0
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts.map +1 -0
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +4 -2
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts +4 -0
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DynamicInputStyles.d.ts +18 -0
- package/dist/widget/components/DynamicInputStyles.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts +2 -2
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/ErrorAnimationIcon.d.ts +2 -0
- package/dist/widget/components/ErrorAnimationIcon.d.ts.map +1 -0
- package/dist/widget/components/FeeBreakdown.d.ts +9 -0
- package/dist/widget/components/FeeBreakdown.d.ts.map +1 -0
- package/dist/widget/components/Fund.d.ts +2 -2
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/{FundSendForm.d.ts → FundSwap.d.ts} +13 -7
- package/dist/widget/components/FundSwap.d.ts.map +1 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts +4 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Identicon.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +0 -3
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/Modal.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +2 -2
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PercentageMaxButtons.d.ts +12 -0
- package/dist/widget/components/PercentageMaxButtons.d.ts.map +1 -0
- package/dist/widget/components/{PaySendForm.d.ts → PoolDeposit.d.ts} +14 -36
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -0
- package/dist/widget/components/{SimpleSwap.d.ts → PoolWithdraw.d.ts} +19 -10
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -0
- package/dist/widget/components/QuoteDetails.d.ts +1 -0
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/Receive.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts +4 -0
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RequiredPropsError.d.ts +8 -0
- package/dist/widget/components/RequiredPropsError.d.ts.map +1 -0
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/SlippageToleranceSettings.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +3 -2
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/SwapSettings.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts +11 -0
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts.map +1 -0
- package/dist/widget/components/TokenImage.d.ts +1 -0
- package/dist/widget/components/TokenImage.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts +16 -0
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Tooltip.d.ts +9 -0
- package/dist/widget/components/Tooltip.d.ts.map +1 -0
- package/dist/widget/components/UserPreferences.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +9 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -0
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +2 -0
- package/dist/widget/css/index.css +554 -0
- package/dist/widget/hooks/useBack.d.ts +1 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +1 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts +3 -3
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +83 -0
- package/dist/widget/hooks/useQuote.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +12 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +2 -2
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/index.js +2 -2
- package/dist/widget/widget.d.ts +9 -4
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +18 -12
- package/src/aave.ts +32 -0
- package/src/abortController.ts +35 -0
- package/src/config.ts +12 -4
- package/src/constants.ts +5 -0
- package/src/error.ts +19 -1
- package/src/estimate.ts +416 -5
- package/src/fees.ts +199 -0
- package/src/intents.ts +161 -11
- package/src/metaTxnMonitor.ts +3 -3
- package/src/metaTxns.ts +3 -5
- package/src/morpho.ts +32 -0
- package/src/prepareSend.ts +714 -550
- package/src/queryParams.ts +2 -1
- package/src/relayer.ts +11 -11
- package/src/sequenceWallet.ts +2 -2
- package/src/tokens.ts +7 -1
- package/src/trails.ts +3 -3
- package/src/transactions.ts +62 -18
- package/src/wallets.ts +8 -0
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountActionsDropdown.tsx +3 -13
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +22 -0
- package/src/widget/components/AccountSettings.tsx +48 -54
- package/src/widget/components/ChainFilterDropdown.tsx +24 -3
- package/src/widget/components/ClassicSwap.tsx +131 -213
- package/src/widget/components/ConnectWallet.tsx +8 -38
- package/src/widget/components/ConnectedWallets.tsx +132 -77
- package/src/widget/components/DynamicInputStyles.tsx +76 -0
- package/src/widget/components/Earn.tsx +82 -593
- package/src/widget/components/ErrorAnimationIcon.tsx +130 -0
- package/src/widget/components/FeeBreakdown.tsx +155 -0
- package/src/widget/components/Fund.tsx +41 -108
- package/src/widget/components/FundMethods.tsx +82 -159
- package/src/widget/components/FundSwap.tsx +52 -0
- package/src/widget/components/FundingMethodSelectorButton.tsx +70 -0
- package/src/widget/components/Identicon.tsx +164 -95
- package/src/widget/components/MeshConnectExchanges.tsx +2 -15
- package/src/widget/components/Modal.tsx +0 -8
- package/src/widget/components/Pay.tsx +214 -237
- package/src/widget/components/PercentageMaxButtons.tsx +77 -0
- package/src/widget/components/PoolDeposit.tsx +569 -0
- package/src/widget/components/PoolWithdraw.tsx +884 -0
- package/src/widget/components/PriceImpactWarning.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +43 -12
- package/src/widget/components/Receipt.tsx +16 -2
- package/src/widget/components/Receive.tsx +0 -2
- package/src/widget/components/RecipientSelectorButton.tsx +44 -0
- package/src/widget/components/Recipients.tsx +63 -157
- package/src/widget/components/RequiredPropsError.tsx +33 -0
- package/src/widget/components/ScreenHeader.tsx +62 -34
- package/src/widget/components/SlippageToleranceSettings.tsx +2 -1
- package/src/widget/components/Swap.tsx +4 -45
- package/src/widget/components/SwapSettings.tsx +2 -14
- package/src/widget/components/ThemeProvider.tsx +2 -1
- package/src/widget/components/TokenDisplayNonSelectable.tsx +40 -0
- package/src/widget/components/TokenImage.tsx +22 -5
- package/src/widget/components/TokenList.tsx +0 -1
- package/src/widget/components/TokenSelector.tsx +63 -53
- package/src/widget/components/TokenSelectorButton.tsx +98 -0
- package/src/widget/components/Tooltip.tsx +51 -0
- package/src/widget/components/TransferPendingVertical.tsx +1 -1
- package/src/widget/components/UserPreferences.tsx +6 -24
- package/src/widget/components/WaasFeeOptions.tsx +450 -0
- package/src/widget/components/WalletConfirmation.tsx +76 -14
- package/src/widget/components/WalletConnect.tsx +93 -29
- package/src/widget/components/WalletList.tsx +4 -2
- package/src/widget/hooks/useBack.tsx +2 -0
- package/src/widget/hooks/useCheckout.ts +36 -20
- package/src/widget/hooks/useCurrentScreen.tsx +1 -0
- package/src/widget/hooks/useDefaultTokenSelection.tsx +104 -28
- package/src/widget/hooks/usePayMessage.tsx +86 -11
- package/src/widget/hooks/useQuote.ts +413 -0
- package/src/widget/hooks/useSelectedFundMethod.tsx +41 -0
- package/src/widget/hooks/useSelectedRecipient.tsx +10 -0
- package/src/widget/hooks/useSendForm.ts +32 -6
- package/src/widget/index.css +27 -0
- package/src/widget/widget.tsx +326 -283
- package/dist/widget/components/FundSendForm.d.ts.map +0 -1
- package/dist/widget/components/PaySendForm.d.ts.map +0 -1
- package/dist/widget/components/SimpleSwap.d.ts.map +0 -1
- package/dist/widget/hooks/useSwapSettings.d.ts +0 -16
- package/dist/widget/hooks/useSwapSettings.d.ts.map +0 -1
- package/src/widget/components/FundSendForm.tsx +0 -903
- package/src/widget/components/PaySendForm.tsx +0 -869
- package/src/widget/components/SimpleSwap.tsx +0 -983
- package/src/widget/hooks/useSwapSettings.tsx +0 -100
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type React from "react"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { truncateAddress } from "../../utils.js"
|
|
5
|
-
import { useTheme } from "../components/ThemeProvider.js"
|
|
6
|
-
import WalletConnectLogoWhite from "../assets/WalletConnect-logo-white.svg"
|
|
7
|
-
import WalletConnectLogoBlack from "../assets/WalletConnect-logo-black.svg"
|
|
2
|
+
import { QrCode, Send, ChevronRight } from "lucide-react"
|
|
3
|
+
import { useSwitchAccount } from "wagmi"
|
|
8
4
|
import { ScreenHeader } from "./ScreenHeader.js"
|
|
5
|
+
import { ConnectedWallets } from "./ConnectedWallets.js"
|
|
6
|
+
import { useCurrentScreen } from "../hooks/useCurrentScreen.js"
|
|
7
|
+
import { useConnections } from "wagmi"
|
|
8
|
+
import { logger } from "../../logger.js"
|
|
9
|
+
import { useSelectedFundMethod } from "../hooks/useSelectedFundMethod.js"
|
|
9
10
|
|
|
10
11
|
export interface FundMethodsProps {
|
|
11
12
|
onBack?: () => void
|
|
@@ -17,178 +18,100 @@ export interface FundMethodsProps {
|
|
|
17
18
|
|
|
18
19
|
const FundMethods: React.FC<FundMethodsProps> = ({
|
|
19
20
|
onBack,
|
|
20
|
-
onSelectWalletConnect,
|
|
21
21
|
onSelectExchangeList,
|
|
22
|
-
onSelectConnectedAccount,
|
|
23
22
|
onSelectQrCode,
|
|
24
23
|
}) => {
|
|
25
|
-
const {
|
|
26
|
-
const
|
|
24
|
+
const { switchAccount } = useSwitchAccount()
|
|
25
|
+
const connections = useConnections()
|
|
26
|
+
const { setCurrentScreen } = useCurrentScreen()
|
|
27
|
+
const { setSelectedFundMethod } = useSelectedFundMethod()
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
// Handle wallet selection - switch to the selected wallet and go to home
|
|
30
|
+
const handleWalletSelect = async (
|
|
31
|
+
walletAddress: string,
|
|
32
|
+
walletConnector: unknown,
|
|
33
|
+
) => {
|
|
34
|
+
try {
|
|
35
|
+
// Find the connection for this wallet
|
|
36
|
+
const connection = connections.find(
|
|
37
|
+
(conn) =>
|
|
38
|
+
conn.accounts.includes(walletAddress as `0x${string}`) &&
|
|
39
|
+
conn.connector.id === (walletConnector as { id: string }).id,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if (connection) {
|
|
43
|
+
await switchAccount({
|
|
44
|
+
connector: connection.connector,
|
|
45
|
+
})
|
|
46
|
+
logger.console.log(`[trails-sdk] Switched to wallet: ${walletAddress}`)
|
|
47
|
+
|
|
48
|
+
// Set funding method to "wallet" since user selected a wallet
|
|
49
|
+
setSelectedFundMethod("wallet")
|
|
50
|
+
|
|
51
|
+
// Navigate to home screen which will redirect to the appropriate mode screen
|
|
52
|
+
setCurrentScreen("home")
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
logger.console.error("[trails-sdk] Failed to switch wallet:", error)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
29
58
|
|
|
30
59
|
return (
|
|
31
60
|
<div className="flex flex-col h-full">
|
|
32
61
|
<ScreenHeader
|
|
33
62
|
onBack={onBack}
|
|
34
|
-
headerContent="
|
|
63
|
+
headerContent="Payment methods"
|
|
35
64
|
headerContentAlign="left"
|
|
36
65
|
rightSideContent={<div className="w-9" />}
|
|
37
|
-
showAccountActions={true}
|
|
38
66
|
/>
|
|
39
67
|
|
|
40
68
|
<div className="flex-1">
|
|
41
|
-
<div className="space-y-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<Wallet className="h-6 w-6 text-gray-600 dark:text-gray-400" />
|
|
49
|
-
<div className="flex-1 text-left">
|
|
50
|
-
<h4 className="font-semibold text-gray-900 dark:text-gray-100">
|
|
51
|
-
Connected Account
|
|
52
|
-
</h4>
|
|
53
|
-
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
54
|
-
Use your connected wallet to fund directly.
|
|
55
|
-
</p>
|
|
56
|
-
<p className="text-xs font-mono text-gray-600 dark:text-gray-300">
|
|
57
|
-
{isConnected && address
|
|
58
|
-
? `${connector?.name || "Connected"}: ${truncateAddress(address)}`
|
|
59
|
-
: "No wallet connected"}
|
|
60
|
-
</p>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
<div className="text-gray-400">
|
|
64
|
-
<svg
|
|
65
|
-
className="w-5 h-5"
|
|
66
|
-
fill="none"
|
|
67
|
-
stroke="currentColor"
|
|
68
|
-
viewBox="0 0 24 24"
|
|
69
|
-
aria-label="Chevron right"
|
|
70
|
-
>
|
|
71
|
-
<path
|
|
72
|
-
strokeLinecap="round"
|
|
73
|
-
strokeLinejoin="round"
|
|
74
|
-
strokeWidth={2}
|
|
75
|
-
d="M9 5l7 7-7 7"
|
|
76
|
-
/>
|
|
77
|
-
</svg>
|
|
78
|
-
</div>
|
|
79
|
-
</button>
|
|
69
|
+
<div className="space-y-4">
|
|
70
|
+
{/* Connected Wallets Section */}
|
|
71
|
+
<ConnectedWallets
|
|
72
|
+
showConnectNewWallet={true}
|
|
73
|
+
onWalletSelect={handleWalletSelect}
|
|
74
|
+
backScreen="fund-methods"
|
|
75
|
+
/>
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
className="
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
src={
|
|
90
|
-
activeTheme === "dark"
|
|
91
|
-
? WalletConnectLogoWhite
|
|
92
|
-
: WalletConnectLogoBlack
|
|
93
|
-
}
|
|
94
|
-
alt="WalletConnect"
|
|
95
|
-
className="h-4 w-4"
|
|
96
|
-
/>
|
|
97
|
-
</div>
|
|
98
|
-
<div className="flex-1 text-left">
|
|
99
|
-
<h4 className="font-semibold text-gray-900 dark:text-gray-100">
|
|
100
|
-
WalletConnect
|
|
101
|
-
</h4>
|
|
102
|
-
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
103
|
-
Connect another wallet.
|
|
104
|
-
</p>
|
|
105
|
-
</div>
|
|
106
|
-
</div>
|
|
107
|
-
<div className="text-gray-400">
|
|
108
|
-
<svg
|
|
109
|
-
className="w-5 h-5"
|
|
110
|
-
fill="none"
|
|
111
|
-
stroke="currentColor"
|
|
112
|
-
viewBox="0 0 24 24"
|
|
113
|
-
aria-label="Chevron right"
|
|
114
|
-
>
|
|
115
|
-
<path
|
|
116
|
-
strokeLinecap="round"
|
|
117
|
-
strokeLinejoin="round"
|
|
118
|
-
strokeWidth={2}
|
|
119
|
-
d="M9 5l7 7-7 7"
|
|
120
|
-
/>
|
|
121
|
-
</svg>
|
|
122
|
-
</div>
|
|
123
|
-
</button>
|
|
77
|
+
{/* Divider */}
|
|
78
|
+
<div className="relative flex items-center justify-center">
|
|
79
|
+
<div className="flex-1 border-t border-gray-200 dark:border-gray-700"></div>
|
|
80
|
+
<span className="px-4 text-sm text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-900">
|
|
81
|
+
or
|
|
82
|
+
</span>
|
|
83
|
+
<div className="flex-1 border-t border-gray-200 dark:border-gray-700"></div>
|
|
84
|
+
</div>
|
|
124
85
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<div className="flex-
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
</h4>
|
|
136
|
-
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
137
|
-
Scan a QR code to deposit funds.
|
|
138
|
-
</p>
|
|
86
|
+
{/* Additional Funding Options */}
|
|
87
|
+
<div className="trails-border-radius-container border trails-border-primary">
|
|
88
|
+
<button
|
|
89
|
+
type="button"
|
|
90
|
+
onClick={onSelectQrCode}
|
|
91
|
+
className="w-full text-left px-3 py-4 text-sm flex items-center justify-between cursor-pointer transition-colors trails-text-primary trails-hover-bg"
|
|
92
|
+
>
|
|
93
|
+
<div className="flex items-center gap-3">
|
|
94
|
+
<QrCode className="w-4 h-4" />
|
|
95
|
+
<span className="text-sm font-bold">Pay with QR Code</span>
|
|
139
96
|
</div>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
stroke="currentColor"
|
|
146
|
-
viewBox="0 0 24 24"
|
|
147
|
-
aria-label="Chevron right"
|
|
148
|
-
>
|
|
149
|
-
<path
|
|
150
|
-
strokeLinecap="round"
|
|
151
|
-
strokeLinejoin="round"
|
|
152
|
-
strokeWidth={2}
|
|
153
|
-
d="M9 5l7 7-7 7"
|
|
154
|
-
/>
|
|
155
|
-
</svg>
|
|
156
|
-
</div>
|
|
157
|
-
</button>
|
|
97
|
+
<ChevronRight className="w-5 h-5 text-gray-400" />
|
|
98
|
+
</button>
|
|
99
|
+
|
|
100
|
+
{/* Divider between buttons */}
|
|
101
|
+
<div className="border-b border-gray-200 dark:border-gray-700"></div>
|
|
158
102
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
<h4 className="font-semibold text-gray-900 dark:text-gray-100">
|
|
168
|
-
Send from Exchange
|
|
169
|
-
</h4>
|
|
170
|
-
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
171
|
-
Transfer from Coinbase, Binance, etc.
|
|
172
|
-
</p>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
onClick={onSelectExchangeList}
|
|
106
|
+
className="w-full text-left px-3 py-4 text-sm flex items-center justify-between cursor-pointer transition-colors trails-text-primary trails-hover-bg"
|
|
107
|
+
>
|
|
108
|
+
<div className="flex items-center gap-3">
|
|
109
|
+
<Send className="w-4 h-4" />
|
|
110
|
+
<span className="text-sm font-bold">Send from Exchange</span>
|
|
173
111
|
</div>
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
className="w-5 h-5"
|
|
178
|
-
fill="none"
|
|
179
|
-
stroke="currentColor"
|
|
180
|
-
viewBox="0 0 24 24"
|
|
181
|
-
aria-label="Chevron right"
|
|
182
|
-
>
|
|
183
|
-
<path
|
|
184
|
-
strokeLinecap="round"
|
|
185
|
-
strokeLinejoin="round"
|
|
186
|
-
strokeWidth={2}
|
|
187
|
-
d="M9 5l7 7-7 7"
|
|
188
|
-
/>
|
|
189
|
-
</svg>
|
|
190
|
-
</div>
|
|
191
|
-
</button>
|
|
112
|
+
<ChevronRight className="w-5 h-5 text-gray-400" />
|
|
113
|
+
</button>
|
|
114
|
+
</div>
|
|
192
115
|
</div>
|
|
193
116
|
</div>
|
|
194
117
|
</div>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import type { Account, WalletClient } from "viem"
|
|
3
|
+
import type { TransactionState } from "../../transactions.js"
|
|
4
|
+
import type { OnCompleteProps, Token } from "../hooks/useSendForm.js"
|
|
5
|
+
import type { SupportedToken } from "../../tokens.js"
|
|
6
|
+
import type { CheckoutOnHandlers } from "../hooks/useCheckout.js"
|
|
7
|
+
import type { PrepareSendQuote } from "../../prepareSend.js"
|
|
8
|
+
import { ClassicSwap } from "./ClassicSwap.js"
|
|
9
|
+
|
|
10
|
+
interface FundProps {
|
|
11
|
+
selectedToken: Token | null
|
|
12
|
+
onSend: (amount: string, recipient: string) => void
|
|
13
|
+
onBack?: () => void
|
|
14
|
+
onConfirm: () => void
|
|
15
|
+
onComplete: (result: OnCompleteProps) => void
|
|
16
|
+
account?: Account
|
|
17
|
+
toRecipient?: string
|
|
18
|
+
toAmount?: string
|
|
19
|
+
toChainId?: number
|
|
20
|
+
toToken?: string
|
|
21
|
+
toCalldata?: string
|
|
22
|
+
walletClient?: WalletClient
|
|
23
|
+
onTransactionStateChange: (transactionStates: TransactionState[]) => void
|
|
24
|
+
onError: (error: Error | string | null) => void
|
|
25
|
+
onWaitingForWalletConfirm: (props: PrepareSendQuote) => void
|
|
26
|
+
paymasterUrls?: Array<{ chainId: number; url: string }>
|
|
27
|
+
gasless?: boolean
|
|
28
|
+
setWalletConfirmRetryHandler: (handler: () => Promise<void>) => void
|
|
29
|
+
quoteProvider?: string
|
|
30
|
+
fundMethod?: string
|
|
31
|
+
onNavigateToMeshConnect?: (
|
|
32
|
+
props: {
|
|
33
|
+
toTokenSymbol: string
|
|
34
|
+
toTokenAmount: string
|
|
35
|
+
toChainId: number
|
|
36
|
+
toRecipientAddress: string
|
|
37
|
+
},
|
|
38
|
+
quote?: PrepareSendQuote | null,
|
|
39
|
+
) => void
|
|
40
|
+
onAmountUpdate?: (amount: string) => void
|
|
41
|
+
checkoutOnHandlers?: CheckoutOnHandlers
|
|
42
|
+
recentTokens?: SupportedToken[]
|
|
43
|
+
onRecentTokenSelect?: (token: SupportedToken) => void
|
|
44
|
+
onTrackToken?: (token: any) => void
|
|
45
|
+
isSequenceWallet?: boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const Fund: React.FC<FundProps> = (props) => {
|
|
49
|
+
return <ClassicSwap {...props} title="Fund" />
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default Fund
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ChevronRight, QrCode, Send } from "lucide-react"
|
|
2
|
+
import type React from "react"
|
|
3
|
+
import { truncateAddress } from "../../utils.js"
|
|
4
|
+
import { useAccount, useConnections } from "wagmi"
|
|
5
|
+
import { Identicon } from "./Identicon.js"
|
|
6
|
+
import { useBack } from "../hooks/useBack.js"
|
|
7
|
+
import { useSelectedFundMethod } from "../hooks/useSelectedFundMethod.js"
|
|
8
|
+
|
|
9
|
+
export const FundingMethodSelectorButton: React.FC = () => {
|
|
10
|
+
const connections = useConnections()
|
|
11
|
+
const { address } = useAccount()
|
|
12
|
+
const { setCurrentScreenWithBack } = useBack()
|
|
13
|
+
const { selectedFundMethod } = useSelectedFundMethod()
|
|
14
|
+
|
|
15
|
+
// Check if there are any connected accounts across all connectors
|
|
16
|
+
const isConnected = connections.length > 0
|
|
17
|
+
// Use the active account from useAccount(), fallback to first connection if needed
|
|
18
|
+
const activeAddress = address || connections[0]?.accounts[0]
|
|
19
|
+
|
|
20
|
+
const handleClick = () => {
|
|
21
|
+
if (isConnected && activeAddress) {
|
|
22
|
+
// If wallet is connected, go to fund methods
|
|
23
|
+
setCurrentScreenWithBack("fund-methods")
|
|
24
|
+
} else {
|
|
25
|
+
// If no wallet connected, go to connect wallet
|
|
26
|
+
setCurrentScreenWithBack("connect")
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<button
|
|
32
|
+
type="button"
|
|
33
|
+
onClick={handleClick}
|
|
34
|
+
className="flex items-center space-x-2 text-blue-500 hover:text-blue-600 transition-colors cursor-pointer bg-transparent border-none p-0"
|
|
35
|
+
title={
|
|
36
|
+
isConnected && activeAddress
|
|
37
|
+
? "Select funding method"
|
|
38
|
+
: "Connect wallet"
|
|
39
|
+
}
|
|
40
|
+
>
|
|
41
|
+
{isConnected && activeAddress ? (
|
|
42
|
+
selectedFundMethod === "qr-code" ? (
|
|
43
|
+
<>
|
|
44
|
+
<QrCode className="w-4 h-4 mr-1" />
|
|
45
|
+
<span className="text-sm font-medium m-0">QR Code</span>
|
|
46
|
+
</>
|
|
47
|
+
) : selectedFundMethod === "exchange" ? (
|
|
48
|
+
<>
|
|
49
|
+
<Send className="w-4 h-4 mr-1" />
|
|
50
|
+
<span className="text-sm font-medium m-0">Exchange</span>
|
|
51
|
+
</>
|
|
52
|
+
) : (
|
|
53
|
+
<>
|
|
54
|
+
<div className="flex items-center mr-1">
|
|
55
|
+
<Identicon value={activeAddress} size={16} />
|
|
56
|
+
</div>
|
|
57
|
+
<span className="text-sm font-medium m-0">
|
|
58
|
+
{truncateAddress(activeAddress, 4, 4)}
|
|
59
|
+
</span>
|
|
60
|
+
</>
|
|
61
|
+
)
|
|
62
|
+
) : (
|
|
63
|
+
<span className="text-sm font-medium mr-1">Connect Wallet</span>
|
|
64
|
+
)}
|
|
65
|
+
<ChevronRight className="w-4 h-4 m-0" />
|
|
66
|
+
</button>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default FundingMethodSelectorButton
|