eco-solver 0.0.1-security → 1.5.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.

Potentially problematic release.


This version of eco-solver might be problematic. Click here for more details.

Files changed (244) hide show
  1. package/.eslintignore +8 -0
  2. package/.eslintrc.js +24 -0
  3. package/.github/workflows/ci.yaml +38 -0
  4. package/.nvmrc +1 -0
  5. package/.prettierignore +3 -0
  6. package/.prettierrc +8 -0
  7. package/Dockerfile +11 -0
  8. package/LICENSE +21 -0
  9. package/README.md +29 -5
  10. package/config/default.ts +135 -0
  11. package/config/development.ts +95 -0
  12. package/config/preproduction.ts +17 -0
  13. package/config/production.ts +17 -0
  14. package/config/staging.ts +17 -0
  15. package/config/test.ts +7 -0
  16. package/index.js +66 -0
  17. package/jest.config.ts +14 -0
  18. package/nest-cli.json +8 -0
  19. package/package.json +115 -6
  20. package/src/api/api.module.ts +27 -0
  21. package/src/api/balance.controller.ts +41 -0
  22. package/src/api/quote.controller.ts +54 -0
  23. package/src/api/tests/balance.controller.spec.ts +113 -0
  24. package/src/api/tests/quote.controller.spec.ts +83 -0
  25. package/src/app.module.ts +74 -0
  26. package/src/balance/balance.module.ts +14 -0
  27. package/src/balance/balance.service.ts +230 -0
  28. package/src/balance/balance.ws.service.ts +104 -0
  29. package/src/balance/types.ts +16 -0
  30. package/src/bullmq/bullmq.helper.ts +41 -0
  31. package/src/bullmq/processors/eth-ws.processor.ts +47 -0
  32. package/src/bullmq/processors/inbox.processor.ts +55 -0
  33. package/src/bullmq/processors/interval.processor.ts +54 -0
  34. package/src/bullmq/processors/processor.module.ts +14 -0
  35. package/src/bullmq/processors/signer.processor.ts +41 -0
  36. package/src/bullmq/processors/solve-intent.processor.ts +73 -0
  37. package/src/bullmq/processors/tests/solve-intent.processor.spec.ts +3 -0
  38. package/src/bullmq/utils/queue.ts +22 -0
  39. package/src/chain-monitor/chain-monitor.module.ts +12 -0
  40. package/src/chain-monitor/chain-sync.service.ts +134 -0
  41. package/src/chain-monitor/tests/chain-sync.service.spec.ts +190 -0
  42. package/src/commander/.eslintrc.js +6 -0
  43. package/src/commander/balance/balance-command.module.ts +12 -0
  44. package/src/commander/balance/balance.command.ts +73 -0
  45. package/src/commander/command-main.ts +15 -0
  46. package/src/commander/commander-app.module.ts +31 -0
  47. package/src/commander/eco-config.command.ts +20 -0
  48. package/src/commander/safe/safe-command.module.ts +11 -0
  49. package/src/commander/safe/safe.command.ts +70 -0
  50. package/src/commander/transfer/client.command.ts +24 -0
  51. package/src/commander/transfer/transfer-command.module.ts +26 -0
  52. package/src/commander/transfer/transfer.command.ts +138 -0
  53. package/src/commander/utils.ts +8 -0
  54. package/src/common/chains/definitions/arbitrum.ts +12 -0
  55. package/src/common/chains/definitions/base.ts +21 -0
  56. package/src/common/chains/definitions/eco.ts +54 -0
  57. package/src/common/chains/definitions/ethereum.ts +22 -0
  58. package/src/common/chains/definitions/helix.ts +53 -0
  59. package/src/common/chains/definitions/mantle.ts +12 -0
  60. package/src/common/chains/definitions/optimism.ts +22 -0
  61. package/src/common/chains/definitions/polygon.ts +12 -0
  62. package/src/common/chains/supported.ts +26 -0
  63. package/src/common/chains/transport.ts +19 -0
  64. package/src/common/errors/eco-error.ts +155 -0
  65. package/src/common/events/constants.ts +3 -0
  66. package/src/common/events/viem.ts +22 -0
  67. package/src/common/logging/eco-log-message.ts +74 -0
  68. package/src/common/redis/constants.ts +55 -0
  69. package/src/common/redis/redis-connection-utils.ts +106 -0
  70. package/src/common/routes/constants.ts +3 -0
  71. package/src/common/utils/objects.ts +34 -0
  72. package/src/common/utils/strings.ts +49 -0
  73. package/src/common/utils/tests/objects.spec.ts +23 -0
  74. package/src/common/utils/tests/strings.spec.ts +22 -0
  75. package/src/common/viem/contracts.ts +25 -0
  76. package/src/common/viem/tests/utils.spec.ts +115 -0
  77. package/src/common/viem/utils.ts +78 -0
  78. package/src/contracts/ERC20.contract.ts +389 -0
  79. package/src/contracts/EntryPoint.V6.contract.ts +1309 -0
  80. package/src/contracts/KernelAccount.abi.ts +87 -0
  81. package/src/contracts/OwnableExecutor.abi.ts +128 -0
  82. package/src/contracts/SimpleAccount.contract.ts +524 -0
  83. package/src/contracts/inbox.ts +8 -0
  84. package/src/contracts/index.ts +9 -0
  85. package/src/contracts/intent-source.ts +55 -0
  86. package/src/contracts/interfaces/index.ts +1 -0
  87. package/src/contracts/interfaces/prover.interface.ts +22 -0
  88. package/src/contracts/prover.ts +9 -0
  89. package/src/contracts/tests/erc20.contract.spec.ts +59 -0
  90. package/src/contracts/utils.ts +31 -0
  91. package/src/decoder/decoder.interface.ts +3 -0
  92. package/src/decoder/tests/utils.spec.ts +36 -0
  93. package/src/decoder/utils.ts +24 -0
  94. package/src/decorators/cacheable.decorator.ts +48 -0
  95. package/src/eco-configs/aws-config.service.ts +75 -0
  96. package/src/eco-configs/eco-config.module.ts +44 -0
  97. package/src/eco-configs/eco-config.service.ts +220 -0
  98. package/src/eco-configs/eco-config.types.ts +278 -0
  99. package/src/eco-configs/interfaces/config-source.interface.ts +3 -0
  100. package/src/eco-configs/tests/aws-config.service.spec.ts +52 -0
  101. package/src/eco-configs/tests/eco-config.service.spec.ts +137 -0
  102. package/src/eco-configs/tests/utils.spec.ts +84 -0
  103. package/src/eco-configs/utils.ts +49 -0
  104. package/src/fee/fee.module.ts +10 -0
  105. package/src/fee/fee.service.ts +467 -0
  106. package/src/fee/tests/fee.service.spec.ts +909 -0
  107. package/src/fee/tests/utils.spec.ts +49 -0
  108. package/src/fee/types.ts +44 -0
  109. package/src/fee/utils.ts +23 -0
  110. package/src/flags/flags.module.ts +10 -0
  111. package/src/flags/flags.service.ts +112 -0
  112. package/src/flags/tests/flags.service.spec.ts +68 -0
  113. package/src/flags/utils.ts +22 -0
  114. package/src/health/constants.ts +1 -0
  115. package/src/health/health.controller.ts +23 -0
  116. package/src/health/health.module.ts +25 -0
  117. package/src/health/health.service.ts +40 -0
  118. package/src/health/indicators/balance.indicator.ts +196 -0
  119. package/src/health/indicators/eco-redis.indicator.ts +23 -0
  120. package/src/health/indicators/git-commit.indicator.ts +67 -0
  121. package/src/health/indicators/mongodb.indicator.ts +11 -0
  122. package/src/health/indicators/permission.indicator.ts +64 -0
  123. package/src/intent/create-intent.service.ts +129 -0
  124. package/src/intent/feasable-intent.service.ts +80 -0
  125. package/src/intent/fulfill-intent.service.ts +318 -0
  126. package/src/intent/intent.controller.ts +199 -0
  127. package/src/intent/intent.module.ts +49 -0
  128. package/src/intent/schemas/intent-call-data.schema.ts +16 -0
  129. package/src/intent/schemas/intent-data.schema.ts +114 -0
  130. package/src/intent/schemas/intent-source.schema.ts +33 -0
  131. package/src/intent/schemas/intent-token-amount.schema.ts +14 -0
  132. package/src/intent/schemas/reward-data.schema.ts +48 -0
  133. package/src/intent/schemas/route-data.schema.ts +52 -0
  134. package/src/intent/schemas/watch-event.schema.ts +32 -0
  135. package/src/intent/tests/create-intent.service.spec.ts +215 -0
  136. package/src/intent/tests/feasable-intent.service.spec.ts +155 -0
  137. package/src/intent/tests/fulfill-intent.service.spec.ts +564 -0
  138. package/src/intent/tests/utils-intent.service.spec.ts +308 -0
  139. package/src/intent/tests/utils.spec.ts +62 -0
  140. package/src/intent/tests/validate-intent.service.spec.ts +297 -0
  141. package/src/intent/tests/validation.service.spec.ts +337 -0
  142. package/src/intent/utils-intent.service.ts +168 -0
  143. package/src/intent/utils.ts +37 -0
  144. package/src/intent/validate-intent.service.ts +176 -0
  145. package/src/intent/validation.sevice.ts +223 -0
  146. package/src/interceptors/big-int.interceptor.ts +30 -0
  147. package/src/intervals/interval.module.ts +18 -0
  148. package/src/intervals/retry-infeasable-intents.service.ts +89 -0
  149. package/src/intervals/tests/retry-infeasable-intents.service.spec.ts +167 -0
  150. package/src/kms/errors.ts +0 -0
  151. package/src/kms/kms.module.ts +12 -0
  152. package/src/kms/kms.service.ts +65 -0
  153. package/src/kms/tests/kms.service.spec.ts +60 -0
  154. package/src/liquidity-manager/jobs/check-balances-cron.job.ts +229 -0
  155. package/src/liquidity-manager/jobs/liquidity-manager.job.ts +52 -0
  156. package/src/liquidity-manager/jobs/rebalance.job.ts +61 -0
  157. package/src/liquidity-manager/liquidity-manager.module.ts +29 -0
  158. package/src/liquidity-manager/processors/base.processor.ts +117 -0
  159. package/src/liquidity-manager/processors/eco-protocol-intents.processor.ts +34 -0
  160. package/src/liquidity-manager/processors/grouped-jobs.processor.ts +103 -0
  161. package/src/liquidity-manager/queues/liquidity-manager.queue.ts +48 -0
  162. package/src/liquidity-manager/schemas/rebalance-token.schema.ts +32 -0
  163. package/src/liquidity-manager/schemas/rebalance.schema.ts +32 -0
  164. package/src/liquidity-manager/services/liquidity-manager.service.ts +188 -0
  165. package/src/liquidity-manager/services/liquidity-provider.service.ts +25 -0
  166. package/src/liquidity-manager/services/liquidity-providers/LiFi/lifi-provider.service.spec.ts +125 -0
  167. package/src/liquidity-manager/services/liquidity-providers/LiFi/lifi-provider.service.ts +117 -0
  168. package/src/liquidity-manager/services/liquidity-providers/LiFi/utils/get-transaction-hashes.ts +16 -0
  169. package/src/liquidity-manager/tests/liquidity-manager.service.spec.ts +142 -0
  170. package/src/liquidity-manager/types/token-state.enum.ts +5 -0
  171. package/src/liquidity-manager/types/types.d.ts +52 -0
  172. package/src/liquidity-manager/utils/address.ts +5 -0
  173. package/src/liquidity-manager/utils/math.ts +9 -0
  174. package/src/liquidity-manager/utils/serialize.spec.ts +24 -0
  175. package/src/liquidity-manager/utils/serialize.ts +47 -0
  176. package/src/liquidity-manager/utils/token.ts +91 -0
  177. package/src/main.ts +63 -0
  178. package/src/nest-redlock/nest-redlock.config.ts +14 -0
  179. package/src/nest-redlock/nest-redlock.interface.ts +5 -0
  180. package/src/nest-redlock/nest-redlock.module.ts +64 -0
  181. package/src/nest-redlock/nest-redlock.service.ts +59 -0
  182. package/src/prover/proof.service.ts +184 -0
  183. package/src/prover/prover.module.ts +10 -0
  184. package/src/prover/tests/proof.service.spec.ts +154 -0
  185. package/src/quote/dto/quote.intent.data.dto.ts +35 -0
  186. package/src/quote/dto/quote.reward.data.dto.ts +67 -0
  187. package/src/quote/dto/quote.route.data.dto.ts +71 -0
  188. package/src/quote/dto/types.ts +18 -0
  189. package/src/quote/errors.ts +215 -0
  190. package/src/quote/quote.module.ts +17 -0
  191. package/src/quote/quote.service.ts +299 -0
  192. package/src/quote/schemas/quote-call.schema.ts +16 -0
  193. package/src/quote/schemas/quote-intent.schema.ts +27 -0
  194. package/src/quote/schemas/quote-reward.schema.ts +24 -0
  195. package/src/quote/schemas/quote-route.schema.ts +30 -0
  196. package/src/quote/schemas/quote-token.schema.ts +14 -0
  197. package/src/quote/tests/quote.service.spec.ts +444 -0
  198. package/src/sign/atomic-signer.service.ts +24 -0
  199. package/src/sign/atomic.nonce.service.ts +114 -0
  200. package/src/sign/kms-account/kmsToAccount.ts +73 -0
  201. package/src/sign/kms-account/signKms.ts +30 -0
  202. package/src/sign/kms-account/signKmsTransaction.ts +37 -0
  203. package/src/sign/kms-account/signKmsTypedData.ts +21 -0
  204. package/src/sign/nonce.service.ts +89 -0
  205. package/src/sign/schemas/nonce.schema.ts +36 -0
  206. package/src/sign/sign.controller.ts +52 -0
  207. package/src/sign/sign.helper.ts +23 -0
  208. package/src/sign/sign.module.ts +27 -0
  209. package/src/sign/signer-kms.service.ts +27 -0
  210. package/src/sign/signer.service.ts +26 -0
  211. package/src/solver/filters/tests/valid-smart-wallet.service.spec.ts +87 -0
  212. package/src/solver/filters/valid-smart-wallet.service.ts +58 -0
  213. package/src/solver/solver.module.ts +10 -0
  214. package/src/transaction/multichain-public-client.service.ts +15 -0
  215. package/src/transaction/smart-wallets/kernel/actions/encodeData.kernel.ts +57 -0
  216. package/src/transaction/smart-wallets/kernel/create-kernel-client-v2.account.ts +183 -0
  217. package/src/transaction/smart-wallets/kernel/create.kernel.account.ts +270 -0
  218. package/src/transaction/smart-wallets/kernel/index.ts +2 -0
  219. package/src/transaction/smart-wallets/kernel/kernel-account-client-v2.service.ts +90 -0
  220. package/src/transaction/smart-wallets/kernel/kernel-account-client.service.ts +107 -0
  221. package/src/transaction/smart-wallets/kernel/kernel-account.client.ts +105 -0
  222. package/src/transaction/smart-wallets/kernel/kernel-account.config.ts +34 -0
  223. package/src/transaction/smart-wallets/simple-account/create.simple.account.ts +19 -0
  224. package/src/transaction/smart-wallets/simple-account/index.ts +2 -0
  225. package/src/transaction/smart-wallets/simple-account/simple-account-client.service.ts +42 -0
  226. package/src/transaction/smart-wallets/simple-account/simple-account.client.ts +83 -0
  227. package/src/transaction/smart-wallets/simple-account/simple-account.config.ts +5 -0
  228. package/src/transaction/smart-wallets/smart-wallet.types.ts +38 -0
  229. package/src/transaction/smart-wallets/utils.ts +14 -0
  230. package/src/transaction/transaction.module.ts +25 -0
  231. package/src/transaction/viem_multichain_client.service.ts +100 -0
  232. package/src/transforms/viem-address.decorator.ts +14 -0
  233. package/src/utils/bigint.ts +44 -0
  234. package/src/utils/types.ts +18 -0
  235. package/src/watch/intent/tests/watch-create-intent.service.spec.ts +257 -0
  236. package/src/watch/intent/tests/watch-fulfillment.service.spec.ts +141 -0
  237. package/src/watch/intent/watch-create-intent.service.ts +106 -0
  238. package/src/watch/intent/watch-event.service.ts +133 -0
  239. package/src/watch/intent/watch-fulfillment.service.ts +115 -0
  240. package/src/watch/watch.module.ts +13 -0
  241. package/test/app.e2e-spec.ts +21 -0
  242. package/test/jest-e2e.json +9 -0
  243. package/tsconfig.build.json +4 -0
  244. package/tsconfig.json +29 -0
@@ -0,0 +1,524 @@
1
+ export const SimpleAccountAbi = [
2
+ {
3
+ inputs: [
4
+ {
5
+ internalType: 'contract IEntryPoint',
6
+ name: 'anEntryPoint',
7
+ type: 'address',
8
+ },
9
+ ],
10
+ stateMutability: 'nonpayable',
11
+ type: 'constructor',
12
+ },
13
+ {
14
+ anonymous: false,
15
+ inputs: [
16
+ {
17
+ indexed: false,
18
+ internalType: 'address',
19
+ name: 'previousAdmin',
20
+ type: 'address',
21
+ },
22
+ {
23
+ indexed: false,
24
+ internalType: 'address',
25
+ name: 'newAdmin',
26
+ type: 'address',
27
+ },
28
+ ],
29
+ name: 'AdminChanged',
30
+ type: 'event',
31
+ },
32
+ {
33
+ anonymous: false,
34
+ inputs: [
35
+ {
36
+ indexed: true,
37
+ internalType: 'address',
38
+ name: 'beacon',
39
+ type: 'address',
40
+ },
41
+ ],
42
+ name: 'BeaconUpgraded',
43
+ type: 'event',
44
+ },
45
+ {
46
+ anonymous: false,
47
+ inputs: [
48
+ {
49
+ indexed: false,
50
+ internalType: 'uint8',
51
+ name: 'version',
52
+ type: 'uint8',
53
+ },
54
+ ],
55
+ name: 'Initialized',
56
+ type: 'event',
57
+ },
58
+ {
59
+ anonymous: false,
60
+ inputs: [
61
+ {
62
+ indexed: true,
63
+ internalType: 'contract IEntryPoint',
64
+ name: 'entryPoint',
65
+ type: 'address',
66
+ },
67
+ {
68
+ indexed: true,
69
+ internalType: 'address',
70
+ name: 'owner',
71
+ type: 'address',
72
+ },
73
+ ],
74
+ name: 'SimpleAccountInitialized',
75
+ type: 'event',
76
+ },
77
+ {
78
+ anonymous: false,
79
+ inputs: [
80
+ {
81
+ indexed: true,
82
+ internalType: 'address',
83
+ name: 'implementation',
84
+ type: 'address',
85
+ },
86
+ ],
87
+ name: 'Upgraded',
88
+ type: 'event',
89
+ },
90
+ {
91
+ inputs: [],
92
+ name: 'addDeposit',
93
+ outputs: [],
94
+ stateMutability: 'payable',
95
+ type: 'function',
96
+ },
97
+ {
98
+ inputs: [],
99
+ name: 'entryPoint',
100
+ outputs: [
101
+ {
102
+ internalType: 'contract IEntryPoint',
103
+ name: '',
104
+ type: 'address',
105
+ },
106
+ ],
107
+ stateMutability: 'view',
108
+ type: 'function',
109
+ },
110
+ {
111
+ inputs: [
112
+ {
113
+ internalType: 'address',
114
+ name: 'dest',
115
+ type: 'address',
116
+ },
117
+ {
118
+ internalType: 'uint256',
119
+ name: 'value',
120
+ type: 'uint256',
121
+ },
122
+ {
123
+ internalType: 'bytes',
124
+ name: 'func',
125
+ type: 'bytes',
126
+ },
127
+ ],
128
+ name: 'execute',
129
+ outputs: [],
130
+ stateMutability: 'nonpayable',
131
+ type: 'function',
132
+ },
133
+ {
134
+ inputs: [
135
+ {
136
+ internalType: 'address[]',
137
+ name: 'dest',
138
+ type: 'address[]',
139
+ },
140
+ {
141
+ internalType: 'bytes[]',
142
+ name: 'func',
143
+ type: 'bytes[]',
144
+ },
145
+ ],
146
+ name: 'executeBatch',
147
+ outputs: [],
148
+ stateMutability: 'nonpayable',
149
+ type: 'function',
150
+ },
151
+ {
152
+ inputs: [],
153
+ name: 'getDeposit',
154
+ outputs: [
155
+ {
156
+ internalType: 'uint256',
157
+ name: '',
158
+ type: 'uint256',
159
+ },
160
+ ],
161
+ stateMutability: 'view',
162
+ type: 'function',
163
+ },
164
+ {
165
+ inputs: [],
166
+ name: 'getNonce',
167
+ outputs: [
168
+ {
169
+ internalType: 'uint256',
170
+ name: '',
171
+ type: 'uint256',
172
+ },
173
+ ],
174
+ stateMutability: 'view',
175
+ type: 'function',
176
+ },
177
+ {
178
+ inputs: [
179
+ {
180
+ internalType: 'address',
181
+ name: 'anOwner',
182
+ type: 'address',
183
+ },
184
+ ],
185
+ name: 'initialize',
186
+ outputs: [],
187
+ stateMutability: 'nonpayable',
188
+ type: 'function',
189
+ },
190
+ {
191
+ inputs: [
192
+ {
193
+ internalType: 'address',
194
+ name: '',
195
+ type: 'address',
196
+ },
197
+ {
198
+ internalType: 'address',
199
+ name: '',
200
+ type: 'address',
201
+ },
202
+ {
203
+ internalType: 'uint256[]',
204
+ name: '',
205
+ type: 'uint256[]',
206
+ },
207
+ {
208
+ internalType: 'uint256[]',
209
+ name: '',
210
+ type: 'uint256[]',
211
+ },
212
+ {
213
+ internalType: 'bytes',
214
+ name: '',
215
+ type: 'bytes',
216
+ },
217
+ ],
218
+ name: 'onERC1155BatchReceived',
219
+ outputs: [
220
+ {
221
+ internalType: 'bytes4',
222
+ name: '',
223
+ type: 'bytes4',
224
+ },
225
+ ],
226
+ stateMutability: 'pure',
227
+ type: 'function',
228
+ },
229
+ {
230
+ inputs: [
231
+ {
232
+ internalType: 'address',
233
+ name: '',
234
+ type: 'address',
235
+ },
236
+ {
237
+ internalType: 'address',
238
+ name: '',
239
+ type: 'address',
240
+ },
241
+ {
242
+ internalType: 'uint256',
243
+ name: '',
244
+ type: 'uint256',
245
+ },
246
+ {
247
+ internalType: 'uint256',
248
+ name: '',
249
+ type: 'uint256',
250
+ },
251
+ {
252
+ internalType: 'bytes',
253
+ name: '',
254
+ type: 'bytes',
255
+ },
256
+ ],
257
+ name: 'onERC1155Received',
258
+ outputs: [
259
+ {
260
+ internalType: 'bytes4',
261
+ name: '',
262
+ type: 'bytes4',
263
+ },
264
+ ],
265
+ stateMutability: 'pure',
266
+ type: 'function',
267
+ },
268
+ {
269
+ inputs: [
270
+ {
271
+ internalType: 'address',
272
+ name: '',
273
+ type: 'address',
274
+ },
275
+ {
276
+ internalType: 'address',
277
+ name: '',
278
+ type: 'address',
279
+ },
280
+ {
281
+ internalType: 'uint256',
282
+ name: '',
283
+ type: 'uint256',
284
+ },
285
+ {
286
+ internalType: 'bytes',
287
+ name: '',
288
+ type: 'bytes',
289
+ },
290
+ ],
291
+ name: 'onERC721Received',
292
+ outputs: [
293
+ {
294
+ internalType: 'bytes4',
295
+ name: '',
296
+ type: 'bytes4',
297
+ },
298
+ ],
299
+ stateMutability: 'pure',
300
+ type: 'function',
301
+ },
302
+ {
303
+ inputs: [],
304
+ name: 'owner',
305
+ outputs: [
306
+ {
307
+ internalType: 'address',
308
+ name: '',
309
+ type: 'address',
310
+ },
311
+ ],
312
+ stateMutability: 'view',
313
+ type: 'function',
314
+ },
315
+ {
316
+ inputs: [],
317
+ name: 'proxiableUUID',
318
+ outputs: [
319
+ {
320
+ internalType: 'bytes32',
321
+ name: '',
322
+ type: 'bytes32',
323
+ },
324
+ ],
325
+ stateMutability: 'view',
326
+ type: 'function',
327
+ },
328
+ {
329
+ inputs: [
330
+ {
331
+ internalType: 'bytes4',
332
+ name: 'interfaceId',
333
+ type: 'bytes4',
334
+ },
335
+ ],
336
+ name: 'supportsInterface',
337
+ outputs: [
338
+ {
339
+ internalType: 'bool',
340
+ name: '',
341
+ type: 'bool',
342
+ },
343
+ ],
344
+ stateMutability: 'view',
345
+ type: 'function',
346
+ },
347
+ {
348
+ inputs: [
349
+ {
350
+ internalType: 'address',
351
+ name: '',
352
+ type: 'address',
353
+ },
354
+ {
355
+ internalType: 'address',
356
+ name: '',
357
+ type: 'address',
358
+ },
359
+ {
360
+ internalType: 'address',
361
+ name: '',
362
+ type: 'address',
363
+ },
364
+ {
365
+ internalType: 'uint256',
366
+ name: '',
367
+ type: 'uint256',
368
+ },
369
+ {
370
+ internalType: 'bytes',
371
+ name: '',
372
+ type: 'bytes',
373
+ },
374
+ {
375
+ internalType: 'bytes',
376
+ name: '',
377
+ type: 'bytes',
378
+ },
379
+ ],
380
+ name: 'tokensReceived',
381
+ outputs: [],
382
+ stateMutability: 'pure',
383
+ type: 'function',
384
+ },
385
+ {
386
+ inputs: [
387
+ {
388
+ internalType: 'address',
389
+ name: 'newImplementation',
390
+ type: 'address',
391
+ },
392
+ ],
393
+ name: 'upgradeTo',
394
+ outputs: [],
395
+ stateMutability: 'nonpayable',
396
+ type: 'function',
397
+ },
398
+ {
399
+ inputs: [
400
+ {
401
+ internalType: 'address',
402
+ name: 'newImplementation',
403
+ type: 'address',
404
+ },
405
+ {
406
+ internalType: 'bytes',
407
+ name: 'data',
408
+ type: 'bytes',
409
+ },
410
+ ],
411
+ name: 'upgradeToAndCall',
412
+ outputs: [],
413
+ stateMutability: 'payable',
414
+ type: 'function',
415
+ },
416
+ {
417
+ inputs: [
418
+ {
419
+ components: [
420
+ {
421
+ internalType: 'address',
422
+ name: 'sender',
423
+ type: 'address',
424
+ },
425
+ {
426
+ internalType: 'uint256',
427
+ name: 'nonce',
428
+ type: 'uint256',
429
+ },
430
+ {
431
+ internalType: 'bytes',
432
+ name: 'initCode',
433
+ type: 'bytes',
434
+ },
435
+ {
436
+ internalType: 'bytes',
437
+ name: 'callData',
438
+ type: 'bytes',
439
+ },
440
+ {
441
+ internalType: 'uint256',
442
+ name: 'callGasLimit',
443
+ type: 'uint256',
444
+ },
445
+ {
446
+ internalType: 'uint256',
447
+ name: 'verificationGasLimit',
448
+ type: 'uint256',
449
+ },
450
+ {
451
+ internalType: 'uint256',
452
+ name: 'preVerificationGas',
453
+ type: 'uint256',
454
+ },
455
+ {
456
+ internalType: 'uint256',
457
+ name: 'maxFeePerGas',
458
+ type: 'uint256',
459
+ },
460
+ {
461
+ internalType: 'uint256',
462
+ name: 'maxPriorityFeePerGas',
463
+ type: 'uint256',
464
+ },
465
+ {
466
+ internalType: 'bytes',
467
+ name: 'paymasterAndData',
468
+ type: 'bytes',
469
+ },
470
+ {
471
+ internalType: 'bytes',
472
+ name: 'signature',
473
+ type: 'bytes',
474
+ },
475
+ ],
476
+ internalType: 'struct UserOperation',
477
+ name: 'userOp',
478
+ type: 'tuple',
479
+ },
480
+ {
481
+ internalType: 'bytes32',
482
+ name: 'userOpHash',
483
+ type: 'bytes32',
484
+ },
485
+ {
486
+ internalType: 'uint256',
487
+ name: 'missingAccountFunds',
488
+ type: 'uint256',
489
+ },
490
+ ],
491
+ name: 'validateUserOp',
492
+ outputs: [
493
+ {
494
+ internalType: 'uint256',
495
+ name: 'validationData',
496
+ type: 'uint256',
497
+ },
498
+ ],
499
+ stateMutability: 'nonpayable',
500
+ type: 'function',
501
+ },
502
+ {
503
+ inputs: [
504
+ {
505
+ internalType: 'address payable',
506
+ name: 'withdrawAddress',
507
+ type: 'address',
508
+ },
509
+ {
510
+ internalType: 'uint256',
511
+ name: 'amount',
512
+ type: 'uint256',
513
+ },
514
+ ],
515
+ name: 'withdrawDepositTo',
516
+ outputs: [],
517
+ stateMutability: 'nonpayable',
518
+ type: 'function',
519
+ },
520
+ {
521
+ stateMutability: 'payable',
522
+ type: 'receive',
523
+ },
524
+ ] as const
@@ -0,0 +1,8 @@
1
+ import { InboxAbi } from '@eco-foundation/routes-ts'
2
+ import { ExtractAbiEvent } from 'abitype'
3
+ import { Prettify, Log } from 'viem'
4
+
5
+ // Define the type for the Fulfillment event log
6
+ export type FulfillmentLog = Prettify<
7
+ Log<bigint, number, false, ExtractAbiEvent<typeof InboxAbi, 'Fulfillment'>, true>
8
+ >
@@ -0,0 +1,9 @@
1
+ export * from './ERC20.contract'
2
+ export * from './intent-source'
3
+ export * from './prover'
4
+ export * from './SimpleAccount.contract'
5
+ export * from './utils'
6
+ export * from './KernelAccount.abi'
7
+ export * from './OwnableExecutor.abi'
8
+ // interfaces
9
+ export * from './interfaces'
@@ -0,0 +1,55 @@
1
+ import { decodeEventLog, DecodeEventLogReturnType, GetEventArgs, Hex, Log, Prettify } from 'viem'
2
+ import { ExtractAbiEvent } from 'abitype'
3
+ import { Network } from 'alchemy-sdk'
4
+ import { IntentSourceAbi } from '@eco-foundation/routes-ts'
5
+ import { CallDataType, RewardTokensType } from '@/quote/dto/types'
6
+
7
+ // Define the type for the IntentSource struct in the contract, and add the hash and logIndex fields
8
+ export type IntentCreatedEventViemType = Prettify<
9
+ GetEventArgs<
10
+ typeof IntentSourceAbi,
11
+ 'IntentCreated',
12
+ {
13
+ EnableUnion: true
14
+ IndexedOnly: false
15
+ Required: false
16
+ }
17
+ > & {
18
+ hash: Hex
19
+ logIndex: number
20
+ }
21
+ >
22
+ /**
23
+ * Define the interface for the calls field in the IntentSource event
24
+ */
25
+ export interface CallDataInterface extends CallDataType {}
26
+
27
+ /**
28
+ * Define the interface for the token amount field in the IntentSource event
29
+ */
30
+ export interface RewardTokensInterface extends RewardTokensType {}
31
+
32
+ /**
33
+ * Define the type for the IntentSource event log
34
+ */
35
+ export type IntentCreatedEventLog = DecodeEventLogReturnType<
36
+ typeof IntentSourceAbi,
37
+ 'IntentCreated'
38
+ >
39
+
40
+ // Define the type for the IntentCreated event log
41
+ export type IntentCreatedLog = Prettify<
42
+ Log<bigint, number, false, ExtractAbiEvent<typeof IntentSourceAbi, 'IntentCreated'>, true> & {
43
+ sourceNetwork: Network
44
+ sourceChainID: bigint
45
+ }
46
+ >
47
+
48
+ export function decodeCreateIntentLog(data: Hex, topics: [signature: Hex, ...args: Hex[]] | []) {
49
+ return decodeEventLog({
50
+ abi: IntentSourceAbi,
51
+ eventName: 'IntentCreated',
52
+ topics,
53
+ data,
54
+ })
55
+ }
@@ -0,0 +1 @@
1
+ export * from './prover.interface'
@@ -0,0 +1,22 @@
1
+ import { ViemCall } from '../utils'
2
+
3
+ export const ProverInterfaceAbi = [
4
+ {
5
+ inputs: [],
6
+ name: 'getProofType',
7
+ outputs: [
8
+ {
9
+ internalType: 'enum IProver.ProofType',
10
+ name: '',
11
+ type: 'uint8',
12
+ },
13
+ ],
14
+ stateMutability: 'pure',
15
+ type: 'function',
16
+ },
17
+ ] as const
18
+
19
+ /**
20
+ * Call type for the getProofType function
21
+ */
22
+ export type ProofCall = ViemCall<typeof ProverInterfaceAbi, 'pure'>
@@ -0,0 +1,9 @@
1
+ export const PROOF_STORAGE = 0
2
+ export const PROOF_HYPERLANE = 1
3
+
4
+ export type ProofType = typeof PROOF_STORAGE | typeof PROOF_HYPERLANE
5
+
6
+ export const Proofs: Record<string, ProofType> = {
7
+ Storage: PROOF_STORAGE,
8
+ Hyperlane: PROOF_HYPERLANE,
9
+ }
@@ -0,0 +1,59 @@
1
+ import { isERC20Target } from '@/contracts/ERC20.contract'
2
+ const address1 = '0x1111111111111111111111111111111111111111'
3
+
4
+ describe('ERC20 contract', () => {
5
+ describe('on isERC20Target', () => {
6
+ it('should return false if the target data is null', async () => {
7
+ expect(isERC20Target(null)).toBe(false)
8
+ })
9
+
10
+ it('should return false if the target data is not erc20', async () => {
11
+ expect(
12
+ isERC20Target({
13
+ targetConfig: { contractType: 'erc721' },
14
+ } as any),
15
+ ).toBe(false)
16
+ })
17
+
18
+ it('should return false if the target selector isnt the permitted selector', async () => {
19
+ expect(
20
+ isERC20Target(
21
+ {
22
+ targetConfig: { contractType: 'erc20' },
23
+ selector: '0x70a08231', //balanceOf
24
+ } as any,
25
+ '0xa123123',
26
+ ),
27
+ ).toBe(false)
28
+ })
29
+
30
+ it('should return false if the target selector is not transfer', async () => {
31
+ expect(
32
+ isERC20Target({
33
+ targetConfig: { contractType: 'erc20' },
34
+ selector: '0x70a08231', //balanceOf
35
+ } as any),
36
+ ).toBe(false)
37
+ })
38
+
39
+ it('should return false if the target selector args are incorrect', async () => {
40
+ expect(
41
+ isERC20Target({
42
+ targetConfig: { contractType: 'erc20' },
43
+ selector: '0xa9059cbb', //transfer
44
+ decodedFunctionData: { args: [address1] },
45
+ } as any),
46
+ ).toBe(false)
47
+ })
48
+
49
+ it('should return true if the target selector and args are for erc20 transfer', async () => {
50
+ expect(
51
+ isERC20Target({
52
+ targetConfig: { contractType: 'erc20' },
53
+ selector: '0xa9059cbb', //transfer
54
+ decodedFunctionData: { args: [address1, 100n] },
55
+ } as any),
56
+ ).toBe(true)
57
+ })
58
+ })
59
+ })