@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,108 @@
1
+ //! Endpoint errors
2
+
3
+ use lz_utils::error::{Error, format_error};
4
+
5
+ #[derive(Drop)]
6
+ pub enum EndpointError {
7
+ /// Triggered when a message is committed by a contract that is not a valid receive library for
8
+ /// the given path.
9
+ InvalidReceiveLibrary,
10
+ /// Triggered when an attempt is made to commit a message to a path that has not been
11
+ /// initialized.
12
+ PathNotInitializable,
13
+ PathNotCommittable,
14
+ InvalidPayloadHash,
15
+ /// Triggered when a message with an invalid nonce is received.
16
+ InvalidNonce,
17
+ /// Triggered when the payload hash of a received message does not match the committed payload
18
+ /// hash.
19
+ PayloadHashNotFound,
20
+ /// Triggered when the value sent with `lz_receive` exceeds the executor's token allowance.
21
+ LzReceiveValueExceedsAllowance,
22
+ /// Triggered when an unauthorized address attempts to perform a restricted action.
23
+ Unauthorized,
24
+ /// Triggered when an attempt is made to pay fees in the LZ token, but no LZ token address is
25
+ /// set.
26
+ LzTokenUnavailable,
27
+ /// Triggered when an attempt is made to pay fees in the LZ token, but the fee is zero.
28
+ ZeroLzTokenFee,
29
+ /// Triggered when the fees provided are insufficient to cover the cost of the message.
30
+ InsufficientFee,
31
+ }
32
+
33
+ impl ErrorNameImpl of Error<EndpointError> {
34
+ fn prefix() -> ByteArray {
35
+ "LZ_ENDPOINT"
36
+ }
37
+
38
+ fn name(self: EndpointError) -> ByteArray {
39
+ match self {
40
+ EndpointError::InvalidReceiveLibrary => "INVALID_RECEIVE_LIBRARY",
41
+ EndpointError::PathNotInitializable => "PATH_NOT_INITIALIZABLE",
42
+ EndpointError::PathNotCommittable => "PATH_NOT_COMMITTABLE",
43
+ EndpointError::InvalidPayloadHash => "INVALID_PAYLOAD_HASH",
44
+ EndpointError::InvalidNonce => "INVALID_NONCE",
45
+ EndpointError::PayloadHashNotFound => "PAYLOAD_HASH_NOT_FOUND",
46
+ EndpointError::LzReceiveValueExceedsAllowance => "LZ_RECEIVE_VALUE_EXCEEDS_ALLOWANCE",
47
+ EndpointError::Unauthorized => "UNAUTHORIZED",
48
+ EndpointError::LzTokenUnavailable => "LZ_TOKEN_UNAVAILABLE",
49
+ EndpointError::ZeroLzTokenFee => "ZERO_LZ_TOKEN_FEE",
50
+ EndpointError::InsufficientFee => "INSUFFICIENT_FEE",
51
+ }
52
+ }
53
+ }
54
+
55
+ pub fn err_invalid_receive_library() -> ByteArray {
56
+ format_error(EndpointError::InvalidReceiveLibrary, "")
57
+ }
58
+
59
+ pub fn err_path_not_initializable() -> ByteArray {
60
+ format_error(EndpointError::PathNotInitializable, "")
61
+ }
62
+
63
+ pub fn err_path_not_committable() -> ByteArray {
64
+ format_error(EndpointError::PathNotCommittable, "")
65
+ }
66
+
67
+ pub fn err_invalid_payload_hash() -> ByteArray {
68
+ format_error(EndpointError::InvalidPayloadHash, "")
69
+ }
70
+
71
+ pub fn err_lz_receive_value_exceeds_allowance(
72
+ lz_receive_value: u256, allowance: u256,
73
+ ) -> ByteArray {
74
+ format_error(
75
+ EndpointError::LzReceiveValueExceedsAllowance,
76
+ format!("LZ receive value: {}, Allowance: {}", lz_receive_value, allowance),
77
+ )
78
+ }
79
+
80
+ pub fn err_unauthorized() -> ByteArray {
81
+ format_error(EndpointError::Unauthorized, "")
82
+ }
83
+
84
+ pub fn err_lz_token_unavailable() -> ByteArray {
85
+ format_error(EndpointError::LzTokenUnavailable, "")
86
+ }
87
+
88
+ pub fn err_zero_lz_token_fee() -> ByteArray {
89
+ format_error(EndpointError::ZeroLzTokenFee, "")
90
+ }
91
+
92
+ pub fn err_insufficient_fee(
93
+ required_native_fee: u256,
94
+ supplied_native_fee: u256,
95
+ required_lz_token_fee: u256,
96
+ supplied_lz_token_fee: u256,
97
+ ) -> ByteArray {
98
+ format_error(
99
+ EndpointError::InsufficientFee,
100
+ format!(
101
+ "Required native fee: {}, Supplied native fee: {}, Required lz token fee: {}, Supplied lz token fee: {}",
102
+ required_native_fee,
103
+ supplied_native_fee,
104
+ required_lz_token_fee,
105
+ supplied_lz_token_fee,
106
+ ),
107
+ )
108
+ }
@@ -0,0 +1,124 @@
1
+ //! Endpoint events
2
+
3
+ use lz_utils::bytes::Bytes32;
4
+ use starknet::ContractAddress;
5
+ use crate::common::structs::packet::Origin;
6
+
7
+ /// Emitted when a packet is sent from the Endpoint.
8
+ #[derive(Drop, Debug, PartialEq, starknet::Event)]
9
+ pub struct PacketSent {
10
+ /// The encoded packet data.
11
+ pub encoded_packet: ByteArray,
12
+ /// The options specified for the message.
13
+ pub options: ByteArray,
14
+ /// The address of the send library used.
15
+ #[key]
16
+ pub send_library: ContractAddress,
17
+ }
18
+
19
+ /// Emitted when a packet is committed for verification.
20
+ #[derive(Drop, Debug, PartialEq, starknet::Event)]
21
+ pub struct PacketCommitted {
22
+ /// The origin of the packet.
23
+ #[key]
24
+ pub origin: Origin,
25
+ /// The intended receiver of the packet.
26
+ #[key]
27
+ pub receiver: ContractAddress,
28
+ /// The hash of the packet's payload.
29
+ #[key]
30
+ pub payload_hash: Bytes32,
31
+ }
32
+
33
+ /// Emitted when a packet is successfully delivered to the receiver.
34
+ #[derive(Drop, Debug, PartialEq, starknet::Event)]
35
+ pub struct PacketDelivered {
36
+ /// The origin of the packet.
37
+ #[key]
38
+ pub origin: Origin,
39
+ /// The receiver of the packet.
40
+ #[key]
41
+ pub receiver: ContractAddress,
42
+ }
43
+
44
+ /// Emitted when a receive message fails.
45
+ #[derive(Drop, Debug, PartialEq, starknet::Event)]
46
+ pub struct LzReceiveAlert {
47
+ /// The origin of the message.
48
+ #[key]
49
+ pub origin: Origin,
50
+ /// The intended receiver of the message.
51
+ #[key]
52
+ pub receiver: ContractAddress,
53
+ /// The address of the executor that triggered the alert.
54
+ #[key]
55
+ pub executor: ContractAddress,
56
+ /// The GUID of the message.
57
+ #[key]
58
+ pub guid: Bytes32,
59
+ /// The gas amount related to the alert.
60
+ pub gas: u256,
61
+ /// The value sent with the message.
62
+ pub value: u256,
63
+ /// The message payload.
64
+ pub message: ByteArray,
65
+ /// Extra data provided with the alert.
66
+ pub extra_data: ByteArray,
67
+ /// The reason for the alert.
68
+ pub reason: Array<felt252>,
69
+ }
70
+
71
+ /// Emitted when a new message library is registered.
72
+ #[derive(Drop, Debug, PartialEq, starknet::Event)]
73
+ pub struct LibraryRegistered {
74
+ /// The address of the registered library.
75
+ #[key]
76
+ pub library: ContractAddress,
77
+ }
78
+
79
+ /// Emitted when a send library is set for a specific sender and destination EID.
80
+ #[derive(Drop, Debug, PartialEq, starknet::Event)]
81
+ pub struct SendLibrarySet {
82
+ /// The sender's address.
83
+ #[key]
84
+ pub sender: ContractAddress,
85
+ /// The destination EID.
86
+ #[key]
87
+ pub dst_eid: u32,
88
+ /// The address of the send library.
89
+ #[key]
90
+ pub library: ContractAddress,
91
+ }
92
+
93
+ /// Emitted when a receive library is set for a specific receiver and source EID.
94
+ #[derive(Drop, Debug, PartialEq, starknet::Event)]
95
+ pub struct ReceiveLibrarySet {
96
+ /// The receiver's address.
97
+ #[key]
98
+ pub receiver: ContractAddress,
99
+ /// The source EID.
100
+ #[key]
101
+ pub src_eid: u32,
102
+ /// The address of the receive library.
103
+ #[key]
104
+ pub library: ContractAddress,
105
+ }
106
+
107
+ /// Emitted when the LZ token address is set.
108
+ #[derive(Drop, Debug, PartialEq, starknet::Event)]
109
+ pub struct LzTokenSet {
110
+ /// The new address of the LZ token.
111
+ #[key]
112
+ pub lz_token_address: ContractAddress,
113
+ }
114
+
115
+ /// Emitted when a delegate is set for an OApp.
116
+ #[derive(Drop, starknet::Event)]
117
+ pub struct DelegateSet {
118
+ /// The OApp's address.
119
+ #[key]
120
+ pub oapp: ContractAddress,
121
+ /// The delegate's address.
122
+ #[key]
123
+ pub delegate: ContractAddress,
124
+ }
@@ -0,0 +1,286 @@
1
+ //! Endpoint interface
2
+
3
+ use lz_utils::bytes::Bytes32;
4
+ use starknet::ContractAddress;
5
+ use crate::MessagingFee;
6
+ use crate::common::structs::messaging::{MessageReceipt, MessagingParams};
7
+ use crate::common::structs::packet::Origin;
8
+
9
+ /// # `IEndpoint` Interface
10
+ ///
11
+ /// The `IEndpoint` interface is the central component of the LayerZero protocol, designed to
12
+ /// facilitate seamless, secure, and efficient cross-chain messaging. As the primary entry point for
13
+ /// all LayerZero messages, the Endpoint contract manages the entire lifecycle of a message, from
14
+ /// sending to receiving, while ensuring reliable delivery and robust security. It provides a
15
+ /// comprehensive set of functionalities that enable developers to build sophisticated omnichain
16
+ /// applications (OApps) with ease.
17
+ ///
18
+ /// ## Key Features
19
+ /// - **Message Sending and Receiving**: Core functions for sending and receiving messages across
20
+ /// different blockchains,
21
+ /// abstracting away the complexities of cross-chain communication.
22
+ /// - **Configurable Security**: OApps can define their own security requirements by specifying a
23
+ /// set of Data Verification
24
+ /// Networks (DVNs) and a threshold of required verifications, ensuring that each message meets
25
+ /// the application's security standards.
26
+ /// - **Fee Quotation**: Provides a mechanism to quote the cost of sending a message, allowing
27
+ /// applications to estimate
28
+ /// and manage transaction fees transparently.
29
+ /// - **Message Verification and Execution**: Verifies the authenticity of incoming messages through
30
+ /// the configured DVNs
31
+ /// and ensures that only valid messages are executed.
32
+ /// - **Commit-Store-Execute Pattern**: Implements a secure message handling pattern where message
33
+ /// commitments are stored
34
+ /// on-chain and executed only after successful verification, preventing race conditions and other
35
+ /// security vulnerabilities.
36
+ /// - **Alerts and Error Handling**: Includes a system for receiving alerts about failed messages,
37
+ /// enabling robust error
38
+ /// handling and recovery mechanisms.
39
+ /// - **Delegate and Token Management**: Supports delegation of OApp configuration management and
40
+ /// allows for the use of
41
+ /// a specific token for paying LayerZero fees.
42
+ #[derive(Drop, Serde)]
43
+ pub enum ExecutionState {
44
+ NotExecutable, // executor: waits for PayloadVerified event and starts polling for executable
45
+ VerifiedButNotExecutable, // executor: starts active polling for executable
46
+ Executable,
47
+ Executed,
48
+ }
49
+
50
+ #[starknet::interface]
51
+ pub trait IEndpoint<TContractState> {
52
+ /// Sends a message to a remote OApp.
53
+ ///
54
+ /// # Arguments
55
+ ///
56
+ /// * `params` - A `MessagingParams` struct containing the destination EID, receiver address,
57
+ /// message payload,
58
+ /// OApp-specific options, and whether to pay in the LZ token.
59
+ /// * `refund_address` - The address to which any remaining gas fees should be refunded.
60
+ ///
61
+ /// # Returns
62
+ ///
63
+ /// * `MessageReceipt` - A struct containing the GUID of the message and the nonce.
64
+ ///
65
+ /// @dev This function is the primary entry point for sending a message from a local OApp to a
66
+ /// remote OApp.
67
+ /// It encodes the message, calculates the required fee, and dispatches it to the LayerZero
68
+ /// network.
69
+ fn send(
70
+ ref self: TContractState, params: MessagingParams, refund_address: ContractAddress,
71
+ ) -> MessageReceipt;
72
+
73
+ /// Quotes the fee for sending a message.
74
+ ///
75
+ /// # Arguments
76
+ ///
77
+ /// * `params` - A `MessagingParams` struct containing the destination EID, receiver address,
78
+ /// message payload,
79
+ /// OApp-specific options, and whether to pay in the LZ token.
80
+ /// * `sender` - The address of the OApp sending the message.
81
+ ///
82
+ /// # Returns
83
+ ///
84
+ /// * `MessagingFee` - A struct containing the native fee and the LZ token fee required to send
85
+ /// the message.
86
+ ///
87
+ /// @dev This function allows an OApp to estimate the cost of sending a message before actually
88
+ /// sending it.
89
+ /// The fee is calculated based on the message parameters and the current network conditions.
90
+ fn quote(
91
+ self: @TContractState, params: MessagingParams, sender: ContractAddress,
92
+ ) -> MessagingFee;
93
+
94
+ /// Commits a message to be verified by the DVNs.
95
+ ///
96
+ /// # Arguments
97
+ ///
98
+ /// * `origin` - An `Origin` struct containing the source EID and sender address.
99
+ /// * `receiver` - The address of the OApp that will receive the message.
100
+ /// * `payload_hash` - The Keccak-256 hash of the message payload.
101
+ ///
102
+ /// @dev This function is called by the LayerZero network to commit a message to the destination
103
+ /// Endpoint.
104
+ /// It stores a hash of the message payload, which will be used later for verification.
105
+ /// This is part of the commit-store-execute pattern to ensure secure message handling.
106
+ fn commit(
107
+ ref self: TContractState, origin: Origin, receiver: ContractAddress, payload_hash: Bytes32,
108
+ );
109
+
110
+ /// Receives and executes a message from a remote OApp.
111
+ ///
112
+ /// # Arguments
113
+ ///
114
+ /// * `origin` - An `Origin` struct containing the source EID and sender address.
115
+ /// * `receiver` - The address of the OApp that will receive the message.
116
+ /// * `guid` - The globally unique identifier of the message.
117
+ /// * `message` - The message payload.
118
+ /// * `value` - The value sent with the message.
119
+ /// * `extra_data` - Additional data provided by the DVNs.
120
+ ///
121
+ /// @dev This function is called by the LayerZero network after a message has been successfully
122
+ /// verified.
123
+ /// It decodes the message and calls the `lz_receive` function on the destination OApp.
124
+ fn lz_receive(
125
+ ref self: TContractState,
126
+ origin: Origin,
127
+ receiver: ContractAddress,
128
+ guid: Bytes32,
129
+ message: ByteArray,
130
+ // every payment is an ERC20 transfer on Starknet
131
+ value: u256,
132
+ extra_data: ByteArray,
133
+ );
134
+
135
+ /// Receives an alert about a failed message.
136
+ ///
137
+ /// # Arguments
138
+ ///
139
+ /// * `origin` - An `Origin` struct containing the source EID and sender address.
140
+ /// * `receiver` - The address of the OApp that was supposed to receive the message.
141
+ /// * `guid` - The GUID of the failed message.
142
+ /// * `gas` - The amount of gas used before the failure.
143
+ /// * `value` - The value sent with the message.
144
+ /// * `message` - The message payload.
145
+ /// * `extra_data` - Additional data provided by the DVNs.
146
+ /// * `reason` - An array of felts describing the reason for the failure.
147
+ ///
148
+ /// @dev This function is called by the LayerZero network when a message fails to be delivered
149
+ /// or executed.
150
+ /// It allows the OApp to handle the failure gracefully, for example, by retrying the message or
151
+ /// notifying a user.
152
+ fn lz_receive_alert(
153
+ ref self: TContractState,
154
+ origin: Origin,
155
+ receiver: ContractAddress,
156
+ guid: Bytes32,
157
+ gas: u256,
158
+ value: u256,
159
+ message: ByteArray,
160
+ extra_data: ByteArray,
161
+ reason: Array<felt252>,
162
+ );
163
+
164
+ /// Clears a stored message payload from the contract's storage.
165
+ ///
166
+ /// # Arguments
167
+ ///
168
+ /// * `origin` - An `Origin` struct containing the source EID and sender address.
169
+ /// * `receiver` - The address of the OApp that received the message.
170
+ /// * `guid` - The GUID of the message.
171
+ /// * `message` - The message payload.
172
+ ///
173
+ /// @dev This function is called by the LayerZero network after a message has been successfully
174
+ /// executed to remove the stored payload hash and free up storage space.
175
+ fn clear(
176
+ ref self: TContractState,
177
+ origin: Origin,
178
+ receiver: ContractAddress,
179
+ guid: Bytes32,
180
+ message: ByteArray,
181
+ );
182
+
183
+ /// Gets the address of the LZ token used for paying fees.
184
+ ///
185
+ /// # Returns
186
+ ///
187
+ /// * `lz_token_address` - The address of the LZ token contract.
188
+ ///
189
+ /// @dev The LZ token is an alternative to the native token for paying LayerZero fees.
190
+ /// This function returns the address of the LZ token contract.
191
+ fn get_lz_token(self: @TContractState) -> ContractAddress;
192
+
193
+ /// Gets the endpoint ID (EID) of the local chain.
194
+ ///
195
+ /// # Returns
196
+ ///
197
+ /// * `eid` - The EID of the local chain.
198
+ ///
199
+ /// @dev The EID is a unique identifier for each chain supported by LayerZero.
200
+ /// This function returns the EID of the chain where the Endpoint contract is deployed.
201
+ fn get_eid(self: @TContractState) -> u32;
202
+
203
+ /// Sets the address of the LZ token used for paying fees.
204
+ ///
205
+ /// # Arguments
206
+ ///
207
+ /// * `lz_token_address` - The new address of the LZ token contract.
208
+ fn set_lz_token(ref self: TContractState, lz_token_address: ContractAddress);
209
+
210
+ /// Sets the delegate for an OApp.
211
+ ///
212
+ /// # Arguments
213
+ /// * `delegate` - The address to be set as the delegate.
214
+ ///
215
+ /// @dev The delegate is an address that is authorized to manage the OApp's configurations,
216
+ /// such as the required DVNs and the verification threshold.
217
+ /// This allows for separation of concerns, where the OApp owner can delegate configuration
218
+ /// management to a separate address.
219
+ fn set_delegate(ref self: TContractState, delegate: ContractAddress);
220
+
221
+ /// Gets the delegate for an OApp.
222
+ ///
223
+ /// # Arguments
224
+ /// * `oapp` - The address of the OApp.
225
+ ///
226
+ /// # Returns
227
+ /// * `ContractAddress` - The address of the delegate.
228
+ fn get_delegate(self: @TContractState, oapp: ContractAddress) -> ContractAddress;
229
+
230
+
231
+ /// Checks if a message path is initializable.
232
+ ///
233
+ /// # Arguments
234
+ ///
235
+ /// * `origin` - An `Origin` struct containing the source EID and sender address.
236
+ /// * `receiver` - The address of the OApp that will receive the message.
237
+ ///
238
+ /// # Returns
239
+ /// * `bool` - `true` if the message path is initializable, `false` otherwise.
240
+ ///
241
+ /// @dev A message path is initializable if it has not been configured yet.
242
+ /// This function is used to determine if a new configuration can be set for a given message
243
+ /// path.
244
+ fn initializable(self: @TContractState, origin: Origin, receiver: ContractAddress) -> bool;
245
+
246
+ /// Check if the message is committable
247
+ ///
248
+ /// # Arguments
249
+ ///
250
+ /// * `origin`: The origin of the message
251
+ /// * `receiver`: The receiver of the message
252
+ ///
253
+ /// # Returns
254
+ /// * `bool` - True if the message is committable, false otherwise
255
+ fn committable(self: @TContractState, origin: Origin, receiver: ContractAddress) -> bool;
256
+
257
+ /// Check if the message is committable with a receive library
258
+ ///
259
+ /// # Arguments
260
+ ///
261
+ /// * `origin`: The origin of the message
262
+ /// * `receiver`: The receiver of the message
263
+ /// * `receive_lib`: The receive library of the message
264
+ ///
265
+ /// # Returns
266
+ /// * `bool` - True if the message is committable with a receive library, false otherwise
267
+ fn committable_with_receive_lib(
268
+ self: @TContractState,
269
+ origin: Origin,
270
+ receiver: ContractAddress,
271
+ receive_lib: ContractAddress,
272
+ ) -> bool;
273
+
274
+ /// Check if the message is executable
275
+ ///
276
+ /// # Arguments
277
+ ///
278
+ /// * `origin` - An `Origin` struct containing the source EID and sender address.
279
+ /// * `receiver` - The address of the OApp that will receive the message.
280
+ ///
281
+ /// # Returns
282
+ /// * `ExecutionState` - The execution state of the message
283
+ fn executable(
284
+ self: @TContractState, origin: Origin, receiver: ContractAddress,
285
+ ) -> ExecutionState;
286
+ }
@@ -0,0 +1,62 @@
1
+ //! LayerZero composer interface
2
+
3
+ use lz_utils::bytes::Bytes32;
4
+ use starknet::ContractAddress;
5
+
6
+ /// # `ILayerZeroComposer` Interface
7
+ ///
8
+ /// The `ILayerZeroComposer` interface is responsible for receiving and processing compose payloads
9
+ /// from LayerZero messages.
10
+ /// It provides a function for handling the compose request and verifying the payload before
11
+ /// executing it.
12
+ ///
13
+ /// ## Key Features
14
+ /// - **Compose Handling**: Receives and processes compose payloads from LayerZero messages.
15
+ /// - **Verification**: Verifies the compose request and payload before executing it.
16
+ /// - **Security**: Ensures that only valid compose requests are processed.
17
+ ///
18
+ /// Contracts that wish to receive compose payloads must implement this
19
+ /// interface. The endpoint's `MessagingComposer` component verifies the
20
+ /// compose request and then invokes `lz_compose` on the target contract.
21
+ ///
22
+ /// ## High-level flow
23
+ /// - An OApp on the source chain requests a compose to a target contract
24
+ /// on the destination chain
25
+ /// - The destination endpoint's `MessagingComposer` validates the request,
26
+ /// prevents reentrancy by marking the message as received, and, if
27
+ /// `value > 0`, transfers the configured compose token to the target
28
+ /// contract before calling `lz_compose`
29
+ /// - The target contract handles the payload in `lz_compose`
30
+ #[starknet::interface]
31
+ pub trait ILayerZeroComposer<TContractState> {
32
+ /// Receives a compose payload for a previously delivered LayerZero message
33
+ ///
34
+ /// This function is called by the endpoint's `MessagingComposer` after it
35
+ /// has verified the compose request and optionally transferred value to
36
+ /// this contract. Implementations must not assume that the caller equals
37
+ /// `from`; the caller is the executor that relayed the compose.
38
+ ///
39
+ /// # Arguments
40
+ /// * `from` - The originating OApp address that initiated the compose on the
41
+ /// source chain
42
+ /// * `guid` - Globally unique identifier of the original LayerZero message
43
+ /// * `message` - Opaque compose payload provided by the sender
44
+ /// * `executor` - The contract address that executed the compose on-chain
45
+ /// * `extra_data` - Additional metadata from the executor (e.g., execution
46
+ /// context or options); protocol-opaque
47
+ /// * `value` - Amount of compose token that was transferred to this
48
+ /// contract immediately before this call (0 if none)
49
+ ///
50
+ /// # Panics
51
+ /// * Implementation-defined. Implementations should revert if the payload is invalid for this
52
+ /// contract or if execution preconditions are not met.
53
+ fn lz_compose(
54
+ ref self: TContractState,
55
+ from: ContractAddress,
56
+ guid: Bytes32,
57
+ message: ByteArray,
58
+ executor: ContractAddress,
59
+ extra_data: ByteArray,
60
+ value: u256,
61
+ );
62
+ }
@@ -0,0 +1,63 @@
1
+ //! LayerZero receiver interface
2
+
3
+ use lz_utils::bytes::Bytes32;
4
+ use starknet::ContractAddress;
5
+ use crate::common::structs::packet::Origin;
6
+
7
+ /// # `ILayerZeroReceiver` Interface
8
+ ///
9
+ /// The `ILayerZeroReceiver` interface is responsible for receiving and processing LayerZero
10
+ /// messages from other chains.
11
+ /// It provides a function for handling the received message and executing the payload.
12
+ ///
13
+ /// ## Key Features
14
+ /// - **Message Receiving**: Receives and processes LayerZero messages from other chains.
15
+ /// - **Execution**: Executes the received message payload.
16
+ /// - **Security**: Ensures that only valid messages are processed.
17
+ #[starknet::interface]
18
+ pub trait ILayerZeroReceiver<TContractState> {
19
+ /// Receives and processes LayerZero messages from other chains
20
+ /// This is the main entry point for incoming cross-chain messages
21
+ ///
22
+ /// # Arguments
23
+ ///
24
+ /// * `origin`: The origin information containing source endpoint ID and sender
25
+ /// * `guid`: Globally unique identifier for this message
26
+ /// * `message`: The actual message payload as bytes
27
+ /// * `executor`: The contract address of the executor handling this message
28
+ /// * `extra_data`: Additional data that may be used for message processing
29
+ fn lz_receive(
30
+ ref self: TContractState,
31
+ origin: Origin,
32
+ guid: Bytes32,
33
+ message: ByteArray,
34
+ executor: ContractAddress,
35
+ value: u256,
36
+ extra_data: ByteArray,
37
+ );
38
+
39
+ /// Checks if a path can be initialized for the given origin
40
+ /// This is used to determine if a new communication path should be allowed
41
+ ///
42
+ /// # Arguments
43
+ ///
44
+ /// * `origin`: The origin information to check for path initialization
45
+ ///
46
+ /// # Returns
47
+ ///
48
+ /// True if the path can be initialized, false otherwise
49
+ fn allow_initialize_path(self: @TContractState, origin: Origin) -> bool;
50
+
51
+ /// Gets the next nonce value for a specific source endpoint and sender
52
+ /// Nonces are used to ensure message ordering and prevent replay attacks
53
+ ///
54
+ /// # Arguments
55
+ ///
56
+ /// * `src_eid`: The source endpoint ID
57
+ /// * `sender`: The sender address as a 32-byte value
58
+ ///
59
+ /// # Returns
60
+ ///
61
+ /// The next nonce value as a u64
62
+ fn next_nonce(self: @TContractState, src_eid: u32, sender: Bytes32) -> u64;
63
+ }