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.
Files changed (267) hide show
  1. package/dist/aave.d.ts +2 -0
  2. package/dist/aave.d.ts.map +1 -1
  3. package/dist/abortController.d.ts +8 -0
  4. package/dist/abortController.d.ts.map +1 -0
  5. package/dist/{ccip-CXlshvBY.js → ccip-BMB3uDZt.js} +1 -1
  6. package/dist/config.d.ts +0 -5
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/constants.d.ts +4 -4
  9. package/dist/constants.d.ts.map +1 -1
  10. package/dist/error.d.ts +4 -1
  11. package/dist/error.d.ts.map +1 -1
  12. package/dist/fees.d.ts +19 -0
  13. package/dist/fees.d.ts.map +1 -0
  14. package/dist/{index-_QuyGrjU.js → index-QXPUrZVv.js} +48719 -50852
  15. package/dist/index.d.ts +9 -8
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +811 -784
  18. package/dist/intentReceiptMonitor.d.ts +24 -0
  19. package/dist/intentReceiptMonitor.d.ts.map +1 -0
  20. package/dist/intentReceiptPoller.d.ts +69 -0
  21. package/dist/intentReceiptPoller.d.ts.map +1 -0
  22. package/dist/intents.d.ts +15 -11
  23. package/dist/intents.d.ts.map +1 -1
  24. package/dist/morpho.d.ts +6 -5
  25. package/dist/morpho.d.ts.map +1 -1
  26. package/dist/mutations.d.ts +16 -0
  27. package/dist/mutations.d.ts.map +1 -0
  28. package/dist/preconditions.d.ts +5 -4
  29. package/dist/preconditions.d.ts.map +1 -1
  30. package/dist/prepareSend.d.ts +7 -258
  31. package/dist/prepareSend.d.ts.map +1 -1
  32. package/dist/prices.d.ts +9 -6
  33. package/dist/prices.d.ts.map +1 -1
  34. package/dist/sequenceWallet.d.ts +3 -16
  35. package/dist/sequenceWallet.d.ts.map +1 -1
  36. package/dist/tokenBalances.d.ts +17 -13
  37. package/dist/tokenBalances.d.ts.map +1 -1
  38. package/dist/trails.d.ts +24 -40
  39. package/dist/trails.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 +6 -3
  85. package/dist/transactions.d.ts.map +1 -1
  86. package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts +4 -0
  87. package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts.map +1 -0
  88. package/dist/widget/components/AccountSettings.d.ts.map +1 -1
  89. package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
  90. package/dist/widget/components/ClassicSwap.d.ts +2 -3
  91. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  92. package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
  93. package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
  94. package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
  95. package/dist/widget/components/DynamicInputStyles.d.ts +18 -0
  96. package/dist/widget/components/DynamicInputStyles.d.ts.map +1 -0
  97. package/dist/widget/components/DynamicSizeInputField.d.ts +13 -0
  98. package/dist/widget/components/DynamicSizeInputField.d.ts.map +1 -0
  99. package/dist/widget/components/Earn.d.ts +2 -3
  100. package/dist/widget/components/Earn.d.ts.map +1 -1
  101. package/dist/widget/components/ErrorAnimationIcon.d.ts +2 -0
  102. package/dist/widget/components/ErrorAnimationIcon.d.ts.map +1 -0
  103. package/dist/widget/components/FeeBreakdown.d.ts +9 -0
  104. package/dist/widget/components/FeeBreakdown.d.ts.map +1 -0
  105. package/dist/widget/components/FeeOptions.d.ts +5 -13
  106. package/dist/widget/components/FeeOptions.d.ts.map +1 -1
  107. package/dist/widget/components/Fund.d.ts +2 -3
  108. package/dist/widget/components/Fund.d.ts.map +1 -1
  109. package/dist/widget/components/FundMethods.d.ts.map +1 -1
  110. package/dist/widget/components/FundSwap.d.ts +2 -3
  111. package/dist/widget/components/FundSwap.d.ts.map +1 -1
  112. package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
  113. package/dist/widget/components/Identicon.d.ts.map +1 -1
  114. package/dist/widget/components/MeshConnectExchanges.d.ts +0 -3
  115. package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
  116. package/dist/widget/components/Modal.d.ts.map +1 -1
  117. package/dist/widget/components/Pay.d.ts +2 -3
  118. package/dist/widget/components/Pay.d.ts.map +1 -1
  119. package/dist/widget/components/PoolDeposit.d.ts +3 -3
  120. package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
  121. package/dist/widget/components/PoolWithdraw.d.ts +3 -20
  122. package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
  123. package/dist/widget/components/QuoteDetails.d.ts +2 -0
  124. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  125. package/dist/widget/components/Receipt.d.ts.map +1 -1
  126. package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
  127. package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
  128. package/dist/widget/components/Swap.d.ts +2 -3
  129. package/dist/widget/components/Swap.d.ts.map +1 -1
  130. package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
  131. package/dist/widget/components/TokenDisplayNonSelectable.d.ts +11 -0
  132. package/dist/widget/components/TokenDisplayNonSelectable.d.ts.map +1 -0
  133. package/dist/widget/components/TokenSelector.d.ts.map +1 -1
  134. package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -1
  135. package/dist/widget/components/Tooltip.d.ts +9 -0
  136. package/dist/widget/components/Tooltip.d.ts.map +1 -0
  137. package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
  138. package/dist/widget/components/WaasFeeOptions.d.ts +1 -0
  139. package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
  140. package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
  141. package/dist/widget/components/WalletConnect.d.ts.map +1 -1
  142. package/dist/widget/css/compiled.css +2 -2
  143. package/dist/widget/hooks/useCheckout.d.ts +17 -4
  144. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  145. package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
  146. package/dist/widget/hooks/useQuote.d.ts +82 -0
  147. package/dist/widget/hooks/useQuote.d.ts.map +1 -0
  148. package/dist/widget/hooks/useSelectedFeeToken.d.ts +1 -0
  149. package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
  150. package/dist/widget/hooks/useSendForm.d.ts +5 -6
  151. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  152. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  153. package/dist/widget/hooks/useWalletConnectionContext.d.ts +25 -0
  154. package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +1 -0
  155. package/dist/widget/index.js +2 -2
  156. package/dist/widget/widget.d.ts +17 -7
  157. package/dist/widget/widget.d.ts.map +1 -1
  158. package/package.json +19 -21
  159. package/src/aave.ts +54 -1
  160. package/src/abortController.ts +35 -0
  161. package/src/config.ts +57 -58
  162. package/src/constants.ts +11 -9
  163. package/src/error.ts +21 -3
  164. package/src/fees.ts +210 -0
  165. package/src/index.ts +35 -13
  166. package/src/intentReceiptMonitor.ts +102 -0
  167. package/src/intentReceiptPoller.ts +299 -0
  168. package/src/intents.ts +205 -171
  169. package/src/morpho.ts +58 -9
  170. package/src/mutations.ts +129 -0
  171. package/src/preconditions.ts +16 -21
  172. package/src/prepareSend.ts +92 -4699
  173. package/src/prices.ts +26 -22
  174. package/src/relaySdk.ts +2 -2
  175. package/src/sequenceWallet.ts +6 -73
  176. package/src/tokenBalances.ts +175 -69
  177. package/src/trails.ts +230 -722
  178. package/src/transactionIntent/constants.ts +11 -0
  179. package/src/transactionIntent/deposits/depositOrchestrator.ts +210 -0
  180. package/src/transactionIntent/deposits/gaslessDeposit.ts +588 -0
  181. package/src/transactionIntent/deposits/index.ts +3 -0
  182. package/src/transactionIntent/deposits/standardDeposit.ts +379 -0
  183. package/src/transactionIntent/execution/index.ts +1 -0
  184. package/src/transactionIntent/execution/transactionState.ts +35 -0
  185. package/src/transactionIntent/handlers/crossChain.ts +1707 -0
  186. package/src/transactionIntent/handlers/index.ts +3 -0
  187. package/src/transactionIntent/handlers/sameChainDifferentToken.ts +323 -0
  188. package/src/transactionIntent/handlers/sameChainSameToken.ts +712 -0
  189. package/src/transactionIntent/index.ts +9 -0
  190. package/src/transactionIntent/quote/feeExtractors.ts +81 -0
  191. package/src/transactionIntent/quote/index.ts +3 -0
  192. package/src/transactionIntent/quote/normalizeQuote.ts +367 -0
  193. package/src/transactionIntent/quote/quoteHelpers.ts +53 -0
  194. package/src/transactionIntent/types.ts +157 -0
  195. package/src/transactionIntent/utils/balanceChecker.ts +96 -0
  196. package/src/transactionIntent/utils/index.ts +3 -0
  197. package/src/transactionIntent/utils/lifiHelpers.ts +68 -0
  198. package/src/transactionIntent/utils/testnetHelpers.ts +10 -0
  199. package/src/transactionIntent/validators.ts +57 -0
  200. package/src/transactions.ts +98 -71
  201. package/src/widget/compiled.css +2 -2
  202. package/src/widget/components/AccountIntentTransactionHistory.tsx +36 -36
  203. package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +22 -0
  204. package/src/widget/components/AccountSettings.tsx +70 -41
  205. package/src/widget/components/ChainFilterDropdown.tsx +24 -3
  206. package/src/widget/components/ClassicSwap.tsx +44 -107
  207. package/src/widget/components/ConfigDisplay.tsx +0 -11
  208. package/src/widget/components/ConnectWallet.tsx +4 -1
  209. package/src/widget/components/ConnectedWallets.tsx +51 -25
  210. package/src/widget/components/DynamicInputStyles.tsx +76 -0
  211. package/src/widget/components/DynamicSizeInputField.tsx +109 -0
  212. package/src/widget/components/Earn.tsx +34 -45
  213. package/src/widget/components/ErrorAnimationIcon.tsx +130 -0
  214. package/src/widget/components/FeeBreakdown.tsx +155 -0
  215. package/src/widget/components/FeeOption.tsx +2 -2
  216. package/src/widget/components/FeeOptions.tsx +151 -112
  217. package/src/widget/components/Fund.tsx +10 -29
  218. package/src/widget/components/FundMethods.tsx +4 -3
  219. package/src/widget/components/FundSwap.tsx +2 -3
  220. package/src/widget/components/FundingMethodSelectorButton.tsx +24 -14
  221. package/src/widget/components/Identicon.tsx +164 -95
  222. package/src/widget/components/MeshConnectExchanges.tsx +2 -15
  223. package/src/widget/components/Modal.tsx +0 -12
  224. package/src/widget/components/Pay.tsx +72 -75
  225. package/src/widget/components/PoolDeposit.tsx +221 -242
  226. package/src/widget/components/PoolWithdraw.tsx +347 -469
  227. package/src/widget/components/PriceImpactWarning.tsx +1 -1
  228. package/src/widget/components/QuoteDetails.tsx +906 -484
  229. package/src/widget/components/Receipt.tsx +16 -2
  230. package/src/widget/components/RecipientSelectorButton.tsx +7 -5
  231. package/src/widget/components/Recipients.tsx +1 -1
  232. package/src/widget/components/ScreenHeader.tsx +60 -36
  233. package/src/widget/components/Swap.tsx +2 -3
  234. package/src/widget/components/ThemeProvider.tsx +2 -1
  235. package/src/widget/components/TokenDisplayNonSelectable.tsx +40 -0
  236. package/src/widget/components/TokenImage.tsx +1 -1
  237. package/src/widget/components/TokenSelector.tsx +62 -53
  238. package/src/widget/components/TokenSelectorButton.tsx +38 -15
  239. package/src/widget/components/Tooltip.tsx +51 -0
  240. package/src/widget/components/TransferPendingVertical.tsx +12 -8
  241. package/src/widget/components/WaasFeeOptions.tsx +139 -4
  242. package/src/widget/components/WalletConfirmation.tsx +23 -13
  243. package/src/widget/components/WalletConnect.tsx +93 -29
  244. package/src/widget/hooks/useAmountUsd.ts +9 -9
  245. package/src/widget/hooks/useCheckout.ts +97 -9
  246. package/src/widget/hooks/useDefaultTokenSelection.tsx +27 -21
  247. package/src/widget/hooks/useQuote.ts +466 -0
  248. package/src/widget/hooks/useSelectedFeeToken.tsx +32 -37
  249. package/src/widget/hooks/useSendForm.ts +45 -51
  250. package/src/widget/hooks/useTokenList.ts +34 -26
  251. package/src/widget/hooks/useWalletConnectionContext.tsx +128 -0
  252. package/src/widget/widget.tsx +365 -390
  253. package/dist/apiClient.d.ts +0 -9
  254. package/dist/apiClient.d.ts.map +0 -1
  255. package/dist/intentEntrypoint.d.ts +0 -114
  256. package/dist/intentEntrypoint.d.ts.map +0 -1
  257. package/dist/metaTxnMonitor.d.ts +0 -15
  258. package/dist/metaTxnMonitor.d.ts.map +0 -1
  259. package/dist/metaTxns.d.ts +0 -11
  260. package/dist/metaTxns.d.ts.map +0 -1
  261. package/dist/relayer.d.ts +0 -43
  262. package/dist/relayer.d.ts.map +0 -1
  263. package/src/apiClient.ts +0 -35
  264. package/src/intentEntrypoint.ts +0 -203
  265. package/src/metaTxnMonitor.ts +0 -171
  266. package/src/metaTxns.ts +0 -45
  267. package/src/relayer.ts +0 -289
@@ -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
  }`}
@@ -86,25 +92,8 @@ const WalletItem: React.FC<WalletItemProps> = ({
86
92
  {/* Identicon */}
87
93
  <Identicon value={wallet.address} size={32} />
88
94
  <div className="flex flex-col items-start space-y-1">
89
- <div className="flex items-center space-x-2">
90
- {/* Wallet Icon */}
91
- {typeof wallet.walletConfig?.icon === "string" ? (
92
- <img
93
- src={wallet.walletConfig.icon}
94
- alt={wallet.walletConfig.name}
95
- className="h-4 w-4"
96
- />
97
- ) : (
98
- <Wallet className="h-4 w-4 text-gray-600 dark:text-gray-400" />
99
- )}
100
- <span className="text-sm font-bold text-gray-900 dark:text-gray-100">
101
- {wallet.walletConfig?.name ||
102
- wallet.connector?.name ||
103
- "Wallet"}
104
- </span>
105
- </div>
106
- <div className="flex items-center space-x-1">
107
- <span className="text-xs text-gray-500 dark:text-gray-400 font-mono">
95
+ <div className="flex items-center space-x-1 m-0">
96
+ <span className="text-sm font-bold text-gray-900 dark:text-gray-100 whitespace-nowrap">
108
97
  {truncateAddress(wallet.address)}
109
98
  </span>
110
99
  <div
@@ -147,16 +136,33 @@ const WalletItem: React.FC<WalletItemProps> = ({
147
136
  )}
148
137
  </div>
149
138
  </div>
139
+ <div className="flex items-center space-x-2">
140
+ {/* Wallet Icon */}
141
+ {typeof wallet.walletConfig?.icon === "string" ? (
142
+ <img
143
+ src={wallet.walletConfig.icon}
144
+ alt={wallet.walletConfig.name}
145
+ className="h-3.5 w-3.5 mr-1"
146
+ />
147
+ ) : (
148
+ <Wallet className="h-3.5 w-3.5 text-gray-600 dark:text-gray-400 mr-1" />
149
+ )}
150
+ <span className="text-xs text-gray-500 dark:text-gray-400">
151
+ {wallet.walletConfig?.name ||
152
+ wallet.connector?.name ||
153
+ "Wallet"}
154
+ </span>
155
+ </div>
150
156
  </div>
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 ? (
159
- <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">
164
+ ) : !onWalletSelect && !hideActiveState ? (
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>
162
168
  ) : null}
@@ -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
 
@@ -324,7 +331,7 @@ export const ConnectedWallets: React.FC<ConnectedWalletsProps> = ({
324
331
  return (
325
332
  <div className={`space-y-2 ${className}`}>
326
333
  {/* Header */}
327
- <div className="text-sm font-medium text-gray-700 dark:text-gray-300 text-left mb-3">
334
+ <div className="text-sm font-medium text-gray-900 dark:text-gray-100 text-left mb-2">
328
335
  Connected Wallets
329
336
  </div>
330
337
 
@@ -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,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
+ }
@@ -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
@@ -14,8 +14,8 @@ import type { SupportedToken } from "../../tokens.js"
14
14
  interface EarnProps {
15
15
  onBack?: () => void
16
16
  onContinue: () => void
17
- account: Account
18
- walletClient: WalletClient
17
+ account?: Account
18
+ walletClient?: WalletClient
19
19
  onTransactionStateChange: (transactionStates: TransactionState[]) => void
20
20
  onError: (error: Error | string | null) => void
21
21
  onWaitingForWalletConfirm: (props: PrepareSendQuote) => void
@@ -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,
@@ -64,6 +62,7 @@ export const Earn: React.FC<EarnProps> = ({
64
62
  onTrackToken,
65
63
  }) => {
66
64
  const [activeTab, setActiveTab] = useState<"deposit" | "withdraw">("deposit")
65
+ const [isShowingPoolSelector, setIsShowingPoolSelector] = useState(false) // Track if pool selector is shown
67
66
 
68
67
  return (
69
68
  <div className="space-y-2">
@@ -74,33 +73,35 @@ export const Earn: React.FC<EarnProps> = ({
74
73
  showAccountActions={true}
75
74
  />
76
75
 
77
- {/* Tabs */}
78
- <div className="flex justify-start space-x-2">
79
- <button
80
- type="button"
81
- onClick={() => setActiveTab("deposit")}
82
- className={`flex items-center space-x-2 py-2 px-4 text-xs font-bold cursor-pointer trails-border-radius-input ${
83
- activeTab === "deposit"
84
- ? "trails-bg-secondary text-blue-500"
85
- : "trails-text-secondary"
86
- }`}
87
- >
88
- <ArrowDownCircle className="w-4 h-4" />
89
- <span>Deposit</span>
90
- </button>
91
- <button
92
- type="button"
93
- onClick={() => setActiveTab("withdraw")}
94
- className={`flex items-center space-x-2 py-2 px-4 text-xs font-bold cursor-pointer trails-border-radius-input ${
95
- activeTab === "withdraw"
96
- ? "trails-bg-secondary text-blue-500"
97
- : "trails-text-secondary"
98
- }`}
99
- >
100
- <ArrowUpCircle className="w-4 h-4" />
101
- <span>Withdraw</span>
102
- </button>
103
- </div>
76
+ {/* Tabs - only show when not in pool selector mode */}
77
+ {!isShowingPoolSelector && (
78
+ <div className="flex justify-start space-x-2">
79
+ <button
80
+ type="button"
81
+ onClick={() => setActiveTab("deposit")}
82
+ className={`flex items-center space-x-2 py-2 px-4 text-xs font-bold cursor-pointer trails-border-radius-input ${
83
+ activeTab === "deposit"
84
+ ? "trails-bg-secondary text-blue-500"
85
+ : "trails-text-secondary"
86
+ }`}
87
+ >
88
+ <ArrowDownCircle className="w-4 h-4" />
89
+ <span>Deposit</span>
90
+ </button>
91
+ <button
92
+ type="button"
93
+ onClick={() => setActiveTab("withdraw")}
94
+ className={`flex items-center space-x-2 py-2 px-4 text-xs font-bold cursor-pointer trails-border-radius-input ${
95
+ activeTab === "withdraw"
96
+ ? "trails-bg-secondary text-blue-500"
97
+ : "trails-text-secondary"
98
+ }`}
99
+ >
100
+ <ArrowUpCircle className="w-4 h-4" />
101
+ <span>Withdraw</span>
102
+ </button>
103
+ </div>
104
+ )}
104
105
 
105
106
  {/* Content */}
106
107
  {activeTab === "deposit" ? (
@@ -114,7 +115,6 @@ export const Earn: React.FC<EarnProps> = ({
114
115
  onComplete={onComplete}
115
116
  onSend={onSend}
116
117
  paymasterUrls={paymasterUrls}
117
- gasless={gasless}
118
118
  setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
119
119
  quoteProvider={quoteProvider}
120
120
  fundMethod={fundMethod}
@@ -123,6 +123,7 @@ export const Earn: React.FC<EarnProps> = ({
123
123
  recentTokens={recentTokens}
124
124
  onRecentTokenSelect={onRecentTokenSelect}
125
125
  onTrackToken={onTrackToken}
126
+ onPoolSelectorStateChange={setIsShowingPoolSelector}
126
127
  />
127
128
  ) : (
128
129
  <PoolWithdraw
@@ -130,20 +131,8 @@ export const Earn: React.FC<EarnProps> = ({
130
131
  walletClient={walletClient}
131
132
  onTransactionStateChange={onTransactionStateChange}
132
133
  onError={onError}
133
- onWaitingForWalletConfirm={onWaitingForWalletConfirm}
134
- onConfirm={onConfirm}
135
134
  onComplete={onComplete}
136
- onSend={onSend}
137
- paymasterUrls={paymasterUrls}
138
- gasless={gasless}
139
- setWalletConfirmRetryHandler={setWalletConfirmRetryHandler}
140
- quoteProvider={quoteProvider}
141
- fundMethod={fundMethod}
142
- onNavigateToMeshConnect={onNavigateToMeshConnect}
143
- checkoutOnHandlers={checkoutOnHandlers}
144
- recentTokens={recentTokens}
145
- onRecentTokenSelect={onRecentTokenSelect}
146
- onTrackToken={onTrackToken}
135
+ onPoolSelectorStateChange={setIsShowingPoolSelector}
147
136
  />
148
137
  )}
149
138
  </div>
@@ -0,0 +1,130 @@
1
+ import { type CSSProperties, useEffect, useState } from "react"
2
+
3
+ export function ErrorAnimationIcon() {
4
+ const [animate, setAnimate] = useState(false)
5
+
6
+ useEffect(() => {
7
+ const timer = setTimeout(() => {
8
+ setAnimate(true)
9
+ }, 100)
10
+
11
+ return () => clearTimeout(timer)
12
+ }, [])
13
+
14
+ const styles: Record<string, CSSProperties> = {
15
+ container: {
16
+ width: "80px",
17
+ height: "80px",
18
+ position: "relative" as const,
19
+ },
20
+ circleContainer: {
21
+ position: "relative" as const,
22
+ width: "100%",
23
+ height: "100%",
24
+ },
25
+ circleFill: {
26
+ position: "absolute" as const,
27
+ top: 0,
28
+ left: 0,
29
+ width: "100%",
30
+ height: "100%",
31
+ borderRadius: "50%",
32
+ backgroundColor: "#ef4444",
33
+ transform: animate ? "scale(1)" : "scale(0)",
34
+ opacity: animate ? 1 : 0,
35
+ transition: "transform 0.15s ease-out 0.3s, opacity 0.15s ease-out 0.3s",
36
+ },
37
+ progressRing: {
38
+ position: "absolute" as const,
39
+ top: 0,
40
+ left: 0,
41
+ width: "100%",
42
+ height: "100%",
43
+ transform: "rotate(-90deg)",
44
+ },
45
+ circle: {
46
+ fill: "none",
47
+ stroke: "url(#redGradient)",
48
+ strokeWidth: 4,
49
+ strokeLinecap: "round" as const,
50
+ strokeDasharray: 226,
51
+ strokeDashoffset: animate ? 0 : 226,
52
+ transition: "stroke-dashoffset 0.3s ease-out",
53
+ },
54
+ xContainer: {
55
+ position: "absolute" as const,
56
+ top: "50%",
57
+ left: "50%",
58
+ transform: animate
59
+ ? "translate(-50%, -50%) scale(1)"
60
+ : "translate(-50%, -50%) scale(0)",
61
+ opacity: animate ? 1 : 0,
62
+ zIndex: 10,
63
+ transition: "transform 0.1s ease-out 0.4s, opacity 0.1s ease-out 0.4s",
64
+ },
65
+ xPath: {
66
+ fill: "none",
67
+ stroke: "white",
68
+ strokeWidth: 3,
69
+ strokeLinecap: "round" as const,
70
+ strokeLinejoin: "round" as const,
71
+ strokeDasharray: 15,
72
+ strokeDashoffset: animate ? 0 : 15,
73
+ transition: "stroke-dashoffset 0.15s ease-out 0.45s",
74
+ },
75
+ xPathSecond: {
76
+ fill: "none",
77
+ stroke: "white",
78
+ strokeWidth: 3,
79
+ strokeLinecap: "round" as const,
80
+ strokeLinejoin: "round" as const,
81
+ strokeDasharray: 15,
82
+ strokeDashoffset: animate ? 0 : 15,
83
+ transition: "stroke-dashoffset 0.15s ease-out 0.5s",
84
+ },
85
+ }
86
+
87
+ return (
88
+ <div style={styles.container}>
89
+ <div style={styles.circleContainer}>
90
+ {/* Circle fill */}
91
+ <div style={styles.circleFill} />
92
+
93
+ {/* Progress ring */}
94
+ <svg style={styles.progressRing}>
95
+ <defs>
96
+ <radialGradient
97
+ id="redGradient"
98
+ cx="50%"
99
+ cy="50%"
100
+ r="50%"
101
+ gradientUnits="objectBoundingBox"
102
+ >
103
+ <stop
104
+ offset="0%"
105
+ style={{ stopColor: "#ef4444", stopOpacity: 0 }}
106
+ />
107
+ <stop
108
+ offset="70%"
109
+ style={{ stopColor: "#ef4444", stopOpacity: 0.3 }}
110
+ />
111
+ <stop
112
+ offset="100%"
113
+ style={{ stopColor: "#ef4444", stopOpacity: 1 }}
114
+ />
115
+ </radialGradient>
116
+ </defs>
117
+ <circle cx="40" cy="40" r="36" style={styles.circle} />
118
+ </svg>
119
+
120
+ {/* X icon */}
121
+ <div style={styles.xContainer}>
122
+ <svg width="48" height="48" viewBox="0 0 24 24">
123
+ <path d="M6 6L18 18" style={styles.xPath} />
124
+ <path d="M18 6L6 18" style={styles.xPathSecond} />
125
+ </svg>
126
+ </div>
127
+ </div>
128
+ </div>
129
+ )
130
+ }