@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,751 @@
|
|
|
1
|
+
//! OFT core tests
|
|
2
|
+
|
|
3
|
+
use alexandria_bytes::byte_array_ext::ByteArrayTraitExt;
|
|
4
|
+
use layerzero::common::constants::DEAD_ADDRESS;
|
|
5
|
+
use layerzero::common::structs::messaging::MessagingFee;
|
|
6
|
+
use layerzero::common::structs::packet::Origin;
|
|
7
|
+
use layerzero::endpoint::interfaces::layerzero_receiver::{
|
|
8
|
+
ILayerZeroReceiverDispatcher, ILayerZeroReceiverDispatcherTrait,
|
|
9
|
+
};
|
|
10
|
+
use layerzero::oapps::oapp::interface::{IOAppDispatcher, IOAppDispatcherTrait};
|
|
11
|
+
use layerzero::oapps::oft::errors::{
|
|
12
|
+
err_amount_sd_overflowed, err_invalid_local_decimals, err_slippage_exceeded,
|
|
13
|
+
};
|
|
14
|
+
use layerzero::oapps::oft::events::MsgInspectorSet;
|
|
15
|
+
use layerzero::oapps::oft::interface::{
|
|
16
|
+
IOFTDispatcher, IOFTDispatcherTrait, IOFTSafeDispatcher, IOFTSafeDispatcherTrait,
|
|
17
|
+
};
|
|
18
|
+
use layerzero::oapps::oft::oft_core::OFTCoreComponent::Event as OFTEvent;
|
|
19
|
+
use layerzero::oapps::oft::structs::SendParam;
|
|
20
|
+
use lz_utils::bytes::{Bytes32, ContractAddressIntoBytes32};
|
|
21
|
+
use openzeppelin::access::ownable::OwnableComponent;
|
|
22
|
+
use openzeppelin::token::erc20::interface::{IERC20Dispatcher, IERC20DispatcherTrait};
|
|
23
|
+
use snforge_std::{
|
|
24
|
+
ContractClassTrait, DeclareResultTrait, EventSpyAssertionsTrait, declare, spy_events,
|
|
25
|
+
start_cheat_caller_address, start_mock_call, stop_cheat_caller_address,
|
|
26
|
+
};
|
|
27
|
+
use starknet::ContractAddress;
|
|
28
|
+
use starkware_utils_testing::test_utils::{assert_panic_with_error, assert_panic_with_felt_error};
|
|
29
|
+
use crate::mocks::oft_core::interface::{
|
|
30
|
+
IMockOFTCoreDispatcher, IMockOFTCoreDispatcherTrait, IMockOFTCoreSafeDispatcher,
|
|
31
|
+
IMockOFTCoreSafeDispatcherTrait,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// =============================== Test Constants =================================
|
|
35
|
+
|
|
36
|
+
pub const FAKE_ENDPOINT: ContractAddress = 'fake_endpoint'.try_into().unwrap();
|
|
37
|
+
pub const OWNER: ContractAddress = 'owner'.try_into().unwrap();
|
|
38
|
+
pub const STARK_TOKEN: ContractAddress = 'stark_token'.try_into().unwrap();
|
|
39
|
+
pub const USER: ContractAddress = 'user'.try_into().unwrap();
|
|
40
|
+
pub const RECIPIENT: ContractAddress = 'recipient'.try_into().unwrap();
|
|
41
|
+
pub const REFUND_ADDRESS: ContractAddress = 'refund'.try_into().unwrap();
|
|
42
|
+
pub const DST_EID: u32 = 101;
|
|
43
|
+
pub const SRC_EID: u32 = 201;
|
|
44
|
+
pub const SHARED_DECIMALS: u8 = 6;
|
|
45
|
+
pub const LOCAL_DECIMALS: u8 = 18;
|
|
46
|
+
|
|
47
|
+
// Test amounts
|
|
48
|
+
pub const TEST_AMOUNT_LD: u256 = 1000000000000000000_u256; // 1 token with 18 decimals
|
|
49
|
+
pub const TEST_AMOUNT_SD: u64 = 1000000_u64; // 1 token with 6 decimals
|
|
50
|
+
pub const MIN_AMOUNT_LD: u256 = 900000000000000000_u256; // 0.9 token with 18 decimals
|
|
51
|
+
pub const DUST_AMOUNT: u256 = 1000000000000000123_u256; // Amount with dust
|
|
52
|
+
pub const CLEAN_AMOUNT: u256 = 1000000000000000000_u256; // Amount without dust
|
|
53
|
+
|
|
54
|
+
// Error messages handled by imported error functions
|
|
55
|
+
|
|
56
|
+
// =============================== Helper Functions =================================
|
|
57
|
+
|
|
58
|
+
fn MOCK_GUID() -> Bytes32 {
|
|
59
|
+
Bytes32 { value: 0xabcdef123456789 }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fn MOCK_ORIGIN() -> Origin {
|
|
63
|
+
Origin { src_eid: SRC_EID, sender: MOCK_PEER(), nonce: 1 }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fn MOCK_PEER() -> Bytes32 {
|
|
67
|
+
Bytes32 { value: 0x123456789abcdef }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
fn deploy_mock_erc20() -> ContractAddress {
|
|
71
|
+
let contract = declare("MockERC20").unwrap().contract_class();
|
|
72
|
+
let (address, _) = contract
|
|
73
|
+
.deploy(
|
|
74
|
+
@array![
|
|
75
|
+
1000000000000000000_u256.low.into(), 1000000000000000000_u256.high.into(),
|
|
76
|
+
OWNER.into(),
|
|
77
|
+
],
|
|
78
|
+
)
|
|
79
|
+
.unwrap();
|
|
80
|
+
address
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fn deploy_oft() -> (ContractAddress, ContractAddress) {
|
|
84
|
+
let stark_token = deploy_mock_erc20();
|
|
85
|
+
|
|
86
|
+
let contract = declare("OFT").unwrap().contract_class();
|
|
87
|
+
let mut params = array![];
|
|
88
|
+
|
|
89
|
+
let name: ByteArray = "TestOFT";
|
|
90
|
+
let symbol: ByteArray = "TOFT";
|
|
91
|
+
|
|
92
|
+
name.serialize(ref params);
|
|
93
|
+
symbol.serialize(ref params);
|
|
94
|
+
FAKE_ENDPOINT.serialize(ref params);
|
|
95
|
+
OWNER.serialize(ref params);
|
|
96
|
+
stark_token.serialize(ref params);
|
|
97
|
+
|
|
98
|
+
let (address, _) = contract.deploy(@params).unwrap();
|
|
99
|
+
(address, stark_token)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
fn deploy_mock_oft_core() -> ContractAddress {
|
|
103
|
+
let stark_token = deploy_mock_erc20();
|
|
104
|
+
|
|
105
|
+
let contract = declare("MockOFTCore").unwrap().contract_class();
|
|
106
|
+
let (address, _) = contract
|
|
107
|
+
.deploy(@array![FAKE_ENDPOINT.into(), OWNER.into(), stark_token.into()])
|
|
108
|
+
.unwrap();
|
|
109
|
+
address
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fn deploy_mock_message_inspector() -> ContractAddress {
|
|
113
|
+
let contract = declare("MockMessageInspector").unwrap().contract_class();
|
|
114
|
+
let (address, _) = contract.deploy(@array![]).unwrap();
|
|
115
|
+
address
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fn setup_oft_with_peers(oft_address: ContractAddress) {
|
|
119
|
+
let oapp = IOAppDispatcher { contract_address: oft_address };
|
|
120
|
+
|
|
121
|
+
start_cheat_caller_address(oft_address, OWNER);
|
|
122
|
+
oapp.set_peer(DST_EID, MOCK_PEER());
|
|
123
|
+
oapp.set_peer(SRC_EID, MOCK_PEER());
|
|
124
|
+
stop_cheat_caller_address(oft_address);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
fn mint_tokens_to_user(oft_address: ContractAddress, user: ContractAddress, amount_sd: u64) {
|
|
128
|
+
let lz_receiver = ILayerZeroReceiverDispatcher { contract_address: oft_address };
|
|
129
|
+
let mut message: ByteArray = Default::default();
|
|
130
|
+
let user_bytes32: Bytes32 = user.into();
|
|
131
|
+
message.append_u256(user_bytes32.value);
|
|
132
|
+
message.append_u64(amount_sd);
|
|
133
|
+
|
|
134
|
+
start_cheat_caller_address(oft_address, FAKE_ENDPOINT);
|
|
135
|
+
lz_receiver.lz_receive(MOCK_ORIGIN(), MOCK_GUID(), message, user, 0, Default::default());
|
|
136
|
+
stop_cheat_caller_address(oft_address);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
fn setup_native_fee_payment(
|
|
140
|
+
stark_token_address: ContractAddress,
|
|
141
|
+
oft_address: ContractAddress,
|
|
142
|
+
user: ContractAddress,
|
|
143
|
+
fee_amount: u256,
|
|
144
|
+
) {
|
|
145
|
+
let stark_erc20 = IERC20Dispatcher { contract_address: stark_token_address };
|
|
146
|
+
|
|
147
|
+
start_cheat_caller_address(stark_token_address, OWNER);
|
|
148
|
+
stark_erc20.transfer(user, fee_amount * 100);
|
|
149
|
+
stop_cheat_caller_address(stark_token_address);
|
|
150
|
+
|
|
151
|
+
start_cheat_caller_address(stark_token_address, user);
|
|
152
|
+
stark_erc20.approve(oft_address, fee_amount * 100);
|
|
153
|
+
stop_cheat_caller_address(stark_token_address);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
fn create_test_send_param() -> SendParam {
|
|
157
|
+
SendParam {
|
|
158
|
+
dst_eid: DST_EID,
|
|
159
|
+
to: RECIPIENT.into(),
|
|
160
|
+
amount_ld: TEST_AMOUNT_LD,
|
|
161
|
+
min_amount_ld: MIN_AMOUNT_LD,
|
|
162
|
+
extra_options: Default::default(),
|
|
163
|
+
compose_msg: Default::default(),
|
|
164
|
+
oft_cmd: Default::default(),
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
fn create_test_send_param_with_extra_options() -> SendParam {
|
|
169
|
+
SendParam {
|
|
170
|
+
dst_eid: DST_EID,
|
|
171
|
+
to: RECIPIENT.into(),
|
|
172
|
+
amount_ld: TEST_AMOUNT_LD,
|
|
173
|
+
min_amount_ld: MIN_AMOUNT_LD,
|
|
174
|
+
extra_options: "extra_options",
|
|
175
|
+
compose_msg: Default::default(),
|
|
176
|
+
oft_cmd: Default::default(),
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
fn create_test_send_param_with_compose() -> SendParam {
|
|
181
|
+
let mut compose_msg: ByteArray = Default::default();
|
|
182
|
+
compose_msg.append(@"test compose message");
|
|
183
|
+
|
|
184
|
+
SendParam {
|
|
185
|
+
dst_eid: DST_EID,
|
|
186
|
+
to: RECIPIENT.into(),
|
|
187
|
+
amount_ld: TEST_AMOUNT_LD,
|
|
188
|
+
min_amount_ld: MIN_AMOUNT_LD,
|
|
189
|
+
extra_options: Default::default(),
|
|
190
|
+
compose_msg,
|
|
191
|
+
oft_cmd: Default::default(),
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// =============================== Basic Interface Tests =================================
|
|
196
|
+
|
|
197
|
+
#[test]
|
|
198
|
+
fn test_oft_version() {
|
|
199
|
+
let (oft_address, _) = deploy_oft();
|
|
200
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
201
|
+
|
|
202
|
+
let version = oft.oft_version();
|
|
203
|
+
assert(version.interface_id == 1_u32, 'Wrong interface ID');
|
|
204
|
+
assert(version.version == 1_u64, 'Wrong version');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
#[test]
|
|
208
|
+
fn test_token_address() {
|
|
209
|
+
let (oft_address, _) = deploy_oft();
|
|
210
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
211
|
+
|
|
212
|
+
let token_address = oft.token();
|
|
213
|
+
assert(token_address == oft_address, 'Token address should be self');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#[test]
|
|
217
|
+
fn test_approval_not_required() {
|
|
218
|
+
let (oft_address, _) = deploy_oft();
|
|
219
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
220
|
+
|
|
221
|
+
let approval_required = oft.approval_required();
|
|
222
|
+
assert(!approval_required, 'Approval not required');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
#[test]
|
|
226
|
+
fn test_shared_decimals() {
|
|
227
|
+
let (oft_address, _) = deploy_oft();
|
|
228
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
229
|
+
|
|
230
|
+
let decimals = oft.shared_decimals();
|
|
231
|
+
assert(decimals == SHARED_DECIMALS, 'Wrong shared decimals');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// =============================== Initialization Tests =================================
|
|
235
|
+
|
|
236
|
+
#[test]
|
|
237
|
+
fn test_initializer_valid_decimals() {
|
|
238
|
+
let mock_address = deploy_mock_oft_core();
|
|
239
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
240
|
+
|
|
241
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
242
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
243
|
+
stop_cheat_caller_address(mock_address);
|
|
244
|
+
|
|
245
|
+
let conversion_rate = mock.test_decimal_conversion_rate();
|
|
246
|
+
|
|
247
|
+
assert(conversion_rate == 1000000000000_u256, 'Wrong conversion rate');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
#[test]
|
|
251
|
+
fn test_initializer_same_decimals() {
|
|
252
|
+
let mock_address = deploy_mock_oft_core();
|
|
253
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
254
|
+
|
|
255
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
256
|
+
mock.test_initializer(6);
|
|
257
|
+
stop_cheat_caller_address(mock_address);
|
|
258
|
+
|
|
259
|
+
// this will be 1 since the shared decimals are 6 and the local decimals are 6
|
|
260
|
+
let conversion_rate = mock.test_decimal_conversion_rate();
|
|
261
|
+
assert(conversion_rate == 1_u256, 'Rate should be 1');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
#[test]
|
|
265
|
+
#[feature("safe_dispatcher")]
|
|
266
|
+
fn test_initializer_invalid_decimals() {
|
|
267
|
+
let mock_address = deploy_mock_oft_core();
|
|
268
|
+
let mock_safe = IMockOFTCoreSafeDispatcher { contract_address: mock_address };
|
|
269
|
+
|
|
270
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
271
|
+
|
|
272
|
+
let result = mock_safe.test_initializer(5); // local < shared (invalid)
|
|
273
|
+
|
|
274
|
+
stop_cheat_caller_address(mock_address);
|
|
275
|
+
|
|
276
|
+
assert_panic_with_error(result, err_invalid_local_decimals(5, 6));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// =============================== Decimal Conversion Tests =================================
|
|
280
|
+
|
|
281
|
+
#[test]
|
|
282
|
+
fn test_to_ld_conversion() {
|
|
283
|
+
let mock_address = deploy_mock_oft_core();
|
|
284
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
285
|
+
|
|
286
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
287
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
288
|
+
stop_cheat_caller_address(mock_address);
|
|
289
|
+
|
|
290
|
+
let amount_ld = mock.test_to_ld(1_u64);
|
|
291
|
+
assert(amount_ld == 1000000000000_u256, 'Wrong _to_ld conversion');
|
|
292
|
+
|
|
293
|
+
let large_amount_ld = mock.test_to_ld(1000000_u64);
|
|
294
|
+
assert(large_amount_ld == 1000000000000000000_u256, 'Wrong large conversion');
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
#[test]
|
|
298
|
+
fn test_to_sd_conversion() {
|
|
299
|
+
let mock_address = deploy_mock_oft_core();
|
|
300
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
301
|
+
|
|
302
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
303
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
304
|
+
stop_cheat_caller_address(mock_address);
|
|
305
|
+
|
|
306
|
+
let amount_sd = mock.test_to_sd(1000000000000_u256);
|
|
307
|
+
assert(amount_sd == 1_u64, 'Wrong _to_sd conversion');
|
|
308
|
+
|
|
309
|
+
let large_amount_sd = mock.test_to_sd(1000000000000000000_u256);
|
|
310
|
+
assert(large_amount_sd == 1000000_u64, 'Wrong large conversion');
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
#[test]
|
|
314
|
+
fn test_decimal_conversions_roundtrip() {
|
|
315
|
+
let mock_address = deploy_mock_oft_core();
|
|
316
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
317
|
+
|
|
318
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
319
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
320
|
+
stop_cheat_caller_address(mock_address);
|
|
321
|
+
|
|
322
|
+
let original_sd = 1000_u64;
|
|
323
|
+
let amount_ld = mock.test_to_ld(original_sd);
|
|
324
|
+
let back_to_sd = mock.test_to_sd(amount_ld);
|
|
325
|
+
assert(back_to_sd == original_sd, 'Round trip failed');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
#[test]
|
|
329
|
+
fn test_decimal_conversions_edge_cases() {
|
|
330
|
+
let mock_address = deploy_mock_oft_core();
|
|
331
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
332
|
+
|
|
333
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
334
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
335
|
+
stop_cheat_caller_address(mock_address);
|
|
336
|
+
|
|
337
|
+
// Test zero
|
|
338
|
+
assert(mock.test_to_ld(0_u64) == 0_u256, 'Zero conversion failed');
|
|
339
|
+
assert(mock.test_to_sd(0_u256) == 0_u64, 'Zero conversion failed');
|
|
340
|
+
|
|
341
|
+
// Test max values
|
|
342
|
+
let max_sd = 0xffffffffffffffff_u64;
|
|
343
|
+
let max_ld = mock.test_to_ld(max_sd);
|
|
344
|
+
assert(max_ld > max_sd.into(), 'Max conversion failed');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
#[test]
|
|
348
|
+
#[feature("safe_dispatcher")]
|
|
349
|
+
fn test_to_sd_overflow() {
|
|
350
|
+
let mock_address = deploy_mock_oft_core();
|
|
351
|
+
let mock_safe = IMockOFTCoreSafeDispatcher { contract_address: mock_address };
|
|
352
|
+
|
|
353
|
+
let conversion_rate = mock_safe.test_decimal_conversion_rate().unwrap();
|
|
354
|
+
|
|
355
|
+
let overflow_amount = 0x1_0000_0000_0000_0000 * conversion_rate;
|
|
356
|
+
|
|
357
|
+
let result = mock_safe.test_to_sd(overflow_amount);
|
|
358
|
+
|
|
359
|
+
assert_panic_with_error(result, err_amount_sd_overflowed(overflow_amount / conversion_rate));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// =============================== Dust Removal Tests =================================
|
|
363
|
+
|
|
364
|
+
#[test]
|
|
365
|
+
fn test_remove_dust_basic() {
|
|
366
|
+
let mock_address = deploy_mock_oft_core();
|
|
367
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
368
|
+
|
|
369
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
370
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
371
|
+
stop_cheat_caller_address(mock_address);
|
|
372
|
+
|
|
373
|
+
let cleaned_amount = mock.test_remove_dust(DUST_AMOUNT);
|
|
374
|
+
assert(cleaned_amount == CLEAN_AMOUNT, 'Dust not removed');
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
#[test]
|
|
378
|
+
fn test_remove_dust_clean_amount() {
|
|
379
|
+
let mock_address = deploy_mock_oft_core();
|
|
380
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
381
|
+
|
|
382
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
383
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
384
|
+
stop_cheat_caller_address(mock_address);
|
|
385
|
+
|
|
386
|
+
let still_clean = mock.test_remove_dust(CLEAN_AMOUNT);
|
|
387
|
+
assert(still_clean == CLEAN_AMOUNT, 'Clean amount changed');
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
#[test]
|
|
391
|
+
fn test_remove_dust_edge_cases() {
|
|
392
|
+
let mock_address = deploy_mock_oft_core();
|
|
393
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
394
|
+
|
|
395
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
396
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
397
|
+
stop_cheat_caller_address(mock_address);
|
|
398
|
+
|
|
399
|
+
// Test zero
|
|
400
|
+
assert(mock.test_remove_dust(0_u256) == 0_u256, 'Zero dust removal failed');
|
|
401
|
+
|
|
402
|
+
// Test amount smaller than conversion rate
|
|
403
|
+
let small_amount = 999999999999_u256; // Less than 10^12
|
|
404
|
+
assert(mock.test_remove_dust(small_amount) == 0_u256, 'Small dust removal failed');
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// =============================== Debit View Tests =================================
|
|
408
|
+
|
|
409
|
+
#[test]
|
|
410
|
+
fn test_debit_view_success() {
|
|
411
|
+
let mock_address = deploy_mock_oft_core();
|
|
412
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
413
|
+
|
|
414
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
415
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
416
|
+
stop_cheat_caller_address(mock_address);
|
|
417
|
+
|
|
418
|
+
let oft_debit = mock.test_debit_view(TEST_AMOUNT_LD, MIN_AMOUNT_LD, DST_EID);
|
|
419
|
+
assert(oft_debit.amount_sent_ld == CLEAN_AMOUNT, 'Wrong sent amount');
|
|
420
|
+
assert(oft_debit.amount_received_ld == CLEAN_AMOUNT, 'Wrong received amount');
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
#[test]
|
|
424
|
+
#[feature("safe_dispatcher")]
|
|
425
|
+
fn test_debit_view_slippage_exceeded() {
|
|
426
|
+
let mock_address = deploy_mock_oft_core();
|
|
427
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
428
|
+
let mock_safe = IMockOFTCoreSafeDispatcher { contract_address: mock_address };
|
|
429
|
+
|
|
430
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
431
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
432
|
+
stop_cheat_caller_address(mock_address);
|
|
433
|
+
|
|
434
|
+
let high_min_amount = TEST_AMOUNT_LD + 1_u256;
|
|
435
|
+
|
|
436
|
+
let result = mock_safe.test_debit_view(TEST_AMOUNT_LD, high_min_amount, DST_EID);
|
|
437
|
+
assert_panic_with_error(result, err_slippage_exceeded(CLEAN_AMOUNT, high_min_amount));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
#[test]
|
|
441
|
+
fn test_debit_view_exact_min_amount() {
|
|
442
|
+
let mock_address = deploy_mock_oft_core();
|
|
443
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
444
|
+
|
|
445
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
446
|
+
mock.test_initializer(LOCAL_DECIMALS);
|
|
447
|
+
stop_cheat_caller_address(mock_address);
|
|
448
|
+
|
|
449
|
+
let oft_debit = mock.test_debit_view(TEST_AMOUNT_LD, CLEAN_AMOUNT, DST_EID);
|
|
450
|
+
assert(oft_debit.amount_sent_ld == CLEAN_AMOUNT, 'Wrong sent amount');
|
|
451
|
+
assert(oft_debit.amount_received_ld == CLEAN_AMOUNT, 'Wrong received amount');
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// =============================== Msg Inspector Tests =================================
|
|
455
|
+
|
|
456
|
+
#[test]
|
|
457
|
+
fn test_set_msg_inspector() {
|
|
458
|
+
let (oft_address, _) = deploy_oft();
|
|
459
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
460
|
+
|
|
461
|
+
let mut spy = spy_events();
|
|
462
|
+
|
|
463
|
+
start_cheat_caller_address(oft_address, OWNER);
|
|
464
|
+
oft.set_msg_inspector(OWNER);
|
|
465
|
+
stop_cheat_caller_address(oft_address);
|
|
466
|
+
|
|
467
|
+
let msg_inspector_set_event = OFTEvent::MsgInspectorSet(
|
|
468
|
+
MsgInspectorSet { msg_inspector: OWNER },
|
|
469
|
+
);
|
|
470
|
+
spy.assert_emitted(@array![(oft_address, msg_inspector_set_event)]);
|
|
471
|
+
|
|
472
|
+
let msg_inspector = oft.msg_inspector();
|
|
473
|
+
assert(msg_inspector == OWNER, 'Msg inspector not set');
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
#[test]
|
|
477
|
+
#[feature("safe_dispatcher")]
|
|
478
|
+
fn test_set_msg_inspector_not_owner() {
|
|
479
|
+
let (oft_address, _) = deploy_oft();
|
|
480
|
+
let oft_safe = IOFTSafeDispatcher { contract_address: oft_address };
|
|
481
|
+
|
|
482
|
+
start_cheat_caller_address(oft_address, USER);
|
|
483
|
+
let result = oft_safe.set_msg_inspector(OWNER);
|
|
484
|
+
stop_cheat_caller_address(oft_address);
|
|
485
|
+
|
|
486
|
+
assert_panic_with_felt_error(result, OwnableComponent::Errors::NOT_OWNER);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
#[test]
|
|
490
|
+
fn test_build_msg_and_options() {
|
|
491
|
+
let mock_address = deploy_mock_oft_core();
|
|
492
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
493
|
+
|
|
494
|
+
let mut send_param = create_test_send_param_with_extra_options();
|
|
495
|
+
let result = mock.test_build_msg_and_options(send_param, TEST_AMOUNT_LD);
|
|
496
|
+
|
|
497
|
+
assert(result.message.len() > 0, 'Message should not be empty');
|
|
498
|
+
assert(result.options.len() > 0, 'Options should not be empty');
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
#[test]
|
|
502
|
+
#[should_panic(expected: "Invalid message or options")]
|
|
503
|
+
fn test_should_fail_build_msg_and_options() {
|
|
504
|
+
let mock_address = deploy_mock_oft_core();
|
|
505
|
+
let mock_inspector_address = deploy_mock_message_inspector();
|
|
506
|
+
let mock = IMockOFTCoreDispatcher { contract_address: mock_address };
|
|
507
|
+
|
|
508
|
+
start_cheat_caller_address(mock_address, OWNER);
|
|
509
|
+
mock.test_set_msg_inspector(mock_inspector_address);
|
|
510
|
+
stop_cheat_caller_address(mock_address);
|
|
511
|
+
|
|
512
|
+
let mut send_param = create_test_send_param_with_extra_options();
|
|
513
|
+
mock.test_build_msg_and_options(send_param, TEST_AMOUNT_LD);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// =============================== Quote Tests =================================
|
|
517
|
+
|
|
518
|
+
#[test]
|
|
519
|
+
fn test_quote_oft_basic() {
|
|
520
|
+
let (oft_address, _) = deploy_oft();
|
|
521
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
522
|
+
|
|
523
|
+
let send_param = create_test_send_param();
|
|
524
|
+
let quote = oft.quote_oft(send_param);
|
|
525
|
+
let erc20 = IERC20Dispatcher { contract_address: oft_address };
|
|
526
|
+
let supply = erc20.total_supply();
|
|
527
|
+
|
|
528
|
+
assert(quote.receipt.amount_sent_ld == CLEAN_AMOUNT, 'Wrong sent amount');
|
|
529
|
+
assert(quote.receipt.amount_received_ld == CLEAN_AMOUNT, 'Wrong received amount');
|
|
530
|
+
assert(quote.limit.min_amount_ld == 0, 'Wrong min limit');
|
|
531
|
+
assert(quote.limit.max_amount_ld == supply, 'Wrong max limit');
|
|
532
|
+
assert(quote.oft_fee_details.len() == 0, 'Should have no fees');
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
#[test]
|
|
536
|
+
fn test_quote_oft_with_dust() {
|
|
537
|
+
let (oft_address, _) = deploy_oft();
|
|
538
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
539
|
+
|
|
540
|
+
let mut send_param = create_test_send_param();
|
|
541
|
+
send_param.amount_ld = DUST_AMOUNT;
|
|
542
|
+
|
|
543
|
+
let quote = oft.quote_oft(send_param);
|
|
544
|
+
|
|
545
|
+
assert(quote.receipt.amount_sent_ld == CLEAN_AMOUNT, 'Dust not removed');
|
|
546
|
+
assert(quote.receipt.amount_received_ld == CLEAN_AMOUNT, 'Dust not removed');
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
#[test]
|
|
550
|
+
fn test_quote_send() {
|
|
551
|
+
let (oft_address, _) = deploy_oft();
|
|
552
|
+
setup_oft_with_peers(oft_address);
|
|
553
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
554
|
+
|
|
555
|
+
let expected_fee = MessagingFee { native_fee: 100, lz_token_fee: 10 };
|
|
556
|
+
start_mock_call(FAKE_ENDPOINT, selector!("quote"), expected_fee.clone());
|
|
557
|
+
|
|
558
|
+
let send_param = create_test_send_param();
|
|
559
|
+
let fee = oft.quote_send(send_param, false);
|
|
560
|
+
|
|
561
|
+
assert(fee.native_fee == 100, 'Wrong native fee');
|
|
562
|
+
assert(fee.lz_token_fee == 10, 'Wrong LZ token fee');
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
#[test]
|
|
566
|
+
fn test_quote_send_pay_in_lz_token() {
|
|
567
|
+
let (oft_address, _) = deploy_oft();
|
|
568
|
+
setup_oft_with_peers(oft_address);
|
|
569
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
570
|
+
|
|
571
|
+
let expected_fee = MessagingFee { native_fee: 0, lz_token_fee: 50 };
|
|
572
|
+
start_mock_call(FAKE_ENDPOINT, selector!("quote"), expected_fee.clone());
|
|
573
|
+
|
|
574
|
+
let send_param = create_test_send_param();
|
|
575
|
+
let fee = oft.quote_send(send_param, true);
|
|
576
|
+
|
|
577
|
+
assert(fee.native_fee == 0, 'Wrong native fee');
|
|
578
|
+
assert(fee.lz_token_fee == 50, 'Wrong LZ token fee');
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// =============================== Send Tests =================================
|
|
582
|
+
|
|
583
|
+
#[test]
|
|
584
|
+
fn test_send_basic() {
|
|
585
|
+
let (oft_address, stark_token_address) = deploy_oft();
|
|
586
|
+
setup_oft_with_peers(oft_address);
|
|
587
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
588
|
+
let erc20 = IERC20Dispatcher { contract_address: oft_address };
|
|
589
|
+
|
|
590
|
+
mint_tokens_to_user(oft_address, USER, TEST_AMOUNT_SD * 2);
|
|
591
|
+
setup_native_fee_payment(stark_token_address, oft_address, USER, 100);
|
|
592
|
+
|
|
593
|
+
let mock_receipt = layerzero::MessageReceipt { guid: MOCK_GUID(), nonce: 1, payees: array![] };
|
|
594
|
+
start_mock_call(FAKE_ENDPOINT, selector!("send"), mock_receipt.clone());
|
|
595
|
+
|
|
596
|
+
let initial_balance = erc20.balance_of(USER);
|
|
597
|
+
assert(initial_balance >= TEST_AMOUNT_LD, 'Insufficient balance');
|
|
598
|
+
|
|
599
|
+
let send_param = create_test_send_param();
|
|
600
|
+
let fee = MessagingFee { native_fee: 100, lz_token_fee: 0 };
|
|
601
|
+
|
|
602
|
+
start_cheat_caller_address(oft_address, USER);
|
|
603
|
+
let result = oft.send(send_param, fee, REFUND_ADDRESS);
|
|
604
|
+
stop_cheat_caller_address(oft_address);
|
|
605
|
+
|
|
606
|
+
let final_balance = erc20.balance_of(USER);
|
|
607
|
+
assert(final_balance == initial_balance - CLEAN_AMOUNT, 'Tokens not burned');
|
|
608
|
+
|
|
609
|
+
assert(result.oft_receipt.amount_sent_ld == CLEAN_AMOUNT, 'Wrong sent amount');
|
|
610
|
+
assert(result.oft_receipt.amount_received_ld == CLEAN_AMOUNT, 'Wrong received amount');
|
|
611
|
+
assert(result.message_receipt.guid == mock_receipt.guid, 'Wrong guid');
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
#[test]
|
|
615
|
+
fn test_send_with_compose() {
|
|
616
|
+
let (oft_address, stark_token_address) = deploy_oft();
|
|
617
|
+
setup_oft_with_peers(oft_address);
|
|
618
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
619
|
+
|
|
620
|
+
mint_tokens_to_user(oft_address, USER, TEST_AMOUNT_SD * 2);
|
|
621
|
+
setup_native_fee_payment(stark_token_address, oft_address, USER, 100);
|
|
622
|
+
|
|
623
|
+
let mock_receipt = layerzero::MessageReceipt { guid: MOCK_GUID(), nonce: 1, payees: array![] };
|
|
624
|
+
start_mock_call(FAKE_ENDPOINT, selector!("send"), mock_receipt.clone());
|
|
625
|
+
|
|
626
|
+
let send_param = create_test_send_param_with_compose();
|
|
627
|
+
let fee = MessagingFee { native_fee: 100, lz_token_fee: 0 };
|
|
628
|
+
|
|
629
|
+
start_cheat_caller_address(oft_address, USER);
|
|
630
|
+
let result = oft.send(send_param, fee, REFUND_ADDRESS);
|
|
631
|
+
stop_cheat_caller_address(oft_address);
|
|
632
|
+
|
|
633
|
+
assert(result.oft_receipt.amount_sent_ld == CLEAN_AMOUNT, 'Wrong sent amount');
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// =============================== Receive Tests =================================
|
|
637
|
+
|
|
638
|
+
#[test]
|
|
639
|
+
fn test_lz_receive_basic() {
|
|
640
|
+
let (oft_address, _) = deploy_oft();
|
|
641
|
+
setup_oft_with_peers(oft_address);
|
|
642
|
+
let lz_receiver = ILayerZeroReceiverDispatcher { contract_address: oft_address };
|
|
643
|
+
let erc20 = IERC20Dispatcher { contract_address: oft_address };
|
|
644
|
+
|
|
645
|
+
let mut message: ByteArray = Default::default();
|
|
646
|
+
let recipient_bytes32: Bytes32 = RECIPIENT.into();
|
|
647
|
+
message.append_u256(recipient_bytes32.value);
|
|
648
|
+
message.append_u64(TEST_AMOUNT_SD);
|
|
649
|
+
|
|
650
|
+
let initial_balance = erc20.balance_of(RECIPIENT);
|
|
651
|
+
|
|
652
|
+
start_cheat_caller_address(oft_address, FAKE_ENDPOINT);
|
|
653
|
+
lz_receiver.lz_receive(MOCK_ORIGIN(), MOCK_GUID(), message, USER, 0, Default::default());
|
|
654
|
+
stop_cheat_caller_address(oft_address);
|
|
655
|
+
|
|
656
|
+
let final_balance = erc20.balance_of(RECIPIENT);
|
|
657
|
+
let expected_amount = TEST_AMOUNT_LD;
|
|
658
|
+
assert(final_balance == initial_balance + expected_amount, 'Tokens not minted');
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
#[test]
|
|
662
|
+
fn test_lz_receive_zero_address() {
|
|
663
|
+
let (oft_address, _) = deploy_oft();
|
|
664
|
+
setup_oft_with_peers(oft_address);
|
|
665
|
+
let lz_receiver = ILayerZeroReceiverDispatcher { contract_address: oft_address };
|
|
666
|
+
let erc20 = IERC20Dispatcher { contract_address: oft_address };
|
|
667
|
+
|
|
668
|
+
let mut message: ByteArray = Default::default();
|
|
669
|
+
message.append_u256(0); // Zero address
|
|
670
|
+
message.append_u64(TEST_AMOUNT_SD);
|
|
671
|
+
|
|
672
|
+
let initial_balance = erc20.balance_of(DEAD_ADDRESS);
|
|
673
|
+
|
|
674
|
+
start_cheat_caller_address(oft_address, FAKE_ENDPOINT);
|
|
675
|
+
lz_receiver.lz_receive(MOCK_ORIGIN(), MOCK_GUID(), message, USER, 0, Default::default());
|
|
676
|
+
stop_cheat_caller_address(oft_address);
|
|
677
|
+
|
|
678
|
+
let final_balance = erc20.balance_of(DEAD_ADDRESS);
|
|
679
|
+
assert(final_balance == initial_balance + TEST_AMOUNT_LD, 'Zero address handling failed');
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// =============================== Integration Tests =================================
|
|
683
|
+
|
|
684
|
+
#[test]
|
|
685
|
+
fn test_complete_cross_chain_flow() {
|
|
686
|
+
let (oft_address, stark_token_address) = deploy_oft();
|
|
687
|
+
setup_oft_with_peers(oft_address);
|
|
688
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
689
|
+
let lz_receiver = ILayerZeroReceiverDispatcher { contract_address: oft_address };
|
|
690
|
+
let erc20 = IERC20Dispatcher { contract_address: oft_address };
|
|
691
|
+
|
|
692
|
+
// Step 1: Setup user with tokens
|
|
693
|
+
mint_tokens_to_user(oft_address, USER, TEST_AMOUNT_SD * 4);
|
|
694
|
+
setup_native_fee_payment(stark_token_address, oft_address, USER, 100);
|
|
695
|
+
|
|
696
|
+
let initial_user_balance = erc20.balance_of(USER);
|
|
697
|
+
let initial_recipient_balance = erc20.balance_of(RECIPIENT);
|
|
698
|
+
|
|
699
|
+
// Step 2: Send tokens
|
|
700
|
+
let mock_receipt = layerzero::MessageReceipt { guid: MOCK_GUID(), nonce: 1, payees: array![] };
|
|
701
|
+
start_mock_call(FAKE_ENDPOINT, selector!("send"), mock_receipt.clone());
|
|
702
|
+
|
|
703
|
+
let send_param = create_test_send_param();
|
|
704
|
+
let fee = MessagingFee { native_fee: 100, lz_token_fee: 0 };
|
|
705
|
+
|
|
706
|
+
start_cheat_caller_address(oft_address, USER);
|
|
707
|
+
oft.send(send_param, fee, REFUND_ADDRESS);
|
|
708
|
+
stop_cheat_caller_address(oft_address);
|
|
709
|
+
|
|
710
|
+
let user_balance_after_send = erc20.balance_of(USER);
|
|
711
|
+
assert(user_balance_after_send == initial_user_balance - CLEAN_AMOUNT, 'Tokens not burned');
|
|
712
|
+
|
|
713
|
+
// Step 3: Receive tokens
|
|
714
|
+
let mut message: ByteArray = Default::default();
|
|
715
|
+
let recipient_bytes32: Bytes32 = RECIPIENT.into();
|
|
716
|
+
message.append_u256(recipient_bytes32.value);
|
|
717
|
+
message.append_u64(TEST_AMOUNT_SD);
|
|
718
|
+
|
|
719
|
+
start_cheat_caller_address(oft_address, FAKE_ENDPOINT);
|
|
720
|
+
lz_receiver.lz_receive(MOCK_ORIGIN(), MOCK_GUID(), message, USER, 0, Default::default());
|
|
721
|
+
stop_cheat_caller_address(oft_address);
|
|
722
|
+
|
|
723
|
+
let recipient_balance_after_receive = erc20.balance_of(RECIPIENT);
|
|
724
|
+
assert(
|
|
725
|
+
recipient_balance_after_receive == initial_recipient_balance + TEST_AMOUNT_LD,
|
|
726
|
+
'Tokens not minted',
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
#[test]
|
|
731
|
+
fn test_send_operation_completes() {
|
|
732
|
+
let (oft_address, stark_token_address) = deploy_oft();
|
|
733
|
+
setup_oft_with_peers(oft_address);
|
|
734
|
+
let oft = IOFTDispatcher { contract_address: oft_address };
|
|
735
|
+
|
|
736
|
+
mint_tokens_to_user(oft_address, USER, TEST_AMOUNT_SD * 2);
|
|
737
|
+
setup_native_fee_payment(stark_token_address, oft_address, USER, 100);
|
|
738
|
+
|
|
739
|
+
let mock_receipt = layerzero::MessageReceipt { guid: MOCK_GUID(), nonce: 1, payees: array![] };
|
|
740
|
+
start_mock_call(FAKE_ENDPOINT, selector!("send"), mock_receipt.clone());
|
|
741
|
+
|
|
742
|
+
let send_param = create_test_send_param();
|
|
743
|
+
let fee = MessagingFee { native_fee: 100, lz_token_fee: 0 };
|
|
744
|
+
|
|
745
|
+
start_cheat_caller_address(oft_address, USER);
|
|
746
|
+
let result = oft.send(send_param, fee, REFUND_ADDRESS);
|
|
747
|
+
stop_cheat_caller_address(oft_address);
|
|
748
|
+
|
|
749
|
+
// Test completes successfully if no panic occurs
|
|
750
|
+
assert(result.oft_receipt.amount_sent_ld > 0, 'Send operation failed');
|
|
751
|
+
}
|