@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,720 @@
|
|
|
1
|
+
//! Message library manager component
|
|
2
|
+
|
|
3
|
+
/// # `MessageLibManagerComponent`
|
|
4
|
+
///
|
|
5
|
+
/// The MessageLibManager is the core component responsible for managing the lifecycle of message
|
|
6
|
+
/// libraries within the LayerZero protocol. It provides a unified interface for:
|
|
7
|
+
///
|
|
8
|
+
/// - **Library Registration**: Validating and registering message libraries that implement the
|
|
9
|
+
/// IMessageLib interface - **Default Library Management**: Managing protocol-wide default libraries
|
|
10
|
+
/// for each endpoint - **Per-OApp Configuration**: Allowing individual OApps to configure custom
|
|
11
|
+
/// send/receive libraries - **Grace Period Handling**: Managing smooth transitions between library
|
|
12
|
+
/// versions with configurable timeouts
|
|
13
|
+
/// requests to the appropriate message libraries
|
|
14
|
+
///
|
|
15
|
+
/// ## Library Resolution Logic
|
|
16
|
+
///
|
|
17
|
+
/// ### Send Libraries
|
|
18
|
+
/// When an OApp sends a message, the library resolution follows this priority:
|
|
19
|
+
/// 1. OApp's custom send library (if configured)
|
|
20
|
+
/// 2. Protocol's default send library for the destination endpoint
|
|
21
|
+
///
|
|
22
|
+
/// ### Receive Libraries
|
|
23
|
+
/// When validating incoming messages, libraries are considered valid if they are:
|
|
24
|
+
/// 1. The currently configured receive library for the OApp/endpoint
|
|
25
|
+
/// 2. A library in its grace period (during library transitions)
|
|
26
|
+
///
|
|
27
|
+
/// ## Grace Period Mechanism
|
|
28
|
+
///
|
|
29
|
+
/// To ensure smooth upgrades without breaking in-flight messages, the MessageLibManager supports
|
|
30
|
+
/// grace periods during library transitions. When a new receive library is set, the old library
|
|
31
|
+
/// can remain valid for a specified number of blocks, allowing time for pending messages to be
|
|
32
|
+
/// processed.
|
|
33
|
+
#[starknet::component]
|
|
34
|
+
pub mod MessageLibManagerComponent {
|
|
35
|
+
use core::num::traits::Zero;
|
|
36
|
+
use openzeppelin::access::ownable::OwnableComponent;
|
|
37
|
+
use openzeppelin::access::ownable::OwnableComponent::{
|
|
38
|
+
InternalImpl as OwnableInternalImpl, InternalTrait as OwnableInternalTrait,
|
|
39
|
+
};
|
|
40
|
+
use starknet::storage::{
|
|
41
|
+
Map, MutableVecTrait, StoragePathEntry, StoragePointerReadAccess, StoragePointerWriteAccess,
|
|
42
|
+
Vec, VecTrait,
|
|
43
|
+
};
|
|
44
|
+
use starknet::{ContractAddress, get_block_number};
|
|
45
|
+
use starkware_utils::errors::assert_with_byte_array;
|
|
46
|
+
use crate::common::constants::ZERO_ADDRESS;
|
|
47
|
+
use crate::endpoint::message_lib_manager::errors::{
|
|
48
|
+
err_already_registered, err_default_receive_lib_unavailable,
|
|
49
|
+
err_default_send_lib_unavailable, err_invalid_expiry, err_only_non_default_lib,
|
|
50
|
+
err_only_receive_lib, err_only_registered_lib, err_only_registered_or_default_lib,
|
|
51
|
+
err_only_send_lib, err_same_value, err_unsupported_eid,
|
|
52
|
+
};
|
|
53
|
+
use crate::endpoint::message_lib_manager::events::{
|
|
54
|
+
DefaultReceiveLibrarySet, DefaultReceiveLibraryTimeoutSet, DefaultSendLibrarySet,
|
|
55
|
+
LibraryRegistered, ReceiveLibrarySet, ReceiveLibraryTimeoutSet, SendLibrarySet,
|
|
56
|
+
};
|
|
57
|
+
use crate::endpoint::message_lib_manager::interface::IMessageLibManager;
|
|
58
|
+
use crate::endpoint::message_lib_manager::structs::{GetLibraryResponse, Timeout};
|
|
59
|
+
use crate::message_lib::interface::{IMessageLibDispatcher, IMessageLibDispatcherTrait};
|
|
60
|
+
use crate::message_lib::structs::{MessageLibType, SetConfigParam};
|
|
61
|
+
|
|
62
|
+
/// Constant representing the default library (address 0)
|
|
63
|
+
/// Used to indicate when an OApp wants to use the protocol's default library
|
|
64
|
+
pub const DEFAULT_LIB: ContractAddress = ZERO_ADDRESS;
|
|
65
|
+
|
|
66
|
+
const DEFAULT_EXPIRY: u64 = 0;
|
|
67
|
+
|
|
68
|
+
const DEFAULT_TIMEOUT: Timeout = Timeout { lib: DEFAULT_LIB, expiry: DEFAULT_EXPIRY };
|
|
69
|
+
|
|
70
|
+
/// =============================== Storage =================================
|
|
71
|
+
#[storage]
|
|
72
|
+
pub struct Storage {
|
|
73
|
+
/// Immutable library that reverts both on send and quote operations
|
|
74
|
+
/// This is set during initialization and provides a way to "block" an endpoint
|
|
75
|
+
pub blocked_library: ContractAddress,
|
|
76
|
+
/// Mapping to track which libraries have been registered with the endpoint
|
|
77
|
+
/// Only registered libraries can be used as send/receive libraries or defaults
|
|
78
|
+
/// lib_address => is_registered
|
|
79
|
+
pub is_registered_library: Map<ContractAddress, bool>,
|
|
80
|
+
/// Dynamic array storing all registered library addresses
|
|
81
|
+
/// Used for querying the complete list of registered libraries
|
|
82
|
+
pub registered_libraries: Vec<ContractAddress>,
|
|
83
|
+
/// OApp-specific send library configurations
|
|
84
|
+
/// Maps from sender address to destination endpoint to library address
|
|
85
|
+
/// If not set or set to DEFAULT_LIB, resolves to the default send library
|
|
86
|
+
/// sender_address => dst_eid => library_address
|
|
87
|
+
pub send_library: Map<ContractAddress, Map<u32, ContractAddress>>,
|
|
88
|
+
/// OApp-specific receive library configurations
|
|
89
|
+
/// Maps from receiver address to source endpoint to library address
|
|
90
|
+
/// If not set or set to DEFAULT_LIB, resolves to the default receive library
|
|
91
|
+
/// receiver_address => src_eid => library_address
|
|
92
|
+
pub receive_library: Map<ContractAddress, Map<u32, ContractAddress>>,
|
|
93
|
+
/// Timeout configurations for OApp-specific receive library transitions
|
|
94
|
+
/// Stores grace period information when OApps upgrade their receive libraries
|
|
95
|
+
/// receiver_address => src_eid => timeout_info
|
|
96
|
+
pub receive_library_timeout: Map<ContractAddress, Map<u32, Timeout>>,
|
|
97
|
+
/// Protocol-wide default send libraries for each endpoint
|
|
98
|
+
/// Used when OApps haven't configured a custom send library
|
|
99
|
+
/// dst_eid => library_address
|
|
100
|
+
pub default_send_library: Map<u32, ContractAddress>,
|
|
101
|
+
/// Protocol-wide default receive libraries for each endpoint
|
|
102
|
+
/// Used when OApps haven't configured a custom receive library
|
|
103
|
+
/// src_eid => library_address
|
|
104
|
+
pub default_receive_library: Map<u32, ContractAddress>,
|
|
105
|
+
/// Timeout configurations for default receive library transitions
|
|
106
|
+
/// Manages grace periods when the protocol upgrades default receive libraries
|
|
107
|
+
/// src_eid => timeout_info
|
|
108
|
+
pub default_receive_library_timeout: Map<u32, Timeout>,
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// =============================== Events =================================
|
|
112
|
+
#[event]
|
|
113
|
+
#[derive(Drop, starknet::Event)]
|
|
114
|
+
pub enum Event {
|
|
115
|
+
LibraryRegistered: LibraryRegistered,
|
|
116
|
+
SendLibrarySet: SendLibrarySet,
|
|
117
|
+
ReceiveLibrarySet: ReceiveLibrarySet,
|
|
118
|
+
DefaultSendLibrarySet: DefaultSendLibrarySet,
|
|
119
|
+
DefaultReceiveLibrarySet: DefaultReceiveLibrarySet,
|
|
120
|
+
ReceiveLibraryTimeoutSet: ReceiveLibraryTimeoutSet,
|
|
121
|
+
DefaultReceiveLibraryTimeoutSet: DefaultReceiveLibraryTimeoutSet,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// =============================== Hooks =================================
|
|
125
|
+
pub trait IMessageLibManagerHooks<TContractState> {
|
|
126
|
+
fn _assert_authorized(self: @ComponentState<TContractState>, oapp: ContractAddress);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// =============================== Implementation =================================
|
|
130
|
+
#[embeddable_as(MessageLibManagerImpl)]
|
|
131
|
+
impl MessageLibManager<
|
|
132
|
+
TContractState,
|
|
133
|
+
+HasComponent<TContractState>,
|
|
134
|
+
impl Ownable: OwnableComponent::HasComponent<TContractState>,
|
|
135
|
+
impl MessageLibManagerHooks: IMessageLibManagerHooks<TContractState>,
|
|
136
|
+
+Drop<TContractState>,
|
|
137
|
+
> of IMessageLibManager<ComponentState<TContractState>> {
|
|
138
|
+
// ========================= Library Registration =========================
|
|
139
|
+
|
|
140
|
+
fn register_library(ref self: ComponentState<TContractState>, lib: ContractAddress) {
|
|
141
|
+
// Only the owner can register new libraries
|
|
142
|
+
self._assert_only_owner();
|
|
143
|
+
|
|
144
|
+
let is_registered_entry = self.is_registered_library.entry(lib);
|
|
145
|
+
|
|
146
|
+
// Must not have been registered before to prevent duplicates
|
|
147
|
+
assert_with_byte_array(!is_registered_entry.read(), err_already_registered());
|
|
148
|
+
|
|
149
|
+
// Query the library for its type to ensure it implements IMessageLib.
|
|
150
|
+
// This adds a safety check at registration time similar to EVM parity.
|
|
151
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: lib };
|
|
152
|
+
let _ = lib_dispatcher.message_lib_type();
|
|
153
|
+
|
|
154
|
+
// Add to registered libraries mapping and array
|
|
155
|
+
is_registered_entry.write(true);
|
|
156
|
+
self.registered_libraries.push(lib);
|
|
157
|
+
|
|
158
|
+
self.emit(LibraryRegistered { library: lib });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
fn is_registered_library(
|
|
162
|
+
self: @ComponentState<TContractState>, lib: ContractAddress,
|
|
163
|
+
) -> bool {
|
|
164
|
+
self.is_registered_library.entry(lib).read()
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
fn get_registered_libraries(
|
|
168
|
+
self: @ComponentState<TContractState>,
|
|
169
|
+
) -> Array<ContractAddress> {
|
|
170
|
+
let mut libraries = array![];
|
|
171
|
+
|
|
172
|
+
// Iterate through all registered libraries and collect them
|
|
173
|
+
for i in 0..self.registered_libraries.len() {
|
|
174
|
+
libraries.append(self.registered_libraries.get(i).unwrap().read());
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
libraries
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ========================= Send Library Management =========================
|
|
181
|
+
|
|
182
|
+
fn set_send_library(
|
|
183
|
+
ref self: ComponentState<TContractState>,
|
|
184
|
+
oapp: ContractAddress,
|
|
185
|
+
eid: u32,
|
|
186
|
+
lib: ContractAddress,
|
|
187
|
+
) {
|
|
188
|
+
// Only the OApp itself can set its send library
|
|
189
|
+
self._assert_authorized(oapp);
|
|
190
|
+
|
|
191
|
+
let send_library_entry = self.send_library.entry(oapp).entry(eid);
|
|
192
|
+
// Prevent no-op updates (must provide a different value)
|
|
193
|
+
let old_lib = send_library_entry.read();
|
|
194
|
+
assert_with_byte_array(old_lib != lib, err_same_value());
|
|
195
|
+
|
|
196
|
+
// Validate library registration, type, and endpoint support
|
|
197
|
+
self._assert_registered_or_default(lib);
|
|
198
|
+
self._assert_send_lib(lib);
|
|
199
|
+
self._assert_supported_send_eid(lib, eid);
|
|
200
|
+
|
|
201
|
+
// Update the send library configuration
|
|
202
|
+
send_library_entry.write(lib);
|
|
203
|
+
self.emit(SendLibrarySet { sender: oapp, dst_eid: eid, library: lib });
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
fn get_send_library(
|
|
207
|
+
self: @ComponentState<TContractState>, oapp: ContractAddress, dst_eid: u32,
|
|
208
|
+
) -> GetLibraryResponse {
|
|
209
|
+
// Get the OApp's custom send library configuration
|
|
210
|
+
let lib = self.send_library.entry(oapp).entry(dst_eid).read();
|
|
211
|
+
|
|
212
|
+
// If not set or set to DEFAULT_LIB, resolve to the protocol default
|
|
213
|
+
if lib == DEFAULT_LIB {
|
|
214
|
+
let default_lib = self.default_send_library.entry(dst_eid).read();
|
|
215
|
+
assert_with_byte_array(
|
|
216
|
+
default_lib.is_non_zero(), err_default_send_lib_unavailable(),
|
|
217
|
+
);
|
|
218
|
+
GetLibraryResponse { lib: default_lib, is_default: true }
|
|
219
|
+
} else {
|
|
220
|
+
GetLibraryResponse { lib, is_default: false }
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
fn get_raw_send_library(
|
|
225
|
+
self: @ComponentState<TContractState>, oapp: ContractAddress, dst_eid: u32,
|
|
226
|
+
) -> ContractAddress {
|
|
227
|
+
self.send_library.entry(oapp).entry(dst_eid).read()
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
fn is_default_send_library(
|
|
231
|
+
self: @ComponentState<TContractState>, oapp: ContractAddress, dst_eid: u32,
|
|
232
|
+
) -> bool {
|
|
233
|
+
// Check if the OApp is using the protocol's default send library
|
|
234
|
+
self.send_library.entry(oapp).entry(dst_eid).read() == DEFAULT_LIB
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
fn set_default_send_library(
|
|
238
|
+
ref self: ComponentState<TContractState>, eid: u32, lib: ContractAddress,
|
|
239
|
+
) {
|
|
240
|
+
// Only the protocol owner can set default libraries
|
|
241
|
+
self._assert_only_owner();
|
|
242
|
+
|
|
243
|
+
// Prevent no-op updates (must provide a different value)
|
|
244
|
+
let old_lib = self.default_send_library.entry(eid).read();
|
|
245
|
+
assert_with_byte_array(old_lib != lib, err_same_value());
|
|
246
|
+
|
|
247
|
+
// Validate library registration, type, and endpoint support
|
|
248
|
+
self._assert_registered(lib);
|
|
249
|
+
self._assert_send_lib(lib);
|
|
250
|
+
self._assert_supported_send_eid(lib, eid);
|
|
251
|
+
|
|
252
|
+
// Update the default send library for the endpoint
|
|
253
|
+
self.default_send_library.entry(eid).write(lib);
|
|
254
|
+
self.emit(DefaultSendLibrarySet { eid, library: lib });
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
fn get_default_send_library(
|
|
258
|
+
self: @ComponentState<TContractState>, eid: u32,
|
|
259
|
+
) -> ContractAddress {
|
|
260
|
+
self.default_send_library.entry(eid).read()
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// ========================= Receive Library Management =========================
|
|
264
|
+
|
|
265
|
+
fn set_receive_library(
|
|
266
|
+
ref self: ComponentState<TContractState>,
|
|
267
|
+
oapp: ContractAddress,
|
|
268
|
+
eid: u32,
|
|
269
|
+
lib: ContractAddress,
|
|
270
|
+
grace_period: u64,
|
|
271
|
+
) {
|
|
272
|
+
// Only the OApp itself can set its receive library
|
|
273
|
+
self._assert_authorized(oapp);
|
|
274
|
+
|
|
275
|
+
let receive_library_entry = self.receive_library.entry(oapp).entry(eid);
|
|
276
|
+
// Prevent no-op updates (must provide new values)
|
|
277
|
+
let old_lib = receive_library_entry.read();
|
|
278
|
+
assert_with_byte_array(old_lib != lib, err_same_value());
|
|
279
|
+
|
|
280
|
+
// Validate library registration, type, and endpoint support
|
|
281
|
+
self._assert_registered_or_default(lib);
|
|
282
|
+
self._assert_receive_lib(lib);
|
|
283
|
+
self._assert_supported_receive_eid(lib, eid);
|
|
284
|
+
|
|
285
|
+
// Update the receive library configuration
|
|
286
|
+
receive_library_entry.write(lib);
|
|
287
|
+
self.emit(ReceiveLibrarySet { receiver: oapp, src_eid: eid, library: lib });
|
|
288
|
+
|
|
289
|
+
if grace_period > 0 {
|
|
290
|
+
// To simplify logic, we only allow timeout if neither new lib nor old lib is
|
|
291
|
+
// DEFAULT_LIB. This prevents complex interactions with default library timeouts.
|
|
292
|
+
assert_with_byte_array(
|
|
293
|
+
old_lib != DEFAULT_LIB && lib != DEFAULT_LIB, err_only_non_default_lib(),
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
// Set grace period for the old library to remain valid during transition
|
|
297
|
+
let timeout = Timeout { lib: old_lib, expiry: get_block_number() + grace_period };
|
|
298
|
+
self.receive_library_timeout.entry(oapp).entry(eid).write(timeout);
|
|
299
|
+
self
|
|
300
|
+
.emit(
|
|
301
|
+
ReceiveLibraryTimeoutSet {
|
|
302
|
+
oapp, eid, library: old_lib, expiry: timeout.expiry,
|
|
303
|
+
},
|
|
304
|
+
);
|
|
305
|
+
} else {
|
|
306
|
+
// Clear any existing timeout when no grace period is specified
|
|
307
|
+
// this writes the default value for Timeout struct
|
|
308
|
+
self.receive_library_timeout.entry(oapp).entry(eid).write(DEFAULT_TIMEOUT);
|
|
309
|
+
self
|
|
310
|
+
.emit(
|
|
311
|
+
ReceiveLibraryTimeoutSet {
|
|
312
|
+
oapp, eid, library: old_lib, expiry: DEFAULT_EXPIRY,
|
|
313
|
+
},
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
fn get_receive_library(
|
|
319
|
+
self: @ComponentState<TContractState>, oapp: ContractAddress, src_eid: u32,
|
|
320
|
+
) -> GetLibraryResponse {
|
|
321
|
+
// Get the OApp's custom receive library configuration
|
|
322
|
+
let lib = self.receive_library.entry(oapp).entry(src_eid).read();
|
|
323
|
+
|
|
324
|
+
// If not set or set to DEFAULT_LIB, resolve to the protocol default
|
|
325
|
+
if lib == DEFAULT_LIB {
|
|
326
|
+
let default_lib = self.default_receive_library.entry(src_eid).read();
|
|
327
|
+
assert_with_byte_array(
|
|
328
|
+
!default_lib.is_zero(), err_default_receive_lib_unavailable(),
|
|
329
|
+
);
|
|
330
|
+
GetLibraryResponse {
|
|
331
|
+
lib: default_lib, is_default: true,
|
|
332
|
+
} // Return library and indicate it's the default
|
|
333
|
+
} else {
|
|
334
|
+
GetLibraryResponse {
|
|
335
|
+
lib, is_default: false,
|
|
336
|
+
} // Return custom library and indicate it's not the default
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
fn get_raw_receive_library(
|
|
341
|
+
self: @ComponentState<TContractState>, oapp: ContractAddress, src_eid: u32,
|
|
342
|
+
) -> ContractAddress {
|
|
343
|
+
self.receive_library.entry(oapp).entry(src_eid).read()
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
fn is_valid_receive_library(
|
|
347
|
+
self: @ComponentState<TContractState>,
|
|
348
|
+
oapp: ContractAddress,
|
|
349
|
+
src_eid: u32,
|
|
350
|
+
lib: ContractAddress,
|
|
351
|
+
) -> bool {
|
|
352
|
+
// First check if the lib is the currently configured receive library
|
|
353
|
+
let GetLibraryResponse {
|
|
354
|
+
lib: expected_lib, is_default,
|
|
355
|
+
} = self.get_receive_library(oapp, src_eid);
|
|
356
|
+
if lib == expected_lib {
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// If not the current library, check if it's in a valid grace period
|
|
361
|
+
// Use the appropriate timeout configuration based on whether default is being used
|
|
362
|
+
let timeout = if is_default {
|
|
363
|
+
// OApp is using default library, check default timeout configuration
|
|
364
|
+
self.default_receive_library_timeout.entry(src_eid).read()
|
|
365
|
+
} else {
|
|
366
|
+
// OApp has custom library, check OApp-specific timeout configuration
|
|
367
|
+
self.receive_library_timeout.entry(oapp).entry(src_eid).read()
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// Library is valid if it matches the timeout library and hasn't expired
|
|
371
|
+
timeout.lib == lib && timeout.expiry > get_block_number()
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
fn set_default_receive_library(
|
|
375
|
+
ref self: ComponentState<TContractState>,
|
|
376
|
+
eid: u32,
|
|
377
|
+
lib: ContractAddress,
|
|
378
|
+
grace_period: u64,
|
|
379
|
+
) {
|
|
380
|
+
// Only the protocol owner can set default libraries
|
|
381
|
+
self._assert_only_owner();
|
|
382
|
+
|
|
383
|
+
// Prevent no-op updates (must provide a different value)
|
|
384
|
+
let old_lib = self.default_receive_library.entry(eid).read();
|
|
385
|
+
assert_with_byte_array(old_lib != lib, err_same_value());
|
|
386
|
+
|
|
387
|
+
// Validate library registration, type, and endpoint support
|
|
388
|
+
self._assert_registered(lib);
|
|
389
|
+
self._assert_receive_lib(lib);
|
|
390
|
+
self._assert_supported_receive_eid(lib, eid);
|
|
391
|
+
|
|
392
|
+
// Update the default receive library for the endpoint
|
|
393
|
+
self.default_receive_library.entry(eid).write(lib);
|
|
394
|
+
self.emit(DefaultReceiveLibrarySet { eid, library: lib });
|
|
395
|
+
|
|
396
|
+
if grace_period > 0 {
|
|
397
|
+
// Set grace period for the old default library to remain valid
|
|
398
|
+
let timeout = Timeout { lib: old_lib, expiry: get_block_number() + grace_period };
|
|
399
|
+
self.default_receive_library_timeout.entry(eid).write(timeout);
|
|
400
|
+
self
|
|
401
|
+
.emit(
|
|
402
|
+
DefaultReceiveLibraryTimeoutSet {
|
|
403
|
+
eid, library: old_lib, expiry: timeout.expiry,
|
|
404
|
+
},
|
|
405
|
+
);
|
|
406
|
+
} else {
|
|
407
|
+
// Remove any existing timeout configuration
|
|
408
|
+
// this writes the default value for Timeout struct
|
|
409
|
+
self.default_receive_library_timeout.entry(eid).write(DEFAULT_TIMEOUT);
|
|
410
|
+
self
|
|
411
|
+
.emit(
|
|
412
|
+
DefaultReceiveLibraryTimeoutSet {
|
|
413
|
+
eid, library: old_lib, expiry: DEFAULT_EXPIRY,
|
|
414
|
+
},
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
fn get_default_receive_library(
|
|
420
|
+
self: @ComponentState<TContractState>, eid: u32,
|
|
421
|
+
) -> ContractAddress {
|
|
422
|
+
self.default_receive_library.entry(eid).read()
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
fn is_default_receive_library(
|
|
426
|
+
self: @ComponentState<TContractState>, oapp: ContractAddress, src_eid: u32,
|
|
427
|
+
) -> bool {
|
|
428
|
+
self.receive_library.entry(oapp).entry(src_eid).read() == DEFAULT_LIB
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
fn set_receive_library_timeout(
|
|
432
|
+
ref self: ComponentState<TContractState>,
|
|
433
|
+
oapp: ContractAddress,
|
|
434
|
+
eid: u32,
|
|
435
|
+
lib: ContractAddress,
|
|
436
|
+
expiry: u64,
|
|
437
|
+
) {
|
|
438
|
+
// Only the OApp itself can manage its timeout configurations
|
|
439
|
+
self._assert_authorized(oapp);
|
|
440
|
+
|
|
441
|
+
// Validate library registration, type, and endpoint support
|
|
442
|
+
self._assert_registered(lib);
|
|
443
|
+
self._assert_receive_lib(lib);
|
|
444
|
+
self._assert_supported_receive_eid(lib, eid);
|
|
445
|
+
|
|
446
|
+
let GetLibraryResponse { is_default, .. } = self.get_receive_library(oapp, eid);
|
|
447
|
+
// OApps using default libraries cannot set custom timeouts
|
|
448
|
+
assert_with_byte_array(!is_default, err_only_non_default_lib());
|
|
449
|
+
|
|
450
|
+
if expiry > 0 {
|
|
451
|
+
// Set new timeout configuration (expiry must be in the future)
|
|
452
|
+
assert_with_byte_array(expiry > get_block_number(), err_invalid_expiry());
|
|
453
|
+
let timeout = Timeout { lib, expiry };
|
|
454
|
+
self.receive_library_timeout.entry(oapp).entry(eid).write(timeout);
|
|
455
|
+
} else {
|
|
456
|
+
// Remove the timeout configuration (force expire)
|
|
457
|
+
self.receive_library_timeout.entry(oapp).entry(eid).write(DEFAULT_TIMEOUT);
|
|
458
|
+
}
|
|
459
|
+
self.emit(ReceiveLibraryTimeoutSet { oapp, eid, library: lib, expiry });
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
fn get_receive_library_timeout(
|
|
463
|
+
self: @ComponentState<TContractState>,
|
|
464
|
+
oapp: ContractAddress,
|
|
465
|
+
eid: u32,
|
|
466
|
+
lib: ContractAddress,
|
|
467
|
+
) -> Timeout {
|
|
468
|
+
self.receive_library_timeout.entry(oapp).entry(eid).read()
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
fn set_default_receive_library_timeout(
|
|
472
|
+
ref self: ComponentState<TContractState>, eid: u32, lib: ContractAddress, expiry: u64,
|
|
473
|
+
) {
|
|
474
|
+
// Only the protocol owner can manage default timeout configurations
|
|
475
|
+
self._assert_only_owner();
|
|
476
|
+
|
|
477
|
+
// Validate library registration, type, and endpoint support
|
|
478
|
+
self._assert_registered(lib);
|
|
479
|
+
self._assert_receive_lib(lib);
|
|
480
|
+
self._assert_supported_receive_eid(lib, eid);
|
|
481
|
+
|
|
482
|
+
if expiry > 0 {
|
|
483
|
+
// Set new default timeout configuration (expiry must be in the future)
|
|
484
|
+
assert_with_byte_array(expiry > get_block_number(), err_invalid_expiry());
|
|
485
|
+
let timeout = Timeout { lib, expiry };
|
|
486
|
+
self.default_receive_library_timeout.entry(eid).write(timeout);
|
|
487
|
+
} else {
|
|
488
|
+
// Remove the default timeout configuration (force expire)
|
|
489
|
+
self.default_receive_library_timeout.entry(eid).write(DEFAULT_TIMEOUT);
|
|
490
|
+
}
|
|
491
|
+
self.emit(DefaultReceiveLibraryTimeoutSet { eid, library: lib, expiry });
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
fn get_default_receive_library_timeout(
|
|
495
|
+
self: @ComponentState<TContractState>, eid: u32,
|
|
496
|
+
) -> Timeout {
|
|
497
|
+
self.default_receive_library_timeout.entry(eid).read()
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// ========================= Configuration Management =========================
|
|
501
|
+
|
|
502
|
+
fn set_send_config(
|
|
503
|
+
ref self: ComponentState<TContractState>,
|
|
504
|
+
oapp: ContractAddress,
|
|
505
|
+
lib: ContractAddress,
|
|
506
|
+
params: Array<SetConfigParam>,
|
|
507
|
+
) {
|
|
508
|
+
// Only the OApp itself can set its send configuration
|
|
509
|
+
self._assert_authorized(oapp);
|
|
510
|
+
|
|
511
|
+
self._assert_registered(lib);
|
|
512
|
+
self._assert_send_lib(lib);
|
|
513
|
+
|
|
514
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: lib };
|
|
515
|
+
lib_dispatcher.set_send_config(oapp, params);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
fn set_receive_config(
|
|
519
|
+
ref self: ComponentState<TContractState>,
|
|
520
|
+
oapp: ContractAddress,
|
|
521
|
+
lib: ContractAddress,
|
|
522
|
+
params: Array<SetConfigParam>,
|
|
523
|
+
) {
|
|
524
|
+
// Only the OApp itself can set its receive configuration
|
|
525
|
+
self._assert_authorized(oapp);
|
|
526
|
+
|
|
527
|
+
self._assert_registered(lib);
|
|
528
|
+
self._assert_receive_lib(lib);
|
|
529
|
+
|
|
530
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: lib };
|
|
531
|
+
lib_dispatcher.set_receive_config(oapp, params);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
fn get_send_config(
|
|
535
|
+
self: @ComponentState<TContractState>,
|
|
536
|
+
oapp: ContractAddress,
|
|
537
|
+
lib: ContractAddress,
|
|
538
|
+
eid: u32,
|
|
539
|
+
config_type: u32,
|
|
540
|
+
) -> Array<felt252> {
|
|
541
|
+
// Only registered libraries can provide configuration
|
|
542
|
+
self._assert_registered(lib);
|
|
543
|
+
|
|
544
|
+
// Delegate configuration query to the message library
|
|
545
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: lib };
|
|
546
|
+
lib_dispatcher.get_send_config(eid, oapp, config_type)
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
fn get_receive_config(
|
|
550
|
+
self: @ComponentState<TContractState>,
|
|
551
|
+
oapp: ContractAddress,
|
|
552
|
+
lib: ContractAddress,
|
|
553
|
+
eid: u32,
|
|
554
|
+
config_type: u32,
|
|
555
|
+
) -> Array<felt252> {
|
|
556
|
+
// Only registered libraries can provide configuration
|
|
557
|
+
self._assert_registered(lib);
|
|
558
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: lib };
|
|
559
|
+
lib_dispatcher.get_receive_config(eid, oapp, config_type)
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// ========================= Utility Functions =========================
|
|
563
|
+
|
|
564
|
+
fn is_supported_eid(self: @ComponentState<TContractState>, eid: u32) -> bool {
|
|
565
|
+
// An endpoint is considered supported if it has both default send and receive libraries
|
|
566
|
+
let default_send = self.default_send_library.entry(eid).read();
|
|
567
|
+
let default_receive = self.default_receive_library.entry(eid).read();
|
|
568
|
+
!default_send.is_zero() && !default_receive.is_zero()
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/// =============================== Internal Functions =================================
|
|
573
|
+
#[generate_trait]
|
|
574
|
+
pub impl InternalImpl<
|
|
575
|
+
TContractState,
|
|
576
|
+
+HasComponent<TContractState>,
|
|
577
|
+
impl Ownable: OwnableComponent::HasComponent<TContractState>,
|
|
578
|
+
+Drop<TContractState>,
|
|
579
|
+
> of InternalTrait<TContractState> {
|
|
580
|
+
/// Initialize the MessageLibManager component with a blocked library
|
|
581
|
+
///
|
|
582
|
+
/// The blocked library is automatically registered and serves as a way to
|
|
583
|
+
/// disable sending/receiving on specific endpoints by setting it as the default.
|
|
584
|
+
///
|
|
585
|
+
/// # Arguments
|
|
586
|
+
/// * `blocked_library` - Address of the library that blocks operations
|
|
587
|
+
fn initializer(ref self: ComponentState<TContractState>, blocked_library: ContractAddress) {
|
|
588
|
+
// Query the library for its type to ensure it implements IMessageLib.
|
|
589
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: blocked_library };
|
|
590
|
+
let _ = lib_dispatcher.message_lib_type();
|
|
591
|
+
|
|
592
|
+
self.blocked_library.write(blocked_library);
|
|
593
|
+
|
|
594
|
+
// Register blocked library directly without owner check during initialization
|
|
595
|
+
self.is_registered_library.entry(blocked_library).write(true);
|
|
596
|
+
self.registered_libraries.push(blocked_library);
|
|
597
|
+
self.emit(LibraryRegistered { library: blocked_library });
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/// Assert that the caller is the contract owner
|
|
601
|
+
///
|
|
602
|
+
/// Uses the Ownable component to verify ownership permissions.
|
|
603
|
+
/// Used for operations that require protocol-level administrative access.
|
|
604
|
+
fn _assert_only_owner(self: @ComponentState<TContractState>) {
|
|
605
|
+
let ownable = get_dep_component!(self, Ownable);
|
|
606
|
+
ownable.assert_only_owner();
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/// Assert that a library is registered with the endpoint
|
|
610
|
+
///
|
|
611
|
+
/// # Arguments
|
|
612
|
+
/// * `lib` - The library address to validate
|
|
613
|
+
///
|
|
614
|
+
/// # Panics
|
|
615
|
+
/// * If the library is not registered
|
|
616
|
+
fn _assert_registered(self: @ComponentState<TContractState>, lib: ContractAddress) {
|
|
617
|
+
assert_with_byte_array(
|
|
618
|
+
self.is_registered_library.entry(lib).read(), err_only_registered_lib(),
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/// Assert that a library is registered or is the DEFAULT_LIB constant
|
|
623
|
+
///
|
|
624
|
+
/// This allows functions to accept either a registered library or the special
|
|
625
|
+
/// DEFAULT_LIB value that indicates the default library should be used.
|
|
626
|
+
///
|
|
627
|
+
/// # Arguments
|
|
628
|
+
/// * `lib` - The library address to validate
|
|
629
|
+
///
|
|
630
|
+
/// # Panics
|
|
631
|
+
/// * If the library is not registered and is not DEFAULT_LIB
|
|
632
|
+
fn _assert_registered_or_default(
|
|
633
|
+
self: @ComponentState<TContractState>, lib: ContractAddress,
|
|
634
|
+
) {
|
|
635
|
+
if lib != DEFAULT_LIB {
|
|
636
|
+
assert_with_byte_array(
|
|
637
|
+
self.is_registered_library.entry(lib).read(),
|
|
638
|
+
err_only_registered_or_default_lib(),
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/// Assert that a library supports send operations
|
|
644
|
+
///
|
|
645
|
+
/// Validates that the library's type is either Send or SendAndReceive.
|
|
646
|
+
/// Skips validation for DEFAULT_LIB as it will be resolved later.
|
|
647
|
+
///
|
|
648
|
+
/// # Arguments
|
|
649
|
+
/// * `lib` - The library address to validate
|
|
650
|
+
///
|
|
651
|
+
/// # Panics
|
|
652
|
+
/// * If the library doesn't support send operations
|
|
653
|
+
fn _assert_send_lib(self: @ComponentState<TContractState>, lib: ContractAddress) {
|
|
654
|
+
if lib != DEFAULT_LIB {
|
|
655
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: lib };
|
|
656
|
+
let lib_type = lib_dispatcher.message_lib_type();
|
|
657
|
+
assert_with_byte_array(
|
|
658
|
+
lib_type == MessageLibType::Send || lib_type == MessageLibType::SendAndReceive,
|
|
659
|
+
err_only_send_lib(),
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/// Assert that a library supports receive operations
|
|
665
|
+
///
|
|
666
|
+
/// Validates that the library's type is either Receive or SendAndReceive.
|
|
667
|
+
/// Skips validation for DEFAULT_LIB as it will be resolved later.
|
|
668
|
+
///
|
|
669
|
+
/// # Arguments
|
|
670
|
+
/// * `lib` - The library address to validate
|
|
671
|
+
///
|
|
672
|
+
/// # Panics
|
|
673
|
+
/// * If the library doesn't support receive operations
|
|
674
|
+
fn _assert_receive_lib(self: @ComponentState<TContractState>, lib: ContractAddress) {
|
|
675
|
+
if lib != DEFAULT_LIB {
|
|
676
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: lib };
|
|
677
|
+
let lib_type = lib_dispatcher.message_lib_type();
|
|
678
|
+
assert_with_byte_array(
|
|
679
|
+
lib_type == MessageLibType::Receive
|
|
680
|
+
|| lib_type == MessageLibType::SendAndReceive,
|
|
681
|
+
err_only_receive_lib(),
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/// Assert that a library supports operations for a specific endpoint
|
|
687
|
+
///
|
|
688
|
+
/// Validates that the library has enabled support for the given endpoint ID.
|
|
689
|
+
/// This ensures libraries can only be used for endpoints they're designed to handle.
|
|
690
|
+
/// Skips validation for DEFAULT_LIB as it will be resolved later.
|
|
691
|
+
///
|
|
692
|
+
/// # Arguments
|
|
693
|
+
/// * `lib` - The library address to validate
|
|
694
|
+
/// * `eid` - The endpoint ID to check support for
|
|
695
|
+
///
|
|
696
|
+
/// # Panics
|
|
697
|
+
/// * If the library doesn't support the specified endpoint
|
|
698
|
+
fn _assert_supported_send_eid(
|
|
699
|
+
self: @ComponentState<TContractState>, lib: ContractAddress, eid: u32,
|
|
700
|
+
) {
|
|
701
|
+
if lib != DEFAULT_LIB {
|
|
702
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: lib };
|
|
703
|
+
assert_with_byte_array(
|
|
704
|
+
lib_dispatcher.is_supported_send_eid(eid), err_unsupported_eid(eid),
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
fn _assert_supported_receive_eid(
|
|
710
|
+
self: @ComponentState<TContractState>, lib: ContractAddress, eid: u32,
|
|
711
|
+
) {
|
|
712
|
+
if lib != DEFAULT_LIB {
|
|
713
|
+
let lib_dispatcher = IMessageLibDispatcher { contract_address: lib };
|
|
714
|
+
assert_with_byte_array(
|
|
715
|
+
lib_dispatcher.is_supported_receive_eid(eid), err_unsupported_eid(eid),
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|