0xtrails 0.1.13 → 0.2.1

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 (256) hide show
  1. package/dist/aave.d.ts.map +1 -1
  2. package/dist/analytics.d.ts +12 -2
  3. package/dist/analytics.d.ts.map +1 -1
  4. package/dist/apiClient.d.ts +1 -1
  5. package/dist/apiClient.d.ts.map +1 -1
  6. package/dist/{ccip-D3gTQONK.js → ccip-BbfANth7.js} +12 -12
  7. package/dist/cctp.d.ts.map +1 -1
  8. package/dist/cctpqueue.d.ts +3 -3
  9. package/dist/cctpqueue.d.ts.map +1 -1
  10. package/dist/chains.d.ts.map +1 -1
  11. package/dist/config.d.ts +18 -5
  12. package/dist/config.d.ts.map +1 -1
  13. package/dist/constants.d.ts +6 -5
  14. package/dist/constants.d.ts.map +1 -1
  15. package/dist/contractUtils.d.ts +2 -0
  16. package/dist/contractUtils.d.ts.map +1 -1
  17. package/dist/customChains.d.ts +24 -0
  18. package/dist/customChains.d.ts.map +1 -0
  19. package/dist/gasless.d.ts +19 -7
  20. package/dist/gasless.d.ts.map +1 -1
  21. package/dist/{index-CnUM7lKf.js → index-WpIVoh3X.js} +36741 -31761
  22. package/dist/index.d.ts +5 -3
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +405 -394
  25. package/dist/indexerClient.d.ts +10 -0
  26. package/dist/indexerClient.d.ts.map +1 -1
  27. package/dist/intentEntrypoint.d.ts +122 -0
  28. package/dist/intentEntrypoint.d.ts.map +1 -0
  29. package/dist/intents.d.ts +5 -3
  30. package/dist/intents.d.ts.map +1 -1
  31. package/dist/metaTxnMonitor.d.ts.map +1 -1
  32. package/dist/morpho.d.ts.map +1 -1
  33. package/dist/pools.d.ts +3 -1
  34. package/dist/pools.d.ts.map +1 -1
  35. package/dist/prepareSend.d.ts +18 -9
  36. package/dist/prepareSend.d.ts.map +1 -1
  37. package/dist/prices.d.ts +1 -1
  38. package/dist/prices.d.ts.map +1 -1
  39. package/dist/relaySdk.d.ts.map +1 -1
  40. package/dist/relayer.d.ts.map +1 -1
  41. package/dist/toast.d.ts +9 -0
  42. package/dist/toast.d.ts.map +1 -0
  43. package/dist/tokenBalances.d.ts +6 -2
  44. package/dist/tokenBalances.d.ts.map +1 -1
  45. package/dist/tokens.d.ts.map +1 -1
  46. package/dist/trails.d.ts +6 -5
  47. package/dist/trails.d.ts.map +1 -1
  48. package/dist/trailsClient.d.ts +12 -0
  49. package/dist/trailsClient.d.ts.map +1 -0
  50. package/dist/trailsRouter.d.ts +22 -0
  51. package/dist/trailsRouter.d.ts.map +1 -0
  52. package/dist/transactions.d.ts +8 -1
  53. package/dist/transactions.d.ts.map +1 -1
  54. package/dist/wallets.d.ts.map +1 -1
  55. package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
  56. package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
  57. package/dist/widget/components/AccountSettings.d.ts +7 -0
  58. package/dist/widget/components/AccountSettings.d.ts.map +1 -0
  59. package/dist/widget/components/ChainList.d.ts +0 -1
  60. package/dist/widget/components/ChainList.d.ts.map +1 -1
  61. package/dist/widget/components/ClassicSwap.d.ts +46 -0
  62. package/dist/widget/components/ClassicSwap.d.ts.map +1 -0
  63. package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
  64. package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
  65. package/dist/widget/components/ConnectedWallets.d.ts +9 -0
  66. package/dist/widget/components/ConnectedWallets.d.ts.map +1 -0
  67. package/dist/widget/components/DebugMenu.d.ts.map +1 -1
  68. package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
  69. package/dist/widget/components/DebugToast.d.ts +3 -0
  70. package/dist/widget/components/DebugToast.d.ts.map +1 -0
  71. package/dist/widget/components/Earn.d.ts.map +1 -1
  72. package/dist/widget/components/EarnPools.d.ts.map +1 -1
  73. package/dist/widget/components/FeeOption.d.ts +22 -0
  74. package/dist/widget/components/FeeOption.d.ts.map +1 -0
  75. package/dist/widget/components/FeeOptions.d.ts +13 -17
  76. package/dist/widget/components/FeeOptions.d.ts.map +1 -1
  77. package/dist/widget/components/Fund.d.ts +44 -0
  78. package/dist/widget/components/Fund.d.ts.map +1 -0
  79. package/dist/widget/components/FundMethods.d.ts +1 -1
  80. package/dist/widget/components/FundMethods.d.ts.map +1 -1
  81. package/dist/widget/components/FundSendForm.d.ts.map +1 -1
  82. package/dist/widget/components/Identicon.d.ts +9 -0
  83. package/dist/widget/components/Identicon.d.ts.map +1 -0
  84. package/dist/widget/components/MeshConnectExchanges.d.ts +5 -2
  85. package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
  86. package/dist/widget/components/MeshConnectFlow.d.ts +2 -0
  87. package/dist/widget/components/MeshConnectFlow.d.ts.map +1 -1
  88. package/dist/widget/components/NativeGasOption.d.ts +12 -0
  89. package/dist/widget/components/NativeGasOption.d.ts.map +1 -0
  90. package/dist/widget/components/Pay.d.ts +46 -0
  91. package/dist/widget/components/Pay.d.ts.map +1 -0
  92. package/dist/widget/components/PaySendForm.d.ts.map +1 -1
  93. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  94. package/dist/widget/components/Receive.d.ts.map +1 -1
  95. package/dist/widget/components/RecentTokens.d.ts.map +1 -1
  96. package/dist/widget/components/Recipients.d.ts +9 -0
  97. package/dist/widget/components/Recipients.d.ts.map +1 -0
  98. package/dist/widget/components/RefundWarning.d.ts +9 -0
  99. package/dist/widget/components/RefundWarning.d.ts.map +1 -0
  100. package/dist/widget/components/SimpleSwap.d.ts.map +1 -1
  101. package/dist/widget/components/Swap.d.ts.map +1 -1
  102. package/dist/widget/components/SwapSettings.d.ts +1 -5
  103. package/dist/widget/components/SwapSettings.d.ts.map +1 -1
  104. package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
  105. package/dist/widget/components/ThemeSyncer.d.ts +6 -0
  106. package/dist/widget/components/ThemeSyncer.d.ts.map +1 -0
  107. package/dist/widget/components/Toast.d.ts +24 -0
  108. package/dist/widget/components/Toast.d.ts.map +1 -0
  109. package/dist/widget/components/TokenList.d.ts.map +1 -1
  110. package/dist/widget/components/TokenSelector.d.ts.map +1 -1
  111. package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
  112. package/dist/widget/components/TruncatedAddress.d.ts +2 -0
  113. package/dist/widget/components/TruncatedAddress.d.ts.map +1 -1
  114. package/dist/widget/components/UserPreferences.d.ts +7 -0
  115. package/dist/widget/components/UserPreferences.d.ts.map +1 -0
  116. package/dist/widget/hooks/useBack.d.ts +2 -0
  117. package/dist/widget/hooks/useBack.d.ts.map +1 -1
  118. package/dist/widget/hooks/useBalanceVisible.d.ts +1 -0
  119. package/dist/widget/hooks/useBalanceVisible.d.ts.map +1 -1
  120. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  121. package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
  122. package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
  123. package/dist/widget/hooks/useDebugScreens.d.ts +1 -1
  124. package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
  125. package/dist/widget/hooks/useDefaultTokenSelection.d.ts +54 -0
  126. package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -0
  127. package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
  128. package/dist/widget/hooks/usePayMessage.d.ts +34 -0
  129. package/dist/widget/hooks/usePayMessage.d.ts.map +1 -0
  130. package/dist/widget/hooks/useRecipients.d.ts +17 -0
  131. package/dist/widget/hooks/useRecipients.d.ts.map +1 -0
  132. package/dist/widget/hooks/useSelectedFeeToken.d.ts +32 -0
  133. package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -0
  134. package/dist/widget/hooks/useSelectedMeshExchange.d.ts +14 -0
  135. package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +1 -0
  136. package/dist/widget/hooks/useSelectedRecipient.d.ts +12 -0
  137. package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -0
  138. package/dist/widget/hooks/useSendForm.d.ts +10 -13
  139. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  140. package/dist/widget/hooks/useSwapAmount.d.ts +13 -0
  141. package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -0
  142. package/dist/widget/hooks/useSwapSettings.d.ts +16 -0
  143. package/dist/widget/hooks/useSwapSettings.d.ts.map +1 -0
  144. package/dist/widget/hooks/useTargetAmount.d.ts +5 -0
  145. package/dist/widget/hooks/useTargetAmount.d.ts.map +1 -0
  146. package/dist/widget/hooks/useTheme.d.ts +14 -0
  147. package/dist/widget/hooks/useTheme.d.ts.map +1 -0
  148. package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
  149. package/dist/widget/index.js +2 -2
  150. package/dist/widget/widget.d.ts +9 -0
  151. package/dist/widget/widget.d.ts.map +1 -1
  152. package/package.json +38 -36
  153. package/src/aave.ts +6 -1
  154. package/src/analytics.ts +109 -53
  155. package/src/apiClient.ts +1 -1
  156. package/src/cctp.ts +6 -2
  157. package/src/cctpqueue.ts +7 -7
  158. package/src/chains.ts +18 -0
  159. package/src/config.ts +63 -17
  160. package/src/constants.ts +20 -16
  161. package/src/contractUtils.ts +33 -2
  162. package/src/customChains.ts +24 -0
  163. package/src/gasless.ts +162 -109
  164. package/src/index.ts +11 -1
  165. package/src/indexerClient.ts +73 -1
  166. package/src/intentEntrypoint.ts +218 -0
  167. package/src/intents.ts +85 -54
  168. package/src/metaTxnMonitor.ts +1 -0
  169. package/src/morpho.ts +13 -2
  170. package/src/pools.ts +68 -86
  171. package/src/prepareSend.ts +1719 -967
  172. package/src/prices.ts +51 -7
  173. package/src/relaySdk.ts +6 -4
  174. package/src/relayer.ts +6 -3
  175. package/src/toast.ts +110 -0
  176. package/src/tokenBalances.ts +112 -20
  177. package/src/tokens.ts +70 -7
  178. package/src/trails.ts +81 -80
  179. package/src/trailsClient.ts +48 -0
  180. package/src/{proxyCaller.ts → trailsRouter.ts} +25 -20
  181. package/src/transactions.ts +30 -88
  182. package/src/umd.tsx +1 -1
  183. package/src/wallets.ts +2 -1
  184. package/src/widget/assets/sequence-logo.svg +15 -0
  185. package/src/widget/compiled.css +2 -2
  186. package/src/widget/components/AccountActionsDropdown.tsx +18 -159
  187. package/src/widget/components/AccountIntentTransactionHistory.tsx +346 -63
  188. package/src/widget/components/AccountSettings.tsx +102 -0
  189. package/src/widget/components/ChainFilterDropdown.tsx +1 -1
  190. package/src/widget/components/ChainList.tsx +10 -20
  191. package/src/widget/components/ClassicSwap.tsx +921 -0
  192. package/src/widget/components/ConfigDisplay.tsx +41 -5
  193. package/src/widget/components/ConnectWallet.tsx +168 -11
  194. package/src/widget/components/ConnectedWallets.tsx +342 -0
  195. package/src/widget/components/DebugMenu.tsx +2 -0
  196. package/src/widget/components/DebugScreensList.tsx +3 -0
  197. package/src/widget/components/DebugToast.tsx +63 -0
  198. package/src/widget/components/Earn.tsx +112 -143
  199. package/src/widget/components/EarnPools.tsx +2 -4
  200. package/src/widget/components/EarnPoolsFilters.tsx +6 -6
  201. package/src/widget/components/FeeOption.tsx +78 -0
  202. package/src/widget/components/FeeOptions.tsx +192 -127
  203. package/src/widget/components/Fund.tsx +1236 -0
  204. package/src/widget/components/FundMethods.tsx +4 -4
  205. package/src/widget/components/FundSendForm.tsx +1 -34
  206. package/src/widget/components/Identicon.tsx +158 -0
  207. package/src/widget/components/MeshConnectExchanges.tsx +32 -3
  208. package/src/widget/components/MeshConnectFlow.tsx +23 -4
  209. package/src/widget/components/NativeGasOption.tsx +99 -0
  210. package/src/widget/components/Pay.tsx +1092 -0
  211. package/src/widget/components/PaySendForm.tsx +1 -38
  212. package/src/widget/components/QuoteDetails.tsx +1 -30
  213. package/src/widget/components/Receipt.tsx +1 -1
  214. package/src/widget/components/Receive.tsx +4 -2
  215. package/src/widget/components/RecentTokens.tsx +2 -1
  216. package/src/widget/components/Recipients.tsx +448 -0
  217. package/src/widget/components/RefundWarning.tsx +61 -0
  218. package/src/widget/components/ScreenHeader.tsx +1 -1
  219. package/src/widget/components/SimpleSwap.tsx +74 -58
  220. package/src/widget/components/Swap.tsx +35 -853
  221. package/src/widget/components/SwapSettings.tsx +5 -11
  222. package/src/widget/components/ThemeProvider.tsx +32 -0
  223. package/src/widget/components/ThemeSyncer.tsx +47 -0
  224. package/src/widget/components/Toast.tsx +315 -0
  225. package/src/widget/components/TokenList.tsx +2 -34
  226. package/src/widget/components/TokenSelector.tsx +14 -3
  227. package/src/widget/components/TransactionDetails.tsx +153 -13
  228. package/src/widget/components/TransferPendingVertical.tsx +1 -1
  229. package/src/widget/components/TruncatedAddress.tsx +5 -1
  230. package/src/widget/components/UserPreferences.tsx +155 -0
  231. package/src/widget/components/WalletList.tsx +1 -1
  232. package/src/widget/hooks/useBack.tsx +4 -0
  233. package/src/widget/hooks/useBalanceVisible.tsx +40 -2
  234. package/src/widget/hooks/useCheckout.ts +13 -0
  235. package/src/widget/hooks/useCurrentScreen.tsx +4 -0
  236. package/src/widget/hooks/useDebugScreens.ts +12 -2
  237. package/src/widget/hooks/useDefaultTokenSelection.tsx +471 -0
  238. package/src/widget/hooks/useIntentTransactionHistory.ts +212 -0
  239. package/src/widget/hooks/usePayMessage.tsx +370 -0
  240. package/src/widget/hooks/useRecipients.ts +168 -0
  241. package/src/widget/hooks/useSelectedFeeToken.tsx +299 -0
  242. package/src/widget/hooks/useSelectedMeshExchange.tsx +46 -0
  243. package/src/widget/hooks/useSelectedRecipient.tsx +48 -0
  244. package/src/widget/hooks/useSendForm.ts +257 -49
  245. package/src/widget/hooks/useSwapAmount.tsx +50 -0
  246. package/src/widget/hooks/useSwapSettings.tsx +100 -0
  247. package/src/widget/hooks/useTargetAmount.ts +23 -0
  248. package/src/widget/hooks/useTheme.tsx +80 -0
  249. package/src/widget/hooks/useTokenList.ts +20 -11
  250. package/src/widget/index.css +45 -21
  251. package/src/widget/widget.tsx +294 -136
  252. package/dist/address.d.ts +0 -2
  253. package/dist/address.d.ts.map +0 -1
  254. package/dist/proxyCaller.d.ts +0 -21
  255. package/dist/proxyCaller.d.ts.map +0 -1
  256. package/src/address.ts +0 -6
package/src/chains.ts CHANGED
@@ -30,6 +30,7 @@ import {
30
30
  soneiumMinato,
31
31
  xaiTestnet,
32
32
  etherlinkTestnet,
33
+ somniaTestnet,
33
34
  } from "viem/chains"
34
35
  import { getRelaySupportedChains } from "./relaySdk.js"
35
36
  import { getLifiSupportedChains } from "./lifi.js"
@@ -38,6 +39,7 @@ import {
38
39
  getSequenceNodeGatewayUrl,
39
40
  } from "./config.js"
40
41
  import type { QuoteProvider } from "./intents.js"
42
+ import { somnia } from "./customChains.js"
41
43
 
42
44
  export function getAllChains(): Chain[] {
43
45
  return [
@@ -48,6 +50,7 @@ export function getAllChains(): Chain[] {
48
50
  gnosis,
49
51
  polygon,
50
52
  soneium,
53
+ somnia,
51
54
  xai,
52
55
  apeChain,
53
56
  arbitrumNova,
@@ -70,6 +73,7 @@ export function getAllChains(): Chain[] {
70
73
  soneiumMinato,
71
74
  xaiTestnet,
72
75
  etherlinkTestnet,
76
+ somniaTestnet,
73
77
  ]
74
78
  }
75
79
 
@@ -87,6 +91,7 @@ function getSequenceRpcUrls(): Record<number, string> {
87
91
  [gnosis.id]: getSequenceRpcUrlFromSlug("gnosis"),
88
92
  [polygon.id]: getSequenceRpcUrlFromSlug("polygon"),
89
93
  [soneium.id]: getSequenceRpcUrlFromSlug("soneium"),
94
+ [somnia.id]: getSequenceRpcUrlFromSlug("somnia"),
90
95
  [xai.id]: getSequenceRpcUrlFromSlug("xai"),
91
96
  [apeChain.id]: getSequenceRpcUrlFromSlug("apechain"),
92
97
  [arbitrumNova.id]: getSequenceRpcUrlFromSlug("arbitrum-nova"),
@@ -124,6 +129,7 @@ export const supportedSequenceChains: Record<number, Chain> = {
124
129
  [optimism.id]: getChainInfo(optimism.id)!,
125
130
  [polygon.id]: getChainInfo(polygon.id)!,
126
131
  [soneium.id]: getChainInfo(soneium.id)!,
132
+ [somnia.id]: getChainInfo(somnia.id)!,
127
133
  [xai.id]: getChainInfo(xai.id)!,
128
134
  [katana.id]: getChainInfo(katana.id)!,
129
135
  [etherlink.id]: getChainInfo(etherlink.id)!,
@@ -143,6 +149,7 @@ export const supportedSequenceTestnetChains: Record<number, Chain> = {
143
149
  [soneiumMinato.id]: getChainInfo(soneiumMinato.id)!,
144
150
  [xaiTestnet.id]: getChainInfo(xaiTestnet.id)!,
145
151
  [etherlinkTestnet.id]: getChainInfo(etherlinkTestnet.id)!,
152
+ [somniaTestnet.id]: getChainInfo(somniaTestnet.id)!,
146
153
  }
147
154
 
148
155
  export const mainnetChainsToTestnetChains: Record<number, Chain> = {
@@ -161,6 +168,7 @@ export const mainnetChainsToTestnetChains: Record<number, Chain> = {
161
168
  [arbitrumNova.id]: arbitrumSepolia,
162
169
  [apeChain.id]: sepolia,
163
170
  [etherlink.id]: etherlinkTestnet,
171
+ [somnia.id]: somniaTestnet,
164
172
  }
165
173
 
166
174
  // Helper to get chain info
@@ -189,6 +197,16 @@ export function getChainInfo(
189
197
  }
190
198
  }
191
199
 
200
+ // Override explorer URLs for specific chains
201
+ if (chainId === katana.id && chainInfo) {
202
+ chainInfo.blockExplorers = {
203
+ default: {
204
+ name: "Katanascan",
205
+ url: "https://katanascan.com", // use katanascan instead of explorer.katanarpc.com
206
+ },
207
+ }
208
+ }
209
+
192
210
  return chainInfo
193
211
  }
194
212
 
package/src/config.ts CHANGED
@@ -6,20 +6,23 @@ import {
6
6
  PROD_SEQUENCE_PROJECT_ACCESS_KEY,
7
7
  DEV_SEQUENCE_INDEXER_URL,
8
8
  DEV_SEQUENCE_API_URL,
9
+ DEV_TRAILS_API_URL,
9
10
  DEV_SEQUENCE_PROJECT_ACCESS_KEY,
10
11
  DEFAULT_SEQUENCE_ENV,
11
12
  PROD_SEQUENCE_NODE_GATEWAY_URL,
12
13
  DEV_SEQUENCE_NODE_GATEWAY_URL,
14
+ PROD_TRAILS_API_URL,
13
15
  } from "./constants.js"
14
16
  import { getQueryParam } from "./queryParams.js"
15
17
 
16
- type SequenceEnv = "prod" | "dev" | "local" | "cors-anywhere"
18
+ export type SequenceEnv = "prod" | "dev" | "local" | "cors-anywhere"
17
19
 
18
20
  export const globalConfig: {
19
21
  sequenceProjectAccessKey: string
20
22
  sequenceIndexerUrl: string
21
23
  sequenceNodeGatewayUrl: string
22
24
  sequenceApiUrl: string
25
+ trailsApiUrl: string
23
26
  sequenceEnv: SequenceEnv
24
27
  walletConnectProjectId: string
25
28
  slippageTolerance: string
@@ -27,11 +30,12 @@ export const globalConfig: {
27
30
  commitHash: string | undefined
28
31
  } = {
29
32
  commitHash: declareCommitHash(),
33
+ sequenceEnv: declareSequenceEnv(),
30
34
  sequenceProjectAccessKey: declareSequenceProjectAccessKey(),
31
35
  sequenceIndexerUrl: declareSequenceIndexerUrl(),
32
36
  sequenceNodeGatewayUrl: declareSequenceNodeGatewayUrl(),
33
37
  sequenceApiUrl: declareSequenceApiUrl(),
34
- sequenceEnv: declareSequenceEnv(),
38
+ trailsApiUrl: declareTrailsApiUrl(),
35
39
  walletConnectProjectId: DEFAULT_WALLETCONNECT_PROJECT_ID,
36
40
  slippageTolerance: DEFAULT_SLIPPAGE_TOLERANCE,
37
41
  debug: false,
@@ -49,12 +53,18 @@ export function declareSequenceEnv(): SequenceEnv {
49
53
  if (getEnvVar("ENV") === "development" || getEnvVar("ENV") === "dev") {
50
54
  return "dev"
51
55
  }
52
- if (
53
- getEnvVar("CF_PAGES_BRANCH") === "master" ||
54
- getEnvVar("CF_PAGES_BRANCH") === "main" ||
55
- getEnvVar("ENV") === "production" ||
56
- getEnvVar("ENV") === "prod"
57
- ) {
56
+
57
+ // Special handling for Cloudflare Pages branches
58
+ const cfPagesBranch = getEnvVar("CF_PAGES_BRANCH")
59
+ if (cfPagesBranch) {
60
+ // If running on Cloudflare Pages, all branches except "production" default to dev
61
+ if (cfPagesBranch === "prod" || cfPagesBranch === "production") {
62
+ return "prod"
63
+ }
64
+ return "dev"
65
+ }
66
+
67
+ if (getEnvVar("ENV") === "production" || getEnvVar("ENV") === "prod") {
58
68
  return "prod"
59
69
  }
60
70
  }
@@ -74,11 +84,21 @@ export function declareSequenceApiUrl() {
74
84
  return PROD_SEQUENCE_API_URL
75
85
  }
76
86
  if (declareSequenceEnv() === "local") {
77
- return getEnvVar("TEST_API_URL") || DEV_SEQUENCE_API_URL
87
+ return getEnvVar("SEQUENCE_API_URL") || DEV_SEQUENCE_API_URL
78
88
  }
79
89
  return DEV_SEQUENCE_API_URL
80
90
  }
81
91
 
92
+ export function declareTrailsApiUrl() {
93
+ if (declareSequenceEnv() === "prod") {
94
+ return PROD_TRAILS_API_URL
95
+ }
96
+ if (declareSequenceEnv() === "local") {
97
+ return getEnvVar("TRAILS_API_URL") || DEV_TRAILS_API_URL
98
+ }
99
+ return DEV_TRAILS_API_URL
100
+ }
101
+
82
102
  export function declareSequenceNodeGatewayUrl() {
83
103
  if (declareSequenceEnv() === "prod") {
84
104
  return PROD_SEQUENCE_NODE_GATEWAY_URL
@@ -87,9 +107,21 @@ export function declareSequenceNodeGatewayUrl() {
87
107
  }
88
108
 
89
109
  export function declareSequenceProjectAccessKey() {
90
- if (declareSequenceEnv() === "prod") {
110
+ const sequenceEnv = declareSequenceEnv()
111
+
112
+ // Check for explicit env var override
113
+ if (typeof process !== "undefined") {
114
+ const envVarKey = getEnvVar("SEQUENCE_PROJECT_ACCESS_KEY")
115
+ if (envVarKey) {
116
+ return envVarKey
117
+ }
118
+ }
119
+
120
+ // Use dev/prod keys based on environment
121
+ if (sequenceEnv === "prod") {
91
122
  return PROD_SEQUENCE_PROJECT_ACCESS_KEY
92
123
  }
124
+
93
125
  return DEV_SEQUENCE_PROJECT_ACCESS_KEY
94
126
  }
95
127
 
@@ -105,6 +137,10 @@ export function declareCommitHash() {
105
137
  return cfPagesCommitHash || viteCommitHash
106
138
  }
107
139
 
140
+ export function getSequenceConfig() {
141
+ return globalConfig
142
+ }
143
+
108
144
  export function getSequenceProjectAccessKey() {
109
145
  return globalConfig.sequenceProjectAccessKey
110
146
  }
@@ -137,25 +173,40 @@ export function getSequenceApiUrl() {
137
173
  return globalConfig.sequenceApiUrl
138
174
  }
139
175
 
176
+ export function setTrailsApiUrl(trailsApiUrl: string) {
177
+ globalConfig.trailsApiUrl = trailsApiUrl
178
+ }
179
+
180
+ export function getTrailsApiUrl() {
181
+ return globalConfig.trailsApiUrl
182
+ }
183
+
140
184
  export function setSequenceEnv(sequenceEnv: SequenceEnv) {
141
185
  globalConfig.sequenceEnv = sequenceEnv
142
186
 
143
187
  if (sequenceEnv === "prod") {
144
188
  setSequenceIndexerUrl(PROD_SEQUENCE_INDEXER_URL)
145
189
  setSequenceApiUrl(PROD_SEQUENCE_API_URL)
190
+ setTrailsApiUrl(PROD_TRAILS_API_URL)
146
191
  setSequenceNodeGatewayUrl(PROD_SEQUENCE_NODE_GATEWAY_URL)
192
+ setSequenceProjectAccessKey(PROD_SEQUENCE_PROJECT_ACCESS_KEY)
147
193
  }
148
194
 
149
195
  if (sequenceEnv === "local") {
150
- if (getEnvVar("API_URL")) {
151
- setSequenceApiUrl(getEnvVar("API_URL"))
196
+ if (getEnvVar("SEQUENCE_API_URL")) {
197
+ setSequenceApiUrl(getEnvVar("SEQUENCE_API_URL"))
198
+ }
199
+ if (getEnvVar("TRAILS_API_URL")) {
200
+ setTrailsApiUrl(getEnvVar("TRAILS_API_URL"))
152
201
  }
153
202
  }
154
203
 
155
204
  if (sequenceEnv === "dev") {
156
205
  setSequenceIndexerUrl(DEV_SEQUENCE_INDEXER_URL)
157
206
  setSequenceApiUrl(DEV_SEQUENCE_API_URL)
207
+ setTrailsApiUrl(DEV_TRAILS_API_URL)
158
208
  setSequenceNodeGatewayUrl(DEV_SEQUENCE_NODE_GATEWAY_URL)
209
+ setSequenceProjectAccessKey(DEV_SEQUENCE_PROJECT_ACCESS_KEY)
159
210
  }
160
211
  }
161
212
 
@@ -208,13 +259,8 @@ export function getAccountIntentTransactionHistory() {
208
259
  return FeatureFlags.accountIntentTransactionHistory
209
260
  }
210
261
 
211
- export function getSameChainSwapDifferentIntentAddresses() {
212
- return FeatureFlags.sameChainSwapDifferentIntentAddresses
213
- }
214
-
215
262
  export const FeatureFlags = {
216
263
  accountIntentTransactionHistory: false,
217
- sameChainSwapDifferentIntentAddresses: false,
218
264
  }
219
265
 
220
266
  export function getEnvVar(name: string) {
package/src/constants.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { AddressOverrides } from "@0xsequence/trails-api"
1
2
  import type { Context as ContextLike } from "@0xsequence/wallet-primitives"
2
3
 
3
4
  export const SEQUENCE_V3_CONTRACT_ADDRESSES: ContextLike.Context = {
@@ -8,34 +9,39 @@ export const SEQUENCE_V3_CONTRACT_ADDRESSES: ContextLike.Context = {
8
9
  "0x6041600e3d396021805130553df33d3d36153402601f57363d3d373d363d30545af43d82803e903d91601f57fd5bf3" as `0x${string}`,
9
10
  }
10
11
 
11
- export const TRAILS_BALANCE_INJECTOR_ADDRESS =
12
- "0x9eCA6CEf73799402a1afe4779f588f03034c5D0f"
12
+ export const SEQUENCE_V3_CONTRACT_ADDRESSES_OVERRIDES: AddressOverrides = {
13
+ sequenceWalletFactoryAddress: SEQUENCE_V3_CONTRACT_ADDRESSES.factory,
14
+ sequenceWalletMainModuleAddress: SEQUENCE_V3_CONTRACT_ADDRESSES.stage1,
15
+ sequenceWalletMainModuleUpgradableAddress:
16
+ SEQUENCE_V3_CONTRACT_ADDRESSES.stage2,
17
+ } as AddressOverrides
18
+
19
+ export const TRAILS_ROUTER_ADDRESS =
20
+ "0x07abd6f71aE3EAD08b2B6D5d091eE24d32dc1Dfa"
21
+
22
+ export const TRAILS_INTENT_ENTRYPOINT_ADDRESS =
23
+ "0xf9dF60584Da03f8D83fF1Bed663465734B2221a7"
13
24
 
14
25
  export const ATTESATION_SIGNER_ADDRESS =
15
26
  "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
16
27
 
17
- export const TRAILS_LIFI_SAPIENT_SIGNER_ADDRESS =
18
- "0xd7571bd1e3af468c3a49966c9a92a2e907cdfa52"
19
- export const TRAILS_RELAY_SAPIENT_SIGNER_ADDRESS =
20
- "0x9a013e7d186611af36a918ef23d81886e8c256f8"
21
- export const TRAILS_CCTP_SAPIENT_SIGNER_ADDRESS =
22
- "0xc1A9B197eBb31Fc2B613C59dAC3f3E5698A429D0"
23
-
24
28
  export const DEFAULT_SEQUENCE_ENV = "prod"
25
29
 
26
30
  export const PROD_SEQUENCE_NODE_GATEWAY_URL = "https://nodes.sequence.app"
27
31
  export const PROD_SEQUENCE_INDEXER_URL = "https://indexer.sequence.app"
28
32
  export const PROD_SEQUENCE_API_URL = "https://api.sequence.app"
33
+ export const PROD_TRAILS_API_URL = "https://trails-api.sequence.app"
29
34
  export const DEV_SEQUENCE_NODE_GATEWAY_URL = "https://dev-nodes.sequence.app"
30
35
  export const DEV_SEQUENCE_INDEXER_URL = "https://dev-indexer.sequence.app"
31
36
  export const DEV_SEQUENCE_API_URL = "https://dev-api.sequence.app"
37
+ export const DEV_TRAILS_API_URL = "https://dev-trails-api.sequence-dev.app"
32
38
 
39
+ // TODO: Update with new single address once latest contracts are deployed
33
40
  export const intentEntrypoints: Record<number, `0x${string}`> = {
34
- 8453: "0x2bf4c63199eD7D8A737E8DB2cC19E0C0103F6bE3",
35
- 84532: "0xdcd9160492C6D43ABbd28D4d06F68ad77f1A0F2b",
36
- 421614: "0xf18A16E1C778baCA5d6f7F48cC4c9bb913e5e579",
37
- 42161: "0x674827B6BE8780DBdb96DC02c735275e3a982c90",
38
- 137: "0x4dBb20eA3A969F1A44d7653D4Dc8632B853E36DE",
41
+ 8453: "0x80DB82D640F9Df20Cfe89fa4E70B0EcC56f3715c", // Base
42
+ 42161: "0x20CC15eb516Ba56398c28CE1A567e3a82889Db46", // Arbitrum One
43
+ 137: "0x1C69bCdcD751785F2a3b815333B46AB150370E6E", // Polygon
44
+ 747474: "0x814A110fF7c664C26e6c3e2E6E85C23291e4359e", // Katana
39
45
  }
40
46
 
41
47
  // This is used for Sequence Indexer and API
@@ -54,5 +60,3 @@ export const DEFAULT_WALLETCONNECT_PROJECT_ID =
54
60
  export const SITE_URL = "https://trails.build/"
55
61
 
56
62
  export const DEFAULT_SLIPPAGE_TOLERANCE = "0.05" // 0.001 = 0.1%, 0.005 = 0.5%, 0.03 = 3%, 0.05 = 5%
57
-
58
- export const MINIMUM_USD_AMOUNT_FOR_SWAP = "0.15"
@@ -1,5 +1,6 @@
1
1
  import { createPublicClient, http } from "viem"
2
2
  import { getChainInfo } from "./chains.js"
3
+ import { logger } from "./logger.js"
3
4
 
4
5
  export async function getIsContract(address: `0x${string}`, chainId: number) {
5
6
  const client = createPublicClient({
@@ -8,9 +9,39 @@ export async function getIsContract(address: `0x${string}`, chainId: number) {
8
9
  })
9
10
 
10
11
  const code = await client.getCode({ address })
11
- return code !== "0x"
12
+ const isNonZero = isNonZeroHexString(code)
13
+ const is7702 = is7702ContractCode(code)
14
+ const isContract = isNonZero && !is7702
15
+
16
+ logger.console.log(
17
+ "[trails-sdk] code:",
18
+ code?.slice(0, 10),
19
+ "address:",
20
+ address,
21
+ "chainId:",
22
+ chainId,
23
+ "isContract:",
24
+ isContract,
25
+ )
26
+
27
+ return isContract
28
+ }
29
+
30
+ export function is7702ContractCode(hex: string | undefined): boolean {
31
+ return hex?.startsWith("0xef0100") || false
32
+ }
33
+
34
+ export function isNonZeroHexString(hex: string | undefined): boolean {
35
+ return (
36
+ hex !== undefined &&
37
+ hex !== "" &&
38
+ hex !== "0" &&
39
+ hex !== "0x" &&
40
+ hex !== "0x0" &&
41
+ hex !== "0x00"
42
+ )
12
43
  }
13
44
 
14
45
  export function getIsCustomCalldata(calldata: string | undefined): boolean {
15
- return calldata !== undefined && calldata !== "" && calldata !== "0x"
46
+ return isNonZeroHexString(calldata)
16
47
  }
@@ -0,0 +1,24 @@
1
+ // Custom chain definition for Somnia
2
+ export const somnia = {
3
+ id: 5031,
4
+ name: "Somnia",
5
+ nativeCurrency: {
6
+ decimals: 18,
7
+ name: "SOMI",
8
+ symbol: "SOMI",
9
+ },
10
+ rpcUrls: {
11
+ default: {
12
+ http: ["https://api.infra.mainnet.somnia.network"],
13
+ },
14
+ public: {
15
+ http: ["https://api.infra.mainnet.somnia.network"],
16
+ },
17
+ },
18
+ blockExplorers: {
19
+ default: {
20
+ name: "Somnia Explorer",
21
+ url: "https://explorer.somnia.network/",
22
+ },
23
+ },
24
+ } as const