0xtrails 0.2.6 → 0.4.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.
Files changed (218) hide show
  1. package/dist/aave.d.ts +2 -0
  2. package/dist/aave.d.ts.map +1 -1
  3. package/dist/{ccip-Xjh9d1gb.js → ccip-BpQGQiWq.js} +7 -7
  4. package/dist/config.d.ts +0 -5
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/constants.d.ts +2 -4
  7. package/dist/constants.d.ts.map +1 -1
  8. package/dist/error.d.ts +4 -1
  9. package/dist/error.d.ts.map +1 -1
  10. package/dist/fees.d.ts +2 -2
  11. package/dist/fees.d.ts.map +1 -1
  12. package/dist/{index-BnhdZ8Ho.js → index-DsJM5F-V.js} +46084 -48697
  13. package/dist/index.d.ts +9 -8
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +741 -923
  16. package/dist/intentReceiptMonitor.d.ts +24 -0
  17. package/dist/intentReceiptMonitor.d.ts.map +1 -0
  18. package/dist/intentReceiptPoller.d.ts +69 -0
  19. package/dist/intentReceiptPoller.d.ts.map +1 -0
  20. package/dist/intents.d.ts +15 -11
  21. package/dist/intents.d.ts.map +1 -1
  22. package/dist/morpho.d.ts +6 -5
  23. package/dist/morpho.d.ts.map +1 -1
  24. package/dist/mutations.d.ts +16 -0
  25. package/dist/mutations.d.ts.map +1 -0
  26. package/dist/preconditions.d.ts +5 -4
  27. package/dist/preconditions.d.ts.map +1 -1
  28. package/dist/prepareSend.d.ts +5 -190
  29. package/dist/prepareSend.d.ts.map +1 -1
  30. package/dist/prices.d.ts +9 -6
  31. package/dist/prices.d.ts.map +1 -1
  32. package/dist/sequenceWallet.d.ts +3 -16
  33. package/dist/sequenceWallet.d.ts.map +1 -1
  34. package/dist/tokenBalances.d.ts +17 -13
  35. package/dist/tokenBalances.d.ts.map +1 -1
  36. package/dist/trails.d.ts +24 -40
  37. package/dist/trails.d.ts.map +1 -1
  38. package/dist/trailsClient.d.ts +5 -6
  39. package/dist/trailsClient.d.ts.map +1 -1
  40. package/dist/transactionIntent/constants.d.ts +7 -0
  41. package/dist/transactionIntent/constants.d.ts.map +1 -0
  42. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +44 -0
  43. package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -0
  44. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +30 -0
  45. package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -0
  46. package/dist/transactionIntent/deposits/index.d.ts +4 -0
  47. package/dist/transactionIntent/deposits/index.d.ts.map +1 -0
  48. package/dist/transactionIntent/deposits/standardDeposit.d.ts +30 -0
  49. package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -0
  50. package/dist/transactionIntent/execution/index.d.ts +2 -0
  51. package/dist/transactionIntent/execution/index.d.ts.map +1 -0
  52. package/dist/transactionIntent/execution/transactionState.d.ts +5 -0
  53. package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -0
  54. package/dist/transactionIntent/handlers/crossChain.d.ts +82 -0
  55. package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -0
  56. package/dist/transactionIntent/handlers/index.d.ts +4 -0
  57. package/dist/transactionIntent/handlers/index.d.ts.map +1 -0
  58. package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +62 -0
  59. package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +1 -0
  60. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +72 -0
  61. package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -0
  62. package/dist/transactionIntent/index.d.ts +9 -0
  63. package/dist/transactionIntent/index.d.ts.map +1 -0
  64. package/dist/transactionIntent/quote/feeExtractors.d.ts +17 -0
  65. package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -0
  66. package/dist/transactionIntent/quote/index.d.ts +4 -0
  67. package/dist/transactionIntent/quote/index.d.ts.map +1 -0
  68. package/dist/transactionIntent/quote/normalizeQuote.d.ts +34 -0
  69. package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -0
  70. package/dist/transactionIntent/quote/quoteHelpers.d.ts +5 -0
  71. package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -0
  72. package/dist/transactionIntent/types.d.ts +131 -0
  73. package/dist/transactionIntent/types.d.ts.map +1 -0
  74. package/dist/transactionIntent/utils/balanceChecker.d.ts +18 -0
  75. package/dist/transactionIntent/utils/balanceChecker.d.ts.map +1 -0
  76. package/dist/transactionIntent/utils/index.d.ts +4 -0
  77. package/dist/transactionIntent/utils/index.d.ts.map +1 -0
  78. package/dist/transactionIntent/utils/lifiHelpers.d.ts +10 -0
  79. package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +1 -0
  80. package/dist/transactionIntent/utils/testnetHelpers.d.ts +3 -0
  81. package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -0
  82. package/dist/transactionIntent/validators.d.ts +6 -0
  83. package/dist/transactionIntent/validators.d.ts.map +1 -0
  84. package/dist/transactions.d.ts +2 -1
  85. package/dist/transactions.d.ts.map +1 -1
  86. package/dist/widget/components/AccountSettings.d.ts.map +1 -1
  87. package/dist/widget/components/ClassicSwap.d.ts +0 -1
  88. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  89. package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
  90. package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
  91. package/dist/widget/components/DynamicSizeInputField.d.ts +13 -0
  92. package/dist/widget/components/DynamicSizeInputField.d.ts.map +1 -0
  93. package/dist/widget/components/Earn.d.ts +0 -1
  94. package/dist/widget/components/Earn.d.ts.map +1 -1
  95. package/dist/widget/components/FeeOptions.d.ts +5 -13
  96. package/dist/widget/components/FeeOptions.d.ts.map +1 -1
  97. package/dist/widget/components/Fund.d.ts +0 -1
  98. package/dist/widget/components/Fund.d.ts.map +1 -1
  99. package/dist/widget/components/FundMethods.d.ts.map +1 -1
  100. package/dist/widget/components/FundSwap.d.ts +0 -1
  101. package/dist/widget/components/FundSwap.d.ts.map +1 -1
  102. package/dist/widget/components/Pay.d.ts +0 -1
  103. package/dist/widget/components/Pay.d.ts.map +1 -1
  104. package/dist/widget/components/PoolDeposit.d.ts +0 -1
  105. package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
  106. package/dist/widget/components/PoolWithdraw.d.ts +0 -18
  107. package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
  108. package/dist/widget/components/QuoteDetails.d.ts +1 -0
  109. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  110. package/dist/widget/components/Swap.d.ts +0 -1
  111. package/dist/widget/components/Swap.d.ts.map +1 -1
  112. package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
  113. package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
  114. package/dist/widget/css/compiled.css +2 -2
  115. package/dist/widget/hooks/useCheckout.d.ts +17 -4
  116. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  117. package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
  118. package/dist/widget/hooks/useQuote.d.ts +3 -4
  119. package/dist/widget/hooks/useQuote.d.ts.map +1 -1
  120. package/dist/widget/hooks/useSelectedFeeToken.d.ts +1 -0
  121. package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
  122. package/dist/widget/hooks/useSendForm.d.ts +3 -4
  123. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  124. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  125. package/dist/widget/hooks/useWalletConnectionContext.d.ts +25 -0
  126. package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +1 -0
  127. package/dist/widget/index.js +1 -1
  128. package/dist/widget/widget.d.ts +12 -7
  129. package/dist/widget/widget.d.ts.map +1 -1
  130. package/package.json +21 -23
  131. package/src/aave.ts +54 -1
  132. package/src/config.ts +57 -58
  133. package/src/constants.ts +8 -9
  134. package/src/error.ts +21 -3
  135. package/src/fees.ts +53 -42
  136. package/src/index.ts +35 -13
  137. package/src/intentReceiptMonitor.ts +102 -0
  138. package/src/intentReceiptPoller.ts +299 -0
  139. package/src/intents.ts +206 -172
  140. package/src/morpho.ts +58 -9
  141. package/src/mutations.ts +129 -0
  142. package/src/preconditions.ts +16 -21
  143. package/src/prepareSend.ts +80 -4514
  144. package/src/prices.ts +26 -22
  145. package/src/relaySdk.ts +2 -2
  146. package/src/sequenceWallet.ts +6 -73
  147. package/src/tokenBalances.ts +175 -69
  148. package/src/trails.ts +230 -722
  149. package/src/trailsClient.ts +10 -23
  150. package/src/transactionIntent/constants.ts +11 -0
  151. package/src/transactionIntent/deposits/depositOrchestrator.ts +210 -0
  152. package/src/transactionIntent/deposits/gaslessDeposit.ts +588 -0
  153. package/src/transactionIntent/deposits/index.ts +3 -0
  154. package/src/transactionIntent/deposits/standardDeposit.ts +379 -0
  155. package/src/transactionIntent/execution/index.ts +1 -0
  156. package/src/transactionIntent/execution/transactionState.ts +35 -0
  157. package/src/transactionIntent/handlers/crossChain.ts +1707 -0
  158. package/src/transactionIntent/handlers/index.ts +3 -0
  159. package/src/transactionIntent/handlers/sameChainDifferentToken.ts +323 -0
  160. package/src/transactionIntent/handlers/sameChainSameToken.ts +712 -0
  161. package/src/transactionIntent/index.ts +9 -0
  162. package/src/transactionIntent/quote/feeExtractors.ts +81 -0
  163. package/src/transactionIntent/quote/index.ts +3 -0
  164. package/src/transactionIntent/quote/normalizeQuote.ts +367 -0
  165. package/src/transactionIntent/quote/quoteHelpers.ts +53 -0
  166. package/src/transactionIntent/types.ts +157 -0
  167. package/src/transactionIntent/utils/balanceChecker.ts +96 -0
  168. package/src/transactionIntent/utils/index.ts +3 -0
  169. package/src/transactionIntent/utils/lifiHelpers.ts +68 -0
  170. package/src/transactionIntent/utils/testnetHelpers.ts +10 -0
  171. package/src/transactionIntent/validators.ts +57 -0
  172. package/src/transactions.ts +36 -53
  173. package/src/widget/compiled.css +2 -2
  174. package/src/widget/components/AccountIntentTransactionHistory.tsx +36 -36
  175. package/src/widget/components/AccountSettings.tsx +23 -6
  176. package/src/widget/components/ClassicSwap.tsx +28 -53
  177. package/src/widget/components/ConfigDisplay.tsx +0 -11
  178. package/src/widget/components/ConnectedWallets.tsx +30 -4
  179. package/src/widget/components/DynamicSizeInputField.tsx +109 -0
  180. package/src/widget/components/Earn.tsx +0 -16
  181. package/src/widget/components/FeeBreakdown.tsx +3 -3
  182. package/src/widget/components/FeeOption.tsx +2 -2
  183. package/src/widget/components/FeeOptions.tsx +151 -112
  184. package/src/widget/components/Fund.tsx +0 -3
  185. package/src/widget/components/FundMethods.tsx +4 -3
  186. package/src/widget/components/FundSwap.tsx +0 -1
  187. package/src/widget/components/Pay.tsx +11 -16
  188. package/src/widget/components/PoolDeposit.tsx +35 -32
  189. package/src/widget/components/PoolWithdraw.tsx +153 -256
  190. package/src/widget/components/QuoteDetails.tsx +899 -494
  191. package/src/widget/components/Swap.tsx +0 -1
  192. package/src/widget/components/TransferPendingVertical.tsx +12 -8
  193. package/src/widget/components/WaasFeeOptions.tsx +23 -7
  194. package/src/widget/components/WalletConfirmation.tsx +1 -1
  195. package/src/widget/hooks/useAmountUsd.ts +9 -9
  196. package/src/widget/hooks/useCheckout.ts +97 -9
  197. package/src/widget/hooks/useDefaultTokenSelection.tsx +27 -21
  198. package/src/widget/hooks/useQuote.ts +86 -33
  199. package/src/widget/hooks/useSelectedFeeToken.tsx +32 -37
  200. package/src/widget/hooks/useSendForm.ts +37 -47
  201. package/src/widget/hooks/useTokenList.ts +34 -26
  202. package/src/widget/hooks/useWalletConnectionContext.tsx +128 -0
  203. package/src/widget/widget.tsx +197 -207
  204. package/dist/apiClient.d.ts +0 -9
  205. package/dist/apiClient.d.ts.map +0 -1
  206. package/dist/intentEntrypoint.d.ts +0 -114
  207. package/dist/intentEntrypoint.d.ts.map +0 -1
  208. package/dist/metaTxnMonitor.d.ts +0 -15
  209. package/dist/metaTxnMonitor.d.ts.map +0 -1
  210. package/dist/metaTxns.d.ts +0 -11
  211. package/dist/metaTxns.d.ts.map +0 -1
  212. package/dist/relayer.d.ts +0 -43
  213. package/dist/relayer.d.ts.map +0 -1
  214. package/src/apiClient.ts +0 -35
  215. package/src/intentEntrypoint.ts +0 -203
  216. package/src/metaTxnMonitor.ts +0 -171
  217. package/src/metaTxns.ts +0 -45
  218. 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,17 +27,33 @@ 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
- <ScreenHeader
36
- headerContent="Settings"
37
- headerContentAlign="left"
38
- onBack={onBack}
39
- />
40
+ <div className="flex items-center justify-between h-full">
41
+ <ScreenHeader
42
+ headerContent="Settings"
43
+ headerContentAlign="left"
44
+ onBack={onBack}
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>
56
+ </div>
40
57
 
41
58
  <div className="flex-1">
42
59
  <div className="space-y-4">
@@ -28,7 +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 { useDynamicInputStyles } from "./DynamicInputStyles.js"
31
+ import { DynamicSizeInputField } from "./DynamicSizeInputField.js"
32
+ import { FeeOptions } from "./FeeOptions.js"
32
33
 
33
34
  interface ClassicSwapProps {
34
35
  selectedToken: Token | null
@@ -47,7 +48,6 @@ interface ClassicSwapProps {
47
48
  onError: (error: Error | string | null) => void
48
49
  onWaitingForWalletConfirm: (props: PrepareSendQuote) => void
49
50
  paymasterUrls?: Array<{ chainId: number; url: string }>
50
- gasless?: boolean
51
51
  setWalletConfirmRetryHandler: (handler: () => Promise<void>) => void
52
52
  quoteProvider?: string
53
53
  fundMethod?: string
@@ -86,7 +86,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
86
86
  onError,
87
87
  onWaitingForWalletConfirm,
88
88
  paymasterUrls,
89
- gasless,
90
89
  setWalletConfirmRetryHandler,
91
90
  quoteProvider,
92
91
  fundMethod,
@@ -144,6 +143,9 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
144
143
  quoteError,
145
144
  quoteErrorPrettified,
146
145
  isSameTokenWithoutCustomCalldata,
146
+ feeOptions,
147
+ selectedFeeToken,
148
+ setSelectedFeeToken,
147
149
  } = useSendForm({
148
150
  account,
149
151
  toAmount: tradeType === TradeType.EXACT_OUTPUT ? buyAmount : toAmount,
@@ -156,10 +158,9 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
156
158
  onError,
157
159
  onWaitingForWalletConfirm,
158
160
  paymasterUrls,
159
- gasless,
161
+ onSend,
160
162
  onConfirm,
161
163
  onComplete,
162
- onSend,
163
164
  selectedToken: originToken as any,
164
165
  setWalletConfirmRetryHandler,
165
166
  tradeType: tradeType,
@@ -179,36 +180,16 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
179
180
  }
180
181
  }, [sellAmount, buyAmount, lastInputType, setAmount])
181
182
 
182
- // Handle sell amount input changes with decimal validation
183
+ // Handle sell amount input changes
183
184
  const handleSellAmountChange = useCallback((value: string) => {
184
- // Limit total length to 16 characters
185
- if (value.length > 16) {
186
- return
187
- }
188
-
189
- // Validate decimal places (max 8 decimals)
190
- const decimalMatch = value.match(/^\d*\.?\d{0,8}$/)
191
- if (!decimalMatch && value !== "") {
192
- return // Don't update if more than 8 decimals
193
- }
194
185
  setTradeType(TradeType.EXACT_INPUT)
195
186
  setSellAmount(value)
196
187
  setBuyAmount("")
197
188
  setLastInputType("sell")
198
189
  }, [])
199
190
 
200
- // Handle buy amount input changes with decimal validation
191
+ // Handle buy amount input changes
201
192
  const handleBuyAmountChange = useCallback((value: string) => {
202
- // Limit total length to 16 characters
203
- if (value.length > 16) {
204
- return
205
- }
206
-
207
- // Validate decimal places (max 8 decimals)
208
- const decimalMatch = value.match(/^\d*\.?\d{0,8}$/)
209
- if (!decimalMatch && value !== "") {
210
- return // Don't update if more than 8 decimals
211
- }
212
193
  setTradeType(TradeType.EXACT_OUTPUT)
213
194
  setBuyAmount(value)
214
195
  setSellAmount("")
@@ -363,14 +344,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
363
344
  }
364
345
  }
365
346
 
366
- // Dynamic font size based on input length
367
- const sellInputStyles = useDynamicInputStyles({ inputValue: sellAmount })
368
-
369
- const buyInputStyles = useDynamicInputStyles({
370
- inputValue:
371
- tradeType === TradeType.EXACT_OUTPUT ? buyAmount : toAmountDisplay || "",
372
- })
373
-
374
347
  // Handle source token selection from full-screen selector
375
348
  const handleSourceTokenSelectorSelect = useCallback(
376
349
  (token: any) => {
@@ -560,22 +533,17 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
560
533
  {/* Amount Input */}
561
534
  <div className="flex-1">
562
535
  <div className="flex items-center space-x-2">
563
- <input
536
+ <DynamicSizeInputField
564
537
  ref={inputRef}
565
- id="amount"
566
- type="text"
567
538
  value={sellAmount}
568
539
  onChange={(e) => handleSellAmountChange(e.target.value)}
569
- placeholder={"0"}
570
- className={`w-full bg-transparent font-bold trails-text-primary placeholder:trails-text-muted border-none outline-none ${
540
+ isLoading={
571
541
  isLoadingQuote && tradeType === TradeType.EXACT_OUTPUT
572
- ? "animate-pulse"
573
- : ""
574
- }`}
575
- style={sellInputStyles}
542
+ }
576
543
  readOnly={
577
544
  tradeType === TradeType.EXACT_OUTPUT && isLoadingQuote
578
545
  }
546
+ variant="default"
579
547
  />
580
548
  {isLoadingQuote && tradeType === TradeType.EXACT_OUTPUT && (
581
549
  <div className="animate-spin rounded-full h-4 w-4 border-solid border-b-2 trails-primary" />
@@ -700,8 +668,7 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
700
668
  {/* Output Amount */}
701
669
  <div className="flex-1">
702
670
  <div className="flex items-center space-x-2">
703
- <input
704
- type="text"
671
+ <DynamicSizeInputField
705
672
  value={
706
673
  tradeType === TradeType.EXACT_OUTPUT
707
674
  ? buyAmount
@@ -709,17 +676,15 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
709
676
  }
710
677
  onChange={(e) => handleBuyAmountChange(e.target.value)}
711
678
  onFocus={handleBuyInputFocus}
712
- placeholder={"0"}
713
- className={`w-full bg-transparent font-bold placeholder:trails-text-muted border-none outline-none ${
714
- !amount
715
- ? "text-gray-400 dark:text-gray-500"
716
- : "trails-text-primary"
717
- } ${isLoadingQuote && tradeType === TradeType.EXACT_INPUT ? "animate-pulse" : ""}`}
718
- style={buyInputStyles}
679
+ isLoading={
680
+ isLoadingQuote && tradeType === TradeType.EXACT_INPUT
681
+ }
719
682
  readOnly={
720
683
  (tradeType === TradeType.EXACT_INPUT && isLoadingQuote) ||
721
684
  !!toAmount
722
685
  }
686
+ showPlaceholderStyle={!amount}
687
+ variant="default"
723
688
  />
724
689
  {isLoadingQuote && tradeType === TradeType.EXACT_INPUT && (
725
690
  <div className="animate-spin rounded-full h-4 w-4 border-solid border-b-2 trails-primary" />
@@ -800,10 +765,20 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
800
765
  quote={prepareSendQuote}
801
766
  showContent={true}
802
767
  swapMode={true}
768
+ isRefetching={isLoadingQuote}
803
769
  />
804
770
  </div>
805
771
  )}
806
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
+
807
782
  <button
808
783
  type="submit"
809
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,
@@ -14,6 +14,7 @@ import { useAccountTotalBalanceUsd } from "../../tokenBalances.js"
14
14
  import { Identicon } from "./Identicon.js"
15
15
  import { useBack } from "../hooks/useBack.js"
16
16
  import type { Screen } from "../hooks/useCurrentScreen.js"
17
+ import { useWalletConnectionContext } from "../hooks/useWalletConnectionContext.js"
17
18
 
18
19
  export interface ConnectedWalletsProps {
19
20
  onWalletSwitch?: (address: string) => void
@@ -39,6 +40,7 @@ interface WalletItemProps {
39
40
  onCopyAddress: (address: string, e: React.MouseEvent) => void
40
41
  copiedAddress: string | null
41
42
  showDisconnect?: boolean
43
+ hideActiveState?: boolean
42
44
  }
43
45
 
44
46
  const WalletItem: React.FC<WalletItemProps> = ({
@@ -49,10 +51,14 @@ const WalletItem: React.FC<WalletItemProps> = ({
49
51
  onCopyAddress,
50
52
  copiedAddress,
51
53
  showDisconnect = false,
54
+ hideActiveState = false,
52
55
  }) => {
53
56
  const { totalBalanceUsdFormatted, isLoadingTotalBalanceUsd } =
54
57
  useAccountTotalBalanceUsd(wallet.address)
55
58
 
59
+ // Determine if this wallet should show active state
60
+ const showAsActive = wallet.isActive && !hideActiveState
61
+
56
62
  return (
57
63
  <div className="space-y-1">
58
64
  {/* Wallet Button */}
@@ -75,9 +81,9 @@ const WalletItem: React.FC<WalletItemProps> = ({
75
81
  }
76
82
  }
77
83
  }}
78
- tabIndex={wallet.isActive ? -1 : 0}
84
+ tabIndex={showAsActive ? -1 : 0}
79
85
  className={`group w-full flex items-center justify-between font-medium py-2 px-3 transition-all duration-200 ${
80
- wallet.isActive
86
+ showAsActive
81
87
  ? "bg-blue-50 dark:bg-blue-900/20 text-gray-700 dark:text-gray-300 cursor-pointer"
82
88
  : "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"
83
89
  }`}
@@ -151,11 +157,11 @@ const WalletItem: React.FC<WalletItemProps> = ({
151
157
  </div>
152
158
 
153
159
  <div className="flex items-center gap-2">
154
- {wallet.isActive ? (
160
+ {showAsActive ? (
155
161
  <span className="text-xs px-2 py-1 rounded font-medium bg-blue-500 text-white">
156
162
  Active
157
163
  </span>
158
- ) : !onWalletSelect ? (
164
+ ) : !onWalletSelect && !hideActiveState ? (
159
165
  <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">
160
166
  Set as active
161
167
  </span>
@@ -198,6 +204,7 @@ export const ConnectedWallets: React.FC<ConnectedWalletsProps> = ({
198
204
  const { disconnect } = useDisconnect()
199
205
  const { wallets: allWallets } = useWallets()
200
206
  const { setCurrentScreenWithBack } = useBack()
207
+ const { setConnectionContext } = useWalletConnectionContext()
201
208
  const [error, setError] = useState<string | null>(null)
202
209
  const [copiedAddress, setCopiedAddress] = useState<string | null>(null)
203
210
 
@@ -355,6 +362,7 @@ export const ConnectedWallets: React.FC<ConnectedWalletsProps> = ({
355
362
  onCopyAddress={handleCopyAddress}
356
363
  copiedAddress={copiedAddress}
357
364
  showDisconnect={showDisconnect}
365
+ hideActiveState={backScreen === "recipients"}
358
366
  />
359
367
  {/* Add divider between wallet items */}
360
368
  {index < connectedWallets.length - 1 && (
@@ -377,6 +385,24 @@ export const ConnectedWallets: React.FC<ConnectedWalletsProps> = ({
377
385
  logger.console.log(
378
386
  "[trails-sdk] Navigating from connected-wallets to wallet-list",
379
387
  )
388
+
389
+ // Set wallet connection context based on the origin screen
390
+ if (backScreen === "recipients") {
391
+ logger.console.log(
392
+ "[trails-sdk] Setting wallet connection context for recipient selection",
393
+ )
394
+ // Store the current active wallet info so we can switch back later
395
+ setConnectionContext(
396
+ "recipient-selection",
397
+ backScreen as Screen,
398
+ address,
399
+ connector,
400
+ )
401
+ } else {
402
+ // Default behavior for other screens
403
+ setConnectionContext("general", backScreen as Screen)
404
+ }
405
+
380
406
  setCurrentScreenWithBack("wallet-list", backScreen as Screen)
381
407
  }}
382
408
  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"
@@ -0,0 +1,109 @@
1
+ import { forwardRef, useCallback } from "react"
2
+ import type React from "react"
3
+ import { useDynamicInputStyles } from "./DynamicInputStyles.js"
4
+
5
+ interface DynamicSizeInputFieldProps
6
+ extends Omit<
7
+ React.InputHTMLAttributes<HTMLInputElement>,
8
+ "onChange" | "value" | "type" | "style"
9
+ > {
10
+ value: string
11
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
12
+ isLoading?: boolean
13
+ variant?: "default" | "smaller" | "inline"
14
+ maxDecimals?: number
15
+ maxDigits?: number
16
+ showPlaceholderStyle?: boolean
17
+ }
18
+
19
+ export const DynamicSizeInputField = forwardRef<
20
+ HTMLInputElement,
21
+ DynamicSizeInputFieldProps
22
+ >(
23
+ (
24
+ {
25
+ id = "amount",
26
+ value,
27
+ onChange,
28
+ placeholder = "0",
29
+ isLoading = false,
30
+ className,
31
+ variant = "default",
32
+ maxDecimals = 8,
33
+ maxDigits = 16,
34
+ showPlaceholderStyle = false,
35
+ onFocus,
36
+ onBlur,
37
+ ...restProps
38
+ },
39
+ ref,
40
+ ) => {
41
+ // Dynamic font size based on input length
42
+ const inputStyles = useDynamicInputStyles({
43
+ inputValue: value,
44
+ variant: variant,
45
+ })
46
+
47
+ // Handle input change with validation
48
+ const handleChange = useCallback(
49
+ (e: React.ChangeEvent<HTMLInputElement>) => {
50
+ if (!onChange) return
51
+
52
+ const newValue = e.target.value
53
+
54
+ // Allow empty string
55
+ if (newValue === "") {
56
+ onChange(e)
57
+ return
58
+ }
59
+
60
+ // Limit total length to maxDigits characters
61
+ if (newValue.length > maxDigits) {
62
+ return
63
+ }
64
+
65
+ // Validate decimal places (max maxDecimals decimals) and allow single decimal point
66
+ const decimalRegex = new RegExp(`^\\d*\\.?\\d{0,${maxDecimals}}$`)
67
+ if (!decimalRegex.test(newValue)) {
68
+ return // Don't update if invalid format
69
+ }
70
+
71
+ // If validation passes, call the parent's onChange
72
+ onChange(e)
73
+ },
74
+ [onChange, maxDecimals, maxDigits],
75
+ )
76
+
77
+ // Determine text color based on showPlaceholderStyle
78
+ const textColorClass = showPlaceholderStyle
79
+ ? "text-gray-400 dark:text-gray-500"
80
+ : "trails-text-primary"
81
+
82
+ return (
83
+ <input
84
+ ref={ref}
85
+ id={id}
86
+ type="text"
87
+ value={value}
88
+ onChange={handleChange}
89
+ onFocus={onFocus}
90
+ onBlur={onBlur}
91
+ placeholder={placeholder}
92
+ autoComplete="off"
93
+ className={
94
+ className ||
95
+ `w-full bg-transparent font-bold ${textColorClass} placeholder:trails-text-muted border-none outline-none ${
96
+ isLoading ? "animate-pulse" : ""
97
+ }`
98
+ }
99
+ style={inputStyles}
100
+ inputMode="decimal"
101
+ {...restProps}
102
+ />
103
+ )
104
+ },
105
+ )
106
+
107
+ DynamicSizeInputField.displayName = "DynamicSizeInputField"
108
+
109
+ export default DynamicSizeInputField
@@ -23,7 +23,6 @@ interface EarnProps {
23
23
  onComplete: (result: OnCompleteProps) => void
24
24
  onSend: (amount: string, recipient: string) => void
25
25
  paymasterUrls?: Array<{ chainId: number; url: string }>
26
- gasless?: boolean
27
26
  setWalletConfirmRetryHandler: (handler: () => Promise<void>) => void
28
27
  quoteProvider?: string
29
28
  fundMethod?: string
@@ -53,7 +52,6 @@ export const Earn: React.FC<EarnProps> = ({
53
52
  onComplete,
54
53
  onSend,
55
54
  paymasterUrls,
56
- gasless,
57
55
  setWalletConfirmRetryHandler,
58
56
  quoteProvider,
59
57
  fundMethod,
@@ -117,7 +115,6 @@ export const Earn: React.FC<EarnProps> = ({
117
115
  onComplete={onComplete}
118
116
  onSend={onSend}
119
117
  paymasterUrls={paymasterUrls}
120
- gasless={gasless}
121
118
  setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
122
119
  quoteProvider={quoteProvider}
123
120
  fundMethod={fundMethod}
@@ -134,20 +131,7 @@ export const Earn: React.FC<EarnProps> = ({
134
131
  walletClient={walletClient}
135
132
  onTransactionStateChange={onTransactionStateChange}
136
133
  onError={onError}
137
- onWaitingForWalletConfirm={onWaitingForWalletConfirm}
138
- onConfirm={onConfirm}
139
134
  onComplete={onComplete}
140
- onSend={onSend}
141
- paymasterUrls={paymasterUrls}
142
- gasless={gasless}
143
- setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
144
- quoteProvider={quoteProvider}
145
- fundMethod={fundMethod}
146
- onNavigateToMeshConnect={onNavigateToMeshConnect}
147
- checkoutOnHandlers={checkoutOnHandlers}
148
- recentTokens={recentTokens}
149
- onRecentTokenSelect={onRecentTokenSelect}
150
- onTrackToken={onTrackToken}
151
135
  onPoolSelectorStateChange={setIsShowingPoolSelector}
152
136
  />
153
137
  )}
@@ -38,7 +38,7 @@ const FeeRow: React.FC<FeeRowProps> = ({ label, feeItem, tooltip }) => (
38
38
  {feeItem.amount} {feeItem.tokenSymbol}
39
39
  </div>
40
40
  <div className="text-xs text-gray-500 dark:text-gray-400">
41
- ~{feeItem.usdValue}
41
+ {feeItem.usdValue}
42
42
  </div>
43
43
  </div>
44
44
  </div>
@@ -120,9 +120,9 @@ export const FeeBreakdown: React.FC<FeeBreakdownProps> = ({
120
120
  )}
121
121
  {feeBreakdown.providerFee && (
122
122
  <FeeRow
123
- label="Provider Fee"
123
+ label="Liquidity Provider Fee"
124
124
  feeItem={feeBreakdown.providerFee}
125
- tooltip="Fee charged by the bridge/swap provider for executing the transaction"
125
+ tooltip="Fee charged by the bridge/swap liquidity provider for executing the transaction"
126
126
  />
127
127
  )}
128
128
  {feeBreakdown.trailsFee && (
@@ -47,7 +47,7 @@ export const FeeOption: React.FC<FeeOptionProps> = ({
47
47
  chainId={option.chainId || chainId}
48
48
  size={16}
49
49
  />
50
- <div className="text-left">
50
+ <div className="ml-2 text-left">
51
51
  <div
52
52
  className={`text-xs font-medium ${
53
53
  option.notEnoughBalance
@@ -68,7 +68,7 @@ export const FeeOption: React.FC<FeeOptionProps> = ({
68
68
  : "trails-text-primary"
69
69
  }`}
70
70
  >
71
- {option.amountUsdDisplay}
71
+ {option.amountUsdDisplay}
72
72
  </div>
73
73
  </div>
74
74
  </button>