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,6 +1,6 @@
|
|
|
1
1
|
import { useState } from "react"
|
|
2
2
|
import type React from "react"
|
|
3
|
-
import { Wallet, Copy, X } from "lucide-react"
|
|
3
|
+
import { Wallet, Copy, X, ChevronRight } from "lucide-react"
|
|
4
4
|
import {
|
|
5
5
|
useAccount,
|
|
6
6
|
useConnections,
|
|
@@ -12,11 +12,17 @@ import { logger } from "../../logger.js"
|
|
|
12
12
|
import { truncateAddress } from "../../utils.js"
|
|
13
13
|
import { useAccountTotalBalanceUsd } from "../../tokenBalances.js"
|
|
14
14
|
import { Identicon } from "./Identicon.js"
|
|
15
|
+
import { useBack } from "../hooks/useBack.js"
|
|
16
|
+
import type { Screen } from "../hooks/useCurrentScreen.js"
|
|
15
17
|
|
|
16
18
|
export interface ConnectedWalletsProps {
|
|
17
19
|
onWalletSwitch?: (address: string) => void
|
|
20
|
+
onWalletSelect?: (address: string, connector: any) => void
|
|
18
21
|
showActiveWallet?: boolean
|
|
22
|
+
showConnectNewWallet?: boolean
|
|
23
|
+
showDisconnect?: boolean
|
|
19
24
|
className?: string
|
|
25
|
+
backScreen?: string
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
interface WalletItemProps {
|
|
@@ -28,17 +34,21 @@ interface WalletItemProps {
|
|
|
28
34
|
isActive: boolean
|
|
29
35
|
}
|
|
30
36
|
onWalletSwitch: (address: string, connector: any) => void
|
|
37
|
+
onWalletSelect?: (address: string, connector: any) => void
|
|
31
38
|
onDisconnect: (connector: any, e: React.MouseEvent) => void
|
|
32
39
|
onCopyAddress: (address: string, e: React.MouseEvent) => void
|
|
33
40
|
copiedAddress: string | null
|
|
41
|
+
showDisconnect?: boolean
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
const WalletItem: React.FC<WalletItemProps> = ({
|
|
37
45
|
wallet,
|
|
38
46
|
onWalletSwitch,
|
|
47
|
+
onWalletSelect,
|
|
39
48
|
onDisconnect,
|
|
40
49
|
onCopyAddress,
|
|
41
50
|
copiedAddress,
|
|
51
|
+
showDisconnect = false,
|
|
42
52
|
}) => {
|
|
43
53
|
const { totalBalanceUsdFormatted, isLoadingTotalBalanceUsd } =
|
|
44
54
|
useAccountTotalBalanceUsd(wallet.address)
|
|
@@ -46,22 +56,29 @@ const WalletItem: React.FC<WalletItemProps> = ({
|
|
|
46
56
|
return (
|
|
47
57
|
<div className="space-y-1">
|
|
48
58
|
{/* Wallet Button */}
|
|
49
|
-
<
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
50
61
|
onClick={() => {
|
|
51
|
-
if (
|
|
62
|
+
if (onWalletSelect) {
|
|
63
|
+
onWalletSelect(wallet.address, wallet.connector)
|
|
64
|
+
} else if (!wallet.isActive) {
|
|
52
65
|
onWalletSwitch(wallet.address, wallet.connector)
|
|
53
66
|
}
|
|
54
67
|
}}
|
|
55
68
|
onKeyDown={(e) => {
|
|
56
|
-
if (
|
|
69
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
57
70
|
e.preventDefault()
|
|
58
|
-
|
|
71
|
+
if (onWalletSelect) {
|
|
72
|
+
onWalletSelect(wallet.address, wallet.connector)
|
|
73
|
+
} else if (!wallet.isActive) {
|
|
74
|
+
onWalletSwitch(wallet.address, wallet.connector)
|
|
75
|
+
}
|
|
59
76
|
}
|
|
60
77
|
}}
|
|
61
78
|
tabIndex={wallet.isActive ? -1 : 0}
|
|
62
|
-
className={`group w-full flex items-center justify-between font-medium py-2 px-3
|
|
79
|
+
className={`group w-full flex items-center justify-between font-medium py-2 px-3 transition-all duration-200 ${
|
|
63
80
|
wallet.isActive
|
|
64
|
-
? "bg-blue-50 dark:bg-blue-900/20 text-gray-700 dark:text-gray-300 cursor-
|
|
81
|
+
? "bg-blue-50 dark:bg-blue-900/20 text-gray-700 dark:text-gray-300 cursor-pointer"
|
|
65
82
|
: "bg-gray-50 dark:bg-gray-700 text-gray-700 dark:text-gray-300 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600"
|
|
66
83
|
}`}
|
|
67
84
|
>
|
|
@@ -69,34 +86,11 @@ const WalletItem: React.FC<WalletItemProps> = ({
|
|
|
69
86
|
{/* Identicon */}
|
|
70
87
|
<Identicon value={wallet.address} size={32} />
|
|
71
88
|
<div className="flex flex-col items-start space-y-1">
|
|
72
|
-
<div className="flex items-center space-x-
|
|
73
|
-
|
|
74
|
-
{typeof wallet.walletConfig?.icon === "string" ? (
|
|
75
|
-
<img
|
|
76
|
-
src={wallet.walletConfig.icon}
|
|
77
|
-
alt={wallet.walletConfig.name}
|
|
78
|
-
className="h-4 w-4"
|
|
79
|
-
/>
|
|
80
|
-
) : (
|
|
81
|
-
<Wallet className="h-4 w-4 text-gray-600 dark:text-gray-400" />
|
|
82
|
-
)}
|
|
83
|
-
<span className="text-sm">
|
|
84
|
-
{wallet.walletConfig?.name ||
|
|
85
|
-
wallet.connector?.name ||
|
|
86
|
-
"Wallet"}
|
|
87
|
-
</span>
|
|
88
|
-
{!isLoadingTotalBalanceUsd && totalBalanceUsdFormatted && (
|
|
89
|
-
<span className="text-xs text-gray-400 dark:text-gray-500">
|
|
90
|
-
{totalBalanceUsdFormatted}
|
|
91
|
-
</span>
|
|
92
|
-
)}
|
|
93
|
-
</div>
|
|
94
|
-
<div className="flex items-center space-x-1">
|
|
95
|
-
<span className="text-xs text-gray-500 dark:text-gray-400 font-mono">
|
|
89
|
+
<div className="flex items-center space-x-1 m-0">
|
|
90
|
+
<span className="text-sm font-bold text-gray-900 dark:text-gray-100 whitespace-nowrap">
|
|
96
91
|
{truncateAddress(wallet.address)}
|
|
97
92
|
</span>
|
|
98
|
-
<
|
|
99
|
-
type="button"
|
|
93
|
+
<div
|
|
100
94
|
onClick={(e) => {
|
|
101
95
|
e.preventDefault()
|
|
102
96
|
e.stopPropagation()
|
|
@@ -134,7 +128,24 @@ const WalletItem: React.FC<WalletItemProps> = ({
|
|
|
134
128
|
) : (
|
|
135
129
|
<Copy className="w-3 h-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300" />
|
|
136
130
|
)}
|
|
137
|
-
</
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
<div className="flex items-center space-x-2">
|
|
134
|
+
{/* Wallet Icon */}
|
|
135
|
+
{typeof wallet.walletConfig?.icon === "string" ? (
|
|
136
|
+
<img
|
|
137
|
+
src={wallet.walletConfig.icon}
|
|
138
|
+
alt={wallet.walletConfig.name}
|
|
139
|
+
className="h-3.5 w-3.5 mr-1"
|
|
140
|
+
/>
|
|
141
|
+
) : (
|
|
142
|
+
<Wallet className="h-3.5 w-3.5 text-gray-600 dark:text-gray-400 mr-1" />
|
|
143
|
+
)}
|
|
144
|
+
<span className="text-xs text-gray-500 dark:text-gray-400">
|
|
145
|
+
{wallet.walletConfig?.name ||
|
|
146
|
+
wallet.connector?.name ||
|
|
147
|
+
"Wallet"}
|
|
148
|
+
</span>
|
|
138
149
|
</div>
|
|
139
150
|
</div>
|
|
140
151
|
</div>
|
|
@@ -144,38 +155,49 @@ const WalletItem: React.FC<WalletItemProps> = ({
|
|
|
144
155
|
<span className="text-xs px-2 py-1 rounded font-medium bg-blue-500 text-white">
|
|
145
156
|
Active
|
|
146
157
|
</span>
|
|
147
|
-
) : (
|
|
148
|
-
<span className="text-xs px-2 py-1 rounded font-medium bg-gray-200 text-gray-700 dark:bg-gray-600 dark:text-gray-300 opacity-0 group-hover:opacity-100 transition-opacity duration-200">
|
|
158
|
+
) : !onWalletSelect ? (
|
|
159
|
+
<span className="whitespace-nowrap text-xs px-2 py-1 rounded font-medium bg-gray-200 text-gray-700 dark:bg-gray-600 dark:text-gray-300 opacity-0 group-hover:opacity-100 transition-opacity duration-200">
|
|
149
160
|
Set as active
|
|
150
161
|
</span>
|
|
162
|
+
) : null}
|
|
163
|
+
{!isLoadingTotalBalanceUsd && totalBalanceUsdFormatted && (
|
|
164
|
+
<span className="text-sm font-medium text-gray-700 dark:text-gray-300">
|
|
165
|
+
{totalBalanceUsdFormatted}
|
|
166
|
+
</span>
|
|
167
|
+
)}
|
|
168
|
+
{showDisconnect && (
|
|
169
|
+
<div
|
|
170
|
+
onClick={(e) => onDisconnect(wallet.connector, e)}
|
|
171
|
+
onMouseDown={(e) => e.stopPropagation()}
|
|
172
|
+
onMouseUp={(e) => e.stopPropagation()}
|
|
173
|
+
className="p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-600 opacity-0 group-hover:opacity-100 transition-all duration-200 cursor-pointer"
|
|
174
|
+
title="Disconnect wallet"
|
|
175
|
+
>
|
|
176
|
+
<X className="w-4 h-4 text-gray-500 dark:text-gray-400" />
|
|
177
|
+
</div>
|
|
151
178
|
)}
|
|
152
|
-
<
|
|
153
|
-
type="button"
|
|
154
|
-
onClick={(e) => onDisconnect(wallet.connector, e)}
|
|
155
|
-
onMouseDown={(e) => e.stopPropagation()}
|
|
156
|
-
onMouseUp={(e) => e.stopPropagation()}
|
|
157
|
-
className="p-1 rounded-full hover:bg-gray-200 dark:hover:bg-gray-600 opacity-0 group-hover:opacity-100 transition-all duration-200 cursor-pointer"
|
|
158
|
-
title="Disconnect wallet"
|
|
159
|
-
aria-label="Disconnect wallet"
|
|
160
|
-
>
|
|
161
|
-
<X className="w-4 h-4 text-gray-500 dark:text-gray-400" />
|
|
162
|
-
</button>
|
|
179
|
+
{onWalletSelect && <ChevronRight className="w-5 h-5 text-gray-400" />}
|
|
163
180
|
</div>
|
|
164
|
-
</
|
|
181
|
+
</button>
|
|
165
182
|
</div>
|
|
166
183
|
)
|
|
167
184
|
}
|
|
168
185
|
|
|
169
186
|
export const ConnectedWallets: React.FC<ConnectedWalletsProps> = ({
|
|
170
187
|
onWalletSwitch,
|
|
188
|
+
onWalletSelect,
|
|
171
189
|
showActiveWallet = true,
|
|
190
|
+
showConnectNewWallet = false,
|
|
191
|
+
showDisconnect = false,
|
|
172
192
|
className = "",
|
|
193
|
+
backScreen = "connect",
|
|
173
194
|
}) => {
|
|
174
195
|
const { address, connector } = useAccount()
|
|
175
196
|
const connections = useConnections()
|
|
176
197
|
const { switchAccount } = useSwitchAccount()
|
|
177
198
|
const { disconnect } = useDisconnect()
|
|
178
199
|
const { wallets: allWallets } = useWallets()
|
|
200
|
+
const { setCurrentScreenWithBack } = useBack()
|
|
179
201
|
const [error, setError] = useState<string | null>(null)
|
|
180
202
|
const [copiedAddress, setCopiedAddress] = useState<string | null>(null)
|
|
181
203
|
|
|
@@ -302,39 +324,72 @@ export const ConnectedWallets: React.FC<ConnectedWalletsProps> = ({
|
|
|
302
324
|
return (
|
|
303
325
|
<div className={`space-y-2 ${className}`}>
|
|
304
326
|
{/* Header */}
|
|
305
|
-
<div className="
|
|
306
|
-
|
|
307
|
-
<span className="text-sm font-medium text-gray-500 dark:text-gray-400">
|
|
308
|
-
Connected Wallets
|
|
309
|
-
</span>
|
|
327
|
+
<div className="text-sm font-medium text-gray-900 dark:text-gray-100 text-left mb-2">
|
|
328
|
+
Connected Wallets
|
|
310
329
|
</div>
|
|
311
330
|
|
|
312
|
-
{
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
331
|
+
{/* Connected Wallets Container with Border */}
|
|
332
|
+
<div className="trails-border-radius-container border trails-border-primary">
|
|
333
|
+
{error && (
|
|
334
|
+
<div className="border rounded-lg p-4 bg-red-50 border-red-200 dark:bg-red-900/20 dark:border-red-800 m-3">
|
|
335
|
+
<p className="text-sm break-words text-red-600 dark:text-red-200">
|
|
336
|
+
{error}
|
|
337
|
+
</p>
|
|
338
|
+
</div>
|
|
339
|
+
)}
|
|
319
340
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
341
|
+
{/* Connected Wallets List */}
|
|
342
|
+
{connectedWallets.map((wallet, index) => {
|
|
343
|
+
// Skip active wallet if showActiveWallet is false
|
|
344
|
+
if (!showActiveWallet && wallet.isActive) {
|
|
345
|
+
return null
|
|
346
|
+
}
|
|
326
347
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
348
|
+
return (
|
|
349
|
+
<div key={wallet.address}>
|
|
350
|
+
<WalletItem
|
|
351
|
+
wallet={wallet}
|
|
352
|
+
onWalletSwitch={handleWalletSwitch}
|
|
353
|
+
onWalletSelect={onWalletSelect}
|
|
354
|
+
onDisconnect={handleDisconnect}
|
|
355
|
+
onCopyAddress={handleCopyAddress}
|
|
356
|
+
copiedAddress={copiedAddress}
|
|
357
|
+
showDisconnect={showDisconnect}
|
|
358
|
+
/>
|
|
359
|
+
{/* Add divider between wallet items */}
|
|
360
|
+
{index < connectedWallets.length - 1 && (
|
|
361
|
+
<div className="border-b border-gray-200 dark:border-gray-700"></div>
|
|
362
|
+
)}
|
|
363
|
+
</div>
|
|
364
|
+
)
|
|
365
|
+
})}
|
|
366
|
+
|
|
367
|
+
{/* Connect new wallet Button - inside the same container */}
|
|
368
|
+
{showConnectNewWallet && (
|
|
369
|
+
<>
|
|
370
|
+
{/* Add divider before the connect button */}
|
|
371
|
+
{connectedWallets.length > 0 && (
|
|
372
|
+
<div className="border-b border-gray-200 dark:border-gray-700"></div>
|
|
373
|
+
)}
|
|
374
|
+
<button
|
|
375
|
+
type="button"
|
|
376
|
+
onClick={() => {
|
|
377
|
+
logger.console.log(
|
|
378
|
+
"[trails-sdk] Navigating from connected-wallets to wallet-list",
|
|
379
|
+
)
|
|
380
|
+
setCurrentScreenWithBack("wallet-list", backScreen as Screen)
|
|
381
|
+
}}
|
|
382
|
+
className="w-full text-left px-3 py-4 text-sm flex items-center justify-between cursor-pointer transition-colors trails-text-primary hover:trails-hover-bg"
|
|
383
|
+
>
|
|
384
|
+
<div className="flex items-center gap-3">
|
|
385
|
+
<Wallet className="w-4 h-4" />
|
|
386
|
+
<span className="text-sm font-bold">Connect new wallet</span>
|
|
387
|
+
</div>
|
|
388
|
+
<ChevronRight className="w-5 h-5 text-gray-400" />
|
|
389
|
+
</button>
|
|
390
|
+
</>
|
|
391
|
+
)}
|
|
392
|
+
</div>
|
|
338
393
|
</div>
|
|
339
394
|
)
|
|
340
395
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useMemo } from "react"
|
|
2
|
+
|
|
3
|
+
interface DynamicInputStylesProps {
|
|
4
|
+
inputValue: string
|
|
5
|
+
variant?: "default" | "smaller" | "inline"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const useDynamicInputStyles = ({
|
|
9
|
+
inputValue,
|
|
10
|
+
variant = "default",
|
|
11
|
+
}: DynamicInputStylesProps) => {
|
|
12
|
+
return useMemo(() => {
|
|
13
|
+
const inputLength = inputValue.length
|
|
14
|
+
let fontSize: string
|
|
15
|
+
|
|
16
|
+
if (variant === "smaller") {
|
|
17
|
+
// Used in Fund.tsx - smaller font sizes
|
|
18
|
+
if (inputLength > 15) {
|
|
19
|
+
fontSize = "1rem"
|
|
20
|
+
} else if (inputLength > 12) {
|
|
21
|
+
fontSize = "1.125rem"
|
|
22
|
+
} else if (inputLength > 9) {
|
|
23
|
+
fontSize = "1.25rem"
|
|
24
|
+
} else if (inputLength > 6) {
|
|
25
|
+
fontSize = "1.375rem"
|
|
26
|
+
} else {
|
|
27
|
+
fontSize = "1.5rem"
|
|
28
|
+
}
|
|
29
|
+
} else if (variant === "inline") {
|
|
30
|
+
// Used in PoolWithdraw.tsx and PoolDeposit.tsx - inline styles with width
|
|
31
|
+
if (inputLength > 15) {
|
|
32
|
+
fontSize = "1rem"
|
|
33
|
+
} else if (inputLength > 12) {
|
|
34
|
+
fontSize = "1.125rem"
|
|
35
|
+
} else if (inputLength > 9) {
|
|
36
|
+
fontSize = "1.25rem"
|
|
37
|
+
} else if (inputLength > 6) {
|
|
38
|
+
fontSize = "1.375rem"
|
|
39
|
+
} else {
|
|
40
|
+
fontSize = "1.5rem"
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
// Default variant - used in Pay.tsx and ClassicSwap.tsx
|
|
44
|
+
if (inputLength > 15) {
|
|
45
|
+
fontSize = "1.25rem"
|
|
46
|
+
} else if (inputLength > 12) {
|
|
47
|
+
fontSize = "1.5rem"
|
|
48
|
+
} else if (inputLength > 9) {
|
|
49
|
+
fontSize = "1.75rem"
|
|
50
|
+
} else if (inputLength > 6) {
|
|
51
|
+
fontSize = "2rem"
|
|
52
|
+
} else {
|
|
53
|
+
fontSize = "2.25rem"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const baseStyles = {
|
|
58
|
+
fontSize,
|
|
59
|
+
transition: "all 0.1s ease-in-out",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Add width and other properties for inline variant
|
|
63
|
+
if (variant === "inline") {
|
|
64
|
+
return {
|
|
65
|
+
...baseStyles,
|
|
66
|
+
width: `${Math.max((inputValue || "0").length, 1)}ch`,
|
|
67
|
+
minWidth: "1ch",
|
|
68
|
+
maxWidth: "270px",
|
|
69
|
+
padding: "0",
|
|
70
|
+
margin: "0",
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return baseStyles
|
|
75
|
+
}, [inputValue, variant])
|
|
76
|
+
}
|