@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.
- package/.turbo/turbo-build.log +186 -0
- package/.turbo/turbo-lint.log +71 -0
- package/.turbo/turbo-test.log +937 -0
- package/README.md +41 -0
- package/Scarb.lock +211 -0
- package/Scarb.toml +2 -0
- package/dist/4XD3ZRZ4.cjs +301 -0
- package/dist/4XD3ZRZ4.cjs.map +1 -0
- package/dist/4Z5IPBC3.js +299 -0
- package/dist/4Z5IPBC3.js.map +1 -0
- package/dist/5NEZDLVQ.cjs +474 -0
- package/dist/5NEZDLVQ.cjs.map +1 -0
- package/dist/6JYCOKDE.js +472 -0
- package/dist/6JYCOKDE.js.map +1 -0
- package/dist/7C4PFMIZ.cjs +1288 -0
- package/dist/7C4PFMIZ.cjs.map +1 -0
- package/dist/7ZSGGZUE.js +1229 -0
- package/dist/7ZSGGZUE.js.map +1 -0
- package/dist/ARHOGUYH.cjs +2136 -0
- package/dist/ARHOGUYH.cjs.map +1 -0
- package/dist/CRCRIUFX.js +1264 -0
- package/dist/CRCRIUFX.js.map +1 -0
- package/dist/DB7CQSED.cjs +430 -0
- package/dist/DB7CQSED.cjs.map +1 -0
- package/dist/DFXLWHYP.cjs +1266 -0
- package/dist/DFXLWHYP.cjs.map +1 -0
- package/dist/EOLZCMCK.js +988 -0
- package/dist/EOLZCMCK.js.map +1 -0
- package/dist/FFDPTOWG.cjs +331 -0
- package/dist/FFDPTOWG.cjs.map +1 -0
- package/dist/FOJGEAIO.js +2134 -0
- package/dist/FOJGEAIO.js.map +1 -0
- package/dist/IWIUMVGB.js +629 -0
- package/dist/IWIUMVGB.js.map +1 -0
- package/dist/MUEN6AWV.cjs +697 -0
- package/dist/MUEN6AWV.cjs.map +1 -0
- package/dist/ORE6VBZ4.cjs +990 -0
- package/dist/ORE6VBZ4.cjs.map +1 -0
- package/dist/OUFKWPZ7.js +732 -0
- package/dist/OUFKWPZ7.js.map +1 -0
- package/dist/T2QTYQXJ.js +1229 -0
- package/dist/T2QTYQXJ.js.map +1 -0
- package/dist/UPJTM7BR.cjs +631 -0
- package/dist/UPJTM7BR.cjs.map +1 -0
- package/dist/VNVNX2P3.cjs +1231 -0
- package/dist/VNVNX2P3.cjs.map +1 -0
- package/dist/VUOMXK5T.js +6 -0
- package/dist/VUOMXK5T.js.map +1 -0
- package/dist/WISWRTDG.js +1286 -0
- package/dist/WISWRTDG.js.map +1 -0
- package/dist/WU5L7YIQ.cjs +1231 -0
- package/dist/WU5L7YIQ.cjs.map +1 -0
- package/dist/X3B5JDMZ.js +695 -0
- package/dist/X3B5JDMZ.js.map +1 -0
- package/dist/XYNBDBBV.cjs +297 -0
- package/dist/XYNBDBBV.cjs.map +1 -0
- package/dist/Y5JFPCYJ.cjs +734 -0
- package/dist/Y5JFPCYJ.cjs.map +1 -0
- package/dist/YEHL7IYO.js +295 -0
- package/dist/YEHL7IYO.js.map +1 -0
- package/dist/YJF4D23A.cjs +8 -0
- package/dist/YJF4D23A.cjs.map +1 -0
- package/dist/YTS44OEA.js +428 -0
- package/dist/YTS44OEA.js.map +1 -0
- package/dist/Z2NIUZMW.js +329 -0
- package/dist/Z2NIUZMW.js.map +1 -0
- package/dist/abis/blocked-message-lib.cjs +13 -0
- package/dist/abis/blocked-message-lib.cjs.map +1 -0
- package/dist/abis/blocked-message-lib.d.ts +338 -0
- package/dist/abis/blocked-message-lib.d.ts.map +1 -0
- package/dist/abis/blocked-message-lib.js +4 -0
- package/dist/abis/blocked-message-lib.js.map +1 -0
- package/dist/abis/dvn-fee-lib.cjs +13 -0
- package/dist/abis/dvn-fee-lib.cjs.map +1 -0
- package/dist/abis/dvn-fee-lib.d.ts +214 -0
- package/dist/abis/dvn-fee-lib.d.ts.map +1 -0
- package/dist/abis/dvn-fee-lib.js +4 -0
- package/dist/abis/dvn-fee-lib.js.map +1 -0
- package/dist/abis/dvn.cjs +13 -0
- package/dist/abis/dvn.cjs.map +1 -0
- package/dist/abis/dvn.d.ts +952 -0
- package/dist/abis/dvn.d.ts.map +1 -0
- package/dist/abis/dvn.js +4 -0
- package/dist/abis/dvn.js.map +1 -0
- package/dist/abis/endpoint-v2.cjs +13 -0
- package/dist/abis/endpoint-v2.cjs.map +1 -0
- package/dist/abis/endpoint-v2.d.ts +1580 -0
- package/dist/abis/endpoint-v2.d.ts.map +1 -0
- package/dist/abis/endpoint-v2.js +4 -0
- package/dist/abis/endpoint-v2.js.map +1 -0
- package/dist/abis/executor-fee-lib.cjs +13 -0
- package/dist/abis/executor-fee-lib.cjs.map +1 -0
- package/dist/abis/executor-fee-lib.d.ts +217 -0
- package/dist/abis/executor-fee-lib.d.ts.map +1 -0
- package/dist/abis/executor-fee-lib.js +4 -0
- package/dist/abis/executor-fee-lib.js.map +1 -0
- package/dist/abis/executor.cjs +13 -0
- package/dist/abis/executor.cjs.map +1 -0
- package/dist/abis/executor.d.ts +914 -0
- package/dist/abis/executor.d.ts.map +1 -0
- package/dist/abis/executor.js +4 -0
- package/dist/abis/executor.js.map +1 -0
- package/dist/abis/o-app.cjs +13 -0
- package/dist/abis/o-app.cjs.map +1 -0
- package/dist/abis/o-app.d.ts +311 -0
- package/dist/abis/o-app.d.ts.map +1 -0
- package/dist/abis/o-app.js +4 -0
- package/dist/abis/o-app.js.map +1 -0
- package/dist/abis/oft-adapter.cjs +13 -0
- package/dist/abis/oft-adapter.cjs.map +1 -0
- package/dist/abis/oft-adapter.d.ts +722 -0
- package/dist/abis/oft-adapter.d.ts.map +1 -0
- package/dist/abis/oft-adapter.js +4 -0
- package/dist/abis/oft-adapter.js.map +1 -0
- package/dist/abis/oft.cjs +13 -0
- package/dist/abis/oft.cjs.map +1 -0
- package/dist/abis/oft.d.ts +922 -0
- package/dist/abis/oft.d.ts.map +1 -0
- package/dist/abis/oft.js +4 -0
- package/dist/abis/oft.js.map +1 -0
- package/dist/abis/omni-counter.cjs +13 -0
- package/dist/abis/omni-counter.cjs.map +1 -0
- package/dist/abis/omni-counter.d.ts +459 -0
- package/dist/abis/omni-counter.d.ts.map +1 -0
- package/dist/abis/omni-counter.js +4 -0
- package/dist/abis/omni-counter.js.map +1 -0
- package/dist/abis/price-feed.cjs +13 -0
- package/dist/abis/price-feed.cjs.map +1 -0
- package/dist/abis/price-feed.d.ts +505 -0
- package/dist/abis/price-feed.d.ts.map +1 -0
- package/dist/abis/price-feed.js +4 -0
- package/dist/abis/price-feed.js.map +1 -0
- package/dist/abis/simple-message-lib.cjs +13 -0
- package/dist/abis/simple-message-lib.cjs.map +1 -0
- package/dist/abis/simple-message-lib.d.ts +535 -0
- package/dist/abis/simple-message-lib.d.ts.map +1 -0
- package/dist/abis/simple-message-lib.js +4 -0
- package/dist/abis/simple-message-lib.js.map +1 -0
- package/dist/abis/treasury.cjs +13 -0
- package/dist/abis/treasury.cjs.map +1 -0
- package/dist/abis/treasury.d.ts +240 -0
- package/dist/abis/treasury.d.ts.map +1 -0
- package/dist/abis/treasury.js +4 -0
- package/dist/abis/treasury.js.map +1 -0
- package/dist/abis/ultra-light-node.cjs +13 -0
- package/dist/abis/ultra-light-node.cjs.map +1 -0
- package/dist/abis/ultra-light-node.d.ts +900 -0
- package/dist/abis/ultra-light-node.d.ts.map +1 -0
- package/dist/abis/ultra-light-node.js +4 -0
- package/dist/abis/ultra-light-node.js.map +1 -0
- package/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/scripts/build-abi.cjs +28 -0
- package/dist/scripts/build-abi.cjs.map +1 -0
- package/dist/scripts/build-abi.d.ts +2 -0
- package/dist/scripts/build-abi.d.ts.map +1 -0
- package/dist/scripts/build-abi.js +26 -0
- package/dist/scripts/build-abi.js.map +1 -0
- package/layerzero/README.md +244 -0
- package/layerzero/Scarb.lock +203 -0
- package/layerzero/Scarb.toml +30 -0
- package/layerzero/snfoundry.toml +11 -0
- package/layerzero/src/common/constants.cairo +26 -0
- package/layerzero/src/common/conversions.cairo +16 -0
- package/layerzero/src/common/guid.cairo +20 -0
- package/layerzero/src/common/packet_v1_codec.cairo +307 -0
- package/layerzero/src/common/structs/messaging.cairo +40 -0
- package/layerzero/src/common/structs/packet.cairo +31 -0
- package/layerzero/src/endpoint/constants.cairo +14 -0
- package/layerzero/src/endpoint/endpoint.cairo +688 -0
- package/layerzero/src/endpoint/errors.cairo +108 -0
- package/layerzero/src/endpoint/events.cairo +124 -0
- package/layerzero/src/endpoint/interfaces/endpoint.cairo +286 -0
- package/layerzero/src/endpoint/interfaces/layerzero_composer.cairo +62 -0
- package/layerzero/src/endpoint/interfaces/layerzero_receiver.cairo +63 -0
- package/layerzero/src/endpoint/message_lib_manager/errors.cairo +95 -0
- package/layerzero/src/endpoint/message_lib_manager/events.cairo +90 -0
- package/layerzero/src/endpoint/message_lib_manager/interface.cairo +449 -0
- package/layerzero/src/endpoint/message_lib_manager/message_lib_manager.cairo +720 -0
- package/layerzero/src/endpoint/message_lib_manager/structs.cairo +33 -0
- package/layerzero/src/endpoint/messaging_channel/errors.cairo +37 -0
- package/layerzero/src/endpoint/messaging_channel/events.cairo +58 -0
- package/layerzero/src/endpoint/messaging_channel/interface.cairo +171 -0
- package/layerzero/src/endpoint/messaging_channel/messaging_channel.cairo +453 -0
- package/layerzero/src/endpoint/messaging_composer/errors.cairo +46 -0
- package/layerzero/src/endpoint/messaging_composer/events.cairo +67 -0
- package/layerzero/src/endpoint/messaging_composer/interface.cairo +132 -0
- package/layerzero/src/endpoint/messaging_composer/messaging_composer.cairo +223 -0
- package/layerzero/src/lib.cairo +189 -0
- package/layerzero/src/message_lib/blocked_message_lib.cairo +114 -0
- package/layerzero/src/message_lib/interface.cairo +63 -0
- package/layerzero/src/message_lib/sml/errors.cairo +23 -0
- package/layerzero/src/message_lib/sml/events.cairo +32 -0
- package/layerzero/src/message_lib/sml/simple_message_lib.cairo +312 -0
- package/layerzero/src/message_lib/structs.cairo +22 -0
- package/layerzero/src/message_lib/uln/errors.cairo +128 -0
- package/layerzero/src/message_lib/uln/events.cairo +97 -0
- package/layerzero/src/message_lib/uln/interface.cairo +83 -0
- package/layerzero/src/message_lib/uln/options.cairo +64 -0
- package/layerzero/src/message_lib/uln/structs/executor_config.cairo +35 -0
- package/layerzero/src/message_lib/uln/structs/payment_info.cairo +7 -0
- package/layerzero/src/message_lib/uln/structs/uln_config.cairo +155 -0
- package/layerzero/src/message_lib/uln/structs/uln_config_storage_node.cairo +91 -0
- package/layerzero/src/message_lib/uln/structs/verification.cairo +7 -0
- package/layerzero/src/message_lib/uln/ultra_light_node.cairo +965 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/errors.cairo +22 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/events.cairo +6 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/interface.cairo +34 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/oapp_options_type_3.cairo +120 -0
- package/layerzero/src/oapps/common/oapp_options_type_3/structs.cairo +6 -0
- package/layerzero/src/oapps/counter/constants.cairo +3 -0
- package/layerzero/src/oapps/counter/counter.cairo +170 -0
- package/layerzero/src/oapps/counter/interface.cairo +27 -0
- package/layerzero/src/oapps/counter/structs.cairo +20 -0
- package/layerzero/src/oapps/message_inspector/interface.cairo +21 -0
- package/layerzero/src/oapps/oapp/errors.cairo +72 -0
- package/layerzero/src/oapps/oapp/events.cairo +9 -0
- package/layerzero/src/oapps/oapp/interface.cairo +67 -0
- package/layerzero/src/oapps/oapp/oapp.cairo +70 -0
- package/layerzero/src/oapps/oapp/oapp_core.cairo +448 -0
- package/layerzero/src/oapps/oft/errors.cairo +42 -0
- package/layerzero/src/oapps/oft/events.cairo +33 -0
- package/layerzero/src/oapps/oft/interface.cairo +87 -0
- package/layerzero/src/oapps/oft/oft.cairo +188 -0
- package/layerzero/src/oapps/oft/oft_adapter.cairo +175 -0
- package/layerzero/src/oapps/oft/oft_compose_msg_codec.cairo +128 -0
- package/layerzero/src/oapps/oft/oft_core.cairo +542 -0
- package/layerzero/src/oapps/oft/oft_msg_codec.cairo +131 -0
- package/layerzero/src/oapps/oft/structs.cairo +72 -0
- package/layerzero/src/treasury/errors.cairo +22 -0
- package/layerzero/src/treasury/events.cairo +5 -0
- package/layerzero/src/treasury/interfaces/layerzero_treasury.cairo +54 -0
- package/layerzero/src/treasury/interfaces/lz_token_fee_lib.cairo +45 -0
- package/layerzero/src/treasury/interfaces/treasury_admin.cairo +39 -0
- package/layerzero/src/treasury/treasury.cairo +140 -0
- package/layerzero/src/workers/access_control.cairo +11 -0
- package/layerzero/src/workers/base/base.cairo +238 -0
- package/layerzero/src/workers/base/errors.cairo +24 -0
- package/layerzero/src/workers/base/events.cairo +43 -0
- package/layerzero/src/workers/base/interface.cairo +93 -0
- package/layerzero/src/workers/base/structs.cairo +10 -0
- package/layerzero/src/workers/common.cairo +59 -0
- package/layerzero/src/workers/dvn/constants.cairo +11 -0
- package/layerzero/src/workers/dvn/dvn.cairo +338 -0
- package/layerzero/src/workers/dvn/errors.cairo +80 -0
- package/layerzero/src/workers/dvn/events.cairo +30 -0
- package/layerzero/src/workers/dvn/fee_lib/dvn_fee_lib.cairo +152 -0
- package/layerzero/src/workers/dvn/fee_lib/interface.cairo +45 -0
- package/layerzero/src/workers/dvn/interface.cairo +131 -0
- package/layerzero/src/workers/dvn/options.cairo +125 -0
- package/layerzero/src/workers/dvn/structs.cairo +51 -0
- package/layerzero/src/workers/executor/errors.cairo +159 -0
- package/layerzero/src/workers/executor/events.cairo +32 -0
- package/layerzero/src/workers/executor/executor.cairo +392 -0
- package/layerzero/src/workers/executor/fee_lib/executor_fee_lib.cairo +160 -0
- package/layerzero/src/workers/executor/fee_lib/interface.cairo +87 -0
- package/layerzero/src/workers/executor/interface.cairo +131 -0
- package/layerzero/src/workers/executor/options.cairo +244 -0
- package/layerzero/src/workers/executor/structs.cairo +119 -0
- package/layerzero/src/workers/interface.cairo +32 -0
- package/layerzero/src/workers/price_feed/constants.cairo +7 -0
- package/layerzero/src/workers/price_feed/errors.cairo +28 -0
- package/layerzero/src/workers/price_feed/events.cairo +13 -0
- package/layerzero/src/workers/price_feed/interface.cairo +264 -0
- package/layerzero/src/workers/price_feed/price_feed.cairo +392 -0
- package/layerzero/src/workers/price_feed/structs.cairo +74 -0
- package/layerzero/tests/common/test_constants.cairo +21 -0
- package/layerzero/tests/common/test_guid.cairo +232 -0
- package/layerzero/tests/common/test_packet_v1_codec.cairo +372 -0
- package/layerzero/tests/common/utils.cairo +23 -0
- package/layerzero/tests/e2e/oft_utils.cairo +121 -0
- package/layerzero/tests/e2e/test_counter_with_sml.cairo +194 -0
- package/layerzero/tests/e2e/test_counter_with_uln.cairo +352 -0
- package/layerzero/tests/e2e/test_dvn.cairo +406 -0
- package/layerzero/tests/e2e/test_lz_token.cairo +354 -0
- package/layerzero/tests/e2e/test_oft_compose_with_uln.cairo +364 -0
- package/layerzero/tests/e2e/test_oft_with_sml.cairo +240 -0
- package/layerzero/tests/e2e/test_oft_with_uln.cairo +299 -0
- package/layerzero/tests/e2e/utils.cairo +490 -0
- package/layerzero/tests/endpoint/message_lib_manager/test_message_lib_manager.cairo +2051 -0
- package/layerzero/tests/endpoint/message_lib_manager/utils.cairo +45 -0
- package/layerzero/tests/endpoint/messaging_channel/test_messaging_channel.cairo +621 -0
- package/layerzero/tests/endpoint/messaging_channel/utils.cairo +96 -0
- package/layerzero/tests/endpoint/messaging_composer/test_messaging_composer.cairo +456 -0
- package/layerzero/tests/endpoint/messaging_composer/utils.cairo +75 -0
- package/layerzero/tests/endpoint/test_endpoint_commit.cairo +763 -0
- package/layerzero/tests/endpoint/test_endpoint_lzreceive.cairo +1253 -0
- package/layerzero/tests/endpoint/test_endpoint_quote.cairo +71 -0
- package/layerzero/tests/endpoint/test_endpoint_send.cairo +1327 -0
- package/layerzero/tests/endpoint/utils.cairo +129 -0
- package/layerzero/tests/fuzzable/blockchain_config.cairo +89 -0
- package/layerzero/tests/fuzzable/bytes32.cairo +16 -0
- package/layerzero/tests/fuzzable/contract_address.cairo +67 -0
- package/layerzero/tests/fuzzable/dst_config.cairo +37 -0
- package/layerzero/tests/fuzzable/eid.cairo +23 -0
- package/layerzero/tests/fuzzable/eth_address.cairo +17 -0
- package/layerzero/tests/fuzzable/expiry.cairo +27 -0
- package/layerzero/tests/fuzzable/felt_array.cairo +38 -0
- package/layerzero/tests/fuzzable/inbound_params.cairo +21 -0
- package/layerzero/tests/fuzzable/keys.cairo +16 -0
- package/layerzero/tests/fuzzable/model_type.cairo +27 -0
- package/layerzero/tests/fuzzable/origin.cairo +21 -0
- package/layerzero/tests/fuzzable/price.cairo +32 -0
- package/layerzero/tests/fuzzable/role_admin.cairo +29 -0
- package/layerzero/tests/fuzzable/small_byte_array.cairo +61 -0
- package/layerzero/tests/lib.cairo +177 -0
- package/layerzero/tests/message_lib/sml/test_simple_message_lib.cairo +224 -0
- package/layerzero/tests/message_lib/uln/test_uln_admin.cairo +2150 -0
- package/layerzero/tests/message_lib/uln/test_uln_config.cairo +527 -0
- package/layerzero/tests/message_lib/uln/test_uln_config_storage_node.cairo +69 -0
- package/layerzero/tests/message_lib/uln/test_uln_executor_config.cairo +173 -0
- package/layerzero/tests/message_lib/uln/test_uln_options.cairo +329 -0
- package/layerzero/tests/message_lib/uln/test_uln_quote.cairo +1038 -0
- package/layerzero/tests/message_lib/uln/test_uln_receive.cairo +715 -0
- package/layerzero/tests/message_lib/uln/test_uln_send.cairo +1155 -0
- package/layerzero/tests/message_lib/uln/utils.cairo +59 -0
- package/layerzero/tests/mocks/composer_target.cairo +76 -0
- package/layerzero/tests/mocks/endpoint.cairo +199 -0
- package/layerzero/tests/mocks/erc20/erc20.cairo +50 -0
- package/layerzero/tests/mocks/erc20/interface.cairo +8 -0
- package/layerzero/tests/mocks/message_inspector/message_inspector.cairo +17 -0
- package/layerzero/tests/mocks/message_lib_manager.cairo +98 -0
- package/layerzero/tests/mocks/messaging_channel/interface.cairo +23 -0
- package/layerzero/tests/mocks/messaging_channel/messaging_channel.cairo +138 -0
- package/layerzero/tests/mocks/messaging_composer.cairo +171 -0
- package/layerzero/tests/mocks/oapp_core/interface.cairo +53 -0
- package/layerzero/tests/mocks/oapp_core/oapp_core.cairo +142 -0
- package/layerzero/tests/mocks/oapp_options_type3.cairo +42 -0
- package/layerzero/tests/mocks/oft_core/interface.cairo +28 -0
- package/layerzero/tests/mocks/oft_core/oft_core.cairo +242 -0
- package/layerzero/tests/mocks/receiver.cairo +54 -0
- package/layerzero/tests/mocks/treasury/lz_token_fee_lib.cairo +57 -0
- package/layerzero/tests/mocks/treasury/treasury.cairo +74 -0
- package/layerzero/tests/mocks/uln_config/interface.cairo +12 -0
- package/layerzero/tests/mocks/uln_config/uln_config.cairo +35 -0
- package/layerzero/tests/mocks/workers/base.cairo +80 -0
- package/layerzero/tests/mocks/workers/dvn.cairo +115 -0
- package/layerzero/tests/mocks/workers/executor/decode/decode.cairo +97 -0
- package/layerzero/tests/mocks/workers/executor/decode/interface.cairo +59 -0
- package/layerzero/tests/mocks/workers/executor/executor.cairo +176 -0
- package/layerzero/tests/oapps/common/test_oapp_options_type_3.cairo +279 -0
- package/layerzero/tests/oapps/oft/test_oft_adapter.cairo +441 -0
- package/layerzero/tests/oapps/oft/test_oft_compose_msg_codec.cairo +139 -0
- package/layerzero/tests/oapps/oft/test_oft_core.cairo +751 -0
- package/layerzero/tests/oapps/oft/test_oft_msg_codec.cairo +268 -0
- package/layerzero/tests/oapps/test_counter.cairo +470 -0
- package/layerzero/tests/oapps/test_oapp_core.cairo +750 -0
- package/layerzero/tests/treasury/test_lz_token_fee_lib.cairo +63 -0
- package/layerzero/tests/treasury/test_treasury.cairo +458 -0
- package/layerzero/tests/treasury/utils.cairo +8 -0
- package/layerzero/tests/utils.cairo +48 -0
- package/layerzero/tests/workers/base/test_worker_base.cairo +1097 -0
- package/layerzero/tests/workers/base/utils.cairo +76 -0
- package/layerzero/tests/workers/dvn/fee_lib/test_dvn_fee_lib.cairo +361 -0
- package/layerzero/tests/workers/dvn/test_dvn.cairo +1101 -0
- package/layerzero/tests/workers/dvn/test_dvn_options.cairo +312 -0
- package/layerzero/tests/workers/dvn/utils.cairo +236 -0
- package/layerzero/tests/workers/executor/fee_lib/test_executor_fee_lib.cairo +223 -0
- package/layerzero/tests/workers/executor/test_decode.cairo +612 -0
- package/layerzero/tests/workers/executor/test_executor.cairo +1472 -0
- package/layerzero/tests/workers/executor/utils.cairo +296 -0
- package/layerzero/tests/workers/price_feed/test_price_feed.cairo +879 -0
- package/layerzero/tests/workers/price_feed/utils.cairo +37 -0
- package/libs/enumerable_set/Scarb.lock +24 -0
- package/libs/enumerable_set/Scarb.toml +17 -0
- package/libs/enumerable_set/src/enumerable_set.cairo +118 -0
- package/libs/enumerable_set/src/lib.cairo +4 -0
- package/libs/enumerable_set/tests/lib.cairo +5 -0
- package/libs/enumerable_set/tests/mocks/mock_enumerable_set.cairo +61 -0
- package/libs/enumerable_set/tests/test_enumerable_set.cairo +379 -0
- package/libs/lz_utils/Scarb.lock +24 -0
- package/libs/lz_utils/Scarb.toml +17 -0
- package/libs/lz_utils/src/bytes.cairo +33 -0
- package/libs/lz_utils/src/error.cairo +12 -0
- package/libs/lz_utils/src/keccak.cairo +28 -0
- package/libs/lz_utils/src/lib.cairo +3 -0
- package/libs/multisig/Scarb.lock +172 -0
- package/libs/multisig/Scarb.toml +23 -0
- package/libs/multisig/src/errors.cairo +84 -0
- package/libs/multisig/src/events.cairo +13 -0
- package/libs/multisig/src/interface.cairo +73 -0
- package/libs/multisig/src/lib.cairo +7 -0
- package/libs/multisig/src/multisig.cairo +241 -0
- package/libs/multisig/tests/lib.cairo +4 -0
- package/libs/multisig/tests/mocks/mock_multisig.cairo +57 -0
- package/libs/multisig/tests/test_multisig.cairo +452 -0
- package/package.json +41 -0
- package/src/scripts/build-abi.ts +51 -0
- package/target/CACHEDIR.TAG +3 -0
- package/target/dev/.fingerprint/alexandria_bytes-5ea6u5t70d7qi/alexandria_bytes +1 -0
- package/target/dev/.fingerprint/alexandria_data_structures-0aue3g6q80gs0/alexandria_data_structures +1 -0
- package/target/dev/.fingerprint/alexandria_math-h2fi7jdq4isuu/alexandria_math +1 -0
- package/target/dev/.fingerprint/core-lq3u730l5p1ag/core +1 -0
- package/target/dev/.fingerprint/core-vf7fc6rvic5vi/core +1 -0
- package/target/dev/.fingerprint/enumerable_set-eaerkg8njl85o/enumerable_set +1 -0
- package/target/dev/.fingerprint/enumerable_set-r54oje7t06ku8/enumerable_set +1 -0
- package/target/dev/.fingerprint/layerzero-oqgdqsaddpi2k/layerzero +1 -0
- package/target/dev/.fingerprint/lz_utils-kfkkeueiqg0pa/lz_utils +1 -0
- package/target/dev/.fingerprint/lz_utils-u4v1os6e7gkng/lz_utils +1 -0
- package/target/dev/.fingerprint/multisig-0fjetugejecge/multisig +1 -0
- package/target/dev/.fingerprint/multisig-6j5kqs436hm54/multisig +1 -0
- package/target/dev/.fingerprint/openzeppelin-ei1id1hu088lo/openzeppelin +1 -0
- package/target/dev/.fingerprint/openzeppelin-j9d5nd1qhfnu6/openzeppelin +1 -0
- package/target/dev/.fingerprint/openzeppelin_access-3oa41aikpaek0/openzeppelin_access +1 -0
- package/target/dev/.fingerprint/openzeppelin_access-p5h849v8so76q/openzeppelin_access +1 -0
- package/target/dev/.fingerprint/openzeppelin_account-4qhv5fks84g9u/openzeppelin_account +1 -0
- package/target/dev/.fingerprint/openzeppelin_account-hgbm8ln9ah7rm/openzeppelin_account +1 -0
- package/target/dev/.fingerprint/openzeppelin_finance-n70q9al0cps8i/openzeppelin_finance +1 -0
- package/target/dev/.fingerprint/openzeppelin_finance-nnd4f8703t3ak/openzeppelin_finance +1 -0
- package/target/dev/.fingerprint/openzeppelin_governance-3gnk21ubp5lis/openzeppelin_governance +1 -0
- package/target/dev/.fingerprint/openzeppelin_governance-rj1bfont4fij4/openzeppelin_governance +1 -0
- package/target/dev/.fingerprint/openzeppelin_introspection-3fja9hd1gvbcq/openzeppelin_introspection +1 -0
- package/target/dev/.fingerprint/openzeppelin_introspection-jc3nf5525eet6/openzeppelin_introspection +1 -0
- package/target/dev/.fingerprint/openzeppelin_merkle_tree-4en77ogr2r2l2/openzeppelin_merkle_tree +1 -0
- package/target/dev/.fingerprint/openzeppelin_merkle_tree-4t190frqs4db8/openzeppelin_merkle_tree +1 -0
- package/target/dev/.fingerprint/openzeppelin_presets-aqb0f6p9c0bp6/openzeppelin_presets +1 -0
- package/target/dev/.fingerprint/openzeppelin_presets-nseg8korhin8e/openzeppelin_presets +1 -0
- package/target/dev/.fingerprint/openzeppelin_security-g7p73ji1ih1qg/openzeppelin_security +1 -0
- package/target/dev/.fingerprint/openzeppelin_security-qp5328v80452u/openzeppelin_security +1 -0
- package/target/dev/.fingerprint/openzeppelin_token-jjf7tl9rphc6k/openzeppelin_token +1 -0
- package/target/dev/.fingerprint/openzeppelin_token-r6s43vlpj6rqk/openzeppelin_token +1 -0
- package/target/dev/.fingerprint/openzeppelin_upgrades-0dpbnre7engca/openzeppelin_upgrades +1 -0
- package/target/dev/.fingerprint/openzeppelin_upgrades-2sqgvbuv9s800/openzeppelin_upgrades +1 -0
- package/target/dev/.fingerprint/openzeppelin_utils-mj395ivff1ffo/openzeppelin_utils +1 -0
- package/target/dev/.fingerprint/openzeppelin_utils-oh1hse8sjumgm/openzeppelin_utils +1 -0
- package/target/dev/.fingerprint/starkware_utils-1qnnjnq0pf9u0/starkware_utils +1 -0
- package/target/dev/.fingerprint/starkware_utils-mh8e3te65lju4/starkware_utils +1 -0
- package/target/dev/enumerable_set.sierra.json +1 -0
- package/target/dev/incremental/alexandria_bytes-5ea6u5t70d7qi.bin +0 -0
- package/target/dev/incremental/alexandria_data_structures-0aue3g6q80gs0.bin +0 -0
- package/target/dev/incremental/alexandria_math-h2fi7jdq4isuu.bin +0 -0
- package/target/dev/incremental/core-lq3u730l5p1ag.bin +0 -0
- package/target/dev/incremental/core-vf7fc6rvic5vi.bin +0 -0
- package/target/dev/incremental/enumerable_set-eaerkg8njl85o.bin +0 -0
- package/target/dev/incremental/enumerable_set-r54oje7t06ku8.bin +0 -0
- package/target/dev/incremental/layerzero-oqgdqsaddpi2k.bin +0 -0
- package/target/dev/incremental/lz_utils-kfkkeueiqg0pa.bin +0 -0
- package/target/dev/incremental/lz_utils-u4v1os6e7gkng.bin +0 -0
- package/target/dev/incremental/multisig-0fjetugejecge.bin +0 -0
- package/target/dev/incremental/multisig-6j5kqs436hm54.bin +0 -0
- package/target/dev/incremental/openzeppelin-ei1id1hu088lo.bin +0 -0
- package/target/dev/incremental/openzeppelin-j9d5nd1qhfnu6.bin +0 -0
- package/target/dev/incremental/openzeppelin_access-3oa41aikpaek0.bin +0 -0
- package/target/dev/incremental/openzeppelin_access-p5h849v8so76q.bin +0 -0
- package/target/dev/incremental/openzeppelin_account-4qhv5fks84g9u.bin +0 -0
- package/target/dev/incremental/openzeppelin_account-hgbm8ln9ah7rm.bin +0 -0
- package/target/dev/incremental/openzeppelin_finance-n70q9al0cps8i.bin +0 -0
- package/target/dev/incremental/openzeppelin_finance-nnd4f8703t3ak.bin +0 -0
- package/target/dev/incremental/openzeppelin_governance-3gnk21ubp5lis.bin +0 -0
- package/target/dev/incremental/openzeppelin_governance-rj1bfont4fij4.bin +0 -0
- package/target/dev/incremental/openzeppelin_introspection-3fja9hd1gvbcq.bin +0 -0
- package/target/dev/incremental/openzeppelin_introspection-jc3nf5525eet6.bin +0 -0
- package/target/dev/incremental/openzeppelin_merkle_tree-4en77ogr2r2l2.bin +0 -0
- package/target/dev/incremental/openzeppelin_merkle_tree-4t190frqs4db8.bin +0 -0
- package/target/dev/incremental/openzeppelin_presets-aqb0f6p9c0bp6.bin +0 -0
- package/target/dev/incremental/openzeppelin_presets-nseg8korhin8e.bin +0 -0
- package/target/dev/incremental/openzeppelin_security-g7p73ji1ih1qg.bin +0 -0
- package/target/dev/incremental/openzeppelin_security-qp5328v80452u.bin +0 -0
- package/target/dev/incremental/openzeppelin_token-jjf7tl9rphc6k.bin +0 -0
- package/target/dev/incremental/openzeppelin_token-r6s43vlpj6rqk.bin +0 -0
- package/target/dev/incremental/openzeppelin_upgrades-0dpbnre7engca.bin +0 -0
- package/target/dev/incremental/openzeppelin_upgrades-2sqgvbuv9s800.bin +0 -0
- package/target/dev/incremental/openzeppelin_utils-mj395ivff1ffo.bin +0 -0
- package/target/dev/incremental/openzeppelin_utils-oh1hse8sjumgm.bin +0 -0
- package/target/dev/incremental/starkware_utils-1qnnjnq0pf9u0.bin +0 -0
- package/target/dev/incremental/starkware_utils-mh8e3te65lju4.bin +0 -0
- package/target/dev/layerzero.starknet_artifacts.json +1 -0
- package/target/dev/layerzero_BlockedMessageLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_BlockedMessageLib.contract_class.json +1 -0
- package/target/dev/layerzero_Dvn.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Dvn.contract_class.json +1 -0
- package/target/dev/layerzero_DvnFeeLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_DvnFeeLib.contract_class.json +1 -0
- package/target/dev/layerzero_Endpoint.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Endpoint.contract_class.json +1 -0
- package/target/dev/layerzero_Executor.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Executor.contract_class.json +1 -0
- package/target/dev/layerzero_ExecutorFeeLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_ExecutorFeeLib.contract_class.json +1 -0
- package/target/dev/layerzero_OApp.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OApp.contract_class.json +1 -0
- package/target/dev/layerzero_OFT.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OFT.contract_class.json +1 -0
- package/target/dev/layerzero_OFTAdapter.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OFTAdapter.contract_class.json +1 -0
- package/target/dev/layerzero_OmniCounter.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_OmniCounter.contract_class.json +1 -0
- package/target/dev/layerzero_PriceFeed.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_PriceFeed.contract_class.json +1 -0
- package/target/dev/layerzero_SimpleMessageLib.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_SimpleMessageLib.contract_class.json +1 -0
- package/target/dev/layerzero_Treasury.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_Treasury.contract_class.json +1 -0
- package/target/dev/layerzero_UltraLightNode.compiled_contract_class.json +1 -0
- package/target/dev/layerzero_UltraLightNode.contract_class.json +1 -0
- package/target/dev/lz_utils.sierra.json +1 -0
- package/target/dev/multisig.sierra.json +1 -0
- package/tools/update_contracts.sh +19 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +7 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
//! Messaging composer interface
|
|
2
|
+
|
|
3
|
+
use lz_utils::bytes::Bytes32;
|
|
4
|
+
use starknet::ContractAddress;
|
|
5
|
+
|
|
6
|
+
/// # `IMessagingComposer` Interface
|
|
7
|
+
///
|
|
8
|
+
/// The `IMessagingComposer` manages compose payloads that are sent after a LayerZero message has
|
|
9
|
+
/// been delivered.
|
|
10
|
+
///
|
|
11
|
+
/// ## Key features
|
|
12
|
+
/// - Queueing of compose payloads by the originating OApp
|
|
13
|
+
/// - Verified delivery of compose payloads to a target contract
|
|
14
|
+
/// - Optional value transfer (ERC20) to the target prior to callback
|
|
15
|
+
/// - Alerting hooks for off-chain/executor reporting
|
|
16
|
+
/// - Introspection of the compose queue state
|
|
17
|
+
#[starknet::interface]
|
|
18
|
+
pub trait IMessagingComposer<TContractState> {
|
|
19
|
+
/// Queue a compose payload for later delivery
|
|
20
|
+
///
|
|
21
|
+
/// Records the keccak hash of `message` keyed by (sender, `to`, `guid`, `index`).
|
|
22
|
+
/// A corresponding delivery will be executed via `lz_compose` by an executor.
|
|
23
|
+
///
|
|
24
|
+
/// # Arguments
|
|
25
|
+
/// * `to` - Target contract that will receive the compose callback
|
|
26
|
+
/// * `guid` - Unique identifier of the original LayerZero message
|
|
27
|
+
/// * `index` - Compose index associated with the original message
|
|
28
|
+
/// * `message` - Opaque compose payload
|
|
29
|
+
///
|
|
30
|
+
/// # Emits
|
|
31
|
+
/// * ComposeSent
|
|
32
|
+
///
|
|
33
|
+
/// # Panics
|
|
34
|
+
/// * If a compose payload is already queued for the given (sender, `to`, `guid`, `index`)
|
|
35
|
+
fn send_compose(
|
|
36
|
+
ref self: TContractState,
|
|
37
|
+
to: ContractAddress,
|
|
38
|
+
guid: Bytes32,
|
|
39
|
+
index: u16,
|
|
40
|
+
message: ByteArray,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
/// Deliver a previously queued compose payload to the target contract
|
|
44
|
+
///
|
|
45
|
+
/// Verifies that the provided `message` matches the queued hash, marks the
|
|
46
|
+
/// compose as received to prevent reentrancy, optionally transfers compose
|
|
47
|
+
/// value (ERC20) from the executor to `to`, then calls `ILayerZeroComposer.lz_compose`.
|
|
48
|
+
///
|
|
49
|
+
/// Note: The caller is expected to be the executor. Do not assume `from == caller`.
|
|
50
|
+
///
|
|
51
|
+
/// # Arguments
|
|
52
|
+
/// * `from` - Originating OApp that queued the compose on source chain
|
|
53
|
+
/// * `to` - Target contract that implements `ILayerZeroComposer`
|
|
54
|
+
/// * `guid` - Unique identifier of the original LayerZero message
|
|
55
|
+
/// * `index` - Compose index associated with the original message
|
|
56
|
+
/// * `message` - Compose payload; must match the queued hash
|
|
57
|
+
/// * `extra_data` - Executor-provided metadata (protocol-opaque)
|
|
58
|
+
/// * `value` - Amount of compose token to transfer to `to` prior to callback
|
|
59
|
+
///
|
|
60
|
+
/// # Emits
|
|
61
|
+
/// * ComposeDelivered
|
|
62
|
+
///
|
|
63
|
+
/// # Panics
|
|
64
|
+
/// * If no compose is found or the hash does not match
|
|
65
|
+
/// * If `value > 0` and executor allowance is insufficient
|
|
66
|
+
fn lz_compose(
|
|
67
|
+
ref self: TContractState,
|
|
68
|
+
from: ContractAddress,
|
|
69
|
+
to: ContractAddress,
|
|
70
|
+
guid: Bytes32,
|
|
71
|
+
index: u16,
|
|
72
|
+
message: ByteArray,
|
|
73
|
+
extra_data: ByteArray,
|
|
74
|
+
value: u256,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
/// Report an alert related to compose execution
|
|
78
|
+
///
|
|
79
|
+
/// Allows the executor to emit a structured alert event that associates
|
|
80
|
+
/// telemetry or failure information with a compose attempt. Does not modify
|
|
81
|
+
/// queue state.
|
|
82
|
+
///
|
|
83
|
+
/// # Arguments
|
|
84
|
+
/// * `from` - Originating OApp
|
|
85
|
+
/// * `to` - Target contract
|
|
86
|
+
/// * `guid` - Message GUID
|
|
87
|
+
/// * `index` - Compose index
|
|
88
|
+
/// * `gas` - Gas usage or gas limit context provided by the executor
|
|
89
|
+
/// * `value` - Intended compose token value
|
|
90
|
+
/// * `message` - Compose payload (for correlation)
|
|
91
|
+
/// * `extra_data` - Executor-provided metadata
|
|
92
|
+
/// * `reason` - Opaque reason for the alert
|
|
93
|
+
///
|
|
94
|
+
/// # Emits
|
|
95
|
+
/// * LzComposeAlert
|
|
96
|
+
fn lz_compose_alert(
|
|
97
|
+
ref self: TContractState,
|
|
98
|
+
from: ContractAddress,
|
|
99
|
+
to: ContractAddress,
|
|
100
|
+
guid: Bytes32,
|
|
101
|
+
index: u16,
|
|
102
|
+
gas: u256,
|
|
103
|
+
value: u256,
|
|
104
|
+
message: ByteArray,
|
|
105
|
+
extra_data: ByteArray,
|
|
106
|
+
reason: Array<felt252>,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
/// Inspect the compose queue
|
|
110
|
+
///
|
|
111
|
+
/// Returns the stored value for a compose entry keyed by (`sender`, `to`, `guid`, `index`).
|
|
112
|
+
/// Semantics of the returned `Bytes32`:
|
|
113
|
+
/// - `0` — no compose queued
|
|
114
|
+
/// - `1` — compose has been delivered (RECEIVED_MESSAGE_HASH)
|
|
115
|
+
/// - otherwise — keccak hash of the queued `message`
|
|
116
|
+
///
|
|
117
|
+
/// # Arguments
|
|
118
|
+
/// * `sender` - Originating OApp that called `send_compose`
|
|
119
|
+
/// * `to` - Target contract
|
|
120
|
+
/// * `guid` - Message GUID
|
|
121
|
+
/// * `index` - Compose index
|
|
122
|
+
///
|
|
123
|
+
/// # Returns
|
|
124
|
+
/// * `Bytes32` - Encoded queue state or message hash as described above
|
|
125
|
+
fn get_compose_queue(
|
|
126
|
+
self: @TContractState,
|
|
127
|
+
sender: ContractAddress,
|
|
128
|
+
to: ContractAddress,
|
|
129
|
+
guid: Bytes32,
|
|
130
|
+
index: u16,
|
|
131
|
+
) -> Bytes32;
|
|
132
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
//! Messaging composer component
|
|
2
|
+
|
|
3
|
+
/// # `MessagingComposerComponent`
|
|
4
|
+
///
|
|
5
|
+
/// The `MessagingComposerComponent` is responsible for the lifecycle of "compose"
|
|
6
|
+
/// payloads that are requested by an OApp after a LayerZero message has been
|
|
7
|
+
/// delivered. It provides a minimal, verifiable queue keyed by the originating
|
|
8
|
+
/// OApp, target contract, message GUID, and compose index. The executor later
|
|
9
|
+
/// triggers delivery to the target contract implementing `ILayerZeroComposer`.
|
|
10
|
+
///
|
|
11
|
+
/// ## High-level responsibilities
|
|
12
|
+
/// - Queue compose payloads by recording their keccak hash
|
|
13
|
+
/// - Verify and deliver compose payloads to the target contract
|
|
14
|
+
/// - Optionally transfer an ERC20 compose token to the target prior to callback
|
|
15
|
+
/// - Emit alert events to aid off-chain/executor diagnostics
|
|
16
|
+
/// - Expose read accessors for compose queue inspection
|
|
17
|
+
///
|
|
18
|
+
/// ## Security considerations
|
|
19
|
+
/// - Delivery marks a compose entry as received using a sentinel value to
|
|
20
|
+
/// prevent reentrancy or replay, rather than deleting the entry
|
|
21
|
+
/// - Value transfer requires sufficient allowance from the executor to the
|
|
22
|
+
/// composer contract
|
|
23
|
+
/// - The executor is the caller of `lz_compose`; do not assume `from == caller`
|
|
24
|
+
///
|
|
25
|
+
/// ## Events emitted by the implementation
|
|
26
|
+
/// - `ComposeSent(from, to, guid, index, message)`
|
|
27
|
+
/// - `ComposeDelivered(from, to, guid, index)`
|
|
28
|
+
/// - `LzComposeAlert(from, to, executor, guid, index, gas, value, message, extra_data, reason)`
|
|
29
|
+
#[starknet::component]
|
|
30
|
+
pub mod MessagingComposerComponent {
|
|
31
|
+
use lz_utils::bytes::Bytes32;
|
|
32
|
+
use lz_utils::keccak::keccak256;
|
|
33
|
+
use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};
|
|
34
|
+
use starknet::storage::{
|
|
35
|
+
Map, StoragePathEntry, StoragePointerReadAccess, StoragePointerWriteAccess,
|
|
36
|
+
};
|
|
37
|
+
use starknet::{ContractAddress, get_caller_address, get_contract_address};
|
|
38
|
+
use starkware_utils::errors::assert_with_byte_array;
|
|
39
|
+
use crate::endpoint::constants::EMPTY_PAYLOAD_HASH;
|
|
40
|
+
use crate::endpoint::interfaces::layerzero_composer::{
|
|
41
|
+
ILayerZeroComposerDispatcher, ILayerZeroComposerDispatcherTrait,
|
|
42
|
+
};
|
|
43
|
+
use crate::endpoint::messaging_composer::errors::{
|
|
44
|
+
err_lz_compose_already_exists, err_lz_compose_not_found,
|
|
45
|
+
err_lz_compose_value_exceeds_allowance,
|
|
46
|
+
};
|
|
47
|
+
use crate::endpoint::messaging_composer::events::{
|
|
48
|
+
ComposeDelivered, ComposeSent, LzComposeAlert,
|
|
49
|
+
};
|
|
50
|
+
use crate::endpoint::messaging_composer::interface::IMessagingComposer;
|
|
51
|
+
|
|
52
|
+
/// Sentinel value written to the compose queue when a compose has been
|
|
53
|
+
/// successfully delivered. Used to prevent reentrancy/replay.
|
|
54
|
+
const RECEIVED_MESSAGE_HASH: Bytes32 = Bytes32 { value: 0x1 };
|
|
55
|
+
|
|
56
|
+
#[storage]
|
|
57
|
+
pub struct Storage {
|
|
58
|
+
/// ERC20 token used for value transfer on compose
|
|
59
|
+
compose_token_address: ContractAddress,
|
|
60
|
+
/// Compose queue mapping structure that stores the keccak hash of the
|
|
61
|
+
/// queued payload, or `RECEIVED_MESSAGE_HASH` once delivered.
|
|
62
|
+
/// uses keccak hash
|
|
63
|
+
///
|
|
64
|
+
/// from => to => guid => index => messageHash
|
|
65
|
+
compose_queue: Map<ContractAddress, Map<ContractAddress, Map<Bytes32, Map<u16, Bytes32>>>>,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#[event]
|
|
69
|
+
#[derive(Drop, starknet::Event)]
|
|
70
|
+
pub enum Event {
|
|
71
|
+
ComposeSent: ComposeSent,
|
|
72
|
+
ComposeDelivered: ComposeDelivered,
|
|
73
|
+
LzComposeAlert: LzComposeAlert,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#[embeddable_as(MessagingComposerImpl)]
|
|
77
|
+
impl MessagingComposerImplImpl<
|
|
78
|
+
TContractState, +HasComponent<TContractState>,
|
|
79
|
+
> of IMessagingComposer<ComponentState<TContractState>> {
|
|
80
|
+
/// Queue a compose payload for later delivery
|
|
81
|
+
///
|
|
82
|
+
/// Stores the keccak hash of `message` under the key composed of
|
|
83
|
+
/// `(sender, to, guid, index)`. Reverts if an entry already exists.
|
|
84
|
+
///
|
|
85
|
+
/// Emits: `ComposeSent`
|
|
86
|
+
///
|
|
87
|
+
/// Panics:
|
|
88
|
+
/// - If a compose payload is already queued for the given key
|
|
89
|
+
fn send_compose(
|
|
90
|
+
ref self: ComponentState<TContractState>,
|
|
91
|
+
to: ContractAddress,
|
|
92
|
+
guid: Bytes32,
|
|
93
|
+
index: u16,
|
|
94
|
+
message: ByteArray,
|
|
95
|
+
) {
|
|
96
|
+
let sender = get_caller_address();
|
|
97
|
+
let entry = self.compose_queue.entry(sender).entry(to).entry(guid).entry(index);
|
|
98
|
+
let current_hash = entry.read();
|
|
99
|
+
assert_with_byte_array(
|
|
100
|
+
current_hash == EMPTY_PAYLOAD_HASH, err_lz_compose_already_exists(),
|
|
101
|
+
);
|
|
102
|
+
// Hash message and store it in the compose queue
|
|
103
|
+
// Note: No endianness conversion is required; this is not cross-chain dependent
|
|
104
|
+
let message_hash = keccak256(@message);
|
|
105
|
+
entry.write(message_hash);
|
|
106
|
+
self.emit(ComposeSent { from: sender, to, guid, index, message });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// Deliver a previously queued compose payload to the target contract
|
|
110
|
+
///
|
|
111
|
+
/// Verifies the provided `message` against the queued hash. Marks the
|
|
112
|
+
/// queue entry as received using `RECEIVED_MESSAGE_HASH` to prevent
|
|
113
|
+
/// reentrancy/replay. If `value > 0`, transfers compose token from the
|
|
114
|
+
/// executor (caller) to the target prior to invoking
|
|
115
|
+
/// `ILayerZeroComposer.lz_compose`.
|
|
116
|
+
///
|
|
117
|
+
/// Emits: `ComposeDelivered`
|
|
118
|
+
///
|
|
119
|
+
/// Panics:
|
|
120
|
+
/// - If the compose entry is missing or the hash does not match
|
|
121
|
+
/// - If `value > 0` and the executor's allowance is insufficient
|
|
122
|
+
fn lz_compose(
|
|
123
|
+
ref self: ComponentState<TContractState>,
|
|
124
|
+
from: ContractAddress,
|
|
125
|
+
to: ContractAddress,
|
|
126
|
+
guid: Bytes32,
|
|
127
|
+
index: u16,
|
|
128
|
+
message: ByteArray,
|
|
129
|
+
extra_data: ByteArray,
|
|
130
|
+
value: u256,
|
|
131
|
+
) {
|
|
132
|
+
let entry = self.compose_queue.entry(from).entry(to).entry(guid).entry(index);
|
|
133
|
+
let expected_hash = entry.read();
|
|
134
|
+
let actual_hash = keccak256(@message);
|
|
135
|
+
assert_with_byte_array(
|
|
136
|
+
expected_hash == actual_hash, err_lz_compose_not_found(expected_hash, actual_hash),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// marks the message as received to prevent reentrancy
|
|
140
|
+
// cannot just delete the value, otherwise the message can be sent again and could
|
|
141
|
+
// result in some undefined behaviour even though the sender(composing Oapp) is
|
|
142
|
+
// implicitly fully trusted by the composer.
|
|
143
|
+
// eg. sender may not even realize it has such a bug
|
|
144
|
+
entry.write(RECEIVED_MESSAGE_HASH);
|
|
145
|
+
|
|
146
|
+
let executor = get_caller_address();
|
|
147
|
+
|
|
148
|
+
// Verify allowance and transfer only when value > 0
|
|
149
|
+
if value > 0 {
|
|
150
|
+
let compose_token_dispatcher = IERC20Dispatcher {
|
|
151
|
+
contract_address: self.compose_token_address.read(),
|
|
152
|
+
};
|
|
153
|
+
let allowance = compose_token_dispatcher
|
|
154
|
+
.allowance(executor, get_contract_address());
|
|
155
|
+
assert_with_byte_array(
|
|
156
|
+
value <= allowance, err_lz_compose_value_exceeds_allowance(value, allowance),
|
|
157
|
+
);
|
|
158
|
+
compose_token_dispatcher.transfer_from(executor, to, value);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
let composer_dispatcher = ILayerZeroComposerDispatcher { contract_address: to };
|
|
162
|
+
composer_dispatcher.lz_compose(from, guid, message, executor, extra_data, value);
|
|
163
|
+
|
|
164
|
+
self.emit(ComposeDelivered { from, to, guid, index });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/// Emit an alert related to compose execution
|
|
168
|
+
///
|
|
169
|
+
/// Allows the executor to surface telemetry or failure information for a
|
|
170
|
+
/// compose attempt. This does not modify the compose queue state.
|
|
171
|
+
///
|
|
172
|
+
/// Emits: `LzComposeAlert`
|
|
173
|
+
fn lz_compose_alert(
|
|
174
|
+
ref self: ComponentState<TContractState>,
|
|
175
|
+
from: ContractAddress,
|
|
176
|
+
to: ContractAddress,
|
|
177
|
+
guid: Bytes32,
|
|
178
|
+
index: u16,
|
|
179
|
+
gas: u256,
|
|
180
|
+
value: u256,
|
|
181
|
+
message: ByteArray,
|
|
182
|
+
extra_data: ByteArray,
|
|
183
|
+
reason: Array<felt252>,
|
|
184
|
+
) {
|
|
185
|
+
let executor = get_caller_address();
|
|
186
|
+
self
|
|
187
|
+
.emit(
|
|
188
|
+
LzComposeAlert {
|
|
189
|
+
from, to, executor, guid, index, gas, value, message, extra_data, reason,
|
|
190
|
+
},
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/// Inspect a specific compose queue entry
|
|
195
|
+
///
|
|
196
|
+
/// Returns the stored value for a compose entry keyed by
|
|
197
|
+
/// `(sender, to, guid, index)` with the following semantics:
|
|
198
|
+
/// - `0` — no compose queued
|
|
199
|
+
/// - `RECEIVED_MESSAGE_HASH` (1) — compose delivered
|
|
200
|
+
/// - otherwise — keccak hash of the queued `message`
|
|
201
|
+
fn get_compose_queue(
|
|
202
|
+
self: @ComponentState<TContractState>,
|
|
203
|
+
sender: ContractAddress,
|
|
204
|
+
to: ContractAddress,
|
|
205
|
+
guid: Bytes32,
|
|
206
|
+
index: u16,
|
|
207
|
+
) -> Bytes32 {
|
|
208
|
+
self.compose_queue.entry(sender).entry(to).entry(guid).entry(index).read()
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/// Internal functions for initialization
|
|
213
|
+
#[generate_trait]
|
|
214
|
+
pub impl InternalImpl<
|
|
215
|
+
TContractState, +HasComponent<TContractState>,
|
|
216
|
+
> of InternalTrait<TContractState> {
|
|
217
|
+
/// Initialize the MessagingComposer with the ERC20 token address used
|
|
218
|
+
/// for value transfers during compose delivery.
|
|
219
|
+
fn initializer(ref self: ComponentState<TContractState>, token_address: ContractAddress) {
|
|
220
|
+
self.compose_token_address.write(token_address);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
//! # LayerZero Protocol Implementation for Starknet
|
|
2
|
+
//!
|
|
3
|
+
//! This project provides a comprehensive implementation of the LayerZero protocol for the Starknet
|
|
4
|
+
//! ecosystem.
|
|
5
|
+
//! It includes the core components necessary for enabling seamless cross-chain messaging, allowing
|
|
6
|
+
//! developers to build sophisticated omnichain applications (OApps) that can interact with other
|
|
7
|
+
//! blockchains.
|
|
8
|
+
//!
|
|
9
|
+
//! The project is structured into several modules, each responsible for a specific aspect of the
|
|
10
|
+
//! LayerZero protocol:
|
|
11
|
+
//! - **Common**: Contains shared data structures, constants, and utility functions used across the
|
|
12
|
+
//! project.
|
|
13
|
+
//! - **Endpoint**: The core of the LayerZero protocol, responsible for sending and receiving
|
|
14
|
+
//! messages.
|
|
15
|
+
//! - **MessageLib**: Defines the different message libraries that OApps can use to configure their
|
|
16
|
+
//! security posture.
|
|
17
|
+
//! - **Treasury**: Manages the fees collected by the protocol.
|
|
18
|
+
//! - **Workers**: A collection of contracts that perform specific tasks, such as price feeds and
|
|
19
|
+
//! data verification.
|
|
20
|
+
//! - **OApps**: Example omnichain applications that demonstrate how to use the LayerZero protocol.
|
|
21
|
+
|
|
22
|
+
pub mod common {
|
|
23
|
+
pub mod structs {
|
|
24
|
+
pub mod messaging;
|
|
25
|
+
pub mod packet;
|
|
26
|
+
}
|
|
27
|
+
pub mod constants;
|
|
28
|
+
pub mod conversions;
|
|
29
|
+
pub mod guid;
|
|
30
|
+
pub mod packet_v1_codec;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
pub mod endpoint {
|
|
34
|
+
pub mod message_lib_manager {
|
|
35
|
+
pub mod errors;
|
|
36
|
+
pub mod events;
|
|
37
|
+
pub mod interface;
|
|
38
|
+
pub mod message_lib_manager;
|
|
39
|
+
pub mod structs;
|
|
40
|
+
}
|
|
41
|
+
pub mod messaging_channel {
|
|
42
|
+
pub mod errors;
|
|
43
|
+
pub mod events;
|
|
44
|
+
pub mod interface;
|
|
45
|
+
pub mod messaging_channel;
|
|
46
|
+
}
|
|
47
|
+
pub mod messaging_composer {
|
|
48
|
+
pub mod errors;
|
|
49
|
+
pub mod events;
|
|
50
|
+
pub mod interface;
|
|
51
|
+
pub mod messaging_composer;
|
|
52
|
+
}
|
|
53
|
+
pub mod interfaces {
|
|
54
|
+
pub mod endpoint;
|
|
55
|
+
pub mod layerzero_composer;
|
|
56
|
+
pub mod layerzero_receiver;
|
|
57
|
+
}
|
|
58
|
+
pub mod constants;
|
|
59
|
+
pub mod endpoint;
|
|
60
|
+
pub mod errors;
|
|
61
|
+
pub mod events;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
pub mod message_lib {
|
|
65
|
+
pub mod interface;
|
|
66
|
+
pub mod sml {
|
|
67
|
+
pub mod errors;
|
|
68
|
+
pub mod events;
|
|
69
|
+
pub mod simple_message_lib;
|
|
70
|
+
}
|
|
71
|
+
pub mod structs;
|
|
72
|
+
pub mod uln {
|
|
73
|
+
pub mod errors;
|
|
74
|
+
pub mod events;
|
|
75
|
+
pub mod options;
|
|
76
|
+
pub mod structs {
|
|
77
|
+
pub mod executor_config;
|
|
78
|
+
pub mod payment_info;
|
|
79
|
+
pub mod uln_config;
|
|
80
|
+
pub mod uln_config_storage_node;
|
|
81
|
+
pub mod verification;
|
|
82
|
+
}
|
|
83
|
+
pub mod interface;
|
|
84
|
+
pub mod ultra_light_node;
|
|
85
|
+
}
|
|
86
|
+
pub mod blocked_message_lib;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
pub mod treasury {
|
|
90
|
+
pub mod interfaces {
|
|
91
|
+
pub mod layerzero_treasury;
|
|
92
|
+
pub mod lz_token_fee_lib;
|
|
93
|
+
pub mod treasury_admin;
|
|
94
|
+
}
|
|
95
|
+
pub mod errors;
|
|
96
|
+
pub mod events;
|
|
97
|
+
pub mod treasury;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
pub mod workers {
|
|
101
|
+
pub mod base {
|
|
102
|
+
pub mod base;
|
|
103
|
+
pub mod errors;
|
|
104
|
+
pub mod events;
|
|
105
|
+
pub mod interface;
|
|
106
|
+
pub mod structs;
|
|
107
|
+
}
|
|
108
|
+
pub mod executor {
|
|
109
|
+
pub mod errors;
|
|
110
|
+
pub mod events;
|
|
111
|
+
pub mod executor;
|
|
112
|
+
pub mod fee_lib {
|
|
113
|
+
pub mod executor_fee_lib;
|
|
114
|
+
pub mod interface;
|
|
115
|
+
}
|
|
116
|
+
pub mod interface;
|
|
117
|
+
pub mod options;
|
|
118
|
+
pub mod structs;
|
|
119
|
+
}
|
|
120
|
+
pub mod price_feed {
|
|
121
|
+
pub mod constants;
|
|
122
|
+
pub mod errors;
|
|
123
|
+
pub mod events;
|
|
124
|
+
pub mod interface;
|
|
125
|
+
pub mod price_feed;
|
|
126
|
+
pub mod structs;
|
|
127
|
+
}
|
|
128
|
+
pub mod dvn {
|
|
129
|
+
pub mod constants;
|
|
130
|
+
pub mod dvn;
|
|
131
|
+
pub mod errors;
|
|
132
|
+
pub mod events;
|
|
133
|
+
pub mod fee_lib {
|
|
134
|
+
pub mod dvn_fee_lib;
|
|
135
|
+
pub mod interface;
|
|
136
|
+
}
|
|
137
|
+
pub mod interface;
|
|
138
|
+
pub mod options;
|
|
139
|
+
pub mod structs;
|
|
140
|
+
}
|
|
141
|
+
pub mod access_control;
|
|
142
|
+
pub mod common;
|
|
143
|
+
pub mod interface;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
pub mod oapps {
|
|
147
|
+
pub mod common {
|
|
148
|
+
pub mod oapp_options_type_3 {
|
|
149
|
+
pub mod errors;
|
|
150
|
+
pub mod events;
|
|
151
|
+
pub mod interface;
|
|
152
|
+
pub mod oapp_options_type_3;
|
|
153
|
+
pub mod structs;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
pub mod oapp {
|
|
157
|
+
pub mod errors;
|
|
158
|
+
pub mod events;
|
|
159
|
+
pub mod interface;
|
|
160
|
+
pub mod oapp;
|
|
161
|
+
pub mod oapp_core;
|
|
162
|
+
}
|
|
163
|
+
pub mod oft {
|
|
164
|
+
pub mod errors;
|
|
165
|
+
pub mod events;
|
|
166
|
+
pub mod interface;
|
|
167
|
+
pub mod oft;
|
|
168
|
+
pub mod oft_adapter;
|
|
169
|
+
pub mod oft_compose_msg_codec;
|
|
170
|
+
pub mod oft_core;
|
|
171
|
+
pub mod oft_msg_codec;
|
|
172
|
+
pub mod structs;
|
|
173
|
+
}
|
|
174
|
+
pub mod counter {
|
|
175
|
+
pub mod constants;
|
|
176
|
+
pub mod counter;
|
|
177
|
+
pub mod interface;
|
|
178
|
+
pub mod structs;
|
|
179
|
+
}
|
|
180
|
+
pub mod message_inspector {
|
|
181
|
+
pub mod interface;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Re-export commonly used types for easier access
|
|
186
|
+
pub use common::structs::messaging::{MessageReceipt, MessagingFee, MessagingParams};
|
|
187
|
+
pub use common::structs::packet::{Origin, Packet};
|
|
188
|
+
pub use oapps::oapp::oapp_core::OAppCoreComponent;
|
|
189
|
+
pub use workers::base::base::WorkerBaseComponent;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/// This is a message library that is used to block all messages from being sent or received.
|
|
2
|
+
#[starknet::contract]
|
|
3
|
+
pub mod BlockedMessageLib {
|
|
4
|
+
use core::panics::panic_with_byte_array;
|
|
5
|
+
use lz_utils::bytes::Bytes32;
|
|
6
|
+
use lz_utils::error::{Error, format_error};
|
|
7
|
+
use starknet::ContractAddress;
|
|
8
|
+
use crate::common::structs::messaging::{MessageLibSendResult, MessagingFee};
|
|
9
|
+
use crate::common::structs::packet::Packet;
|
|
10
|
+
use crate::message_lib::interface::{IMessageLib, VerificationState};
|
|
11
|
+
use crate::message_lib::structs::{MessageLibType, SetConfigParam};
|
|
12
|
+
|
|
13
|
+
// === Error Definitions ===
|
|
14
|
+
#[derive(Drop)]
|
|
15
|
+
pub enum BlockedMessageLibError {
|
|
16
|
+
NotImplemented,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
impl ErrorNameImpl of Error<BlockedMessageLibError> {
|
|
20
|
+
fn prefix() -> ByteArray {
|
|
21
|
+
"LZ_BLOCKED_MESSAGE_LIB"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fn name(self: BlockedMessageLibError) -> ByteArray {
|
|
25
|
+
match self {
|
|
26
|
+
BlockedMessageLibError::NotImplemented => "NOT_IMPLEMENTED",
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
pub fn err_not_implemented() -> ByteArray {
|
|
32
|
+
format_error(BlockedMessageLibError::NotImplemented, "")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// === Storage ===
|
|
36
|
+
#[storage]
|
|
37
|
+
struct Storage {}
|
|
38
|
+
|
|
39
|
+
// === Constructor ===
|
|
40
|
+
#[constructor]
|
|
41
|
+
fn constructor(ref self: ContractState) { // No initialization needed
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// === IMessageLib Implementation ===
|
|
45
|
+
#[abi(embed_v0)]
|
|
46
|
+
impl MessageLibImpl of IMessageLib<ContractState> {
|
|
47
|
+
fn send(
|
|
48
|
+
ref self: ContractState, packet: Packet, options: ByteArray, pay_in_lz_token: bool,
|
|
49
|
+
) -> MessageLibSendResult {
|
|
50
|
+
panic_with_byte_array(@err_not_implemented());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fn verify(
|
|
54
|
+
ref self: ContractState,
|
|
55
|
+
packet_header: ByteArray,
|
|
56
|
+
payload_hash: Bytes32,
|
|
57
|
+
confirmations: u64,
|
|
58
|
+
) {
|
|
59
|
+
panic_with_byte_array(@err_not_implemented());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fn commit(ref self: ContractState, packet_header: ByteArray, payload_hash: Bytes32) {
|
|
63
|
+
panic_with_byte_array(@err_not_implemented());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fn quote(
|
|
67
|
+
ref self: ContractState, packet: Packet, options: ByteArray, pay_in_lz_token: bool,
|
|
68
|
+
) -> MessagingFee {
|
|
69
|
+
panic_with_byte_array(@err_not_implemented());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fn message_lib_type(self: @ContractState) -> MessageLibType {
|
|
73
|
+
MessageLibType::SendAndReceive
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
fn is_supported_send_eid(self: @ContractState, dst_eid: u32) -> bool {
|
|
77
|
+
true
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fn is_supported_receive_eid(self: @ContractState, src_eid: u32) -> bool {
|
|
81
|
+
true
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fn set_send_config(
|
|
85
|
+
ref self: ContractState, oapp: ContractAddress, params: Array<SetConfigParam>,
|
|
86
|
+
) {
|
|
87
|
+
panic_with_byte_array(@err_not_implemented());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fn set_receive_config(
|
|
91
|
+
ref self: ContractState, oapp: ContractAddress, params: Array<SetConfigParam>,
|
|
92
|
+
) {
|
|
93
|
+
panic_with_byte_array(@err_not_implemented());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fn get_send_config(
|
|
97
|
+
self: @ContractState, eid: u32, oapp: ContractAddress, config_type: u32,
|
|
98
|
+
) -> Array<felt252> {
|
|
99
|
+
panic_with_byte_array(@err_not_implemented());
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
fn get_receive_config(
|
|
103
|
+
self: @ContractState, eid: u32, oapp: ContractAddress, config_type: u32,
|
|
104
|
+
) -> Array<felt252> {
|
|
105
|
+
panic_with_byte_array(@err_not_implemented());
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fn verifiable(
|
|
109
|
+
self: @ContractState, packet_header: ByteArray, payload_hash: Bytes32,
|
|
110
|
+
) -> VerificationState {
|
|
111
|
+
VerificationState::NotInitializable
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|