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
@@ -1,18 +1,24 @@
1
1
  import { ChevronRight, QrCode, Send } from "lucide-react"
2
2
  import type React from "react"
3
3
  import { truncateAddress } from "../../utils.js"
4
- import { useAccount } from "wagmi"
4
+ import { useAccount, useConnections } from "wagmi"
5
5
  import { Identicon } from "./Identicon.js"
6
6
  import { useBack } from "../hooks/useBack.js"
7
7
  import { useSelectedFundMethod } from "../hooks/useSelectedFundMethod.js"
8
8
 
9
9
  export const FundingMethodSelectorButton: React.FC = () => {
10
- const { address, isConnected } = useAccount()
10
+ const connections = useConnections()
11
+ const { address } = useAccount()
11
12
  const { setCurrentScreenWithBack } = useBack()
12
13
  const { selectedFundMethod } = useSelectedFundMethod()
13
14
 
15
+ // Check if there are any connected accounts across all connectors
16
+ const isConnected = connections.length > 0
17
+ // Use the active account from useAccount(), fallback to first connection if needed
18
+ const activeAddress = address || connections[0]?.accounts[0]
19
+
14
20
  const handleClick = () => {
15
- if (isConnected && address) {
21
+ if (isConnected && activeAddress) {
16
22
  // If wallet is connected, go to fund methods
17
23
  setCurrentScreenWithBack("fund-methods")
18
24
  } else {
@@ -27,32 +33,36 @@ export const FundingMethodSelectorButton: React.FC = () => {
27
33
  onClick={handleClick}
28
34
  className="flex items-center space-x-2 text-blue-500 hover:text-blue-600 transition-colors cursor-pointer bg-transparent border-none p-0"
29
35
  title={
30
- isConnected && address ? "Select funding method" : "Connect wallet"
36
+ isConnected && activeAddress
37
+ ? "Select funding method"
38
+ : "Connect wallet"
31
39
  }
32
40
  >
33
- {isConnected && address ? (
41
+ {isConnected && activeAddress ? (
34
42
  selectedFundMethod === "qr-code" ? (
35
43
  <>
36
- <QrCode className="w-4 h-4" />
37
- <span className="text-sm font-medium">QR Code</span>
44
+ <QrCode className="w-4 h-4 mr-1" />
45
+ <span className="text-sm font-medium m-0">QR Code</span>
38
46
  </>
39
47
  ) : selectedFundMethod === "exchange" ? (
40
48
  <>
41
- <Send className="w-4 h-4" />
42
- <span className="text-sm font-medium">Exchange</span>
49
+ <Send className="w-4 h-4 mr-1" />
50
+ <span className="text-sm font-medium m-0">Exchange</span>
43
51
  </>
44
52
  ) : (
45
53
  <>
46
- <Identicon value={address} size={16} />
47
- <span className="text-sm font-medium">
48
- {truncateAddress(address, 4, 2)}
54
+ <div className="flex items-center mr-1">
55
+ <Identicon value={activeAddress} size={16} />
56
+ </div>
57
+ <span className="text-sm font-medium m-0">
58
+ {truncateAddress(activeAddress, 4, 4)}
49
59
  </span>
50
60
  </>
51
61
  )
52
62
  ) : (
53
- <span className="text-sm font-medium">Connect Wallet</span>
63
+ <span className="text-sm font-medium mr-1">Connect Wallet</span>
54
64
  )}
55
- <ChevronRight className="w-4 h-4" />
65
+ <ChevronRight className="w-4 h-4 m-0" />
56
66
  </button>
57
67
  )
58
68
  }
@@ -1,81 +1,99 @@
1
1
  import type React from "react"
2
+ import { useId } from "react"
3
+
4
+ const MOD = 1000
5
+ const SIZE = 64
6
+ const RADIUS = SIZE / 2
7
+ const prefix = "gradient-avatar-"
8
+
9
+ const scaledMod = (value: number, mod: number = MOD): number => {
10
+ return (value % mod) / (MOD / SIZE)
11
+ }
12
+
13
+ const cyrb53 = (str: string, seed: number = 0): number => {
14
+ let h1 = 0xdeadbeef ^ seed
15
+ let h2 = 0x41c6ce57 ^ seed
2
16
 
3
- // MetaMask-style hash function
4
- const hashCode = (str: string): number => {
5
- let hash = 0
6
17
  for (let i = 0; i < str.length; i++) {
7
- const char = str.charCodeAt(i)
8
- hash = (hash << 5) - hash + char
9
- hash = hash & hash
18
+ const ch = str.charCodeAt(i)
19
+ h1 = Math.imul(h1 ^ ch, 2654435761)
20
+ h2 = Math.imul(h2 ^ ch, 1597334677)
10
21
  }
11
- return Math.abs(hash)
22
+
23
+ h1 =
24
+ Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^
25
+ Math.imul(h2 ^ (h2 >>> 13), 3266489909)
26
+ h2 =
27
+ Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^
28
+ Math.imul(h1 ^ (h1 >>> 13), 3266489909)
29
+
30
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0)
12
31
  }
13
32
 
14
- // Generate MetaMask-style colors (bright and vibrant)
15
- const generateMetaMaskColors = (seed: number) => {
16
- const colors = [
17
- "#FF6B6B",
18
- "#4ECDC4",
19
- "#45B7D1",
20
- "#96CEB4",
21
- "#FECA57",
22
- "#FF9FF3",
23
- "#54A0FF",
24
- "#5F27CD",
25
- "#00D2D3",
26
- "#FF9F43",
27
- "#10AC84",
28
- "#EE5A24",
29
- "#0ABDE3",
30
- "#C44569",
31
- "#F8B500",
32
- "#6C5CE7",
33
- "#A3CB38",
34
- "#FD79A8",
35
- "#636E72",
36
- "#00B894",
37
- ]
38
-
39
- const bg = colors[seed % colors.length]
40
- const spot = colors[(seed + 7) % colors.length]
41
-
42
- return { backgroundColor: bg, spotColor: spot }
33
+ const createId = (name: string, id: string): string => `${prefix}${name}${id}`
34
+
35
+ const createHues = (a: number, _b: number, c: number) => {
36
+ const hueA = a % 360
37
+ const hueB = (a + 120) % 360
38
+ const hueC = c % 360
39
+ return { hueA, hueB, hueC }
43
40
  }
44
41
 
45
- // Generate MetaMask-style pattern
46
- const generateMetaMaskPattern = (address: string) => {
47
- const cleanAddress = address.replace(/^0x/i, "").toLowerCase()
48
-
49
- // Use address to generate deterministic values
50
- const seed = hashCode(cleanAddress)
51
- const { backgroundColor, spotColor } = generateMetaMaskColors(seed)
52
-
53
- // Generate a 8x8 grid pattern like MetaMask
54
- const size = 8
55
- const pattern: boolean[][] = []
56
-
57
- // Generate pattern with symmetry (like MetaMask)
58
- for (let y = 0; y < size; y++) {
59
- const row: boolean[] = []
60
- for (let x = 0; x < size; x++) {
61
- // Create horizontal symmetry
62
- const actualX = x < 4 ? x : 7 - x
63
-
64
- // Use different parts of address for different rows/columns
65
- const addressIndex = (y * 4 + actualX) % cleanAddress.length
66
- const char = cleanAddress.charCodeAt(addressIndex)
67
-
68
- // Determine if this cell should be filled
69
- const shouldFill = (char + seed) % 3 === 0
70
- row.push(shouldFill)
71
- }
72
- pattern.push(row)
42
+ interface Gradient {
43
+ id: string
44
+ stopColor0: string
45
+ stopColor1: string
46
+ cx: number
47
+ cy: number
48
+ r: number
49
+ }
50
+
51
+ interface Gradients {
52
+ background: Gradient
53
+ primary: Gradient
54
+ secondary: Gradient
55
+ }
56
+
57
+ const createGradients = (id: string, address: string): Gradients => {
58
+ const hash = {
59
+ a: cyrb53(`${address}a`, 0),
60
+ b: cyrb53(`${address}b`, 1),
61
+ c: cyrb53(`${address}c`, 2),
62
+ x: cyrb53(`${address}d`, 3),
63
+ y: cyrb53(`${address}e`, 4),
64
+ r: cyrb53(`${address}f`, 5),
73
65
  }
74
66
 
67
+ const { hueA, hueB, hueC } = createHues(hash.a, hash.b, hash.c)
68
+ const cx = scaledMod(hash.x)
69
+ const cy = scaledMod(hash.y)
70
+ const r = SIZE / 10 + scaledMod(hash.r, MOD * 1.5)
71
+
75
72
  return {
76
- backgroundColor,
77
- spotColor,
78
- pattern,
73
+ background: {
74
+ id: createId("background", id),
75
+ stopColor0: `hsl(${hueC}deg 100% 50% / 1)`,
76
+ stopColor1: `hsl(${hueA}deg 100% 50% / 1)`,
77
+ cx,
78
+ cy,
79
+ r,
80
+ },
81
+ primary: {
82
+ id: createId("primary", id),
83
+ stopColor0: `hsl(${hueA}deg 100% 50% / 1)`,
84
+ stopColor1: `hsl(${hueB}deg 100% 50% / 1)`,
85
+ cx,
86
+ cy,
87
+ r,
88
+ },
89
+ secondary: {
90
+ id: createId("secondary", id),
91
+ stopColor0: `hsl(${hueC}deg 100% 50% / 1)`,
92
+ stopColor1: `hsl(${hueB}deg 100% 50% / 1)`,
93
+ cx: cy,
94
+ cy: cx,
95
+ r: r / 2,
96
+ },
79
97
  }
80
98
  }
81
99
 
@@ -90,6 +108,8 @@ export const Identicon: React.FC<IdenticonProps> = ({
90
108
  size = 64,
91
109
  className = "",
92
110
  }) => {
111
+ const id = useId()
112
+
93
113
  if (!value || typeof value !== "string") {
94
114
  return (
95
115
  <div
@@ -104,10 +124,8 @@ export const Identicon: React.FC<IdenticonProps> = ({
104
124
  )
105
125
  }
106
126
 
107
- const { backgroundColor, spotColor, pattern } = generateMetaMaskPattern(value)
108
-
109
- const gridSize = 8
110
- const cellSize = size / gridSize
127
+ const gradients = createGradients(id, value.toLowerCase())
128
+ const getId = (name: string) => createId(name, id)
111
129
 
112
130
  return (
113
131
  <div
@@ -117,39 +135,90 @@ export const Identicon: React.FC<IdenticonProps> = ({
117
135
  height: size,
118
136
  borderRadius: "50%",
119
137
  overflow: "hidden",
120
- backgroundColor: backgroundColor,
138
+ flexShrink: 0,
121
139
  }}
122
140
  >
123
141
  <svg
124
142
  width={size}
125
143
  height={size}
144
+ viewBox={`0 0 ${SIZE} ${SIZE}`}
126
145
  style={{ display: "block" }}
146
+ xmlns="http://www.w3.org/2000/svg"
127
147
  aria-label={`Identicon for ${value}`}
128
148
  >
129
149
  <title>Identicon for {value}</title>
130
- {/* Background circle */}
131
- <circle
132
- cx={size / 2}
133
- cy={size / 2}
134
- r={size / 2}
135
- fill={backgroundColor}
136
- />
137
-
138
- {/* Pattern cells */}
139
- {pattern.map((row, y) =>
140
- row.map((shouldFill, x) =>
141
- shouldFill ? (
142
- <rect
143
- key={`cell-${y}-${x}-${value.slice(-8)}`}
144
- x={x * cellSize}
145
- y={y * cellSize}
146
- width={cellSize}
147
- height={cellSize}
148
- fill={spotColor}
149
- />
150
- ) : null,
151
- ),
152
- )}
150
+
151
+ <defs>
152
+ <clipPath id={getId("circle-clip")}>
153
+ <circle cx={RADIUS} cy={RADIUS} r={RADIUS} />
154
+ </clipPath>
155
+
156
+ <filter
157
+ id={getId("blur-xs")}
158
+ x="-10%"
159
+ y="-10%"
160
+ width="120%"
161
+ height="120%"
162
+ filterUnits="userSpaceOnUse"
163
+ colorInterpolationFilters="sRGB"
164
+ >
165
+ <feFlood floodOpacity="0" result="BackgroundImageFix" />
166
+ <feBlend
167
+ mode="normal"
168
+ in="SourceGraphic"
169
+ in2="BackgroundImageFix"
170
+ result="shape"
171
+ />
172
+ <feGaussianBlur
173
+ stdDeviation={SIZE / 10}
174
+ result="effect1_foregroundBlur"
175
+ />
176
+ </filter>
177
+
178
+ <linearGradient
179
+ id={gradients.background.id}
180
+ x1="0"
181
+ y1="0"
182
+ x2="1"
183
+ y2="1"
184
+ >
185
+ <stop offset="0" stopColor={gradients.background.stopColor0} />
186
+ <stop offset="1" stopColor={gradients.background.stopColor1} />
187
+ </linearGradient>
188
+
189
+ <radialGradient id={gradients.primary.id}>
190
+ <stop offset="0" stopColor={gradients.primary.stopColor0} />
191
+ <stop offset="1" stopColor={gradients.primary.stopColor1} />
192
+ </radialGradient>
193
+
194
+ <radialGradient id={gradients.secondary.id}>
195
+ <stop offset="0" stopColor={gradients.secondary.stopColor0} />
196
+ <stop offset="1" stopColor={gradients.secondary.stopColor1} />
197
+ </radialGradient>
198
+ </defs>
199
+
200
+ <g clipPath={`url(#${getId("circle-clip")})`}>
201
+ <rect
202
+ width="100%"
203
+ height="100%"
204
+ fill={`url(#${gradients.background.id})`}
205
+ />
206
+
207
+ <g filter={`url(#${getId("blur-xs")})`}>
208
+ <circle
209
+ fill={`url(#${gradients.primary.id})`}
210
+ cx={gradients.primary.cx}
211
+ cy={gradients.primary.cy}
212
+ r={gradients.primary.r}
213
+ />
214
+ <circle
215
+ fill={`url(#${gradients.secondary.id})`}
216
+ cx={gradients.secondary.cx}
217
+ cy={gradients.secondary.cy}
218
+ r={gradients.secondary.r}
219
+ />
220
+ </g>
221
+ </g>
153
222
  </svg>
154
223
  </div>
155
224
  )
@@ -12,24 +12,18 @@ import CoinbaseLogo from "../assets/Coinbase_Icon_Logo.svg"
12
12
  import { ScreenHeader } from "./ScreenHeader.js"
13
13
  import { logger } from "../../logger.js"
14
14
  import { useSelectedMeshExchange } from "../hooks/useSelectedMeshExchange.js"
15
- import { useMode } from "../hooks/useMode.js"
16
15
  import { useCurrentScreen } from "../hooks/useCurrentScreen.js"
17
- import type { Mode } from "../../mode.js"
18
- import type { Screen } from "../hooks/useCurrentScreen.js"
19
16
 
20
17
  export interface MeshConnectExchangesProps {
21
18
  onBack?: () => void
22
19
  onSelectExchange?: (integrationId: string, exchangeName: string) => void
23
- getInitialScreenForMode?: (mode: Mode) => Screen
24
20
  }
25
21
 
26
22
  export const MeshConnectExchanges: React.FC<MeshConnectExchangesProps> = ({
27
23
  onBack,
28
24
  onSelectExchange,
29
- getInitialScreenForMode,
30
25
  }) => {
31
26
  const { setSelectedExchange } = useSelectedMeshExchange()
32
- const { mode } = useMode()
33
27
  const { setCurrentScreen } = useCurrentScreen()
34
28
  const [coinbaseId, setCoinbaseId] = useState<string | null>(null)
35
29
  const [binanceId, setBinanceId] = useState<string | null>(null)
@@ -94,15 +88,8 @@ export const MeshConnectExchanges: React.FC<MeshConnectExchangesProps> = ({
94
88
  // Store the selected exchange
95
89
  setSelectedExchange({ integrationId, exchangeName })
96
90
 
97
- // Navigate to the initial screen for the current mode
98
- if (getInitialScreenForMode) {
99
- const currentMode = (mode || "pay") as Mode
100
- const initialScreen = getInitialScreenForMode(currentMode)
101
- logger.console.log(
102
- `[trails-sdk] Navigating to initial screen for mode ${currentMode}: ${initialScreen}`,
103
- )
104
- setCurrentScreen(initialScreen)
105
- }
91
+ // Navigate to home screen
92
+ setCurrentScreen("home")
106
93
  }
107
94
 
108
95
  if (loading) {
@@ -1,4 +1,3 @@
1
- import { X } from "lucide-react"
2
1
  import { AnimatePresence, motion } from "motion/react"
3
2
  import type React from "react"
4
3
  import { useEffect, useRef } from "react"
@@ -70,17 +69,6 @@ const Modal: React.FC<ModalProps> = ({ isOpen, onClose, children }) => {
70
69
  layoutId="modal-content"
71
70
  layout="preserve-aspect"
72
71
  >
73
- <button
74
- type="button"
75
- onClick={onClose}
76
- className="absolute right-4 top-6 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 z-20"
77
- title="Close"
78
- >
79
- <X
80
- className="h-4 w-4"
81
- style={{ transform: "translate(0, -2px)" }}
82
- />
83
- </button>
84
72
  {children}
85
73
  </motion.div>
86
74
  </div>