@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,750 @@
|
|
|
1
|
+
//! OApp core tests
|
|
2
|
+
|
|
3
|
+
use core::num::traits::Pow;
|
|
4
|
+
use layerzero::common::structs::packet::Origin;
|
|
5
|
+
use layerzero::endpoint::interfaces::layerzero_receiver::{
|
|
6
|
+
ILayerZeroReceiverDispatcher, ILayerZeroReceiverDispatcherTrait,
|
|
7
|
+
ILayerZeroReceiverSafeDispatcher, ILayerZeroReceiverSafeDispatcherTrait,
|
|
8
|
+
};
|
|
9
|
+
use layerzero::oapps::oapp::errors::{
|
|
10
|
+
err_lz_token_unavailable, err_no_peer, err_not_enough_lz_token,
|
|
11
|
+
err_not_enough_lz_token_allowance, err_not_enough_native, err_not_enough_native_allowance,
|
|
12
|
+
err_only_endpoint, err_only_peer,
|
|
13
|
+
};
|
|
14
|
+
use layerzero::oapps::oapp::events::PeerSet;
|
|
15
|
+
use layerzero::oapps::oapp::interface::{
|
|
16
|
+
IOAppDispatcher, IOAppDispatcherTrait, IOAppReceiverDispatcher, IOAppReceiverDispatcherTrait,
|
|
17
|
+
IOAppSafeDispatcher, IOAppSafeDispatcherTrait,
|
|
18
|
+
};
|
|
19
|
+
use layerzero::oapps::oapp::oapp_core::OAppCoreComponent;
|
|
20
|
+
use layerzero::{MessageReceipt, MessagingFee};
|
|
21
|
+
use lz_utils::bytes::Bytes32;
|
|
22
|
+
use openzeppelin::access::ownable::OwnableComponent;
|
|
23
|
+
use openzeppelin::access::ownable::interface::{
|
|
24
|
+
IOwnableDispatcher, IOwnableDispatcherTrait, IOwnableSafeDispatcher,
|
|
25
|
+
};
|
|
26
|
+
use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};
|
|
27
|
+
use snforge_std::{
|
|
28
|
+
ContractClassTrait, DeclareResultTrait, EventSpyAssertionsTrait, declare, spy_events,
|
|
29
|
+
start_cheat_caller_address, start_mock_call, stop_cheat_caller_address,
|
|
30
|
+
};
|
|
31
|
+
use starknet::ContractAddress;
|
|
32
|
+
use starkware_utils_testing::test_utils::{assert_panic_with_error, assert_panic_with_felt_error};
|
|
33
|
+
use crate::mocks::oapp_core::interface::{
|
|
34
|
+
IMockOAppCoreDispatcher, IMockOAppCoreDispatcherTrait, IMockOAppCoreSafeDispatcher,
|
|
35
|
+
IMockOAppCoreSafeDispatcherTrait,
|
|
36
|
+
};
|
|
37
|
+
use crate::mocks::oapp_core::oapp_core::MockOAppCore;
|
|
38
|
+
|
|
39
|
+
// Test constants
|
|
40
|
+
const FAKE_ENDPOINT: ContractAddress = 'fake_endpoint'.try_into().unwrap();
|
|
41
|
+
const OWNER: ContractAddress = 'owner'.try_into().unwrap();
|
|
42
|
+
const NON_OWNER: ContractAddress = 'non_owner'.try_into().unwrap();
|
|
43
|
+
const EXECUTOR: ContractAddress = 'executor'.try_into().unwrap();
|
|
44
|
+
const ZERO_ADDRESS: ContractAddress = 0.try_into().unwrap();
|
|
45
|
+
const EID_1: u32 = 101;
|
|
46
|
+
const EID_2: u32 = 102;
|
|
47
|
+
const SRC_EID: u32 = 201;
|
|
48
|
+
const UNKNOWN_EID: u32 = 999;
|
|
49
|
+
const INITIAL_SUPPLY: u256 = 10_u256.pow(10);
|
|
50
|
+
|
|
51
|
+
fn MOCK_PEER_1() -> Bytes32 {
|
|
52
|
+
Bytes32 { value: 0x123456789abcdef }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
fn MOCK_PEER_2() -> Bytes32 {
|
|
56
|
+
Bytes32 { value: 0xfedcba987654321 }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
fn ZERO_PEER() -> Bytes32 {
|
|
60
|
+
Bytes32 { value: 0 }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fn MOCK_GUID() -> Bytes32 {
|
|
64
|
+
Bytes32 { value: 0xabcdef123456789 }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fn MOCK_MESSAGE() -> ByteArray {
|
|
68
|
+
"test message"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fn MOCK_ORIGIN() -> Origin {
|
|
72
|
+
Origin { src_eid: SRC_EID, sender: MOCK_PEER_1(), nonce: 1 }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#[derive(Drop, Copy)]
|
|
76
|
+
struct TestSetup {
|
|
77
|
+
oapp_address: ContractAddress,
|
|
78
|
+
oapp_dispatcher: IOAppDispatcher,
|
|
79
|
+
ownable_dispatcher: IOwnableDispatcher,
|
|
80
|
+
lz_receiver_dispatcher: ILayerZeroReceiverDispatcher,
|
|
81
|
+
oapp_receiver_dispatcher: IOAppReceiverDispatcher,
|
|
82
|
+
oapp_safe_dispatcher: IOAppSafeDispatcher,
|
|
83
|
+
ownable_safe_dispatcher: IOwnableSafeDispatcher,
|
|
84
|
+
lz_receiver_safe_dispatcher: ILayerZeroReceiverSafeDispatcher,
|
|
85
|
+
mock_oapp_core_dispatcher: IMockOAppCoreDispatcher,
|
|
86
|
+
mock_oapp_core_safe_dispatcher: IMockOAppCoreSafeDispatcher,
|
|
87
|
+
stark_token_dispatcher: IERC20Dispatcher,
|
|
88
|
+
lz_token_dispatcher: IERC20Dispatcher,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
fn deploy_test_erc20(owner: ContractAddress) -> ContractAddress {
|
|
93
|
+
let contract = declare("MockERC20").unwrap().contract_class();
|
|
94
|
+
let mut params = array![];
|
|
95
|
+
INITIAL_SUPPLY.serialize(ref params);
|
|
96
|
+
owner.serialize(ref params);
|
|
97
|
+
|
|
98
|
+
let (address, _) = contract.deploy(@params).unwrap();
|
|
99
|
+
address
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
fn deploy_test_oapp_core(
|
|
103
|
+
endpoint: ContractAddress, owner: ContractAddress, stark_token: ContractAddress,
|
|
104
|
+
) -> ContractAddress {
|
|
105
|
+
let contract = declare("MockOAppCore").unwrap().contract_class();
|
|
106
|
+
|
|
107
|
+
let (address, _) = contract
|
|
108
|
+
.deploy(@array![endpoint.into(), owner.into(), stark_token.into()])
|
|
109
|
+
.unwrap();
|
|
110
|
+
address
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
fn setup() -> TestSetup {
|
|
114
|
+
let stark_token = deploy_test_erc20(OWNER);
|
|
115
|
+
let lz_token = deploy_test_erc20(OWNER);
|
|
116
|
+
let oapp_address = deploy_test_oapp_core(FAKE_ENDPOINT, OWNER, stark_token);
|
|
117
|
+
start_mock_call(FAKE_ENDPOINT, selector!("get_lz_token"), lz_token);
|
|
118
|
+
|
|
119
|
+
let oapp_dispatcher = IOAppDispatcher { contract_address: oapp_address };
|
|
120
|
+
let ownable_dispatcher = IOwnableDispatcher { contract_address: oapp_address };
|
|
121
|
+
let lz_receiver_dispatcher = ILayerZeroReceiverDispatcher { contract_address: oapp_address };
|
|
122
|
+
let oapp_receiver_dispatcher = IOAppReceiverDispatcher { contract_address: oapp_address };
|
|
123
|
+
let oapp_safe_dispatcher = IOAppSafeDispatcher { contract_address: oapp_address };
|
|
124
|
+
let ownable_safe_dispatcher = IOwnableSafeDispatcher { contract_address: oapp_address };
|
|
125
|
+
let lz_receiver_safe_dispatcher = ILayerZeroReceiverSafeDispatcher {
|
|
126
|
+
contract_address: oapp_address,
|
|
127
|
+
};
|
|
128
|
+
let mock_oapp_core_dispatcher = IMockOAppCoreDispatcher { contract_address: oapp_address };
|
|
129
|
+
let mock_oapp_core_safe_dispatcher = IMockOAppCoreSafeDispatcher {
|
|
130
|
+
contract_address: oapp_address,
|
|
131
|
+
};
|
|
132
|
+
let stark_token_dispatcher = IERC20Dispatcher { contract_address: stark_token };
|
|
133
|
+
let lz_token_dispatcher = IERC20Dispatcher { contract_address: lz_token };
|
|
134
|
+
// Set up peer for testing
|
|
135
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
136
|
+
oapp_dispatcher.set_peer(SRC_EID, MOCK_PEER_1());
|
|
137
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
138
|
+
stop_cheat_caller_address(oapp_address);
|
|
139
|
+
|
|
140
|
+
TestSetup {
|
|
141
|
+
oapp_address,
|
|
142
|
+
oapp_dispatcher,
|
|
143
|
+
ownable_dispatcher,
|
|
144
|
+
lz_receiver_dispatcher,
|
|
145
|
+
oapp_receiver_dispatcher,
|
|
146
|
+
oapp_safe_dispatcher,
|
|
147
|
+
ownable_safe_dispatcher,
|
|
148
|
+
lz_receiver_safe_dispatcher,
|
|
149
|
+
mock_oapp_core_dispatcher,
|
|
150
|
+
mock_oapp_core_safe_dispatcher,
|
|
151
|
+
stark_token_dispatcher,
|
|
152
|
+
lz_token_dispatcher,
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// =============================== Test Constructor =================================
|
|
157
|
+
|
|
158
|
+
#[test]
|
|
159
|
+
fn test_constructor() {
|
|
160
|
+
let TestSetup { oapp_dispatcher, ownable_dispatcher, .. } = setup();
|
|
161
|
+
assert(oapp_dispatcher.get_endpoint() == FAKE_ENDPOINT, 'Endpoint not set correctly');
|
|
162
|
+
assert(ownable_dispatcher.owner() == OWNER, 'Owner not set correctly');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// =============================== Test OApp Version =================================
|
|
166
|
+
|
|
167
|
+
#[test]
|
|
168
|
+
fn test_oapp_version() {
|
|
169
|
+
let TestSetup { oapp_dispatcher, .. } = setup();
|
|
170
|
+
let (sender_version, receiver_version) = oapp_dispatcher.oapp_version();
|
|
171
|
+
assert(sender_version == 1, 'Sender version should be 1');
|
|
172
|
+
assert(receiver_version == 1, 'Receiver version should be 2');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// =============================== Test Set Peer =================================
|
|
176
|
+
|
|
177
|
+
#[test]
|
|
178
|
+
fn test_set_peer_as_owner() {
|
|
179
|
+
let TestSetup { oapp_address, oapp_dispatcher, .. } = setup();
|
|
180
|
+
let mut spy = spy_events();
|
|
181
|
+
|
|
182
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
183
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
184
|
+
stop_cheat_caller_address(oapp_address);
|
|
185
|
+
|
|
186
|
+
assert(oapp_dispatcher.get_peer(EID_1) == MOCK_PEER_1(), 'Peer not set correctly');
|
|
187
|
+
|
|
188
|
+
let expected_event = MockOAppCore::Event::OAppCoreEvent(
|
|
189
|
+
OAppCoreComponent::Event::PeerSet(PeerSet { eid: EID_1, peer: MOCK_PEER_1() }),
|
|
190
|
+
);
|
|
191
|
+
spy.assert_emitted(@array![(oapp_address, expected_event)]);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
#[test]
|
|
195
|
+
#[feature("safe_dispatcher")]
|
|
196
|
+
fn test_set_peer_fails_as_non_owner() {
|
|
197
|
+
let TestSetup { oapp_address, oapp_safe_dispatcher, .. } = setup();
|
|
198
|
+
|
|
199
|
+
start_cheat_caller_address(oapp_address, NON_OWNER);
|
|
200
|
+
let result = oapp_safe_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
201
|
+
stop_cheat_caller_address(oapp_address);
|
|
202
|
+
|
|
203
|
+
assert_panic_with_felt_error(result, OwnableComponent::Errors::NOT_OWNER);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// =============================== Test Get Peer =================================
|
|
207
|
+
|
|
208
|
+
#[test]
|
|
209
|
+
fn test_get_unset_peer() {
|
|
210
|
+
let TestSetup { oapp_dispatcher, .. } = setup();
|
|
211
|
+
assert(oapp_dispatcher.get_peer(UNKNOWN_EID) == ZERO_PEER(), 'Unset peer should be zero');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#[test]
|
|
215
|
+
fn test_get_set_peer() {
|
|
216
|
+
let TestSetup { oapp_address, oapp_dispatcher, .. } = setup();
|
|
217
|
+
|
|
218
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
219
|
+
oapp_dispatcher.set_peer(EID_2, MOCK_PEER_2());
|
|
220
|
+
stop_cheat_caller_address(oapp_address);
|
|
221
|
+
|
|
222
|
+
assert(oapp_dispatcher.get_peer(EID_2) == MOCK_PEER_2(), 'Peer should match');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// =============================== Test Multiple Peers =================================
|
|
226
|
+
|
|
227
|
+
#[test]
|
|
228
|
+
fn test_set_multiple_peers() {
|
|
229
|
+
let TestSetup { oapp_address, oapp_dispatcher, .. } = setup();
|
|
230
|
+
let mut spy = spy_events();
|
|
231
|
+
|
|
232
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
233
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
234
|
+
oapp_dispatcher.set_peer(EID_2, MOCK_PEER_2());
|
|
235
|
+
stop_cheat_caller_address(oapp_address);
|
|
236
|
+
|
|
237
|
+
assert(oapp_dispatcher.get_peer(EID_1) == MOCK_PEER_1(), 'Peer 1 not set correctly');
|
|
238
|
+
assert(oapp_dispatcher.get_peer(EID_2) == MOCK_PEER_2(), 'Peer 2 not set correctly');
|
|
239
|
+
|
|
240
|
+
let expected_event_1 = MockOAppCore::Event::OAppCoreEvent(
|
|
241
|
+
OAppCoreComponent::Event::PeerSet(PeerSet { eid: EID_1, peer: MOCK_PEER_1() }),
|
|
242
|
+
);
|
|
243
|
+
let expected_event_2 = MockOAppCore::Event::OAppCoreEvent(
|
|
244
|
+
OAppCoreComponent::Event::PeerSet(PeerSet { eid: EID_2, peer: MOCK_PEER_2() }),
|
|
245
|
+
);
|
|
246
|
+
spy.assert_emitted(@array![(oapp_address, expected_event_1), (oapp_address, expected_event_2)]);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// =============================== Test Update Peer =================================
|
|
250
|
+
|
|
251
|
+
#[test]
|
|
252
|
+
fn test_update_peer() {
|
|
253
|
+
let TestSetup { oapp_address, oapp_dispatcher, .. } = setup();
|
|
254
|
+
let mut spy = spy_events();
|
|
255
|
+
|
|
256
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
257
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
258
|
+
assert(oapp_dispatcher.get_peer(EID_1) == MOCK_PEER_1(), 'Peer not set correctly');
|
|
259
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_2());
|
|
260
|
+
stop_cheat_caller_address(oapp_address);
|
|
261
|
+
|
|
262
|
+
assert(oapp_dispatcher.get_peer(EID_1) == MOCK_PEER_2(), 'Peer not updated correctly');
|
|
263
|
+
|
|
264
|
+
let expected_event_1 = MockOAppCore::Event::OAppCoreEvent(
|
|
265
|
+
OAppCoreComponent::Event::PeerSet(PeerSet { eid: EID_1, peer: MOCK_PEER_1() }),
|
|
266
|
+
);
|
|
267
|
+
let expected_event_2 = MockOAppCore::Event::OAppCoreEvent(
|
|
268
|
+
OAppCoreComponent::Event::PeerSet(PeerSet { eid: EID_1, peer: MOCK_PEER_2() }),
|
|
269
|
+
);
|
|
270
|
+
spy.assert_emitted(@array![(oapp_address, expected_event_1), (oapp_address, expected_event_2)]);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// =============================== Test Remove Peer =================================
|
|
274
|
+
|
|
275
|
+
#[test]
|
|
276
|
+
fn test_remove_peer() {
|
|
277
|
+
let TestSetup { oapp_address, oapp_dispatcher, .. } = setup();
|
|
278
|
+
let mut spy = spy_events();
|
|
279
|
+
|
|
280
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
281
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
282
|
+
assert(oapp_dispatcher.get_peer(EID_1) == MOCK_PEER_1(), 'Peer not set correctly');
|
|
283
|
+
oapp_dispatcher.set_peer(EID_1, ZERO_PEER());
|
|
284
|
+
stop_cheat_caller_address(oapp_address);
|
|
285
|
+
|
|
286
|
+
assert(oapp_dispatcher.get_peer(EID_1) == ZERO_PEER(), 'Peer not removed correctly');
|
|
287
|
+
|
|
288
|
+
let expected_removal_event = MockOAppCore::Event::OAppCoreEvent(
|
|
289
|
+
OAppCoreComponent::Event::PeerSet(PeerSet { eid: EID_1, peer: ZERO_PEER() }),
|
|
290
|
+
);
|
|
291
|
+
spy.assert_emitted(@array![(oapp_address, expected_removal_event)]);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// =============================== Test Peer Independence =================================
|
|
295
|
+
|
|
296
|
+
#[test]
|
|
297
|
+
fn test_peer_independence() {
|
|
298
|
+
let TestSetup { oapp_address, oapp_dispatcher, .. } = setup();
|
|
299
|
+
|
|
300
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
301
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
302
|
+
stop_cheat_caller_address(oapp_address);
|
|
303
|
+
|
|
304
|
+
assert(oapp_dispatcher.get_peer(EID_1) == MOCK_PEER_1(), 'EID_1 peer not set');
|
|
305
|
+
assert(oapp_dispatcher.get_peer(EID_2) == ZERO_PEER(), 'EID_2 should be unset');
|
|
306
|
+
assert(oapp_dispatcher.get_peer(UNKNOWN_EID) == ZERO_PEER(), 'Other EIDs should be unset');
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// =============================== Test Ownership =================================
|
|
310
|
+
|
|
311
|
+
#[test]
|
|
312
|
+
fn test_ownership_initial_setup() {
|
|
313
|
+
let TestSetup { ownable_dispatcher, .. } = setup();
|
|
314
|
+
assert(ownable_dispatcher.owner() == OWNER, 'Initial owner incorrect');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
#[test]
|
|
318
|
+
fn test_transfer_ownership() {
|
|
319
|
+
let TestSetup { oapp_address, oapp_dispatcher, ownable_dispatcher, .. } = setup();
|
|
320
|
+
let new_owner = 'new_owner'.try_into().unwrap();
|
|
321
|
+
|
|
322
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
323
|
+
ownable_dispatcher.transfer_ownership(new_owner);
|
|
324
|
+
stop_cheat_caller_address(oapp_address);
|
|
325
|
+
|
|
326
|
+
assert(ownable_dispatcher.owner() == new_owner, 'Ownership not transferred');
|
|
327
|
+
|
|
328
|
+
start_cheat_caller_address(oapp_address, new_owner);
|
|
329
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
330
|
+
stop_cheat_caller_address(oapp_address);
|
|
331
|
+
|
|
332
|
+
assert(oapp_dispatcher.get_peer(EID_1) == MOCK_PEER_1(), 'New owner should set peer');
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
#[test]
|
|
336
|
+
#[feature("safe_dispatcher")]
|
|
337
|
+
fn test_old_owner_cannot_set_peer_after_transfer() {
|
|
338
|
+
let TestSetup { oapp_address, ownable_dispatcher, oapp_safe_dispatcher, .. } = setup();
|
|
339
|
+
let new_owner = 'new_owner'.try_into().unwrap();
|
|
340
|
+
|
|
341
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
342
|
+
ownable_dispatcher.transfer_ownership(new_owner);
|
|
343
|
+
stop_cheat_caller_address(oapp_address);
|
|
344
|
+
|
|
345
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
346
|
+
let result = oapp_safe_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
347
|
+
stop_cheat_caller_address(oapp_address);
|
|
348
|
+
|
|
349
|
+
assert_panic_with_felt_error(result, OwnableComponent::Errors::NOT_OWNER);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// =============================== Test LayerZero Receiver =================================
|
|
353
|
+
|
|
354
|
+
#[test]
|
|
355
|
+
fn test_lz_receive_success() {
|
|
356
|
+
let TestSetup { oapp_address, lz_receiver_dispatcher, .. } = setup();
|
|
357
|
+
|
|
358
|
+
start_cheat_caller_address(oapp_address, FAKE_ENDPOINT);
|
|
359
|
+
lz_receiver_dispatcher
|
|
360
|
+
.lz_receive(MOCK_ORIGIN(), MOCK_GUID(), MOCK_MESSAGE(), EXECUTOR, 0, Default::default());
|
|
361
|
+
stop_cheat_caller_address(oapp_address);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
#[test]
|
|
365
|
+
#[feature("safe_dispatcher")]
|
|
366
|
+
fn test_lz_receive_fails_non_endpoint() {
|
|
367
|
+
let TestSetup { oapp_address, lz_receiver_safe_dispatcher, .. } = setup();
|
|
368
|
+
|
|
369
|
+
start_cheat_caller_address(oapp_address, NON_OWNER);
|
|
370
|
+
let result = lz_receiver_safe_dispatcher
|
|
371
|
+
.lz_receive(MOCK_ORIGIN(), MOCK_GUID(), MOCK_MESSAGE(), EXECUTOR, 0, Default::default());
|
|
372
|
+
stop_cheat_caller_address(oapp_address);
|
|
373
|
+
|
|
374
|
+
assert_panic_with_error(result, err_only_endpoint(FAKE_ENDPOINT));
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
#[test]
|
|
378
|
+
#[feature("safe_dispatcher")]
|
|
379
|
+
fn test_lz_receive_fails_unknown_peer() {
|
|
380
|
+
let TestSetup { oapp_address, lz_receiver_safe_dispatcher, .. } = setup();
|
|
381
|
+
let unknown_origin = Origin {
|
|
382
|
+
src_eid: UNKNOWN_EID, sender: Bytes32 { value: 0x999 }, nonce: 1,
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
start_cheat_caller_address(oapp_address, FAKE_ENDPOINT);
|
|
386
|
+
let result = lz_receiver_safe_dispatcher
|
|
387
|
+
.lz_receive(unknown_origin, MOCK_GUID(), MOCK_MESSAGE(), EXECUTOR, 0, Default::default());
|
|
388
|
+
stop_cheat_caller_address(oapp_address);
|
|
389
|
+
|
|
390
|
+
assert_panic_with_error(result, err_no_peer(UNKNOWN_EID));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
#[test]
|
|
394
|
+
fn test_allow_initialize_path() {
|
|
395
|
+
let TestSetup { lz_receiver_dispatcher, .. } = setup();
|
|
396
|
+
|
|
397
|
+
let is_allowed = lz_receiver_dispatcher.allow_initialize_path(MOCK_ORIGIN());
|
|
398
|
+
assert(is_allowed, 'Path should be allowed');
|
|
399
|
+
|
|
400
|
+
let unknown_origin = Origin {
|
|
401
|
+
src_eid: UNKNOWN_EID, sender: Bytes32 { value: 0x999 }, nonce: 1,
|
|
402
|
+
};
|
|
403
|
+
let is_not_allowed = lz_receiver_dispatcher.allow_initialize_path(unknown_origin);
|
|
404
|
+
assert(!is_not_allowed, 'Unknown path not allowed');
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
#[test]
|
|
408
|
+
fn test_next_nonce() {
|
|
409
|
+
let TestSetup { lz_receiver_dispatcher, .. } = setup();
|
|
410
|
+
|
|
411
|
+
let nonce = lz_receiver_dispatcher.next_nonce(SRC_EID, MOCK_PEER_1());
|
|
412
|
+
assert(nonce == 0, 'Default nonce should be 0');
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// =============================== Test OApp Receiver =================================
|
|
416
|
+
|
|
417
|
+
#[test]
|
|
418
|
+
fn test_is_compose_msg_sender() {
|
|
419
|
+
let TestSetup { oapp_address, oapp_receiver_dispatcher, .. } = setup();
|
|
420
|
+
|
|
421
|
+
let is_sender = oapp_receiver_dispatcher
|
|
422
|
+
.is_compose_msg_sender(MOCK_ORIGIN(), MOCK_MESSAGE(), oapp_address);
|
|
423
|
+
assert(is_sender, 'Contract should be valid sender');
|
|
424
|
+
|
|
425
|
+
let is_not_sender = oapp_receiver_dispatcher
|
|
426
|
+
.is_compose_msg_sender(MOCK_ORIGIN(), MOCK_MESSAGE(), NON_OWNER);
|
|
427
|
+
assert(!is_not_sender, 'Other address not valid sender');
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// =============================== Test OApp Sender =================================
|
|
431
|
+
|
|
432
|
+
// =============================== Test Quote =================================
|
|
433
|
+
|
|
434
|
+
#[test]
|
|
435
|
+
fn test_quote_success() {
|
|
436
|
+
let TestSetup { mock_oapp_core_dispatcher, .. } = setup();
|
|
437
|
+
|
|
438
|
+
// mock endpoint to return a 100 10 message fee
|
|
439
|
+
let expected_result = MessagingFee { native_fee: 100, lz_token_fee: 10 };
|
|
440
|
+
|
|
441
|
+
start_mock_call(FAKE_ENDPOINT, selector!("quote"), expected_result.clone());
|
|
442
|
+
let fee = mock_oapp_core_dispatcher
|
|
443
|
+
.test_quote(EID_1, MOCK_MESSAGE(), Default::default(), false);
|
|
444
|
+
|
|
445
|
+
assert(fee == expected_result, 'Fee should be 100 10');
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
#[test]
|
|
449
|
+
#[feature("safe_dispatcher")]
|
|
450
|
+
fn test_quote_fails_unknown_peer() {
|
|
451
|
+
let TestSetup { mock_oapp_core_safe_dispatcher, .. } = setup();
|
|
452
|
+
|
|
453
|
+
let result = mock_oapp_core_safe_dispatcher
|
|
454
|
+
.test_quote(UNKNOWN_EID, MOCK_MESSAGE(), Default::default(), false);
|
|
455
|
+
|
|
456
|
+
assert_panic_with_error(result, err_no_peer(UNKNOWN_EID));
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// =============================== Test Pay in Token =================================
|
|
460
|
+
|
|
461
|
+
#[test]
|
|
462
|
+
fn test_pay_in_token() {
|
|
463
|
+
// Should take the money into Oapp and approve the endpoint to spend it
|
|
464
|
+
let TestSetup { oapp_address, mock_oapp_core_dispatcher, stark_token_dispatcher, .. } = setup();
|
|
465
|
+
start_cheat_caller_address(stark_token_dispatcher.contract_address, OWNER);
|
|
466
|
+
stark_token_dispatcher.approve(oapp_address, 100);
|
|
467
|
+
stop_cheat_caller_address(stark_token_dispatcher.contract_address);
|
|
468
|
+
mock_oapp_core_dispatcher
|
|
469
|
+
.test_pay_in_token(
|
|
470
|
+
OWNER, FAKE_ENDPOINT, oapp_address, 100, stark_token_dispatcher.contract_address,
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
let stark_balance = stark_token_dispatcher.balance_of(oapp_address);
|
|
474
|
+
assert(stark_balance == 100, 'STARK token not taken');
|
|
475
|
+
let endpoint_allowance = stark_token_dispatcher.allowance(oapp_address, FAKE_ENDPOINT);
|
|
476
|
+
assert(endpoint_allowance == 100, 'STARK token not approved');
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// =============================== Test Pay LZ Token =================================
|
|
480
|
+
|
|
481
|
+
#[test]
|
|
482
|
+
fn test_pay_lz_token() {
|
|
483
|
+
let TestSetup { oapp_address, mock_oapp_core_dispatcher, lz_token_dispatcher, .. } = setup();
|
|
484
|
+
start_cheat_caller_address(lz_token_dispatcher.contract_address, OWNER);
|
|
485
|
+
lz_token_dispatcher.approve(oapp_address, 100);
|
|
486
|
+
stop_cheat_caller_address(lz_token_dispatcher.contract_address);
|
|
487
|
+
mock_oapp_core_dispatcher.test_pay_lz_token(OWNER, FAKE_ENDPOINT, oapp_address, 100);
|
|
488
|
+
|
|
489
|
+
let lz_balance = lz_token_dispatcher.balance_of(oapp_address);
|
|
490
|
+
assert(lz_balance == 100, 'LZ token not taken');
|
|
491
|
+
let endpoint_allowance = lz_token_dispatcher.allowance(oapp_address, FAKE_ENDPOINT);
|
|
492
|
+
assert(endpoint_allowance == 100, 'LZ token not approved');
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
#[test]
|
|
496
|
+
#[feature("safe_dispatcher")]
|
|
497
|
+
fn test_pay_lz_token_fails_not_enough_lz_token_allowance() {
|
|
498
|
+
let TestSetup { oapp_address, mock_oapp_core_safe_dispatcher, .. } = setup();
|
|
499
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
500
|
+
let result = mock_oapp_core_safe_dispatcher
|
|
501
|
+
.test_pay_lz_token(OWNER, FAKE_ENDPOINT, oapp_address, 100);
|
|
502
|
+
stop_cheat_caller_address(oapp_address);
|
|
503
|
+
|
|
504
|
+
assert_panic_with_error(result, err_not_enough_lz_token_allowance(100, 0));
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
#[test]
|
|
508
|
+
#[feature("safe_dispatcher")]
|
|
509
|
+
fn test_pay_lz_token_fails_not_enough_lz_token() {
|
|
510
|
+
let TestSetup { oapp_address, mock_oapp_core_safe_dispatcher, .. } = setup();
|
|
511
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
512
|
+
let result = mock_oapp_core_safe_dispatcher
|
|
513
|
+
.test_pay_lz_token(NON_OWNER, FAKE_ENDPOINT, oapp_address, 100);
|
|
514
|
+
stop_cheat_caller_address(oapp_address);
|
|
515
|
+
assert_panic_with_error(result, err_not_enough_lz_token(100, 0));
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
#[test]
|
|
519
|
+
#[feature("safe_dispatcher")]
|
|
520
|
+
fn test_pay_lz_token_fails_lz_token_unavailable() {
|
|
521
|
+
// Deploy OApp with zero LZ token address
|
|
522
|
+
let stark_token = deploy_test_erc20(OWNER);
|
|
523
|
+
let oapp_address = deploy_test_oapp_core(FAKE_ENDPOINT, OWNER, stark_token);
|
|
524
|
+
// mock lz token to be unavailable
|
|
525
|
+
start_mock_call(FAKE_ENDPOINT, selector!("get_lz_token"), ZERO_ADDRESS);
|
|
526
|
+
let mock_oapp_core_safe_dispatcher = IMockOAppCoreSafeDispatcher {
|
|
527
|
+
contract_address: oapp_address,
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
let result = mock_oapp_core_safe_dispatcher
|
|
531
|
+
.test_pay_lz_token(OWNER, FAKE_ENDPOINT, oapp_address, 100);
|
|
532
|
+
|
|
533
|
+
assert_panic_with_error(result, err_lz_token_unavailable());
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
// =============================== Test Pay Native =================================
|
|
537
|
+
|
|
538
|
+
#[test]
|
|
539
|
+
fn test_pay_native() {
|
|
540
|
+
let TestSetup { oapp_address, mock_oapp_core_dispatcher, stark_token_dispatcher, .. } = setup();
|
|
541
|
+
start_cheat_caller_address(stark_token_dispatcher.contract_address, OWNER);
|
|
542
|
+
stark_token_dispatcher.approve(oapp_address, 100);
|
|
543
|
+
stop_cheat_caller_address(stark_token_dispatcher.contract_address);
|
|
544
|
+
mock_oapp_core_dispatcher.test_pay_native(OWNER, FAKE_ENDPOINT, oapp_address, 100);
|
|
545
|
+
|
|
546
|
+
let stark_balance = stark_token_dispatcher.balance_of(oapp_address);
|
|
547
|
+
assert(stark_balance == 100, 'STARK token not taken');
|
|
548
|
+
let endpoint_allowance = stark_token_dispatcher.allowance(oapp_address, FAKE_ENDPOINT);
|
|
549
|
+
assert(endpoint_allowance == 100, 'STARK token not approved');
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
#[test]
|
|
553
|
+
#[feature("safe_dispatcher")]
|
|
554
|
+
fn test_pay_native_fails_not_enough_native_allowance() {
|
|
555
|
+
let TestSetup { oapp_address, mock_oapp_core_safe_dispatcher, .. } = setup();
|
|
556
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
557
|
+
let result = mock_oapp_core_safe_dispatcher
|
|
558
|
+
.test_pay_native(OWNER, FAKE_ENDPOINT, oapp_address, 100);
|
|
559
|
+
stop_cheat_caller_address(oapp_address);
|
|
560
|
+
assert_panic_with_error(result, err_not_enough_native_allowance(100, 0));
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
#[test]
|
|
564
|
+
#[feature("safe_dispatcher")]
|
|
565
|
+
fn test_pay_native_fails_not_enough_native() {
|
|
566
|
+
let TestSetup { oapp_address, mock_oapp_core_safe_dispatcher, .. } = setup();
|
|
567
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
568
|
+
let result = mock_oapp_core_safe_dispatcher
|
|
569
|
+
.test_pay_native(NON_OWNER, FAKE_ENDPOINT, oapp_address, 100);
|
|
570
|
+
stop_cheat_caller_address(oapp_address);
|
|
571
|
+
assert_panic_with_error(result, err_not_enough_native(100, 0));
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// =============================== Test LZ Send =================================
|
|
575
|
+
|
|
576
|
+
#[test]
|
|
577
|
+
fn test_lz_send_success() {
|
|
578
|
+
let TestSetup {
|
|
579
|
+
oapp_address, mock_oapp_core_dispatcher, stark_token_dispatcher, lz_token_dispatcher, ..,
|
|
580
|
+
} = setup();
|
|
581
|
+
let message = MOCK_MESSAGE();
|
|
582
|
+
let options = Default::default();
|
|
583
|
+
let fee = MessagingFee { native_fee: 100, lz_token_fee: 10 };
|
|
584
|
+
let refund_address = OWNER;
|
|
585
|
+
|
|
586
|
+
let expected_receipt = MessageReceipt {
|
|
587
|
+
guid: Bytes32 { value: 0x1 }, nonce: 0, payees: array![],
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
start_mock_call(FAKE_ENDPOINT, selector!("send"), expected_receipt.clone());
|
|
591
|
+
|
|
592
|
+
// Set up STARK token approval
|
|
593
|
+
start_cheat_caller_address(stark_token_dispatcher.contract_address, OWNER);
|
|
594
|
+
stark_token_dispatcher.approve(oapp_address, 100);
|
|
595
|
+
stop_cheat_caller_address(stark_token_dispatcher.contract_address);
|
|
596
|
+
|
|
597
|
+
// Set up LZ token approval
|
|
598
|
+
start_cheat_caller_address(lz_token_dispatcher.contract_address, OWNER);
|
|
599
|
+
lz_token_dispatcher.approve(oapp_address, 10);
|
|
600
|
+
stop_cheat_caller_address(lz_token_dispatcher.contract_address);
|
|
601
|
+
|
|
602
|
+
// Now make the lz_send call with OWNER as caller to the OApp
|
|
603
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
604
|
+
let receipt = mock_oapp_core_dispatcher
|
|
605
|
+
.test_lz_send(EID_1, message, options, fee, refund_address);
|
|
606
|
+
stop_cheat_caller_address(oapp_address);
|
|
607
|
+
|
|
608
|
+
assert(receipt == expected_receipt, 'Receipt should be correct');
|
|
609
|
+
|
|
610
|
+
// Check that money was taken from the caller and allowance was set to endpoint
|
|
611
|
+
// in this mock the endpoint doesn't do anything so the allowance will still be the
|
|
612
|
+
// given values
|
|
613
|
+
let stark_balance = stark_token_dispatcher.balance_of(OWNER);
|
|
614
|
+
assert(stark_balance == INITIAL_SUPPLY - 100, 'STARK token not taken');
|
|
615
|
+
let oapp_stark_balance = stark_token_dispatcher.balance_of(oapp_address);
|
|
616
|
+
assert(oapp_stark_balance == 100, 'STARK token not received');
|
|
617
|
+
let endpoint_allowance = stark_token_dispatcher.allowance(oapp_address, FAKE_ENDPOINT);
|
|
618
|
+
assert(endpoint_allowance == 100, 'STARK token not approved');
|
|
619
|
+
|
|
620
|
+
let lz_balance = lz_token_dispatcher.balance_of(OWNER);
|
|
621
|
+
assert(lz_balance == INITIAL_SUPPLY - 10, 'LZ token not taken');
|
|
622
|
+
let oapp_lz_balance = lz_token_dispatcher.balance_of(oapp_address);
|
|
623
|
+
assert(oapp_lz_balance == 10, 'LZ token not received');
|
|
624
|
+
let endpoint_allowance = lz_token_dispatcher.allowance(oapp_address, FAKE_ENDPOINT);
|
|
625
|
+
assert(endpoint_allowance == 10, 'LZ token not approved');
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
#[test]
|
|
629
|
+
#[feature("safe_dispatcher")]
|
|
630
|
+
fn test_lz_send_fails_not_peer() {
|
|
631
|
+
let TestSetup { mock_oapp_core_safe_dispatcher, .. } = setup();
|
|
632
|
+
|
|
633
|
+
let result = mock_oapp_core_safe_dispatcher
|
|
634
|
+
.test_lz_send(
|
|
635
|
+
UNKNOWN_EID,
|
|
636
|
+
MOCK_MESSAGE(),
|
|
637
|
+
Default::default(),
|
|
638
|
+
MessagingFee { native_fee: 0, lz_token_fee: 0 },
|
|
639
|
+
OWNER,
|
|
640
|
+
);
|
|
641
|
+
|
|
642
|
+
assert_panic_with_error(result, err_no_peer(UNKNOWN_EID));
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
// =============================== Essential LZ Receive Tests =================================
|
|
647
|
+
|
|
648
|
+
#[test]
|
|
649
|
+
#[feature("safe_dispatcher")]
|
|
650
|
+
fn test_lz_receive_fails_wrong_caller() {
|
|
651
|
+
let TestSetup { oapp_address, lz_receiver_safe_dispatcher, .. } = setup();
|
|
652
|
+
|
|
653
|
+
start_cheat_caller_address(oapp_address, NON_OWNER);
|
|
654
|
+
let result = lz_receiver_safe_dispatcher
|
|
655
|
+
.lz_receive(MOCK_ORIGIN(), MOCK_GUID(), MOCK_MESSAGE(), EXECUTOR, 0, Default::default());
|
|
656
|
+
stop_cheat_caller_address(oapp_address);
|
|
657
|
+
|
|
658
|
+
assert_panic_with_error(result, err_only_endpoint(FAKE_ENDPOINT));
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
#[test]
|
|
662
|
+
#[feature("safe_dispatcher")]
|
|
663
|
+
fn test_lz_receive_fails_unregistered_peer() {
|
|
664
|
+
let TestSetup { oapp_address, lz_receiver_safe_dispatcher, .. } = setup();
|
|
665
|
+
let unknown_origin = Origin { src_eid: UNKNOWN_EID, sender: MOCK_PEER_1(), nonce: 1 };
|
|
666
|
+
|
|
667
|
+
start_cheat_caller_address(oapp_address, FAKE_ENDPOINT);
|
|
668
|
+
let result = lz_receiver_safe_dispatcher
|
|
669
|
+
.lz_receive(unknown_origin, MOCK_GUID(), MOCK_MESSAGE(), EXECUTOR, 0, Default::default());
|
|
670
|
+
stop_cheat_caller_address(oapp_address);
|
|
671
|
+
|
|
672
|
+
assert_panic_with_error(result, err_no_peer(UNKNOWN_EID));
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
#[test]
|
|
676
|
+
fn test_lz_receive_multi_chain() {
|
|
677
|
+
let TestSetup { oapp_address, oapp_dispatcher, lz_receiver_dispatcher, .. } = setup();
|
|
678
|
+
|
|
679
|
+
// Set up peers for different chains
|
|
680
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
681
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
682
|
+
oapp_dispatcher.set_peer(EID_2, MOCK_PEER_2());
|
|
683
|
+
stop_cheat_caller_address(oapp_address);
|
|
684
|
+
|
|
685
|
+
start_cheat_caller_address(oapp_address, FAKE_ENDPOINT);
|
|
686
|
+
|
|
687
|
+
let origin_chain1 = Origin { src_eid: EID_1, sender: MOCK_PEER_1(), nonce: 1 };
|
|
688
|
+
let origin_chain2 = Origin { src_eid: EID_2, sender: MOCK_PEER_2(), nonce: 1 };
|
|
689
|
+
|
|
690
|
+
lz_receiver_dispatcher
|
|
691
|
+
.lz_receive(origin_chain1, MOCK_GUID(), "chain1 msg", EXECUTOR, 0, Default::default());
|
|
692
|
+
lz_receiver_dispatcher
|
|
693
|
+
.lz_receive(origin_chain2, MOCK_GUID(), "chain2 msg", EXECUTOR, 0, Default::default());
|
|
694
|
+
|
|
695
|
+
stop_cheat_caller_address(oapp_address);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
#[test]
|
|
699
|
+
#[feature("safe_dispatcher")]
|
|
700
|
+
fn test_lz_receive_fails_wrong_sender_for_chain() {
|
|
701
|
+
let TestSetup { oapp_address, oapp_dispatcher, lz_receiver_safe_dispatcher, .. } = setup();
|
|
702
|
+
|
|
703
|
+
// Set up peer for EID_1
|
|
704
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
705
|
+
oapp_dispatcher.set_peer(EID_1, MOCK_PEER_1());
|
|
706
|
+
stop_cheat_caller_address(oapp_address);
|
|
707
|
+
|
|
708
|
+
// Try wrong sender for EID_1
|
|
709
|
+
let invalid_origin = Origin { src_eid: EID_1, sender: MOCK_PEER_2(), nonce: 1 };
|
|
710
|
+
|
|
711
|
+
start_cheat_caller_address(oapp_address, FAKE_ENDPOINT);
|
|
712
|
+
let result = lz_receiver_safe_dispatcher
|
|
713
|
+
.lz_receive(invalid_origin, MOCK_GUID(), MOCK_MESSAGE(), EXECUTOR, 0, Default::default());
|
|
714
|
+
stop_cheat_caller_address(oapp_address);
|
|
715
|
+
assert_panic_with_error(result, err_only_peer(EID_1, MOCK_PEER_2()));
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
#[test]
|
|
719
|
+
fn test_lz_receive_empty_message() {
|
|
720
|
+
let TestSetup { oapp_address, lz_receiver_dispatcher, .. } = setup();
|
|
721
|
+
|
|
722
|
+
start_cheat_caller_address(oapp_address, FAKE_ENDPOINT);
|
|
723
|
+
lz_receiver_dispatcher
|
|
724
|
+
.lz_receive(MOCK_ORIGIN(), MOCK_GUID(), "", EXECUTOR, 0, Default::default());
|
|
725
|
+
stop_cheat_caller_address(oapp_address);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// =============================== Test Set Delegate =================================
|
|
729
|
+
|
|
730
|
+
#[test]
|
|
731
|
+
fn test_set_delegate() {
|
|
732
|
+
let TestSetup { oapp_address, oapp_dispatcher, .. } = setup();
|
|
733
|
+
|
|
734
|
+
start_mock_call(FAKE_ENDPOINT, selector!("set_delegate"), OWNER);
|
|
735
|
+
|
|
736
|
+
start_cheat_caller_address(oapp_address, OWNER);
|
|
737
|
+
oapp_dispatcher.set_delegate(OWNER);
|
|
738
|
+
stop_cheat_caller_address(oapp_address);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
#[test]
|
|
742
|
+
#[feature("safe_dispatcher")]
|
|
743
|
+
fn test_set_delegate_fails_not_owner() {
|
|
744
|
+
let TestSetup { oapp_address, oapp_safe_dispatcher, .. } = setup();
|
|
745
|
+
|
|
746
|
+
start_cheat_caller_address(oapp_address, NON_OWNER);
|
|
747
|
+
let result = oapp_safe_dispatcher.set_delegate(OWNER);
|
|
748
|
+
stop_cheat_caller_address(oapp_address);
|
|
749
|
+
assert_panic_with_felt_error(result, OwnableComponent::Errors::NOT_OWNER);
|
|
750
|
+
}
|