@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,83 @@
|
|
|
1
|
+
//! Ultra light node admin interface
|
|
2
|
+
|
|
3
|
+
use layerzero::message_lib::uln::structs::executor_config::ExecutorConfig;
|
|
4
|
+
use layerzero::message_lib::uln::structs::uln_config::{SetDefaultUlnConfigParam, UlnConfig};
|
|
5
|
+
use lz_utils::bytes::Bytes32;
|
|
6
|
+
use starknet::ContractAddress;
|
|
7
|
+
|
|
8
|
+
#[starknet::interface]
|
|
9
|
+
pub trait IUltraLightNodeAdmin<TContractState> {
|
|
10
|
+
// -- Setter functions for configuration
|
|
11
|
+
/// Sets the default ULN send configuration for multiple destination endpoints
|
|
12
|
+
fn set_default_uln_send_config(
|
|
13
|
+
ref self: TContractState, configs: Array<SetDefaultUlnConfigParam>,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
/// Sets the default ULN receive configuration for multiple destination endpoints
|
|
17
|
+
fn set_default_uln_receive_config(
|
|
18
|
+
ref self: TContractState, configs: Array<SetDefaultUlnConfigParam>,
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
/// Sets the default executor configuration for a specific destination endpoint
|
|
22
|
+
fn set_default_executor_config(ref self: TContractState, dst_eid: u32, config: ExecutorConfig);
|
|
23
|
+
|
|
24
|
+
// -- Getter functions for verification
|
|
25
|
+
/// Gets the default ULN send configuration for a destination endpoint
|
|
26
|
+
fn get_default_uln_send_config(self: @TContractState, dst_eid: u32) -> UlnConfig;
|
|
27
|
+
|
|
28
|
+
/// Gets the default ULN receive configuration for a destination endpoint
|
|
29
|
+
fn get_default_uln_receive_config(self: @TContractState, src_eid: u32) -> UlnConfig;
|
|
30
|
+
|
|
31
|
+
/// Gets the raw (stored) ULN send configuration for a specific OApp
|
|
32
|
+
fn get_raw_oapp_uln_send_config(
|
|
33
|
+
self: @TContractState, oapp: ContractAddress, dst_eid: u32,
|
|
34
|
+
) -> UlnConfig;
|
|
35
|
+
|
|
36
|
+
/// Gets the raw (stored) ULN receive configuration for a specific OApp
|
|
37
|
+
fn get_raw_oapp_uln_receive_config(
|
|
38
|
+
self: @TContractState, oapp: ContractAddress, src_eid: u32,
|
|
39
|
+
) -> UlnConfig;
|
|
40
|
+
|
|
41
|
+
/// Gets the effective ULN send configuration for a specific OApp
|
|
42
|
+
fn get_oapp_uln_send_config(
|
|
43
|
+
self: @TContractState, oapp: ContractAddress, dst_eid: u32,
|
|
44
|
+
) -> UlnConfig;
|
|
45
|
+
|
|
46
|
+
/// Gets the effective ULN receive configuration for a specific OApp
|
|
47
|
+
fn get_oapp_uln_receive_config(
|
|
48
|
+
self: @TContractState, oapp: ContractAddress, src_eid: u32,
|
|
49
|
+
) -> UlnConfig;
|
|
50
|
+
|
|
51
|
+
/// Gets the default executor configuration for a destination endpoint
|
|
52
|
+
fn get_default_executor_config(self: @TContractState, dst_eid: u32) -> ExecutorConfig;
|
|
53
|
+
|
|
54
|
+
/// Gets the raw (stored) executor configuration for a specific OApp
|
|
55
|
+
fn get_raw_oapp_executor_config(
|
|
56
|
+
self: @TContractState, oapp: ContractAddress, dst_eid: u32,
|
|
57
|
+
) -> ExecutorConfig;
|
|
58
|
+
|
|
59
|
+
/// Gets the effective executor configuration for a specific OApp
|
|
60
|
+
fn get_oapp_executor_config(
|
|
61
|
+
self: @TContractState, oapp: ContractAddress, dst_eid: u32,
|
|
62
|
+
) -> ExecutorConfig;
|
|
63
|
+
|
|
64
|
+
/// Gets the current treasury contract address
|
|
65
|
+
fn get_treasury(self: @TContractState) -> ContractAddress;
|
|
66
|
+
|
|
67
|
+
/// Sets the treasury floor fee
|
|
68
|
+
fn set_treasury_native_fee_cap(ref self: TContractState, native_fee_cap: u256);
|
|
69
|
+
|
|
70
|
+
/// Gets the treasury native fee cap
|
|
71
|
+
fn get_treasury_native_fee_cap(self: @TContractState) -> u256;
|
|
72
|
+
|
|
73
|
+
/// Checks if the payload has been signed by a DVN
|
|
74
|
+
///
|
|
75
|
+
/// # Arguments
|
|
76
|
+
///
|
|
77
|
+
/// * `header_hash`: The header hash of the payload
|
|
78
|
+
/// * `payload_hash`: The payload hash
|
|
79
|
+
/// * `dvn`: The DVN contract address
|
|
80
|
+
fn has_payload_signed(
|
|
81
|
+
self: @TContractState, header_hash: Bytes32, payload_hash: Bytes32, dvn: ContractAddress,
|
|
82
|
+
) -> bool;
|
|
83
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
use alexandria_bytes::byte_array_ext::ByteArrayTraitExt;
|
|
2
|
+
use core::byte_array::{ByteArray, ByteArrayTrait};
|
|
3
|
+
use starkware_utils::errors::assert_with_byte_array;
|
|
4
|
+
|
|
5
|
+
// Import error functions
|
|
6
|
+
use crate::message_lib::uln::errors::{
|
|
7
|
+
err_invalid_worker_id, err_invalid_worker_options, err_unsupported_option_type,
|
|
8
|
+
};
|
|
9
|
+
use crate::workers::dvn::options::DVN_WORKER_ID;
|
|
10
|
+
use crate::workers::executor::options::EXECUTOR_WORKER_ID;
|
|
11
|
+
|
|
12
|
+
// Option type constants
|
|
13
|
+
pub const TYPE_3: u16 = 3;
|
|
14
|
+
|
|
15
|
+
/// Decode the options into executor_options and dvn_options
|
|
16
|
+
///
|
|
17
|
+
/// # Arguments
|
|
18
|
+
/// * `options` - The options can be either legacy options (type 1 or 2) or type 3 options
|
|
19
|
+
///
|
|
20
|
+
/// # Returns
|
|
21
|
+
/// * `(executor_options, dvn_options)` - The executor options and DVN options in type 3 format
|
|
22
|
+
pub fn split_options(options: @ByteArray) -> (ByteArray, ByteArray) {
|
|
23
|
+
// At least 2 bytes for the option type, but can have no options
|
|
24
|
+
assert_with_byte_array(options.len() >= 2, err_invalid_worker_options(0));
|
|
25
|
+
|
|
26
|
+
// we don't support legacy options here, only allowing option type 3
|
|
27
|
+
let (mut cursor, options_type) = options.read_u16(0);
|
|
28
|
+
assert_with_byte_array(options_type == TYPE_3, err_unsupported_option_type(options_type));
|
|
29
|
+
|
|
30
|
+
// Type3 options: [worker_option][worker_option]...
|
|
31
|
+
// worker_option: [worker_id][option_size][option]
|
|
32
|
+
// worker_id: u8, option_size: u16, option: bytes
|
|
33
|
+
|
|
34
|
+
let mut executor_options: ByteArray = Default::default();
|
|
35
|
+
let mut dvn_options: ByteArray = Default::default();
|
|
36
|
+
|
|
37
|
+
while cursor != options.len() {
|
|
38
|
+
// worker_id can't be zero
|
|
39
|
+
let (new_cursor, worker_id) = options.read_u8(cursor);
|
|
40
|
+
assert_with_byte_array(worker_id != 0, err_invalid_worker_id(0));
|
|
41
|
+
|
|
42
|
+
let (new_cursor, options_size) = options.read_u16(new_cursor);
|
|
43
|
+
assert_with_byte_array(options_size != 0, err_invalid_worker_options(new_cursor));
|
|
44
|
+
|
|
45
|
+
let (new_cursor, option) = options.read_bytes(new_cursor, options_size.into());
|
|
46
|
+
|
|
47
|
+
if worker_id == EXECUTOR_WORKER_ID {
|
|
48
|
+
executor_options.append_u8(EXECUTOR_WORKER_ID);
|
|
49
|
+
executor_options.append_u16(options_size);
|
|
50
|
+
executor_options.append(@option);
|
|
51
|
+
} else if worker_id == DVN_WORKER_ID {
|
|
52
|
+
dvn_options.append_u8(DVN_WORKER_ID);
|
|
53
|
+
dvn_options.append_u16(options_size);
|
|
54
|
+
dvn_options.append(@option);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
cursor = new_cursor;
|
|
58
|
+
|
|
59
|
+
// The cursor must never exceed option length
|
|
60
|
+
assert_with_byte_array(cursor <= options.len(), err_invalid_worker_options(cursor));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
(executor_options, dvn_options)
|
|
64
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//! Executor configuration struct
|
|
2
|
+
|
|
3
|
+
use starknet::ContractAddress;
|
|
4
|
+
use crate::common::constants::ZERO_ADDRESS;
|
|
5
|
+
|
|
6
|
+
#[derive(Drop, Serde, Clone, PartialEq, starknet::Store)]
|
|
7
|
+
pub struct ExecutorConfig {
|
|
8
|
+
pub max_message_size: u32,
|
|
9
|
+
pub executor: ContractAddress,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
impl ExecutorConfigDefault of Default<ExecutorConfig> {
|
|
13
|
+
fn default() -> ExecutorConfig {
|
|
14
|
+
ExecutorConfig { max_message_size: 0, executor: ZERO_ADDRESS }
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
pub trait ExecutorConfigResolver {
|
|
19
|
+
/// Resolves a ULN configuration by merging default and custom configurations
|
|
20
|
+
/// Following the same logic as getUlnConfig in the Solidity implementation
|
|
21
|
+
fn resolve(default_config: @ExecutorConfig, custom_config: @ExecutorConfig) -> ExecutorConfig;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
pub impl ExecutorConfigResolverImpl of ExecutorConfigResolver {
|
|
25
|
+
fn resolve(default_config: @ExecutorConfig, custom_config: @ExecutorConfig) -> ExecutorConfig {
|
|
26
|
+
let mut resolved_config: ExecutorConfig = default_config.clone();
|
|
27
|
+
if *custom_config.max_message_size != 0 {
|
|
28
|
+
resolved_config.max_message_size = *custom_config.max_message_size;
|
|
29
|
+
}
|
|
30
|
+
if !(*custom_config.executor == ZERO_ADDRESS) {
|
|
31
|
+
resolved_config.executor = *custom_config.executor;
|
|
32
|
+
}
|
|
33
|
+
resolved_config
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
use starknet::ContractAddress;
|
|
2
|
+
use starkware_utils::errors::assert_with_byte_array;
|
|
3
|
+
use crate::message_lib::uln::errors::{
|
|
4
|
+
err_invalid_confirmations, err_invalid_optional_dvn_threshold, err_must_have_at_least_one_dvn,
|
|
5
|
+
err_too_many_dvns, err_unsorted_dvns,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
#[derive(Debug, Drop, Serde, Clone, PartialEq)]
|
|
9
|
+
pub struct UlnConfig {
|
|
10
|
+
// Using the has_* method instead of *_is_null (as we did in TON), because
|
|
11
|
+
// The Starknet Map<Key, Value> will always fall back to the default of <Value> if
|
|
12
|
+
// we haven't explicitly set the relevant <Key> in there.
|
|
13
|
+
// If we use the *_is_null method, all of the unset custom configurations will
|
|
14
|
+
// fall back to being not_null, which means an unset custom OApp configuration will overwrite
|
|
15
|
+
// the set default configuration
|
|
16
|
+
// the has_* fields are ignored in the `defaultConfig` variations.
|
|
17
|
+
pub confirmations: u64,
|
|
18
|
+
pub has_confirmations: bool,
|
|
19
|
+
// no duplicates. sorted in ascending order. allowed overlap with optionalDVNs
|
|
20
|
+
pub required_dvns: Array<ContractAddress>,
|
|
21
|
+
pub has_required_dvns: bool,
|
|
22
|
+
// no duplicates. sorted in ascending order. allowed overlap with requiredDVNs
|
|
23
|
+
pub optional_dvns: Array<ContractAddress>,
|
|
24
|
+
pub optional_dvn_threshold: u8, // (0, optionalDvnCount]
|
|
25
|
+
pub has_optional_dvns: bool,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// TODO: This number should be the maximum possible in this VM
|
|
29
|
+
// We will need to profile it to see if it can be lower/higher
|
|
30
|
+
// (main limitation being having to call this amount of DVNs to quote/assignJob)
|
|
31
|
+
pub const MAX_DVN_COUNT: u32 = 255;
|
|
32
|
+
|
|
33
|
+
#[derive(Drop, Serde, Clone, PartialEq)]
|
|
34
|
+
pub struct SetDefaultUlnConfigParam {
|
|
35
|
+
pub eid: u32, // endpoint ID
|
|
36
|
+
pub config: UlnConfig,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
pub trait UlnConfigUtils {
|
|
40
|
+
/// Resolves a ULN configuration by merging default and custom configurations
|
|
41
|
+
/// Following the same logic as getUlnConfig in the Solidity implementation
|
|
42
|
+
fn resolve(default_config: @UlnConfig, custom_config: @UlnConfig) -> UlnConfig;
|
|
43
|
+
|
|
44
|
+
/// Asserts that both dvn arrays of the config have no duplicates
|
|
45
|
+
fn assert_no_duplicate_dvns(config: @UlnConfig);
|
|
46
|
+
|
|
47
|
+
/// Asserts that DVNs are sorted in ascending order with no duplicates
|
|
48
|
+
fn assert_no_duplicates_in_dvn_array(dvns: @Array<ContractAddress>);
|
|
49
|
+
|
|
50
|
+
/// Asserts that at least one DVN is configured
|
|
51
|
+
fn assert_at_least_one_dvn(config: @UlnConfig);
|
|
52
|
+
|
|
53
|
+
/// Asserts that the optional DVN threshold is valid
|
|
54
|
+
fn assert_valid_optional_threshold(config: @UlnConfig);
|
|
55
|
+
|
|
56
|
+
/// Asserts that the total DVN count doesn't exceed the maximum
|
|
57
|
+
fn assert_max_dvn_count(config: @UlnConfig);
|
|
58
|
+
|
|
59
|
+
/// Asserts that the config confirmations are valid
|
|
60
|
+
fn assert_valid_confirmations(confirmations: u64);
|
|
61
|
+
|
|
62
|
+
// Asserts that a standalone config (post-resolve / default) is valid
|
|
63
|
+
fn assert_valid_standalone_config(config: @UlnConfig);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
pub impl UlnConfigUtilsImpl of UlnConfigUtils {
|
|
67
|
+
fn resolve(default_config: @UlnConfig, custom_config: @UlnConfig) -> UlnConfig {
|
|
68
|
+
let mut resolved_config = default_config.clone();
|
|
69
|
+
|
|
70
|
+
// Resolve confirmations
|
|
71
|
+
if *custom_config.has_confirmations {
|
|
72
|
+
resolved_config.confirmations = *custom_config.confirmations;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Resolve required DVNs
|
|
76
|
+
if *custom_config.has_required_dvns {
|
|
77
|
+
resolved_config.required_dvns = custom_config.required_dvns.clone();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Resolve optional DVNs
|
|
81
|
+
if *custom_config.has_optional_dvns {
|
|
82
|
+
resolved_config.optional_dvns = custom_config.optional_dvns.clone();
|
|
83
|
+
resolved_config.optional_dvn_threshold = *custom_config.optional_dvn_threshold;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
Self::assert_valid_standalone_config(@resolved_config);
|
|
87
|
+
|
|
88
|
+
resolved_config
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fn assert_no_duplicate_dvns(config: @UlnConfig) {
|
|
92
|
+
Self::assert_no_duplicates_in_dvn_array(config.required_dvns);
|
|
93
|
+
Self::assert_no_duplicates_in_dvn_array(config.optional_dvns);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fn assert_no_duplicates_in_dvn_array(dvns: @Array<ContractAddress>) {
|
|
97
|
+
let mut last_dvn: ContractAddress = 0.try_into().unwrap();
|
|
98
|
+
let mut i = 0;
|
|
99
|
+
|
|
100
|
+
while i != dvns.len() {
|
|
101
|
+
let current_dvn = *dvns.at(i);
|
|
102
|
+
|
|
103
|
+
// Check if current DVN is less than or equal to the last DVN
|
|
104
|
+
// This ensures both sorting and no duplicates
|
|
105
|
+
assert_with_byte_array(current_dvn > last_dvn.into(), err_unsorted_dvns());
|
|
106
|
+
|
|
107
|
+
last_dvn = current_dvn;
|
|
108
|
+
i += 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fn assert_at_least_one_dvn(config: @UlnConfig) {
|
|
113
|
+
let required_count = config.required_dvns.len();
|
|
114
|
+
let optional_threshold = *config.optional_dvn_threshold;
|
|
115
|
+
|
|
116
|
+
assert_with_byte_array(
|
|
117
|
+
!(required_count == 0 && optional_threshold == 0), err_must_have_at_least_one_dvn(),
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
fn assert_valid_optional_threshold(config: @UlnConfig) {
|
|
122
|
+
let optional_count = config.optional_dvns.len();
|
|
123
|
+
let threshold = *config.optional_dvn_threshold;
|
|
124
|
+
|
|
125
|
+
assert_with_byte_array(
|
|
126
|
+
(optional_count >= threshold.into()),
|
|
127
|
+
err_invalid_optional_dvn_threshold(optional_count, threshold),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
assert_with_byte_array(
|
|
131
|
+
!((optional_count > 0) && (threshold <= 0)),
|
|
132
|
+
err_invalid_optional_dvn_threshold(optional_count, threshold),
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
fn assert_max_dvn_count(config: @UlnConfig) {
|
|
137
|
+
let required_count = config.required_dvns.len();
|
|
138
|
+
let optional_count = config.optional_dvns.len();
|
|
139
|
+
|
|
140
|
+
assert_with_byte_array(
|
|
141
|
+
(optional_count + required_count <= MAX_DVN_COUNT),
|
|
142
|
+
err_too_many_dvns(required_count, optional_count),
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
fn assert_valid_confirmations(confirmations: u64) {
|
|
147
|
+
assert_with_byte_array(confirmations > 0, err_invalid_confirmations());
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
fn assert_valid_standalone_config(config: @UlnConfig) {
|
|
151
|
+
Self::assert_at_least_one_dvn(config);
|
|
152
|
+
Self::assert_valid_optional_threshold(config);
|
|
153
|
+
Self::assert_max_dvn_count(config);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// UlnConfigStorageNode - Storage-compatible version of UlnConfig
|
|
2
|
+
//
|
|
3
|
+
// This is a different version of UlnConfig specifically designed for contract storage.
|
|
4
|
+
// While UlnConfig uses Array<ContractAddress> for DVN lists (which are suitable for
|
|
5
|
+
// function parameters and return values), UlnConfigStorageNode uses Vec<ContractAddress>
|
|
6
|
+
// which is the proper storage type in Starknet for dynamic arrays.
|
|
7
|
+
//
|
|
8
|
+
// Key differences:
|
|
9
|
+
// - UlnConfig: Uses Array<ContractAddress> - suitable for function parameters/returns
|
|
10
|
+
// - UlnConfigStorageNode: Uses Vec<ContractAddress> - required for contract storage
|
|
11
|
+
//
|
|
12
|
+
// We need both because:
|
|
13
|
+
// 1. Arrays cannot be directly stored in contract storage in Starknet
|
|
14
|
+
// 2. Vecs are storage-native but cannot be used in function signatures
|
|
15
|
+
// 3. This provides conversion methods between the two representations
|
|
16
|
+
// 4. Allows efficient storage operations while maintaining clean external interfaces
|
|
17
|
+
|
|
18
|
+
use starknet::ContractAddress;
|
|
19
|
+
use starknet::storage::{
|
|
20
|
+
Mutable, MutableVecTrait, StoragePath, StoragePointerReadAccess, StoragePointerWriteAccess, Vec,
|
|
21
|
+
VecTrait,
|
|
22
|
+
};
|
|
23
|
+
use crate::message_lib::uln::structs::uln_config::UlnConfig;
|
|
24
|
+
|
|
25
|
+
#[starknet::storage_node]
|
|
26
|
+
pub struct UlnConfigStorageNode {
|
|
27
|
+
pub confirmations: u64,
|
|
28
|
+
pub has_confirmations: bool,
|
|
29
|
+
// no duplicates. sorted in ascending order. allowed overlap with optionalDVNs
|
|
30
|
+
pub required_dvns: Vec<ContractAddress>,
|
|
31
|
+
pub has_required_dvns: bool,
|
|
32
|
+
// no duplicates. sorted in ascending order. allowed overlap with requiredDVNs
|
|
33
|
+
pub optional_dvns: Vec<ContractAddress>,
|
|
34
|
+
pub optional_dvn_threshold: u8, // (0, optionalDvnCount]
|
|
35
|
+
pub has_optional_dvns: bool,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#[generate_trait]
|
|
39
|
+
pub impl UlnConfigStorageNodeImpl of UlnConfigStorageNodeTrait {
|
|
40
|
+
// This function is used to take in a UlnConfig and store in a
|
|
41
|
+
// contract storage which has a ConfigNode for storing the config.
|
|
42
|
+
fn set_uln_config(self: StoragePath<Mutable<UlnConfigStorageNode>>, config: UlnConfig) {
|
|
43
|
+
self.confirmations.write(config.confirmations);
|
|
44
|
+
self.has_confirmations.write(config.has_confirmations);
|
|
45
|
+
self.optional_dvn_threshold.write(config.optional_dvn_threshold);
|
|
46
|
+
self.has_required_dvns.write(config.has_required_dvns);
|
|
47
|
+
self.has_optional_dvns.write(config.has_optional_dvns);
|
|
48
|
+
|
|
49
|
+
// convert from Array to Vec
|
|
50
|
+
self._clear_dvns();
|
|
51
|
+
for dvn in config.required_dvns {
|
|
52
|
+
self.required_dvns.push(dvn);
|
|
53
|
+
}
|
|
54
|
+
for dvn in config.optional_dvns {
|
|
55
|
+
self.optional_dvns.push(dvn);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
fn _clear_dvns(self: StoragePath<Mutable<UlnConfigStorageNode>>) {
|
|
60
|
+
while self.required_dvns.len() != 0 {
|
|
61
|
+
let _ = self.required_dvns.pop();
|
|
62
|
+
}
|
|
63
|
+
while self.optional_dvns.len() != 0 {
|
|
64
|
+
let _ = self.optional_dvns.pop();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// This function is used to get the UlnConfig from a
|
|
69
|
+
// contract storage which has a ConfigNode for storing the config.
|
|
70
|
+
fn get_uln_config(self: StoragePath<UlnConfigStorageNode>) -> UlnConfig {
|
|
71
|
+
let mut required_dvns_array = array![];
|
|
72
|
+
let mut optional_dvns_array = array![];
|
|
73
|
+
|
|
74
|
+
for i in 0..self.required_dvns.len() {
|
|
75
|
+
required_dvns_array.append(self.required_dvns.at(i).read());
|
|
76
|
+
}
|
|
77
|
+
for i in 0..self.optional_dvns.len() {
|
|
78
|
+
optional_dvns_array.append(self.optional_dvns.at(i).read());
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
UlnConfig {
|
|
82
|
+
confirmations: self.confirmations.read(),
|
|
83
|
+
has_confirmations: self.has_confirmations.read(),
|
|
84
|
+
required_dvns: required_dvns_array,
|
|
85
|
+
has_required_dvns: self.has_required_dvns.read(),
|
|
86
|
+
optional_dvns: optional_dvns_array,
|
|
87
|
+
optional_dvn_threshold: self.optional_dvn_threshold.read(),
|
|
88
|
+
has_optional_dvns: self.has_optional_dvns.read(),
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|