0xtrails 0.2.5 → 0.3.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/aave.d.ts +2 -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-CXlshvBY.js → ccip-BMB3uDZt.js} +1 -1
- package/dist/config.d.ts +0 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +4 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/fees.d.ts +19 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/{index-_QuyGrjU.js → index-QXPUrZVv.js} +48719 -50852
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +811 -784
- package/dist/intentReceiptMonitor.d.ts +24 -0
- package/dist/intentReceiptMonitor.d.ts.map +1 -0
- package/dist/intentReceiptPoller.d.ts +69 -0
- package/dist/intentReceiptPoller.d.ts.map +1 -0
- package/dist/intents.d.ts +15 -11
- package/dist/intents.d.ts.map +1 -1
- package/dist/morpho.d.ts +6 -5
- package/dist/morpho.d.ts.map +1 -1
- package/dist/mutations.d.ts +16 -0
- package/dist/mutations.d.ts.map +1 -0
- package/dist/preconditions.d.ts +5 -4
- package/dist/preconditions.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +7 -258
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +9 -6
- package/dist/prices.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +3 -16
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +17 -13
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/trails.d.ts +24 -40
- package/dist/trails.d.ts.map +1 -1
- package/dist/transactionIntent/constants.d.ts +7 -0
- package/dist/transactionIntent/constants.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +44 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/index.d.ts +4 -0
- package/dist/transactionIntent/deposits/index.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/execution/index.d.ts +2 -0
- package/dist/transactionIntent/execution/index.d.ts.map +1 -0
- package/dist/transactionIntent/execution/transactionState.d.ts +5 -0
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts +82 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/index.d.ts +4 -0
- package/dist/transactionIntent/handlers/index.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +62 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +72 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -0
- package/dist/transactionIntent/index.d.ts +9 -0
- package/dist/transactionIntent/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts +17 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -0
- package/dist/transactionIntent/quote/index.d.ts +4 -0
- package/dist/transactionIntent/quote/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts +34 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +5 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/types.d.ts +131 -0
- package/dist/transactionIntent/types.d.ts.map +1 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts +18 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts.map +1 -0
- package/dist/transactionIntent/utils/index.d.ts +4 -0
- package/dist/transactionIntent/utils/index.d.ts.map +1 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts +10 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts +3 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/validators.d.ts +6 -0
- package/dist/transactionIntent/validators.d.ts.map +1 -0
- package/dist/transactions.d.ts +6 -3
- package/dist/transactions.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 +2 -3
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- 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/DynamicSizeInputField.d.ts +13 -0
- package/dist/widget/components/DynamicSizeInputField.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts +2 -3
- 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/FeeOptions.d.ts +5 -13
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +2 -3
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSwap.d.ts +2 -3
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
- 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 -3
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +3 -3
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +3 -20
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts +2 -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/RecipientSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +2 -3
- package/dist/widget/components/Swap.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/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Tooltip.d.ts +9 -0
- package/dist/widget/components/Tooltip.d.ts.map +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +1 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +2 -2
- package/dist/widget/hooks/useCheckout.d.ts +17 -4
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +82 -0
- package/dist/widget/hooks/useQuote.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +5 -6
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useWalletConnectionContext.d.ts +25 -0
- package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +1 -0
- package/dist/widget/index.js +2 -2
- package/dist/widget/widget.d.ts +17 -7
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +19 -21
- package/src/aave.ts +54 -1
- package/src/abortController.ts +35 -0
- package/src/config.ts +57 -58
- package/src/constants.ts +11 -9
- package/src/error.ts +21 -3
- package/src/fees.ts +210 -0
- package/src/index.ts +35 -13
- package/src/intentReceiptMonitor.ts +102 -0
- package/src/intentReceiptPoller.ts +299 -0
- package/src/intents.ts +205 -171
- package/src/morpho.ts +58 -9
- package/src/mutations.ts +129 -0
- package/src/preconditions.ts +16 -21
- package/src/prepareSend.ts +92 -4699
- package/src/prices.ts +26 -22
- package/src/relaySdk.ts +2 -2
- package/src/sequenceWallet.ts +6 -73
- package/src/tokenBalances.ts +175 -69
- package/src/trails.ts +230 -722
- package/src/transactionIntent/constants.ts +11 -0
- package/src/transactionIntent/deposits/depositOrchestrator.ts +210 -0
- package/src/transactionIntent/deposits/gaslessDeposit.ts +588 -0
- package/src/transactionIntent/deposits/index.ts +3 -0
- package/src/transactionIntent/deposits/standardDeposit.ts +379 -0
- package/src/transactionIntent/execution/index.ts +1 -0
- package/src/transactionIntent/execution/transactionState.ts +35 -0
- package/src/transactionIntent/handlers/crossChain.ts +1707 -0
- package/src/transactionIntent/handlers/index.ts +3 -0
- package/src/transactionIntent/handlers/sameChainDifferentToken.ts +323 -0
- package/src/transactionIntent/handlers/sameChainSameToken.ts +712 -0
- package/src/transactionIntent/index.ts +9 -0
- package/src/transactionIntent/quote/feeExtractors.ts +81 -0
- package/src/transactionIntent/quote/index.ts +3 -0
- package/src/transactionIntent/quote/normalizeQuote.ts +367 -0
- package/src/transactionIntent/quote/quoteHelpers.ts +53 -0
- package/src/transactionIntent/types.ts +157 -0
- package/src/transactionIntent/utils/balanceChecker.ts +96 -0
- package/src/transactionIntent/utils/index.ts +3 -0
- package/src/transactionIntent/utils/lifiHelpers.ts +68 -0
- package/src/transactionIntent/utils/testnetHelpers.ts +10 -0
- package/src/transactionIntent/validators.ts +57 -0
- package/src/transactions.ts +98 -71
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountIntentTransactionHistory.tsx +36 -36
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +22 -0
- package/src/widget/components/AccountSettings.tsx +70 -41
- package/src/widget/components/ChainFilterDropdown.tsx +24 -3
- package/src/widget/components/ClassicSwap.tsx +44 -107
- package/src/widget/components/ConfigDisplay.tsx +0 -11
- package/src/widget/components/ConnectWallet.tsx +4 -1
- package/src/widget/components/ConnectedWallets.tsx +51 -25
- package/src/widget/components/DynamicInputStyles.tsx +76 -0
- package/src/widget/components/DynamicSizeInputField.tsx +109 -0
- package/src/widget/components/Earn.tsx +34 -45
- package/src/widget/components/ErrorAnimationIcon.tsx +130 -0
- package/src/widget/components/FeeBreakdown.tsx +155 -0
- package/src/widget/components/FeeOption.tsx +2 -2
- package/src/widget/components/FeeOptions.tsx +151 -112
- package/src/widget/components/Fund.tsx +10 -29
- package/src/widget/components/FundMethods.tsx +4 -3
- package/src/widget/components/FundSwap.tsx +2 -3
- package/src/widget/components/FundingMethodSelectorButton.tsx +24 -14
- package/src/widget/components/Identicon.tsx +164 -95
- package/src/widget/components/MeshConnectExchanges.tsx +2 -15
- package/src/widget/components/Modal.tsx +0 -12
- package/src/widget/components/Pay.tsx +72 -75
- package/src/widget/components/PoolDeposit.tsx +221 -242
- package/src/widget/components/PoolWithdraw.tsx +347 -469
- package/src/widget/components/PriceImpactWarning.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +906 -484
- package/src/widget/components/Receipt.tsx +16 -2
- package/src/widget/components/RecipientSelectorButton.tsx +7 -5
- package/src/widget/components/Recipients.tsx +1 -1
- package/src/widget/components/ScreenHeader.tsx +60 -36
- package/src/widget/components/Swap.tsx +2 -3
- package/src/widget/components/ThemeProvider.tsx +2 -1
- package/src/widget/components/TokenDisplayNonSelectable.tsx +40 -0
- package/src/widget/components/TokenImage.tsx +1 -1
- package/src/widget/components/TokenSelector.tsx +62 -53
- package/src/widget/components/TokenSelectorButton.tsx +38 -15
- package/src/widget/components/Tooltip.tsx +51 -0
- package/src/widget/components/TransferPendingVertical.tsx +12 -8
- package/src/widget/components/WaasFeeOptions.tsx +139 -4
- package/src/widget/components/WalletConfirmation.tsx +23 -13
- package/src/widget/components/WalletConnect.tsx +93 -29
- package/src/widget/hooks/useAmountUsd.ts +9 -9
- package/src/widget/hooks/useCheckout.ts +97 -9
- package/src/widget/hooks/useDefaultTokenSelection.tsx +27 -21
- package/src/widget/hooks/useQuote.ts +466 -0
- package/src/widget/hooks/useSelectedFeeToken.tsx +32 -37
- package/src/widget/hooks/useSendForm.ts +45 -51
- package/src/widget/hooks/useTokenList.ts +34 -26
- package/src/widget/hooks/useWalletConnectionContext.tsx +128 -0
- package/src/widget/widget.tsx +365 -390
- package/dist/apiClient.d.ts +0 -9
- package/dist/apiClient.d.ts.map +0 -1
- package/dist/intentEntrypoint.d.ts +0 -114
- package/dist/intentEntrypoint.d.ts.map +0 -1
- package/dist/metaTxnMonitor.d.ts +0 -15
- package/dist/metaTxnMonitor.d.ts.map +0 -1
- package/dist/metaTxns.d.ts +0 -11
- package/dist/metaTxns.d.ts.map +0 -1
- package/dist/relayer.d.ts +0 -43
- package/dist/relayer.d.ts.map +0 -1
- package/src/apiClient.ts +0 -35
- package/src/intentEntrypoint.ts +0 -203
- package/src/metaTxnMonitor.ts +0 -171
- package/src/metaTxns.ts +0 -45
- package/src/relayer.ts +0 -289
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { LogOut, User, ChevronRight, History } from "lucide-react"
|
|
1
|
+
import { LogOut, User, ChevronRight, History, HelpCircle } from "lucide-react"
|
|
2
2
|
import type React from "react"
|
|
3
3
|
import { useWidgetProps } from "../hooks/useWidgetProps.js"
|
|
4
4
|
import type { Screen } from "../hooks/useCurrentScreen.js"
|
|
5
5
|
import { useBack } from "../hooks/useBack.js"
|
|
6
6
|
import { ConnectedWallets } from "./ConnectedWallets.js"
|
|
7
7
|
import { ScreenHeader } from "./ScreenHeader.js"
|
|
8
|
+
import Tooltip from "./Tooltip.js"
|
|
8
9
|
|
|
9
10
|
const ACTIONS = [
|
|
10
11
|
{
|
|
@@ -26,57 +27,85 @@ interface AccountSettingsProps {
|
|
|
26
27
|
onBack?: () => void
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
const onHelp = () => {
|
|
31
|
+
window.open("https://support.trails.build/en/", "_blank")
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
export const AccountSettings: React.FC<AccountSettingsProps> = ({ onBack }) => {
|
|
30
35
|
const { hideDisconnect, decoupleWagmi } = useWidgetProps()
|
|
31
36
|
const { setCurrentScreenWithBack } = useBack()
|
|
32
37
|
|
|
33
38
|
return (
|
|
34
39
|
<div className="flex flex-col h-full">
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{/* Connected Wallets */}
|
|
42
|
-
<div>
|
|
43
|
-
<ConnectedWallets
|
|
44
|
-
showConnectNewWallet={true}
|
|
45
|
-
showDisconnect={true}
|
|
46
|
-
backScreen="account-settings"
|
|
40
|
+
<div className="flex items-center justify-between h-full">
|
|
41
|
+
<ScreenHeader
|
|
42
|
+
headerContent="Settings"
|
|
43
|
+
headerContentAlign="left"
|
|
44
|
+
onBack={onBack}
|
|
47
45
|
/>
|
|
46
|
+
<Tooltip message="Get help" className="mb-4 mr-0">
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
onClick={onHelp}
|
|
50
|
+
className="flex h-8 w-8 justify-center items-center rounded-full bg-gray-50 dark:bg-gray-700 cursor-pointer transition-colors text-gray-900 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-600"
|
|
51
|
+
title="Get help"
|
|
52
|
+
>
|
|
53
|
+
<HelpCircle className="w-4 h-4" />
|
|
54
|
+
</button>
|
|
55
|
+
</Tooltip>
|
|
48
56
|
</div>
|
|
49
57
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
<div className="flex-1">
|
|
59
|
+
<div className="space-y-4">
|
|
60
|
+
{/* Connected Wallets */}
|
|
61
|
+
<ConnectedWallets
|
|
62
|
+
showConnectNewWallet={true}
|
|
63
|
+
showDisconnect={true}
|
|
64
|
+
backScreen="account-settings"
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
{/* Divider */}
|
|
68
|
+
<div className="border-t border-gray-200 dark:border-gray-700"></div>
|
|
69
|
+
|
|
70
|
+
{/* Actions */}
|
|
71
|
+
<div className="trails-border-radius-container border trails-border-primary">
|
|
72
|
+
{ACTIONS.map((action, index) => {
|
|
73
|
+
if (action.disabled) return null
|
|
74
|
+
// Hide disconnect action if hideDisconnect is true
|
|
75
|
+
if (
|
|
76
|
+
(hideDisconnect || decoupleWagmi) &&
|
|
77
|
+
action.screen === "disconnect"
|
|
78
|
+
)
|
|
79
|
+
return null
|
|
80
|
+
|
|
81
|
+
const IconComponent = action.icon
|
|
82
|
+
const isLast = index === ACTIONS.length - 1
|
|
60
83
|
|
|
61
|
-
|
|
84
|
+
return (
|
|
85
|
+
<div key={action.screen}>
|
|
86
|
+
<button
|
|
87
|
+
type="button"
|
|
88
|
+
onClick={() => {
|
|
89
|
+
setCurrentScreenWithBack(action.screen as Screen)
|
|
90
|
+
}}
|
|
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
|
+
<IconComponent className="w-4 h-4" />
|
|
95
|
+
<span className="text-sm font-bold">{action.label}</span>
|
|
96
|
+
</div>
|
|
97
|
+
<ChevronRight className="w-5 h-5 text-gray-400" />
|
|
98
|
+
</button>
|
|
62
99
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<div className="flex items-center gap-3">
|
|
73
|
-
<IconComponent className="w-4 h-4" />
|
|
74
|
-
{action.label}
|
|
75
|
-
</div>
|
|
76
|
-
<ChevronRight className="w-4 h-4 text-gray-400" />
|
|
77
|
-
</button>
|
|
78
|
-
)
|
|
79
|
-
})}
|
|
100
|
+
{/* Divider between buttons (except for the last one) */}
|
|
101
|
+
{!isLast && (
|
|
102
|
+
<div className="border-b border-gray-200 dark:border-gray-700"></div>
|
|
103
|
+
)}
|
|
104
|
+
</div>
|
|
105
|
+
)
|
|
106
|
+
})}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
80
109
|
</div>
|
|
81
110
|
</div>
|
|
82
111
|
)
|
|
@@ -3,6 +3,7 @@ import type React from "react"
|
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from "react"
|
|
4
4
|
import { ChainImage } from "./ChainImage.js"
|
|
5
5
|
import { AllChainsIcon } from "./AllChainsIcon.js"
|
|
6
|
+
import { getChainInfo } from "../../chains.js"
|
|
6
7
|
|
|
7
8
|
export interface Chain {
|
|
8
9
|
chainId: number
|
|
@@ -94,9 +95,29 @@ export const ChainFilterDropdown: React.FC<ChainFilterDropdownProps> = ({
|
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
)
|
|
98
|
+
// Find selected chain in the chains array, or get it from getChainInfo if not found
|
|
99
|
+
// This handles the case where user selects a chain with no tokens
|
|
100
|
+
const selectedChain = useMemo(() => {
|
|
101
|
+
if (selectedChainId === null) return null
|
|
102
|
+
|
|
103
|
+
const chainInList = chains.find(
|
|
104
|
+
(chain) => chain.chainId === selectedChainId,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
if (chainInList) return chainInList
|
|
108
|
+
|
|
109
|
+
// If chain not in list (e.g., no tokens on that chain), get info from getChainInfo
|
|
110
|
+
const chainInfo = getChainInfo(selectedChainId)
|
|
111
|
+
if (chainInfo) {
|
|
112
|
+
return {
|
|
113
|
+
chainId: chainInfo.id,
|
|
114
|
+
name: chainInfo.name,
|
|
115
|
+
imageUrl: chainInfo.imageUrl,
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return null
|
|
120
|
+
}, [chains, selectedChainId])
|
|
100
121
|
|
|
101
122
|
return (
|
|
102
123
|
<div className={`relative ${className}`} ref={dropdownRef}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Loader2, ArrowDown } from "lucide-react"
|
|
2
2
|
import type React from "react"
|
|
3
|
-
import { useCallback, useEffect, useRef, useState
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react"
|
|
4
4
|
import type { Account, WalletClient } from "viem"
|
|
5
5
|
import { zeroAddress } from "viem"
|
|
6
6
|
import type { TransactionState } from "../../transactions.js"
|
|
@@ -28,6 +28,8 @@ import { RecipientSelectorButton } from "./RecipientSelectorButton.js"
|
|
|
28
28
|
import { RefundWarning } from "./RefundWarning.js"
|
|
29
29
|
import { Identicon } from "./Identicon.js"
|
|
30
30
|
import { truncateAddress } from "../../utils.js"
|
|
31
|
+
import { DynamicSizeInputField } from "./DynamicSizeInputField.js"
|
|
32
|
+
import { FeeOptions } from "./FeeOptions.js"
|
|
31
33
|
|
|
32
34
|
interface ClassicSwapProps {
|
|
33
35
|
selectedToken: Token | null
|
|
@@ -35,18 +37,17 @@ interface ClassicSwapProps {
|
|
|
35
37
|
onBack?: () => void
|
|
36
38
|
onConfirm: () => void
|
|
37
39
|
onComplete: (result: OnCompleteProps) => void
|
|
38
|
-
account
|
|
40
|
+
account?: Account
|
|
39
41
|
toRecipient?: string
|
|
40
42
|
toAmount?: string
|
|
41
43
|
toChainId?: number
|
|
42
44
|
toToken?: string
|
|
43
45
|
toCalldata?: string
|
|
44
|
-
walletClient
|
|
46
|
+
walletClient?: WalletClient
|
|
45
47
|
onTransactionStateChange: (transactionStates: TransactionState[]) => void
|
|
46
48
|
onError: (error: Error | string | null) => void
|
|
47
49
|
onWaitingForWalletConfirm: (props: PrepareSendQuote) => void
|
|
48
50
|
paymasterUrls?: Array<{ chainId: number; url: string }>
|
|
49
|
-
gasless?: boolean
|
|
50
51
|
setWalletConfirmRetryHandler: (handler: () => Promise<void>) => void
|
|
51
52
|
quoteProvider?: string
|
|
52
53
|
fundMethod?: string
|
|
@@ -85,7 +86,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
85
86
|
onError,
|
|
86
87
|
onWaitingForWalletConfirm,
|
|
87
88
|
paymasterUrls,
|
|
88
|
-
gasless,
|
|
89
89
|
setWalletConfirmRetryHandler,
|
|
90
90
|
quoteProvider,
|
|
91
91
|
fundMethod,
|
|
@@ -143,10 +143,13 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
143
143
|
quoteError,
|
|
144
144
|
quoteErrorPrettified,
|
|
145
145
|
isSameTokenWithoutCustomCalldata,
|
|
146
|
+
feeOptions,
|
|
147
|
+
selectedFeeToken,
|
|
148
|
+
setSelectedFeeToken,
|
|
146
149
|
} = useSendForm({
|
|
147
150
|
account,
|
|
148
151
|
toAmount: tradeType === TradeType.EXACT_OUTPUT ? buyAmount : toAmount,
|
|
149
|
-
toRecipient: toRecipient || account
|
|
152
|
+
toRecipient: toRecipient || account?.address,
|
|
150
153
|
toChainId,
|
|
151
154
|
toToken,
|
|
152
155
|
toCalldata,
|
|
@@ -155,10 +158,9 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
155
158
|
onError,
|
|
156
159
|
onWaitingForWalletConfirm,
|
|
157
160
|
paymasterUrls,
|
|
158
|
-
|
|
161
|
+
onSend,
|
|
159
162
|
onConfirm,
|
|
160
163
|
onComplete,
|
|
161
|
-
onSend,
|
|
162
164
|
selectedToken: originToken as any,
|
|
163
165
|
setWalletConfirmRetryHandler,
|
|
164
166
|
tradeType: tradeType,
|
|
@@ -178,36 +180,16 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
178
180
|
}
|
|
179
181
|
}, [sellAmount, buyAmount, lastInputType, setAmount])
|
|
180
182
|
|
|
181
|
-
// Handle sell amount input changes
|
|
183
|
+
// Handle sell amount input changes
|
|
182
184
|
const handleSellAmountChange = useCallback((value: string) => {
|
|
183
|
-
// Limit total length to 16 characters
|
|
184
|
-
if (value.length > 16) {
|
|
185
|
-
return
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Validate decimal places (max 8 decimals)
|
|
189
|
-
const decimalMatch = value.match(/^\d*\.?\d{0,8}$/)
|
|
190
|
-
if (!decimalMatch && value !== "") {
|
|
191
|
-
return // Don't update if more than 8 decimals
|
|
192
|
-
}
|
|
193
185
|
setTradeType(TradeType.EXACT_INPUT)
|
|
194
186
|
setSellAmount(value)
|
|
195
187
|
setBuyAmount("")
|
|
196
188
|
setLastInputType("sell")
|
|
197
189
|
}, [])
|
|
198
190
|
|
|
199
|
-
// Handle buy amount input changes
|
|
191
|
+
// Handle buy amount input changes
|
|
200
192
|
const handleBuyAmountChange = useCallback((value: string) => {
|
|
201
|
-
// Limit total length to 16 characters
|
|
202
|
-
if (value.length > 16) {
|
|
203
|
-
return
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Validate decimal places (max 8 decimals)
|
|
207
|
-
const decimalMatch = value.match(/^\d*\.?\d{0,8}$/)
|
|
208
|
-
if (!decimalMatch && value !== "") {
|
|
209
|
-
return // Don't update if more than 8 decimals
|
|
210
|
-
}
|
|
211
193
|
setTradeType(TradeType.EXACT_OUTPUT)
|
|
212
194
|
setBuyAmount(value)
|
|
213
195
|
setSellAmount("")
|
|
@@ -362,53 +344,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
362
344
|
}
|
|
363
345
|
}
|
|
364
346
|
|
|
365
|
-
// Dynamic font size based on input length
|
|
366
|
-
const sellInputStyles = useMemo(() => {
|
|
367
|
-
const inputLength = sellAmount.length
|
|
368
|
-
let fontSize: string
|
|
369
|
-
|
|
370
|
-
if (inputLength > 12) {
|
|
371
|
-
fontSize = "1rem"
|
|
372
|
-
} else if (inputLength > 9) {
|
|
373
|
-
fontSize = "1.25rem"
|
|
374
|
-
} else if (inputLength > 6) {
|
|
375
|
-
fontSize = "1.5rem"
|
|
376
|
-
} else if (inputLength > 3) {
|
|
377
|
-
fontSize = "1.75rem"
|
|
378
|
-
} else {
|
|
379
|
-
fontSize = "2rem"
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
return {
|
|
383
|
-
fontSize,
|
|
384
|
-
transition: "all 0.1s ease-in-out",
|
|
385
|
-
}
|
|
386
|
-
}, [sellAmount.length])
|
|
387
|
-
|
|
388
|
-
const buyInputStyles = useMemo(() => {
|
|
389
|
-
const inputValue =
|
|
390
|
-
tradeType === TradeType.EXACT_OUTPUT ? buyAmount : toAmountDisplay || ""
|
|
391
|
-
const inputLength = inputValue.length
|
|
392
|
-
let fontSize: string
|
|
393
|
-
|
|
394
|
-
if (inputLength > 12) {
|
|
395
|
-
fontSize = "1rem"
|
|
396
|
-
} else if (inputLength > 9) {
|
|
397
|
-
fontSize = "1.25rem"
|
|
398
|
-
} else if (inputLength > 6) {
|
|
399
|
-
fontSize = "1.5rem"
|
|
400
|
-
} else if (inputLength > 3) {
|
|
401
|
-
fontSize = "1.75rem"
|
|
402
|
-
} else {
|
|
403
|
-
fontSize = "2rem"
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
return {
|
|
407
|
-
fontSize,
|
|
408
|
-
transition: "all 0.1s ease-in-out",
|
|
409
|
-
}
|
|
410
|
-
}, [tradeType, buyAmount, toAmountDisplay])
|
|
411
|
-
|
|
412
347
|
// Handle source token selection from full-screen selector
|
|
413
348
|
const handleSourceTokenSelectorSelect = useCallback(
|
|
414
349
|
(token: any) => {
|
|
@@ -585,10 +520,10 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
585
520
|
|
|
586
521
|
<form onSubmit={handleSubmit} className="space-y-1">
|
|
587
522
|
{/* Input Section - Amount + Token Selection */}
|
|
588
|
-
<div className="trails-bg-secondary trails-bg-secondary-hover trails-border-radius-container p-3 group transition-all duration-200 border border-transparent focus-within:!bg-white dark:focus-within:!bg-gray-800 trails-focus-border-secondary min-h-[120px] flex flex-col">
|
|
523
|
+
<div className="pt-4 pb-4 trails-bg-secondary trails-bg-secondary-hover trails-border-radius-container p-3 group transition-all duration-200 border border-transparent focus-within:!bg-white dark:focus-within:!bg-gray-800 trails-focus-border-secondary min-h-[120px] flex flex-col">
|
|
589
524
|
{/* Sell Label */}
|
|
590
|
-
<div className="flex justify-between items-center
|
|
591
|
-
<div className="text-sm font-medium trails-text-secondary text-left">
|
|
525
|
+
<div className="mb-4 flex justify-between items-center">
|
|
526
|
+
<div className="text-sm font-medium trails-text-secondary text-left m-0">
|
|
592
527
|
{mode === "fund" ? "Payment method" : "Sell"}
|
|
593
528
|
</div>
|
|
594
529
|
<FundingMethodSelectorButton />
|
|
@@ -598,22 +533,17 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
598
533
|
{/* Amount Input */}
|
|
599
534
|
<div className="flex-1">
|
|
600
535
|
<div className="flex items-center space-x-2">
|
|
601
|
-
<
|
|
536
|
+
<DynamicSizeInputField
|
|
602
537
|
ref={inputRef}
|
|
603
|
-
id="amount"
|
|
604
|
-
type="text"
|
|
605
538
|
value={sellAmount}
|
|
606
539
|
onChange={(e) => handleSellAmountChange(e.target.value)}
|
|
607
|
-
|
|
608
|
-
className={`w-full bg-transparent font-bold trails-text-primary placeholder:trails-text-muted border-none outline-none ${
|
|
540
|
+
isLoading={
|
|
609
541
|
isLoadingQuote && tradeType === TradeType.EXACT_OUTPUT
|
|
610
|
-
|
|
611
|
-
: ""
|
|
612
|
-
}`}
|
|
613
|
-
style={sellInputStyles}
|
|
542
|
+
}
|
|
614
543
|
readOnly={
|
|
615
544
|
tradeType === TradeType.EXACT_OUTPUT && isLoadingQuote
|
|
616
545
|
}
|
|
546
|
+
variant="default"
|
|
617
547
|
/>
|
|
618
548
|
{isLoadingQuote && tradeType === TradeType.EXACT_OUTPUT && (
|
|
619
549
|
<div className="animate-spin rounded-full h-4 w-4 border-solid border-b-2 trails-primary" />
|
|
@@ -632,10 +562,10 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
632
562
|
</div>
|
|
633
563
|
|
|
634
564
|
{/* Bottom Info Row for sell */}
|
|
635
|
-
<div className="mt-
|
|
565
|
+
<div className="mt-4 flex justify-between items-center">
|
|
636
566
|
{/* USD Amount */}
|
|
637
567
|
{originToken?.symbol && (
|
|
638
|
-
<div className="text-xs
|
|
568
|
+
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
639
569
|
≈{" "}
|
|
640
570
|
{tradeType === TradeType.EXACT_INPUT
|
|
641
571
|
? amountUsdDisplay || "$0.00"
|
|
@@ -650,7 +580,7 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
650
580
|
<div className="flex items-center space-x-2">
|
|
651
581
|
<button
|
|
652
582
|
type="button"
|
|
653
|
-
className="text-xs
|
|
583
|
+
className="text-xs text-gray-500 dark:text-gray-400 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 transition-colors bg-transparent border-none p-0"
|
|
654
584
|
onClick={() => {
|
|
655
585
|
if (balanceFormatted) {
|
|
656
586
|
const balance = parseFloat(balanceFormatted)
|
|
@@ -716,10 +646,10 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
716
646
|
</div>
|
|
717
647
|
|
|
718
648
|
{/* Output Section - Amount + Token Selection */}
|
|
719
|
-
<div className="trails-bg-secondary trails-bg-secondary-hover trails-border-radius-container p-3 transition-all duration-200 border border-transparent focus-within:!bg-white dark:focus-within:!bg-gray-800 trails-focus-border-secondary min-h-[120px] flex flex-col">
|
|
649
|
+
<div className="pt-4 pb-4 trails-bg-secondary trails-bg-secondary-hover trails-border-radius-container p-3 transition-all duration-200 border border-transparent focus-within:!bg-white dark:focus-within:!bg-gray-800 trails-focus-border-secondary min-h-[120px] flex flex-col mb-4">
|
|
720
650
|
{/* Buy Label */}
|
|
721
|
-
<div className="flex justify-between items-center mb-2">
|
|
722
|
-
<div className="text-sm font-medium trails-text-secondary text-left">
|
|
651
|
+
<div className="mb-4 flex justify-between items-center mb-2">
|
|
652
|
+
<div className="text-sm font-medium trails-text-secondary text-left m-0">
|
|
723
653
|
{mode === "fund" ? "Recipient" : "Buy"}
|
|
724
654
|
</div>
|
|
725
655
|
{toRecipient ? (
|
|
@@ -738,8 +668,7 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
738
668
|
{/* Output Amount */}
|
|
739
669
|
<div className="flex-1">
|
|
740
670
|
<div className="flex items-center space-x-2">
|
|
741
|
-
<
|
|
742
|
-
type="text"
|
|
671
|
+
<DynamicSizeInputField
|
|
743
672
|
value={
|
|
744
673
|
tradeType === TradeType.EXACT_OUTPUT
|
|
745
674
|
? buyAmount
|
|
@@ -747,17 +676,15 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
747
676
|
}
|
|
748
677
|
onChange={(e) => handleBuyAmountChange(e.target.value)}
|
|
749
678
|
onFocus={handleBuyInputFocus}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
? "text-gray-400 dark:text-gray-500"
|
|
754
|
-
: "trails-text-primary"
|
|
755
|
-
} ${isLoadingQuote && tradeType === TradeType.EXACT_INPUT ? "animate-pulse" : ""}`}
|
|
756
|
-
style={buyInputStyles}
|
|
679
|
+
isLoading={
|
|
680
|
+
isLoadingQuote && tradeType === TradeType.EXACT_INPUT
|
|
681
|
+
}
|
|
757
682
|
readOnly={
|
|
758
683
|
(tradeType === TradeType.EXACT_INPUT && isLoadingQuote) ||
|
|
759
684
|
!!toAmount
|
|
760
685
|
}
|
|
686
|
+
showPlaceholderStyle={!amount}
|
|
687
|
+
variant="default"
|
|
761
688
|
/>
|
|
762
689
|
{isLoadingQuote && tradeType === TradeType.EXACT_INPUT && (
|
|
763
690
|
<div className="animate-spin rounded-full h-4 w-4 border-solid border-b-2 trails-primary" />
|
|
@@ -777,11 +704,11 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
777
704
|
</div>
|
|
778
705
|
|
|
779
706
|
{/* Bottom Info Row */}
|
|
780
|
-
<div className="mt-
|
|
707
|
+
<div className="mt-4 flex justify-between items-center">
|
|
781
708
|
{/* Destination Amount USD from Quote */}
|
|
782
709
|
{(prepareSendQuote?.destinationAmountUsdDisplay ||
|
|
783
710
|
(isLoadingQuote && tradeType === TradeType.EXACT_INPUT)) && (
|
|
784
|
-
<div className="text-xs
|
|
711
|
+
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
785
712
|
≈{" "}
|
|
786
713
|
{isLoadingQuote && tradeType === TradeType.EXACT_INPUT
|
|
787
714
|
? "$0.00"
|
|
@@ -833,15 +760,25 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
833
760
|
|
|
834
761
|
{/* Quote Details */}
|
|
835
762
|
{prepareSendQuote && (
|
|
836
|
-
<div className="
|
|
763
|
+
<div className="mb-4">
|
|
837
764
|
<QuoteDetails
|
|
838
765
|
quote={prepareSendQuote}
|
|
839
766
|
showContent={true}
|
|
840
767
|
swapMode={true}
|
|
768
|
+
isRefetching={isLoadingQuote}
|
|
841
769
|
/>
|
|
842
770
|
</div>
|
|
843
771
|
)}
|
|
844
772
|
|
|
773
|
+
{/* Fee Options */}
|
|
774
|
+
<FeeOptions
|
|
775
|
+
feeOptions={feeOptions || []}
|
|
776
|
+
selectedFeeToken={selectedFeeToken}
|
|
777
|
+
setSelectedFeeToken={(token) => setSelectedFeeToken(token as any)}
|
|
778
|
+
chainId={originToken?.chainId}
|
|
779
|
+
isRefetching={isLoadingQuote}
|
|
780
|
+
/>
|
|
781
|
+
|
|
845
782
|
<button
|
|
846
783
|
type="submit"
|
|
847
784
|
disabled={
|
|
@@ -10,8 +10,6 @@ import {
|
|
|
10
10
|
getSlippageTolerance,
|
|
11
11
|
getDebug,
|
|
12
12
|
} from "../../config.js"
|
|
13
|
-
import { getRelayerUrl } from "../../relayer.js"
|
|
14
|
-
import type { RelayerEnv } from "../../relayer.js"
|
|
15
13
|
import { getChainInfo } from "../../chains.js"
|
|
16
14
|
import { mainnet } from "viem/chains"
|
|
17
15
|
import { logger } from "../../logger.js"
|
|
@@ -48,9 +46,6 @@ export const ConfigDisplay: React.FC<ConfigDisplayProps> = ({
|
|
|
48
46
|
getSlippageTolerance(),
|
|
49
47
|
)
|
|
50
48
|
const [debugMode, setDebugMode] = useState(getDebug())
|
|
51
|
-
const [relayerUrl, setRelayerUrl] = useState(
|
|
52
|
-
getRelayerUrl({ env: getSequenceEnv() as RelayerEnv }, 1),
|
|
53
|
-
)
|
|
54
49
|
const [rpcNodeUrl, setRpcNodeUrl] = useState(() => {
|
|
55
50
|
const mainnetChain = getChainInfo(mainnet.id)
|
|
56
51
|
return mainnetChain?.rpcUrls?.default?.http?.[0] || "N/A"
|
|
@@ -67,7 +62,6 @@ export const ConfigDisplay: React.FC<ConfigDisplayProps> = ({
|
|
|
67
62
|
setWalletConnectProjectId(getWalletConnectProjectId())
|
|
68
63
|
setSlippageTolerance(getSlippageTolerance())
|
|
69
64
|
setDebugMode(getDebug())
|
|
70
|
-
setRelayerUrl(getRelayerUrl({ env: getSequenceEnv() as RelayerEnv }, 1))
|
|
71
65
|
|
|
72
66
|
// Update RPC Node URL for mainnet
|
|
73
67
|
const mainnetChain = getChainInfo(mainnet.id)
|
|
@@ -99,11 +93,6 @@ export const ConfigDisplay: React.FC<ConfigDisplayProps> = ({
|
|
|
99
93
|
value: sequenceIndexerUrl,
|
|
100
94
|
display: truncateString(sequenceIndexerUrl),
|
|
101
95
|
},
|
|
102
|
-
{
|
|
103
|
-
label: "Relayer URL (1)",
|
|
104
|
-
value: relayerUrl,
|
|
105
|
-
display: truncateString(relayerUrl),
|
|
106
|
-
},
|
|
107
96
|
{
|
|
108
97
|
label: "RPC Node URL (1)",
|
|
109
98
|
value: rpcNodeUrl,
|
|
@@ -36,7 +36,7 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = ({
|
|
|
36
36
|
lastClickedWallet,
|
|
37
37
|
showDisconnect = true,
|
|
38
38
|
}) => {
|
|
39
|
-
const {
|
|
39
|
+
const { address, connector } = useAccount()
|
|
40
40
|
const connections = useConnections()
|
|
41
41
|
const { switchAccount } = useSwitchAccount()
|
|
42
42
|
const { setCurrentScreen } = useCurrentScreen()
|
|
@@ -45,6 +45,9 @@ export const ConnectWallet: React.FC<ConnectWalletProps> = ({
|
|
|
45
45
|
const connectors = useConnectors()
|
|
46
46
|
const [error, setError] = useState<string | null>(null)
|
|
47
47
|
|
|
48
|
+
// Check if there are any connected accounts across all connectors
|
|
49
|
+
const isConnected = connections.length > 0
|
|
50
|
+
|
|
48
51
|
useEffect(() => {
|
|
49
52
|
if (error) {
|
|
50
53
|
if (onError) {
|