@layerzerolabs/protocol-starknet-v2 0.0.34

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 (504) hide show
  1. package/.turbo/turbo-build.log +186 -0
  2. package/.turbo/turbo-lint.log +71 -0
  3. package/.turbo/turbo-test.log +937 -0
  4. package/README.md +41 -0
  5. package/Scarb.lock +211 -0
  6. package/Scarb.toml +2 -0
  7. package/dist/4XD3ZRZ4.cjs +301 -0
  8. package/dist/4XD3ZRZ4.cjs.map +1 -0
  9. package/dist/4Z5IPBC3.js +299 -0
  10. package/dist/4Z5IPBC3.js.map +1 -0
  11. package/dist/5NEZDLVQ.cjs +474 -0
  12. package/dist/5NEZDLVQ.cjs.map +1 -0
  13. package/dist/6JYCOKDE.js +472 -0
  14. package/dist/6JYCOKDE.js.map +1 -0
  15. package/dist/7C4PFMIZ.cjs +1288 -0
  16. package/dist/7C4PFMIZ.cjs.map +1 -0
  17. package/dist/7ZSGGZUE.js +1229 -0
  18. package/dist/7ZSGGZUE.js.map +1 -0
  19. package/dist/ARHOGUYH.cjs +2136 -0
  20. package/dist/ARHOGUYH.cjs.map +1 -0
  21. package/dist/CRCRIUFX.js +1264 -0
  22. package/dist/CRCRIUFX.js.map +1 -0
  23. package/dist/DB7CQSED.cjs +430 -0
  24. package/dist/DB7CQSED.cjs.map +1 -0
  25. package/dist/DFXLWHYP.cjs +1266 -0
  26. package/dist/DFXLWHYP.cjs.map +1 -0
  27. package/dist/EOLZCMCK.js +988 -0
  28. package/dist/EOLZCMCK.js.map +1 -0
  29. package/dist/FFDPTOWG.cjs +331 -0
  30. package/dist/FFDPTOWG.cjs.map +1 -0
  31. package/dist/FOJGEAIO.js +2134 -0
  32. package/dist/FOJGEAIO.js.map +1 -0
  33. package/dist/IWIUMVGB.js +629 -0
  34. package/dist/IWIUMVGB.js.map +1 -0
  35. package/dist/MUEN6AWV.cjs +697 -0
  36. package/dist/MUEN6AWV.cjs.map +1 -0
  37. package/dist/ORE6VBZ4.cjs +990 -0
  38. package/dist/ORE6VBZ4.cjs.map +1 -0
  39. package/dist/OUFKWPZ7.js +732 -0
  40. package/dist/OUFKWPZ7.js.map +1 -0
  41. package/dist/T2QTYQXJ.js +1229 -0
  42. package/dist/T2QTYQXJ.js.map +1 -0
  43. package/dist/UPJTM7BR.cjs +631 -0
  44. package/dist/UPJTM7BR.cjs.map +1 -0
  45. package/dist/VNVNX2P3.cjs +1231 -0
  46. package/dist/VNVNX2P3.cjs.map +1 -0
  47. package/dist/VUOMXK5T.js +6 -0
  48. package/dist/VUOMXK5T.js.map +1 -0
  49. package/dist/WISWRTDG.js +1286 -0
  50. package/dist/WISWRTDG.js.map +1 -0
  51. package/dist/WU5L7YIQ.cjs +1231 -0
  52. package/dist/WU5L7YIQ.cjs.map +1 -0
  53. package/dist/X3B5JDMZ.js +695 -0
  54. package/dist/X3B5JDMZ.js.map +1 -0
  55. package/dist/XYNBDBBV.cjs +297 -0
  56. package/dist/XYNBDBBV.cjs.map +1 -0
  57. package/dist/Y5JFPCYJ.cjs +734 -0
  58. package/dist/Y5JFPCYJ.cjs.map +1 -0
  59. package/dist/YEHL7IYO.js +295 -0
  60. package/dist/YEHL7IYO.js.map +1 -0
  61. package/dist/YJF4D23A.cjs +8 -0
  62. package/dist/YJF4D23A.cjs.map +1 -0
  63. package/dist/YTS44OEA.js +428 -0
  64. package/dist/YTS44OEA.js.map +1 -0
  65. package/dist/Z2NIUZMW.js +329 -0
  66. package/dist/Z2NIUZMW.js.map +1 -0
  67. package/dist/abis/blocked-message-lib.cjs +13 -0
  68. package/dist/abis/blocked-message-lib.cjs.map +1 -0
  69. package/dist/abis/blocked-message-lib.d.ts +338 -0
  70. package/dist/abis/blocked-message-lib.d.ts.map +1 -0
  71. package/dist/abis/blocked-message-lib.js +4 -0
  72. package/dist/abis/blocked-message-lib.js.map +1 -0
  73. package/dist/abis/dvn-fee-lib.cjs +13 -0
  74. package/dist/abis/dvn-fee-lib.cjs.map +1 -0
  75. package/dist/abis/dvn-fee-lib.d.ts +214 -0
  76. package/dist/abis/dvn-fee-lib.d.ts.map +1 -0
  77. package/dist/abis/dvn-fee-lib.js +4 -0
  78. package/dist/abis/dvn-fee-lib.js.map +1 -0
  79. package/dist/abis/dvn.cjs +13 -0
  80. package/dist/abis/dvn.cjs.map +1 -0
  81. package/dist/abis/dvn.d.ts +952 -0
  82. package/dist/abis/dvn.d.ts.map +1 -0
  83. package/dist/abis/dvn.js +4 -0
  84. package/dist/abis/dvn.js.map +1 -0
  85. package/dist/abis/endpoint-v2.cjs +13 -0
  86. package/dist/abis/endpoint-v2.cjs.map +1 -0
  87. package/dist/abis/endpoint-v2.d.ts +1580 -0
  88. package/dist/abis/endpoint-v2.d.ts.map +1 -0
  89. package/dist/abis/endpoint-v2.js +4 -0
  90. package/dist/abis/endpoint-v2.js.map +1 -0
  91. package/dist/abis/executor-fee-lib.cjs +13 -0
  92. package/dist/abis/executor-fee-lib.cjs.map +1 -0
  93. package/dist/abis/executor-fee-lib.d.ts +217 -0
  94. package/dist/abis/executor-fee-lib.d.ts.map +1 -0
  95. package/dist/abis/executor-fee-lib.js +4 -0
  96. package/dist/abis/executor-fee-lib.js.map +1 -0
  97. package/dist/abis/executor.cjs +13 -0
  98. package/dist/abis/executor.cjs.map +1 -0
  99. package/dist/abis/executor.d.ts +914 -0
  100. package/dist/abis/executor.d.ts.map +1 -0
  101. package/dist/abis/executor.js +4 -0
  102. package/dist/abis/executor.js.map +1 -0
  103. package/dist/abis/o-app.cjs +13 -0
  104. package/dist/abis/o-app.cjs.map +1 -0
  105. package/dist/abis/o-app.d.ts +311 -0
  106. package/dist/abis/o-app.d.ts.map +1 -0
  107. package/dist/abis/o-app.js +4 -0
  108. package/dist/abis/o-app.js.map +1 -0
  109. package/dist/abis/oft-adapter.cjs +13 -0
  110. package/dist/abis/oft-adapter.cjs.map +1 -0
  111. package/dist/abis/oft-adapter.d.ts +722 -0
  112. package/dist/abis/oft-adapter.d.ts.map +1 -0
  113. package/dist/abis/oft-adapter.js +4 -0
  114. package/dist/abis/oft-adapter.js.map +1 -0
  115. package/dist/abis/oft.cjs +13 -0
  116. package/dist/abis/oft.cjs.map +1 -0
  117. package/dist/abis/oft.d.ts +922 -0
  118. package/dist/abis/oft.d.ts.map +1 -0
  119. package/dist/abis/oft.js +4 -0
  120. package/dist/abis/oft.js.map +1 -0
  121. package/dist/abis/omni-counter.cjs +13 -0
  122. package/dist/abis/omni-counter.cjs.map +1 -0
  123. package/dist/abis/omni-counter.d.ts +459 -0
  124. package/dist/abis/omni-counter.d.ts.map +1 -0
  125. package/dist/abis/omni-counter.js +4 -0
  126. package/dist/abis/omni-counter.js.map +1 -0
  127. package/dist/abis/price-feed.cjs +13 -0
  128. package/dist/abis/price-feed.cjs.map +1 -0
  129. package/dist/abis/price-feed.d.ts +505 -0
  130. package/dist/abis/price-feed.d.ts.map +1 -0
  131. package/dist/abis/price-feed.js +4 -0
  132. package/dist/abis/price-feed.js.map +1 -0
  133. package/dist/abis/simple-message-lib.cjs +13 -0
  134. package/dist/abis/simple-message-lib.cjs.map +1 -0
  135. package/dist/abis/simple-message-lib.d.ts +535 -0
  136. package/dist/abis/simple-message-lib.d.ts.map +1 -0
  137. package/dist/abis/simple-message-lib.js +4 -0
  138. package/dist/abis/simple-message-lib.js.map +1 -0
  139. package/dist/abis/treasury.cjs +13 -0
  140. package/dist/abis/treasury.cjs.map +1 -0
  141. package/dist/abis/treasury.d.ts +240 -0
  142. package/dist/abis/treasury.d.ts.map +1 -0
  143. package/dist/abis/treasury.js +4 -0
  144. package/dist/abis/treasury.js.map +1 -0
  145. package/dist/abis/ultra-light-node.cjs +13 -0
  146. package/dist/abis/ultra-light-node.cjs.map +1 -0
  147. package/dist/abis/ultra-light-node.d.ts +900 -0
  148. package/dist/abis/ultra-light-node.d.ts.map +1 -0
  149. package/dist/abis/ultra-light-node.js +4 -0
  150. package/dist/abis/ultra-light-node.js.map +1 -0
  151. package/dist/index.cjs +78 -0
  152. package/dist/index.cjs.map +1 -0
  153. package/dist/index.d.ts +15 -0
  154. package/dist/index.d.ts.map +1 -0
  155. package/dist/index.js +17 -0
  156. package/dist/index.js.map +1 -0
  157. package/dist/scripts/build-abi.cjs +28 -0
  158. package/dist/scripts/build-abi.cjs.map +1 -0
  159. package/dist/scripts/build-abi.d.ts +2 -0
  160. package/dist/scripts/build-abi.d.ts.map +1 -0
  161. package/dist/scripts/build-abi.js +26 -0
  162. package/dist/scripts/build-abi.js.map +1 -0
  163. package/layerzero/README.md +244 -0
  164. package/layerzero/Scarb.lock +203 -0
  165. package/layerzero/Scarb.toml +30 -0
  166. package/layerzero/snfoundry.toml +11 -0
  167. package/layerzero/src/common/constants.cairo +26 -0
  168. package/layerzero/src/common/conversions.cairo +16 -0
  169. package/layerzero/src/common/guid.cairo +20 -0
  170. package/layerzero/src/common/packet_v1_codec.cairo +307 -0
  171. package/layerzero/src/common/structs/messaging.cairo +40 -0
  172. package/layerzero/src/common/structs/packet.cairo +31 -0
  173. package/layerzero/src/endpoint/constants.cairo +14 -0
  174. package/layerzero/src/endpoint/endpoint.cairo +688 -0
  175. package/layerzero/src/endpoint/errors.cairo +108 -0
  176. package/layerzero/src/endpoint/events.cairo +124 -0
  177. package/layerzero/src/endpoint/interfaces/endpoint.cairo +286 -0
  178. package/layerzero/src/endpoint/interfaces/layerzero_composer.cairo +62 -0
  179. package/layerzero/src/endpoint/interfaces/layerzero_receiver.cairo +63 -0
  180. package/layerzero/src/endpoint/message_lib_manager/errors.cairo +95 -0
  181. package/layerzero/src/endpoint/message_lib_manager/events.cairo +90 -0
  182. package/layerzero/src/endpoint/message_lib_manager/interface.cairo +449 -0
  183. package/layerzero/src/endpoint/message_lib_manager/message_lib_manager.cairo +720 -0
  184. package/layerzero/src/endpoint/message_lib_manager/structs.cairo +33 -0
  185. package/layerzero/src/endpoint/messaging_channel/errors.cairo +37 -0
  186. package/layerzero/src/endpoint/messaging_channel/events.cairo +58 -0
  187. package/layerzero/src/endpoint/messaging_channel/interface.cairo +171 -0
  188. package/layerzero/src/endpoint/messaging_channel/messaging_channel.cairo +453 -0
  189. package/layerzero/src/endpoint/messaging_composer/errors.cairo +46 -0
  190. package/layerzero/src/endpoint/messaging_composer/events.cairo +67 -0
  191. package/layerzero/src/endpoint/messaging_composer/interface.cairo +132 -0
  192. package/layerzero/src/endpoint/messaging_composer/messaging_composer.cairo +223 -0
  193. package/layerzero/src/lib.cairo +189 -0
  194. package/layerzero/src/message_lib/blocked_message_lib.cairo +114 -0
  195. package/layerzero/src/message_lib/interface.cairo +63 -0
  196. package/layerzero/src/message_lib/sml/errors.cairo +23 -0
  197. package/layerzero/src/message_lib/sml/events.cairo +32 -0
  198. package/layerzero/src/message_lib/sml/simple_message_lib.cairo +312 -0
  199. package/layerzero/src/message_lib/structs.cairo +22 -0
  200. package/layerzero/src/message_lib/uln/errors.cairo +128 -0
  201. package/layerzero/src/message_lib/uln/events.cairo +97 -0
  202. package/layerzero/src/message_lib/uln/interface.cairo +83 -0
  203. package/layerzero/src/message_lib/uln/options.cairo +64 -0
  204. package/layerzero/src/message_lib/uln/structs/executor_config.cairo +35 -0
  205. package/layerzero/src/message_lib/uln/structs/payment_info.cairo +7 -0
  206. package/layerzero/src/message_lib/uln/structs/uln_config.cairo +155 -0
  207. package/layerzero/src/message_lib/uln/structs/uln_config_storage_node.cairo +91 -0
  208. package/layerzero/src/message_lib/uln/structs/verification.cairo +7 -0
  209. package/layerzero/src/message_lib/uln/ultra_light_node.cairo +965 -0
  210. package/layerzero/src/oapps/common/oapp_options_type_3/errors.cairo +22 -0
  211. package/layerzero/src/oapps/common/oapp_options_type_3/events.cairo +6 -0
  212. package/layerzero/src/oapps/common/oapp_options_type_3/interface.cairo +34 -0
  213. package/layerzero/src/oapps/common/oapp_options_type_3/oapp_options_type_3.cairo +120 -0
  214. package/layerzero/src/oapps/common/oapp_options_type_3/structs.cairo +6 -0
  215. package/layerzero/src/oapps/counter/constants.cairo +3 -0
  216. package/layerzero/src/oapps/counter/counter.cairo +170 -0
  217. package/layerzero/src/oapps/counter/interface.cairo +27 -0
  218. package/layerzero/src/oapps/counter/structs.cairo +20 -0
  219. package/layerzero/src/oapps/message_inspector/interface.cairo +21 -0
  220. package/layerzero/src/oapps/oapp/errors.cairo +72 -0
  221. package/layerzero/src/oapps/oapp/events.cairo +9 -0
  222. package/layerzero/src/oapps/oapp/interface.cairo +67 -0
  223. package/layerzero/src/oapps/oapp/oapp.cairo +70 -0
  224. package/layerzero/src/oapps/oapp/oapp_core.cairo +448 -0
  225. package/layerzero/src/oapps/oft/errors.cairo +42 -0
  226. package/layerzero/src/oapps/oft/events.cairo +33 -0
  227. package/layerzero/src/oapps/oft/interface.cairo +87 -0
  228. package/layerzero/src/oapps/oft/oft.cairo +188 -0
  229. package/layerzero/src/oapps/oft/oft_adapter.cairo +175 -0
  230. package/layerzero/src/oapps/oft/oft_compose_msg_codec.cairo +128 -0
  231. package/layerzero/src/oapps/oft/oft_core.cairo +542 -0
  232. package/layerzero/src/oapps/oft/oft_msg_codec.cairo +131 -0
  233. package/layerzero/src/oapps/oft/structs.cairo +72 -0
  234. package/layerzero/src/treasury/errors.cairo +22 -0
  235. package/layerzero/src/treasury/events.cairo +5 -0
  236. package/layerzero/src/treasury/interfaces/layerzero_treasury.cairo +54 -0
  237. package/layerzero/src/treasury/interfaces/lz_token_fee_lib.cairo +45 -0
  238. package/layerzero/src/treasury/interfaces/treasury_admin.cairo +39 -0
  239. package/layerzero/src/treasury/treasury.cairo +140 -0
  240. package/layerzero/src/workers/access_control.cairo +11 -0
  241. package/layerzero/src/workers/base/base.cairo +238 -0
  242. package/layerzero/src/workers/base/errors.cairo +24 -0
  243. package/layerzero/src/workers/base/events.cairo +43 -0
  244. package/layerzero/src/workers/base/interface.cairo +93 -0
  245. package/layerzero/src/workers/base/structs.cairo +10 -0
  246. package/layerzero/src/workers/common.cairo +59 -0
  247. package/layerzero/src/workers/dvn/constants.cairo +11 -0
  248. package/layerzero/src/workers/dvn/dvn.cairo +338 -0
  249. package/layerzero/src/workers/dvn/errors.cairo +80 -0
  250. package/layerzero/src/workers/dvn/events.cairo +30 -0
  251. package/layerzero/src/workers/dvn/fee_lib/dvn_fee_lib.cairo +152 -0
  252. package/layerzero/src/workers/dvn/fee_lib/interface.cairo +45 -0
  253. package/layerzero/src/workers/dvn/interface.cairo +131 -0
  254. package/layerzero/src/workers/dvn/options.cairo +125 -0
  255. package/layerzero/src/workers/dvn/structs.cairo +51 -0
  256. package/layerzero/src/workers/executor/errors.cairo +159 -0
  257. package/layerzero/src/workers/executor/events.cairo +32 -0
  258. package/layerzero/src/workers/executor/executor.cairo +392 -0
  259. package/layerzero/src/workers/executor/fee_lib/executor_fee_lib.cairo +160 -0
  260. package/layerzero/src/workers/executor/fee_lib/interface.cairo +87 -0
  261. package/layerzero/src/workers/executor/interface.cairo +131 -0
  262. package/layerzero/src/workers/executor/options.cairo +244 -0
  263. package/layerzero/src/workers/executor/structs.cairo +119 -0
  264. package/layerzero/src/workers/interface.cairo +32 -0
  265. package/layerzero/src/workers/price_feed/constants.cairo +7 -0
  266. package/layerzero/src/workers/price_feed/errors.cairo +28 -0
  267. package/layerzero/src/workers/price_feed/events.cairo +13 -0
  268. package/layerzero/src/workers/price_feed/interface.cairo +264 -0
  269. package/layerzero/src/workers/price_feed/price_feed.cairo +392 -0
  270. package/layerzero/src/workers/price_feed/structs.cairo +74 -0
  271. package/layerzero/tests/common/test_constants.cairo +21 -0
  272. package/layerzero/tests/common/test_guid.cairo +232 -0
  273. package/layerzero/tests/common/test_packet_v1_codec.cairo +372 -0
  274. package/layerzero/tests/common/utils.cairo +23 -0
  275. package/layerzero/tests/e2e/oft_utils.cairo +121 -0
  276. package/layerzero/tests/e2e/test_counter_with_sml.cairo +194 -0
  277. package/layerzero/tests/e2e/test_counter_with_uln.cairo +352 -0
  278. package/layerzero/tests/e2e/test_dvn.cairo +406 -0
  279. package/layerzero/tests/e2e/test_lz_token.cairo +354 -0
  280. package/layerzero/tests/e2e/test_oft_compose_with_uln.cairo +364 -0
  281. package/layerzero/tests/e2e/test_oft_with_sml.cairo +240 -0
  282. package/layerzero/tests/e2e/test_oft_with_uln.cairo +299 -0
  283. package/layerzero/tests/e2e/utils.cairo +490 -0
  284. package/layerzero/tests/endpoint/message_lib_manager/test_message_lib_manager.cairo +2051 -0
  285. package/layerzero/tests/endpoint/message_lib_manager/utils.cairo +45 -0
  286. package/layerzero/tests/endpoint/messaging_channel/test_messaging_channel.cairo +621 -0
  287. package/layerzero/tests/endpoint/messaging_channel/utils.cairo +96 -0
  288. package/layerzero/tests/endpoint/messaging_composer/test_messaging_composer.cairo +456 -0
  289. package/layerzero/tests/endpoint/messaging_composer/utils.cairo +75 -0
  290. package/layerzero/tests/endpoint/test_endpoint_commit.cairo +763 -0
  291. package/layerzero/tests/endpoint/test_endpoint_lzreceive.cairo +1253 -0
  292. package/layerzero/tests/endpoint/test_endpoint_quote.cairo +71 -0
  293. package/layerzero/tests/endpoint/test_endpoint_send.cairo +1327 -0
  294. package/layerzero/tests/endpoint/utils.cairo +129 -0
  295. package/layerzero/tests/fuzzable/blockchain_config.cairo +89 -0
  296. package/layerzero/tests/fuzzable/bytes32.cairo +16 -0
  297. package/layerzero/tests/fuzzable/contract_address.cairo +67 -0
  298. package/layerzero/tests/fuzzable/dst_config.cairo +37 -0
  299. package/layerzero/tests/fuzzable/eid.cairo +23 -0
  300. package/layerzero/tests/fuzzable/eth_address.cairo +17 -0
  301. package/layerzero/tests/fuzzable/expiry.cairo +27 -0
  302. package/layerzero/tests/fuzzable/felt_array.cairo +38 -0
  303. package/layerzero/tests/fuzzable/inbound_params.cairo +21 -0
  304. package/layerzero/tests/fuzzable/keys.cairo +16 -0
  305. package/layerzero/tests/fuzzable/model_type.cairo +27 -0
  306. package/layerzero/tests/fuzzable/origin.cairo +21 -0
  307. package/layerzero/tests/fuzzable/price.cairo +32 -0
  308. package/layerzero/tests/fuzzable/role_admin.cairo +29 -0
  309. package/layerzero/tests/fuzzable/small_byte_array.cairo +61 -0
  310. package/layerzero/tests/lib.cairo +177 -0
  311. package/layerzero/tests/message_lib/sml/test_simple_message_lib.cairo +224 -0
  312. package/layerzero/tests/message_lib/uln/test_uln_admin.cairo +2150 -0
  313. package/layerzero/tests/message_lib/uln/test_uln_config.cairo +527 -0
  314. package/layerzero/tests/message_lib/uln/test_uln_config_storage_node.cairo +69 -0
  315. package/layerzero/tests/message_lib/uln/test_uln_executor_config.cairo +173 -0
  316. package/layerzero/tests/message_lib/uln/test_uln_options.cairo +329 -0
  317. package/layerzero/tests/message_lib/uln/test_uln_quote.cairo +1038 -0
  318. package/layerzero/tests/message_lib/uln/test_uln_receive.cairo +715 -0
  319. package/layerzero/tests/message_lib/uln/test_uln_send.cairo +1155 -0
  320. package/layerzero/tests/message_lib/uln/utils.cairo +59 -0
  321. package/layerzero/tests/mocks/composer_target.cairo +76 -0
  322. package/layerzero/tests/mocks/endpoint.cairo +199 -0
  323. package/layerzero/tests/mocks/erc20/erc20.cairo +50 -0
  324. package/layerzero/tests/mocks/erc20/interface.cairo +8 -0
  325. package/layerzero/tests/mocks/message_inspector/message_inspector.cairo +17 -0
  326. package/layerzero/tests/mocks/message_lib_manager.cairo +98 -0
  327. package/layerzero/tests/mocks/messaging_channel/interface.cairo +23 -0
  328. package/layerzero/tests/mocks/messaging_channel/messaging_channel.cairo +138 -0
  329. package/layerzero/tests/mocks/messaging_composer.cairo +171 -0
  330. package/layerzero/tests/mocks/oapp_core/interface.cairo +53 -0
  331. package/layerzero/tests/mocks/oapp_core/oapp_core.cairo +142 -0
  332. package/layerzero/tests/mocks/oapp_options_type3.cairo +42 -0
  333. package/layerzero/tests/mocks/oft_core/interface.cairo +28 -0
  334. package/layerzero/tests/mocks/oft_core/oft_core.cairo +242 -0
  335. package/layerzero/tests/mocks/receiver.cairo +54 -0
  336. package/layerzero/tests/mocks/treasury/lz_token_fee_lib.cairo +57 -0
  337. package/layerzero/tests/mocks/treasury/treasury.cairo +74 -0
  338. package/layerzero/tests/mocks/uln_config/interface.cairo +12 -0
  339. package/layerzero/tests/mocks/uln_config/uln_config.cairo +35 -0
  340. package/layerzero/tests/mocks/workers/base.cairo +80 -0
  341. package/layerzero/tests/mocks/workers/dvn.cairo +115 -0
  342. package/layerzero/tests/mocks/workers/executor/decode/decode.cairo +97 -0
  343. package/layerzero/tests/mocks/workers/executor/decode/interface.cairo +59 -0
  344. package/layerzero/tests/mocks/workers/executor/executor.cairo +176 -0
  345. package/layerzero/tests/oapps/common/test_oapp_options_type_3.cairo +279 -0
  346. package/layerzero/tests/oapps/oft/test_oft_adapter.cairo +441 -0
  347. package/layerzero/tests/oapps/oft/test_oft_compose_msg_codec.cairo +139 -0
  348. package/layerzero/tests/oapps/oft/test_oft_core.cairo +751 -0
  349. package/layerzero/tests/oapps/oft/test_oft_msg_codec.cairo +268 -0
  350. package/layerzero/tests/oapps/test_counter.cairo +470 -0
  351. package/layerzero/tests/oapps/test_oapp_core.cairo +750 -0
  352. package/layerzero/tests/treasury/test_lz_token_fee_lib.cairo +63 -0
  353. package/layerzero/tests/treasury/test_treasury.cairo +458 -0
  354. package/layerzero/tests/treasury/utils.cairo +8 -0
  355. package/layerzero/tests/utils.cairo +48 -0
  356. package/layerzero/tests/workers/base/test_worker_base.cairo +1097 -0
  357. package/layerzero/tests/workers/base/utils.cairo +76 -0
  358. package/layerzero/tests/workers/dvn/fee_lib/test_dvn_fee_lib.cairo +361 -0
  359. package/layerzero/tests/workers/dvn/test_dvn.cairo +1101 -0
  360. package/layerzero/tests/workers/dvn/test_dvn_options.cairo +312 -0
  361. package/layerzero/tests/workers/dvn/utils.cairo +236 -0
  362. package/layerzero/tests/workers/executor/fee_lib/test_executor_fee_lib.cairo +223 -0
  363. package/layerzero/tests/workers/executor/test_decode.cairo +612 -0
  364. package/layerzero/tests/workers/executor/test_executor.cairo +1472 -0
  365. package/layerzero/tests/workers/executor/utils.cairo +296 -0
  366. package/layerzero/tests/workers/price_feed/test_price_feed.cairo +879 -0
  367. package/layerzero/tests/workers/price_feed/utils.cairo +37 -0
  368. package/libs/enumerable_set/Scarb.lock +24 -0
  369. package/libs/enumerable_set/Scarb.toml +17 -0
  370. package/libs/enumerable_set/src/enumerable_set.cairo +118 -0
  371. package/libs/enumerable_set/src/lib.cairo +4 -0
  372. package/libs/enumerable_set/tests/lib.cairo +5 -0
  373. package/libs/enumerable_set/tests/mocks/mock_enumerable_set.cairo +61 -0
  374. package/libs/enumerable_set/tests/test_enumerable_set.cairo +379 -0
  375. package/libs/lz_utils/Scarb.lock +24 -0
  376. package/libs/lz_utils/Scarb.toml +17 -0
  377. package/libs/lz_utils/src/bytes.cairo +33 -0
  378. package/libs/lz_utils/src/error.cairo +12 -0
  379. package/libs/lz_utils/src/keccak.cairo +28 -0
  380. package/libs/lz_utils/src/lib.cairo +3 -0
  381. package/libs/multisig/Scarb.lock +172 -0
  382. package/libs/multisig/Scarb.toml +23 -0
  383. package/libs/multisig/src/errors.cairo +84 -0
  384. package/libs/multisig/src/events.cairo +13 -0
  385. package/libs/multisig/src/interface.cairo +73 -0
  386. package/libs/multisig/src/lib.cairo +7 -0
  387. package/libs/multisig/src/multisig.cairo +241 -0
  388. package/libs/multisig/tests/lib.cairo +4 -0
  389. package/libs/multisig/tests/mocks/mock_multisig.cairo +57 -0
  390. package/libs/multisig/tests/test_multisig.cairo +452 -0
  391. package/package.json +41 -0
  392. package/src/scripts/build-abi.ts +51 -0
  393. package/target/CACHEDIR.TAG +3 -0
  394. package/target/dev/.fingerprint/alexandria_bytes-5ea6u5t70d7qi/alexandria_bytes +1 -0
  395. package/target/dev/.fingerprint/alexandria_data_structures-0aue3g6q80gs0/alexandria_data_structures +1 -0
  396. package/target/dev/.fingerprint/alexandria_math-h2fi7jdq4isuu/alexandria_math +1 -0
  397. package/target/dev/.fingerprint/core-lq3u730l5p1ag/core +1 -0
  398. package/target/dev/.fingerprint/core-vf7fc6rvic5vi/core +1 -0
  399. package/target/dev/.fingerprint/enumerable_set-eaerkg8njl85o/enumerable_set +1 -0
  400. package/target/dev/.fingerprint/enumerable_set-r54oje7t06ku8/enumerable_set +1 -0
  401. package/target/dev/.fingerprint/layerzero-oqgdqsaddpi2k/layerzero +1 -0
  402. package/target/dev/.fingerprint/lz_utils-kfkkeueiqg0pa/lz_utils +1 -0
  403. package/target/dev/.fingerprint/lz_utils-u4v1os6e7gkng/lz_utils +1 -0
  404. package/target/dev/.fingerprint/multisig-0fjetugejecge/multisig +1 -0
  405. package/target/dev/.fingerprint/multisig-6j5kqs436hm54/multisig +1 -0
  406. package/target/dev/.fingerprint/openzeppelin-ei1id1hu088lo/openzeppelin +1 -0
  407. package/target/dev/.fingerprint/openzeppelin-j9d5nd1qhfnu6/openzeppelin +1 -0
  408. package/target/dev/.fingerprint/openzeppelin_access-3oa41aikpaek0/openzeppelin_access +1 -0
  409. package/target/dev/.fingerprint/openzeppelin_access-p5h849v8so76q/openzeppelin_access +1 -0
  410. package/target/dev/.fingerprint/openzeppelin_account-4qhv5fks84g9u/openzeppelin_account +1 -0
  411. package/target/dev/.fingerprint/openzeppelin_account-hgbm8ln9ah7rm/openzeppelin_account +1 -0
  412. package/target/dev/.fingerprint/openzeppelin_finance-n70q9al0cps8i/openzeppelin_finance +1 -0
  413. package/target/dev/.fingerprint/openzeppelin_finance-nnd4f8703t3ak/openzeppelin_finance +1 -0
  414. package/target/dev/.fingerprint/openzeppelin_governance-3gnk21ubp5lis/openzeppelin_governance +1 -0
  415. package/target/dev/.fingerprint/openzeppelin_governance-rj1bfont4fij4/openzeppelin_governance +1 -0
  416. package/target/dev/.fingerprint/openzeppelin_introspection-3fja9hd1gvbcq/openzeppelin_introspection +1 -0
  417. package/target/dev/.fingerprint/openzeppelin_introspection-jc3nf5525eet6/openzeppelin_introspection +1 -0
  418. package/target/dev/.fingerprint/openzeppelin_merkle_tree-4en77ogr2r2l2/openzeppelin_merkle_tree +1 -0
  419. package/target/dev/.fingerprint/openzeppelin_merkle_tree-4t190frqs4db8/openzeppelin_merkle_tree +1 -0
  420. package/target/dev/.fingerprint/openzeppelin_presets-aqb0f6p9c0bp6/openzeppelin_presets +1 -0
  421. package/target/dev/.fingerprint/openzeppelin_presets-nseg8korhin8e/openzeppelin_presets +1 -0
  422. package/target/dev/.fingerprint/openzeppelin_security-g7p73ji1ih1qg/openzeppelin_security +1 -0
  423. package/target/dev/.fingerprint/openzeppelin_security-qp5328v80452u/openzeppelin_security +1 -0
  424. package/target/dev/.fingerprint/openzeppelin_token-jjf7tl9rphc6k/openzeppelin_token +1 -0
  425. package/target/dev/.fingerprint/openzeppelin_token-r6s43vlpj6rqk/openzeppelin_token +1 -0
  426. package/target/dev/.fingerprint/openzeppelin_upgrades-0dpbnre7engca/openzeppelin_upgrades +1 -0
  427. package/target/dev/.fingerprint/openzeppelin_upgrades-2sqgvbuv9s800/openzeppelin_upgrades +1 -0
  428. package/target/dev/.fingerprint/openzeppelin_utils-mj395ivff1ffo/openzeppelin_utils +1 -0
  429. package/target/dev/.fingerprint/openzeppelin_utils-oh1hse8sjumgm/openzeppelin_utils +1 -0
  430. package/target/dev/.fingerprint/starkware_utils-1qnnjnq0pf9u0/starkware_utils +1 -0
  431. package/target/dev/.fingerprint/starkware_utils-mh8e3te65lju4/starkware_utils +1 -0
  432. package/target/dev/enumerable_set.sierra.json +1 -0
  433. package/target/dev/incremental/alexandria_bytes-5ea6u5t70d7qi.bin +0 -0
  434. package/target/dev/incremental/alexandria_data_structures-0aue3g6q80gs0.bin +0 -0
  435. package/target/dev/incremental/alexandria_math-h2fi7jdq4isuu.bin +0 -0
  436. package/target/dev/incremental/core-lq3u730l5p1ag.bin +0 -0
  437. package/target/dev/incremental/core-vf7fc6rvic5vi.bin +0 -0
  438. package/target/dev/incremental/enumerable_set-eaerkg8njl85o.bin +0 -0
  439. package/target/dev/incremental/enumerable_set-r54oje7t06ku8.bin +0 -0
  440. package/target/dev/incremental/layerzero-oqgdqsaddpi2k.bin +0 -0
  441. package/target/dev/incremental/lz_utils-kfkkeueiqg0pa.bin +0 -0
  442. package/target/dev/incremental/lz_utils-u4v1os6e7gkng.bin +0 -0
  443. package/target/dev/incremental/multisig-0fjetugejecge.bin +0 -0
  444. package/target/dev/incremental/multisig-6j5kqs436hm54.bin +0 -0
  445. package/target/dev/incremental/openzeppelin-ei1id1hu088lo.bin +0 -0
  446. package/target/dev/incremental/openzeppelin-j9d5nd1qhfnu6.bin +0 -0
  447. package/target/dev/incremental/openzeppelin_access-3oa41aikpaek0.bin +0 -0
  448. package/target/dev/incremental/openzeppelin_access-p5h849v8so76q.bin +0 -0
  449. package/target/dev/incremental/openzeppelin_account-4qhv5fks84g9u.bin +0 -0
  450. package/target/dev/incremental/openzeppelin_account-hgbm8ln9ah7rm.bin +0 -0
  451. package/target/dev/incremental/openzeppelin_finance-n70q9al0cps8i.bin +0 -0
  452. package/target/dev/incremental/openzeppelin_finance-nnd4f8703t3ak.bin +0 -0
  453. package/target/dev/incremental/openzeppelin_governance-3gnk21ubp5lis.bin +0 -0
  454. package/target/dev/incremental/openzeppelin_governance-rj1bfont4fij4.bin +0 -0
  455. package/target/dev/incremental/openzeppelin_introspection-3fja9hd1gvbcq.bin +0 -0
  456. package/target/dev/incremental/openzeppelin_introspection-jc3nf5525eet6.bin +0 -0
  457. package/target/dev/incremental/openzeppelin_merkle_tree-4en77ogr2r2l2.bin +0 -0
  458. package/target/dev/incremental/openzeppelin_merkle_tree-4t190frqs4db8.bin +0 -0
  459. package/target/dev/incremental/openzeppelin_presets-aqb0f6p9c0bp6.bin +0 -0
  460. package/target/dev/incremental/openzeppelin_presets-nseg8korhin8e.bin +0 -0
  461. package/target/dev/incremental/openzeppelin_security-g7p73ji1ih1qg.bin +0 -0
  462. package/target/dev/incremental/openzeppelin_security-qp5328v80452u.bin +0 -0
  463. package/target/dev/incremental/openzeppelin_token-jjf7tl9rphc6k.bin +0 -0
  464. package/target/dev/incremental/openzeppelin_token-r6s43vlpj6rqk.bin +0 -0
  465. package/target/dev/incremental/openzeppelin_upgrades-0dpbnre7engca.bin +0 -0
  466. package/target/dev/incremental/openzeppelin_upgrades-2sqgvbuv9s800.bin +0 -0
  467. package/target/dev/incremental/openzeppelin_utils-mj395ivff1ffo.bin +0 -0
  468. package/target/dev/incremental/openzeppelin_utils-oh1hse8sjumgm.bin +0 -0
  469. package/target/dev/incremental/starkware_utils-1qnnjnq0pf9u0.bin +0 -0
  470. package/target/dev/incremental/starkware_utils-mh8e3te65lju4.bin +0 -0
  471. package/target/dev/layerzero.starknet_artifacts.json +1 -0
  472. package/target/dev/layerzero_BlockedMessageLib.compiled_contract_class.json +1 -0
  473. package/target/dev/layerzero_BlockedMessageLib.contract_class.json +1 -0
  474. package/target/dev/layerzero_Dvn.compiled_contract_class.json +1 -0
  475. package/target/dev/layerzero_Dvn.contract_class.json +1 -0
  476. package/target/dev/layerzero_DvnFeeLib.compiled_contract_class.json +1 -0
  477. package/target/dev/layerzero_DvnFeeLib.contract_class.json +1 -0
  478. package/target/dev/layerzero_Endpoint.compiled_contract_class.json +1 -0
  479. package/target/dev/layerzero_Endpoint.contract_class.json +1 -0
  480. package/target/dev/layerzero_Executor.compiled_contract_class.json +1 -0
  481. package/target/dev/layerzero_Executor.contract_class.json +1 -0
  482. package/target/dev/layerzero_ExecutorFeeLib.compiled_contract_class.json +1 -0
  483. package/target/dev/layerzero_ExecutorFeeLib.contract_class.json +1 -0
  484. package/target/dev/layerzero_OApp.compiled_contract_class.json +1 -0
  485. package/target/dev/layerzero_OApp.contract_class.json +1 -0
  486. package/target/dev/layerzero_OFT.compiled_contract_class.json +1 -0
  487. package/target/dev/layerzero_OFT.contract_class.json +1 -0
  488. package/target/dev/layerzero_OFTAdapter.compiled_contract_class.json +1 -0
  489. package/target/dev/layerzero_OFTAdapter.contract_class.json +1 -0
  490. package/target/dev/layerzero_OmniCounter.compiled_contract_class.json +1 -0
  491. package/target/dev/layerzero_OmniCounter.contract_class.json +1 -0
  492. package/target/dev/layerzero_PriceFeed.compiled_contract_class.json +1 -0
  493. package/target/dev/layerzero_PriceFeed.contract_class.json +1 -0
  494. package/target/dev/layerzero_SimpleMessageLib.compiled_contract_class.json +1 -0
  495. package/target/dev/layerzero_SimpleMessageLib.contract_class.json +1 -0
  496. package/target/dev/layerzero_Treasury.compiled_contract_class.json +1 -0
  497. package/target/dev/layerzero_Treasury.contract_class.json +1 -0
  498. package/target/dev/layerzero_UltraLightNode.compiled_contract_class.json +1 -0
  499. package/target/dev/layerzero_UltraLightNode.contract_class.json +1 -0
  500. package/target/dev/lz_utils.sierra.json +1 -0
  501. package/target/dev/multisig.sierra.json +1 -0
  502. package/tools/update_contracts.sh +19 -0
  503. package/tsconfig.json +20 -0
  504. package/tsup.config.ts +7 -0
@@ -0,0 +1,152 @@
1
+ //! DVN Fee Library contract implementation
2
+
3
+ /// DVN Fee Library contract
4
+ ///
5
+ /// This contract handles fee calculations for DVN operations, separated from the main DVN logic
6
+ /// to provide modularity and easier maintenance of fee-related functionality.
7
+ #[starknet::contract]
8
+ pub mod DvnFeeLib {
9
+ use openzeppelin::access::ownable::OwnableComponent;
10
+ use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};
11
+ use starknet::ContractAddress;
12
+ use starknet::storage::StoragePointerWriteAccess;
13
+ use starkware_utils::errors::assert_with_byte_array;
14
+ use crate::workers::common::apply_premium_and_floor_margin;
15
+ use crate::workers::dvn::constants::{EXECUTE_FIXED_BYTES, SIGNATURE_RAW_BYTES, VERIFY_BYTES};
16
+ use crate::workers::dvn::errors;
17
+ use crate::workers::dvn::fee_lib::interface::{FeeParams, IDvnFeeLib};
18
+ use crate::workers::dvn::structs::DstConfig;
19
+ use crate::workers::price_feed::interface::{
20
+ ILayerZeroPriceFeedDispatcher, ILayerZeroPriceFeedDispatcherTrait,
21
+ };
22
+
23
+ ////////////////
24
+ // Components //
25
+ ////////////////
26
+
27
+ component!(path: OwnableComponent, storage: ownable, event: OwnableEvent);
28
+
29
+ ////////////////
30
+ // Embeddings //
31
+ ////////////////
32
+
33
+ #[abi(embed_v0)]
34
+ impl OwnableImpl = OwnableComponent::OwnableImpl<ContractState>;
35
+ impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>;
36
+
37
+ #[storage]
38
+ struct Storage {
39
+ #[substorage(v0)]
40
+ ownable: OwnableComponent::Storage,
41
+ /// Local endpoint ID v2
42
+ local_eid_v2: u32,
43
+ }
44
+
45
+ #[event]
46
+ #[derive(Drop, starknet::Event)]
47
+ pub enum Event {
48
+ #[flat]
49
+ OwnableEvent: OwnableComponent::Event,
50
+ }
51
+
52
+ #[constructor]
53
+ fn constructor(ref self: ContractState, local_eid_v2: u32, owner: ContractAddress) {
54
+ // Initialize ownable component
55
+ self.ownable.initializer(owner);
56
+
57
+ // Set immutable values
58
+ self.local_eid_v2.write(local_eid_v2);
59
+ }
60
+
61
+ #[abi(embed_v0)]
62
+ impl DvnFeeLibImpl of IDvnFeeLib<ContractState> {
63
+ // ================================== Only Owner =====================================
64
+
65
+ fn withdraw_token(
66
+ ref self: ContractState,
67
+ token_address: ContractAddress,
68
+ to: ContractAddress,
69
+ amount: u256,
70
+ ) {
71
+ self.ownable.assert_only_owner();
72
+ let token_dispatcher = IERC20Dispatcher { contract_address: token_address };
73
+
74
+ // NOTE: (from https://docs.openzeppelin.com/contracts-cairo/1.0.0/erc20)
75
+ // transfer, transfer_from and approve will never return anything different from true
76
+ // because they will revert on any error.
77
+ token_dispatcher.transfer(to, amount);
78
+ }
79
+
80
+ // ================================== External =====================================
81
+
82
+ fn get_fee_on_send(
83
+ ref self: ContractState, params: FeeParams, dst_config: DstConfig, options: ByteArray,
84
+ ) -> u256 {
85
+ self.get_fee(params, dst_config, options)
86
+ }
87
+
88
+ // ================================== View =====================================
89
+
90
+ fn get_fee(
91
+ self: @ContractState, params: FeeParams, dst_config: DstConfig, options: ByteArray,
92
+ ) -> u256 {
93
+ // Check if destination is supported
94
+ assert_with_byte_array(
95
+ dst_config.gas > 0, errors::err_eid_not_supported(params.dst_eid),
96
+ );
97
+
98
+ // Validate options (currently just check it's empty like in original DVN)
99
+ assert_with_byte_array(options.len() == 0, errors::err_invalid_dvn_options(0));
100
+
101
+ // NOTE: Deviation from EVM spec, we don't parse the DVN options here because
102
+ // They're only used in pre-crime and the value is not actually used.
103
+ // Therefore don't currently see the value in implementing the parsing logic here.
104
+
105
+ // Calculate call data size
106
+ let calldata_size = self._get_calldata_size(params.quorum);
107
+
108
+ // Get price feed estimate
109
+ let price_feed = ILayerZeroPriceFeedDispatcher { contract_address: params.price_feed };
110
+ let estimated_fee = price_feed
111
+ .estimate_fee_on_send(params.dst_eid, calldata_size, dst_config.gas.into());
112
+
113
+ // Apply premium and return
114
+ apply_premium_and_floor_margin(
115
+ estimated_fee.gas_fee,
116
+ dst_config.multiplier_bps,
117
+ params.default_multiplier_bps,
118
+ dst_config.floor_margin_usd,
119
+ estimated_fee.native_price_usd,
120
+ )
121
+ }
122
+
123
+ fn version(self: @ContractState) -> (u64, u8) {
124
+ (1, 1)
125
+ }
126
+ }
127
+
128
+ #[generate_trait]
129
+ impl InternalImpl of InternalTrait {
130
+ /// Get the call data size for the quote function
131
+ ///
132
+ /// # Arguments
133
+ ///
134
+ /// * `quorum` - The quorum for the multisig
135
+ ///
136
+ /// # Returns
137
+ ///
138
+ /// * `u32` - The call data size given the quorum amount of signatures
139
+ fn _get_calldata_size(self: @ContractState, quorum: u32) -> u32 {
140
+ const NUM_BYTES: u32 = 32;
141
+ let mut total_signatures_bytes = quorum * SIGNATURE_RAW_BYTES.into();
142
+
143
+ if total_signatures_bytes % NUM_BYTES != 0 {
144
+ total_signatures_bytes = total_signatures_bytes
145
+ - (total_signatures_bytes % NUM_BYTES)
146
+ + NUM_BYTES;
147
+ }
148
+
149
+ EXECUTE_FIXED_BYTES + VERIFY_BYTES + total_signatures_bytes + NUM_BYTES
150
+ }
151
+ }
152
+ }
@@ -0,0 +1,45 @@
1
+ //! DVN Fee Lib interface
2
+
3
+ use starknet::ContractAddress;
4
+ use crate::workers::dvn::structs::DstConfig;
5
+
6
+ /// Fee parameters for DVN fee calculation
7
+ #[derive(Drop, Clone, Serde)]
8
+ pub struct FeeParams {
9
+ pub price_feed: ContractAddress,
10
+ pub dst_eid: u32,
11
+ pub confirmations: u64,
12
+ pub sender: ContractAddress,
13
+ pub quorum: u32,
14
+ pub default_multiplier_bps: u16,
15
+ }
16
+
17
+ /// Interface for DVN Fee Library
18
+ #[starknet::interface]
19
+ pub trait IDvnFeeLib<TContractState> {
20
+ // ================================== Only Owner =====================================
21
+
22
+ /// Withdraw tokens from the fee lib
23
+ /// Enables recovery of funds accidentally sent
24
+ fn withdraw_token(
25
+ ref self: TContractState, token_address: ContractAddress, to: ContractAddress, amount: u256,
26
+ );
27
+
28
+ // ================================== External =====================================
29
+
30
+ /// Get fee function that can change state (e.g. paying price feed)
31
+ fn get_fee_on_send(
32
+ ref self: TContractState, params: FeeParams, dst_config: DstConfig, options: ByteArray,
33
+ ) -> u256;
34
+
35
+ // ================================== View =====================================
36
+
37
+ /// Get fee view function
38
+ fn get_fee(
39
+ self: @TContractState, params: FeeParams, dst_config: DstConfig, options: ByteArray,
40
+ ) -> u256;
41
+
42
+ /// Get version
43
+ /// Returns (major, minor)
44
+ fn version(self: @TContractState) -> (u64, u8);
45
+ }
@@ -0,0 +1,131 @@
1
+ //! DVN interface
2
+
3
+ use lz_utils::bytes::Bytes32;
4
+ use starknet::ClassHash;
5
+ use starknet::account::Call;
6
+ use crate::workers::dvn::structs::{DstConfig, ExecuteParam, SetDstConfigParams};
7
+
8
+ /// Interface for the DVN contract
9
+ #[starknet::interface]
10
+ pub trait IDvn<TContractState> {
11
+ // ================================== Only Admin =====================================
12
+
13
+ /// Set the destination configurations for multiple EIDs
14
+ ///
15
+ /// # Arguments
16
+ ///
17
+ /// * `params` - Array of parameters for setting the destination configuration
18
+ ///
19
+ /// # Access Control
20
+ ///
21
+ /// * Only admins can call this function
22
+ ///
23
+ /// # Events
24
+ ///
25
+ /// * `DstConfigSet` - Emitted when the destination configuration is set
26
+ fn set_dst_config(ref self: TContractState, params: Array<SetDstConfigParams>);
27
+
28
+ /// Execute jobs
29
+ ///
30
+ /// # Arguments
31
+ ///
32
+ /// * `params` - Array of parameters for executing the jobs
33
+ ///
34
+ /// # Access Control
35
+ ///
36
+ /// * Only admins can call this function
37
+ ///
38
+ /// # Events
39
+ ///
40
+ /// * `VerifySignaturesFailed` - Emitted when the signatures verification fails
41
+ /// * `HashAlreadyUsed` - Emitted when the hash is already used
42
+ /// * `ExecuteFailed` - Emitted when the job execution fails
43
+ fn execute(ref self: TContractState, params: Array<ExecuteParam>);
44
+
45
+ // ================================== Only Quorum =====================================
46
+
47
+ /// Function for quorum to change the admin without going through the execute function
48
+ ///
49
+ /// # Arguments
50
+ ///
51
+ /// * `param` - Parameter for changing the admin
52
+ ///
53
+ /// # Access Control
54
+ ///
55
+ /// * Anyone can call this function, but it will only succeed with a quorum of signatures
56
+ ///
57
+ /// # Events
58
+ ///
59
+ /// * `RoleGranted` - Emitted when the admin role is granted (from OpenZeppelin's
60
+ /// [`AccessControlComponent`])
61
+ fn quorum_change_admin(ref self: TContractState, param: ExecuteParam);
62
+
63
+ // ================================== Only Self =====================================
64
+
65
+ /// Upgrade the contract
66
+ ///
67
+ /// # Arguments
68
+ ///
69
+ /// * `new_class_hash` - The new class hash to upgrade to
70
+ ///
71
+ /// # Events
72
+ ///
73
+ /// * `Upgraded` - Emitted when the contract is upgraded (from OpenZeppelin's
74
+ /// [`UpgradeableComponent`])
75
+ ///
76
+ /// @dev Only the contract itself can call this function (enforced by multisig)
77
+ fn upgrade(ref self: TContractState, new_class_hash: ClassHash);
78
+
79
+ /// Upgrade the contract and call a function
80
+ ///
81
+ /// # Arguments
82
+ ///
83
+ /// * `new_class_hash` - The new class hash to upgrade to
84
+ /// * `selector` - The selector to call
85
+ /// * `data` - The data to pass to the function
86
+ ///
87
+ /// # Returns
88
+ ///
89
+ /// * `Span<felt252>` - The response data from the function call
90
+ ///
91
+ /// # Events
92
+ ///
93
+ /// * `Upgraded` - Emitted when the contract is upgraded (from OpenZeppelin's
94
+ /// [`UpgradeableComponent`])
95
+ ///
96
+ /// @dev Only the contract itself can call this function (enforced by multisig)
97
+ fn upgrade_and_call(
98
+ ref self: TContractState,
99
+ new_class_hash: ClassHash,
100
+ selector: felt252,
101
+ calldata: Span<felt252>,
102
+ ) -> Span<felt252>;
103
+
104
+ // ================================== View ==========================================
105
+
106
+ /// Get the destination configuration
107
+ ///
108
+ /// # Arguments
109
+ ///
110
+ /// * `dst_eid` - The destination EID
111
+ ///
112
+ /// # Returns
113
+ ///
114
+ /// * `DstConfig` - The destination configuration
115
+ fn get_dst_config(self: @TContractState, dst_eid: u32) -> DstConfig;
116
+
117
+ /// Hash the call data
118
+ ///
119
+ /// # Arguments
120
+ ///
121
+ /// * `vid` - The VID of the call data
122
+ /// * `call_data` - The call data
123
+ /// * `expiration` - The expiration of the call data
124
+ ///
125
+ /// # Returns
126
+ ///
127
+ /// * `Bytes32` - The keccak hash of the arguments
128
+ fn hash_call_data(
129
+ self: @TContractState, vid: u32, call_data: Call, expiration: u256,
130
+ ) -> Bytes32;
131
+ }
@@ -0,0 +1,125 @@
1
+ //! DVN options
2
+
3
+ use alexandria_bytes::byte_array_ext::ByteArrayTraitExt;
4
+ use core::byte_array::ByteArray;
5
+ use core::dict::{Felt252Dict, Felt252DictEntryTrait};
6
+ use core::nullable::{FromNullableResult, NullableTrait, match_nullable};
7
+ use starkware_utils::errors::assert_with_byte_array;
8
+ use crate::workers::dvn::errors::err_invalid_dvn_options;
9
+ use crate::workers::dvn::structs::DvnOption;
10
+
11
+ // Constants
12
+ pub const DVN_WORKER_ID: u8 = 2;
13
+ pub const OPTION_TYPE_PRECRIME: u8 = 1;
14
+
15
+ /// Group DVN options by their index
16
+ ///
17
+ /// # Arguments
18
+ /// * `options` - The DVN options in format: [worker_id][dvn_option][worker_id][dvn_option]...
19
+ /// where dvn_option = [option_size][dvn_idx][option_type][option]
20
+ /// option_size = len(dvn_idx) + len(option_type) + len(option)
21
+ /// worker_id: u8, dvn_idx: u8, option_size: u16, option_type: u8, option: bytes
22
+ ///
23
+ /// # Returns
24
+ /// * `Felt252Dict<Nullable<ByteArray>>` - The grouped options and their indices
25
+ pub fn group_dvn_options_by_idx(options: @ByteArray) -> Felt252Dict<Nullable<ByteArray>> {
26
+ let mut ret: Felt252Dict<Nullable<ByteArray>> = Default::default();
27
+ if options.len() == 0 {
28
+ return ret;
29
+ }
30
+
31
+ let mut cursor: usize = 0;
32
+
33
+ while cursor != options.len() {
34
+ let DvnOption {
35
+ option_size, dvn_index, option_type, option_data, cursor: new_cursor,
36
+ } = next_dvn_option(options, cursor);
37
+ let option = post_process_option(option_size, dvn_index, option_type, @option_data);
38
+
39
+ // Get the existing entry for this dvn_index
40
+ let (entry, prev_value) = ret.entry(dvn_index.into());
41
+
42
+ // Combine the new option with any existing options for this dvn_index
43
+ let combined_options = match match_nullable(prev_value) {
44
+ FromNullableResult::Null => option,
45
+ FromNullableResult::NotNull(existing) => {
46
+ let mut result = existing.unbox();
47
+ result.append(@option);
48
+ result
49
+ },
50
+ };
51
+
52
+ // Store the combined options back in the dictionary
53
+ ret = entry.finalize(NullableTrait::new(combined_options));
54
+ cursor = new_cursor;
55
+ }
56
+
57
+ ret
58
+ }
59
+
60
+ /// Post-process the option - prefixes other args to the option data
61
+ ///
62
+ /// # Arguments
63
+ ///
64
+ /// * `option_size` - The size of the option
65
+ ///
66
+ /// * `dvn_index` - The index of the DVN
67
+ ///
68
+ /// * `option_type` - The type of the option (e.g. PRECRIME)
69
+ ///
70
+ /// * `option_data` - The data of the option
71
+ ///
72
+ /// # Returns
73
+ ///
74
+ /// * [`ByteArray`] - The post-processed option
75
+ pub fn post_process_option(
76
+ option_size: u16, dvn_index: u8, option_type: u8, option_data: @ByteArray,
77
+ ) -> ByteArray {
78
+ let mut result: ByteArray = Default::default();
79
+
80
+ result.append_byte(DVN_WORKER_ID);
81
+ result.append_u16(option_size);
82
+ result.append_byte(dvn_index);
83
+ result.append_byte(option_type);
84
+ result.append(option_data);
85
+
86
+ result
87
+ }
88
+
89
+ /// Decode the next DVN option from options starting from the specified cursor
90
+ ///
91
+ /// # Arguments
92
+ ///
93
+ /// * `options` - The DVN options byte array
94
+ ///
95
+ /// * `cursor` - The cursor position to start decoding from
96
+ ///
97
+ /// # Returns
98
+ ///
99
+ /// * [`DvnOption`] - The decoded option type, option data, and new cursor position
100
+ pub fn next_dvn_option(options: @ByteArray, cursor: usize) -> DvnOption {
101
+ // Ensure we have enough bytes to read worker id
102
+ assert_with_byte_array(cursor < options.len(), err_invalid_dvn_options(cursor));
103
+
104
+ // skip dvn_id, always equal to DVN_WORKER_ID here = 2;
105
+ let cursor = cursor + 1;
106
+
107
+ let (cursor, option_size) = options.read_u16(cursor);
108
+ assert_with_byte_array(option_size > 2, err_invalid_dvn_options(cursor));
109
+
110
+ let (cursor, dvn_index) = options.read_u8(cursor);
111
+ let (cursor, option_type) = options.read_u8(cursor);
112
+
113
+ // Calculate the length of just the option data (excluding dvn_index and option_type)
114
+ // option_length includes dvn_index (1 byte) + option_type (1 byte) + option data
115
+ let option_data_length = option_size - 2; // subtract 2 bytes for dvn_index and option_type
116
+
117
+ // Extract the option data
118
+ // let option = slice_byte_array(options, new_cursor, option_data_length.into());
119
+ let (_, option) = options.read_bytes(cursor, option_data_length.into());
120
+
121
+ // Calculate the final cursor position
122
+ let final_cursor = cursor + option_data_length.into();
123
+
124
+ DvnOption { option_size, dvn_index, option_type, option_data: option, cursor: final_cursor }
125
+ }
@@ -0,0 +1,51 @@
1
+ //! DVN structs
2
+
3
+ use starknet::account::Call;
4
+ use starknet::secp256_trait::Signature;
5
+
6
+ /// DVN option
7
+ pub struct DvnOption {
8
+ /// Size of the option
9
+ pub option_size: u16,
10
+ /// Index of the DVN
11
+ pub dvn_index: u8,
12
+ /// Type of the option
13
+ pub option_type: u8,
14
+ /// Data of the option
15
+ pub option_data: ByteArray,
16
+ /// Cursor position
17
+ pub cursor: u32,
18
+ }
19
+
20
+ /// Destination config
21
+ #[derive(Copy, Default, Drop, Serde, starknet::Store, PartialEq, Debug)]
22
+ pub struct DstConfig {
23
+ /// Gas for the destination
24
+ pub gas: u64,
25
+ /// Multiplier basis points
26
+ pub multiplier_bps: u16,
27
+ /// Floor margin in USD - uses priceFeed PRICE_RATIO_DENOMINATOR
28
+ pub floor_margin_usd: u128,
29
+ }
30
+
31
+ /// Parameters for setting the destination config
32
+ #[derive(Copy, Default, Drop, Serde, PartialEq, Debug)]
33
+ pub struct SetDstConfigParams {
34
+ /// Destination endpoint ID
35
+ pub dst_eid: u32,
36
+ /// Destination config
37
+ pub config: DstConfig,
38
+ }
39
+
40
+ /// Parameters for executing a job
41
+ #[derive(Drop, Serde, Clone)]
42
+ pub struct ExecuteParam {
43
+ /// Verifier ID
44
+ pub vid: u32,
45
+ /// Call data
46
+ pub call_data: Call,
47
+ /// Expiration of the instruction
48
+ pub expiration: u256,
49
+ /// Signatures for the instruction
50
+ pub signatures: Span<Signature>,
51
+ }
@@ -0,0 +1,159 @@
1
+ //! Executor errors
2
+
3
+ use core::byte_array::ByteArray;
4
+ use lz_utils::error::{Error, format_error};
5
+
6
+ #[derive(Drop)]
7
+ pub enum ExecutorError {
8
+ /// The endpoint ID is not supported.
9
+ EidNotSupported,
10
+ /// The `lz_compose` option is invalid.
11
+ InvalidLzComposeOption,
12
+ /// The `lz_read` option is invalid.
13
+ InvalidLzReadOption,
14
+ /// The `lz_receive` option is invalid.
15
+ InvalidLzReceiveOption,
16
+ /// The native drop option is invalid.
17
+ InvalidNativeDropOption,
18
+ /// The options are invalid.
19
+ InvalidOptions,
20
+ /// The options are malformed.
21
+ MalformedOptions,
22
+ /// The native amount exceeds the cap.
23
+ NativeAmountExceedsCap,
24
+ /// No options were provided.
25
+ NoOptions,
26
+ /// The price feed is not set.
27
+ PriceFeedNotSet,
28
+ /// The `lz_compose` option is not supported.
29
+ UnsupportedOptionLzCompose,
30
+ /// The `lz_read` option is not supported.
31
+ UnsupportedOptionLzRead,
32
+ /// The `lz_receive` option is not supported.
33
+ UnsupportedOptionLzReceive,
34
+ /// The native drop option is not supported.
35
+ UnsupportedOptionNativeDrop,
36
+ /// The option type is not supported.
37
+ UnsupportedOptionType,
38
+ /// Receive with value is not supported.
39
+ UnsupportedReceiveWithValue,
40
+ /// The worker fee library is not set.
41
+ WorkerFeeLibNotSet,
42
+ /// The calldata size is zero.
43
+ ZeroCalldataSize,
44
+ /// The `lz_compose` gas is zero.
45
+ ZeroLzComposeGas,
46
+ /// The `lz_receive` gas is zero.
47
+ ZeroLzReceiveGas,
48
+ }
49
+
50
+ impl ErrorNameImpl of Error<ExecutorError> {
51
+ fn prefix() -> ByteArray {
52
+ "LZ_EXECUTOR"
53
+ }
54
+
55
+ fn name(self: ExecutorError) -> ByteArray {
56
+ match self {
57
+ ExecutorError::EidNotSupported => "EID_NOT_SUPPORTED",
58
+ ExecutorError::InvalidLzComposeOption => "INVALID_LZ_COMPOSE_OPTION",
59
+ ExecutorError::InvalidLzReadOption => "INVALID_LZ_READ_OPTION",
60
+ ExecutorError::InvalidLzReceiveOption => "INVALID_LZ_RECEIVE_OPTION",
61
+ ExecutorError::InvalidNativeDropOption => "INVALID_NATIVE_DROP_OPTION",
62
+ ExecutorError::InvalidOptions => "INVALID_OPTIONS",
63
+ ExecutorError::MalformedOptions => "MALFORMED_OPTIONS",
64
+ ExecutorError::NativeAmountExceedsCap => "NATIVE_AMOUNT_EXCEEDS_CAP",
65
+ ExecutorError::NoOptions => "NO_OPTIONS",
66
+ ExecutorError::PriceFeedNotSet => "PRICE_FEED_NOT_SET",
67
+ ExecutorError::UnsupportedOptionLzCompose => "UNSUPPORTED_OPTION_LZ_COMPOSE",
68
+ ExecutorError::UnsupportedOptionLzRead => "UNSUPPORTED_OPTION_LZ_READ",
69
+ ExecutorError::UnsupportedOptionLzReceive => "UNSUPPORTED_OPTION_LZ_RECEIVE",
70
+ ExecutorError::UnsupportedOptionNativeDrop => "UNSUPPORTED_OPTION_NATIVE_DROP",
71
+ ExecutorError::UnsupportedOptionType => "UNSUPPORTED_OPTION_TYPE",
72
+ ExecutorError::UnsupportedReceiveWithValue => "UNSUPPORTED_RECEIVE_WITH_VALUE",
73
+ ExecutorError::WorkerFeeLibNotSet => "WORKER_FEELIB_NOT_SET",
74
+ ExecutorError::ZeroCalldataSize => "ZERO_CALLDATA_SIZE",
75
+ ExecutorError::ZeroLzComposeGas => "ZERO_LZ_COMPOSE_GAS",
76
+ ExecutorError::ZeroLzReceiveGas => "ZERO_LZ_RECEIVE_GAS",
77
+ }
78
+ }
79
+ }
80
+
81
+ pub fn err_eid_not_supported() -> ByteArray {
82
+ format_error(ExecutorError::EidNotSupported, "")
83
+ }
84
+
85
+ pub fn err_price_feed_not_set() -> ByteArray {
86
+ format_error(ExecutorError::PriceFeedNotSet, "")
87
+ }
88
+
89
+ pub fn err_worker_fee_lib_not_set() -> ByteArray {
90
+ format_error(ExecutorError::WorkerFeeLibNotSet, "")
91
+ }
92
+
93
+ pub fn err_no_options() -> ByteArray {
94
+ format_error(ExecutorError::NoOptions, "")
95
+ }
96
+
97
+ pub fn err_malformed_options() -> ByteArray {
98
+ format_error(ExecutorError::MalformedOptions, "")
99
+ }
100
+
101
+ pub fn err_unsupported_option_lz_receive() -> ByteArray {
102
+ format_error(ExecutorError::UnsupportedOptionLzReceive, "")
103
+ }
104
+
105
+ pub fn err_unsupported_receive_with_value() -> ByteArray {
106
+ format_error(ExecutorError::UnsupportedReceiveWithValue, "")
107
+ }
108
+
109
+ pub fn err_unsupported_option_native_drop() -> ByteArray {
110
+ format_error(ExecutorError::UnsupportedOptionNativeDrop, "")
111
+ }
112
+
113
+ pub fn err_unsupported_option_lz_compose() -> ByteArray {
114
+ format_error(ExecutorError::UnsupportedOptionLzCompose, "")
115
+ }
116
+
117
+ pub fn err_zero_lz_compose_gas() -> ByteArray {
118
+ format_error(ExecutorError::ZeroLzComposeGas, "")
119
+ }
120
+
121
+ pub fn err_unsupported_option_lz_read() -> ByteArray {
122
+ format_error(ExecutorError::UnsupportedOptionLzRead, "")
123
+ }
124
+
125
+ pub fn err_unsupported_option_type() -> ByteArray {
126
+ format_error(ExecutorError::UnsupportedOptionType, "")
127
+ }
128
+
129
+ pub fn err_invalid_options() -> ByteArray {
130
+ format_error(ExecutorError::InvalidOptions, "")
131
+ }
132
+
133
+ pub fn err_native_amount_exceeds_cap() -> ByteArray {
134
+ format_error(ExecutorError::NativeAmountExceedsCap, "")
135
+ }
136
+
137
+ pub fn err_zero_lz_receive_gas() -> ByteArray {
138
+ format_error(ExecutorError::ZeroLzReceiveGas, "")
139
+ }
140
+
141
+ pub fn err_zero_calldata_size() -> ByteArray {
142
+ format_error(ExecutorError::ZeroCalldataSize, "")
143
+ }
144
+
145
+ pub fn err_invalid_lz_receive_option() -> ByteArray {
146
+ format_error(ExecutorError::InvalidLzReceiveOption, "")
147
+ }
148
+
149
+ pub fn err_invalid_native_drop_option() -> ByteArray {
150
+ format_error(ExecutorError::InvalidNativeDropOption, "")
151
+ }
152
+
153
+ pub fn err_invalid_lz_compose_option() -> ByteArray {
154
+ format_error(ExecutorError::InvalidLzComposeOption, "")
155
+ }
156
+
157
+ pub fn err_invalid_lz_read_option() -> ByteArray {
158
+ format_error(ExecutorError::InvalidLzReadOption, "")
159
+ }