@layerzerolabs/protocol-stellar-v2 0.2.13 → 0.2.18
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 +484 -337
- package/.turbo/turbo-lint.log +126 -56
- package/.turbo/turbo-test.log +1403 -984
- package/Cargo.lock +142 -3
- package/Cargo.toml +5 -1
- package/contracts/ERROR_SPEC.md +44 -0
- package/contracts/common-macros/src/auth.rs +113 -0
- package/contracts/common-macros/src/contract_ttl.rs +84 -0
- package/contracts/common-macros/src/lib.rs +219 -29
- package/contracts/common-macros/src/lz_contract.rs +83 -0
- package/contracts/common-macros/src/storage.rs +1 -1
- package/contracts/common-macros/src/tests/{ownable.rs → auth.rs} +48 -15
- package/contracts/common-macros/src/tests/contract_ttl.rs +662 -0
- package/contracts/common-macros/src/tests/mod.rs +3 -2
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +24 -0
- package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__ownable__snapshot_only_owner_preserves_function_signature.snap → common_macros__tests__auth__snapshot_only_auth_preserves_function_signature.snap} +4 -4
- package/contracts/common-macros/src/tests/snapshots/{common_macros__tests__contract_impl__snapshot_generated_contract_impl_code.snap → common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap} +26 -10
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +69 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +48 -48
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_configurable__snapshot_generated_ttl_configurable_code.snap +7 -41
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__upgradeable__snapshot_generated_upgradeable_code.snap +21 -0
- package/contracts/common-macros/src/tests/upgradeable.rs +31 -0
- package/contracts/common-macros/src/ttl_configurable.rs +21 -66
- package/contracts/common-macros/src/ttl_extendable.rs +36 -0
- package/contracts/common-macros/src/upgradeable.rs +76 -0
- package/contracts/common-macros/src/utils.rs +9 -0
- package/contracts/endpoint-v2/src/constants.rs +4 -4
- package/contracts/endpoint-v2/src/endpoint_v2.rs +58 -36
- package/contracts/endpoint-v2/src/errors.rs +4 -3
- package/contracts/endpoint-v2/src/events.rs +1 -1
- package/contracts/endpoint-v2/src/message_lib_manager.rs +18 -5
- package/contracts/endpoint-v2/src/messaging_channel.rs +11 -1
- package/contracts/endpoint-v2/src/messaging_composer.rs +11 -1
- package/contracts/endpoint-v2/src/storage.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +175 -8
- package/contracts/endpoint-v2/src/tests/endpoint_v2/build_outbound_packet.rs +76 -0
- package/contracts/endpoint-v2/src/tests/endpoint_v2/clear.rs +342 -159
- package/contracts/endpoint-v2/src/tests/endpoint_v2/delegate.rs +3 -15
- package/contracts/endpoint-v2/src/tests/endpoint_v2/initializable.rs +20 -31
- package/contracts/endpoint-v2/src/tests/endpoint_v2/lz_receive_alert.rs +126 -164
- package/contracts/endpoint-v2/src/tests/endpoint_v2/mod.rs +1 -0
- package/contracts/endpoint-v2/src/tests/endpoint_v2/native_token.rs +0 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/owner.rs +0 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +311 -304
- package/contracts/endpoint-v2/src/tests/endpoint_v2/quote.rs +423 -96
- package/contracts/endpoint-v2/src/tests/endpoint_v2/recover_token.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +47 -20
- package/contracts/endpoint-v2/src/tests/endpoint_v2/send.rs +373 -403
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_delegate.rs +96 -22
- package/contracts/endpoint-v2/src/tests/endpoint_v2/set_zro.rs +62 -10
- package/contracts/endpoint-v2/src/tests/endpoint_v2/transfer_ownership.rs +4 -4
- package/contracts/endpoint-v2/src/tests/endpoint_v2/ttl_config.rs +8 -11
- package/contracts/endpoint-v2/src/tests/endpoint_v2/verifiable.rs +81 -30
- package/contracts/endpoint-v2/src/tests/endpoint_v2/verify.rs +209 -76
- package/contracts/endpoint-v2/src/tests/endpoint_v2/zro.rs +0 -1
- package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library.rs +24 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/default_receive_library_timeout.rs +40 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/default_send_library.rs +24 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_config.rs +108 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_library_index.rs +52 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_receive_library.rs +92 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_registered_libraries.rs +74 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/get_send_library.rs +83 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/is_registered_library.rs +32 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/is_supported_eid.rs +28 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/is_valid_receive_library.rs +261 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/mod.rs +16 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/receive_library_timeout.rs +62 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +65 -43
- package/contracts/endpoint-v2/src/tests/message_lib_manager/registered_libraries_count.rs +42 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +61 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +4 -6
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +59 -0
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +16 -2
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_config.rs +155 -51
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_lib_timeout.rs +114 -92
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_receive_library.rs +235 -132
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_default_send_library.rs +93 -87
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library.rs +346 -245
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_receive_library_timeout.rs +406 -60
- package/contracts/endpoint-v2/src/tests/message_lib_manager/set_send_library.rs +252 -78
- package/contracts/endpoint-v2/src/tests/message_lib_manager/timeout.rs +102 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/burn.rs +212 -273
- package/contracts/endpoint-v2/src/tests/messaging_channel/clear_payload.rs +203 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound.rs +94 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_nonce.rs +78 -248
- package/contracts/endpoint-v2/src/tests/messaging_channel/inbound_payload_hash.rs +7 -282
- package/contracts/endpoint-v2/src/tests/messaging_channel/lazy_inbound_nonce.rs +6 -274
- package/contracts/endpoint-v2/src/tests/messaging_channel/mod.rs +3 -2
- package/contracts/endpoint-v2/src/tests/messaging_channel/next_guid.rs +86 -178
- package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +328 -212
- package/contracts/endpoint-v2/src/tests/messaging_channel/outbound.rs +68 -0
- package/contracts/endpoint-v2/src/tests/messaging_channel/outbound_nonce.rs +6 -209
- package/contracts/endpoint-v2/src/tests/messaging_channel/skip.rs +207 -159
- package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +142 -153
- package/contracts/endpoint-v2/src/tests/messaging_composer/compose_queue.rs +6 -179
- package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +163 -221
- package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +90 -121
- package/contracts/endpoint-v2/src/tests/mock.rs +18 -4
- package/contracts/endpoint-v2/src/tests/util/build_payload.rs +4 -70
- package/contracts/endpoint-v2/src/tests/util/compute_guid.rs +2 -1
- package/contracts/endpoint-v2/src/tests/util/keccak256.rs +17 -106
- package/contracts/layerzero-views/Cargo.toml +35 -0
- package/contracts/layerzero-views/src/errors.rs +10 -0
- package/contracts/layerzero-views/src/layerzero_view.rs +226 -0
- package/contracts/layerzero-views/src/lib.rs +38 -0
- package/contracts/layerzero-views/src/storage.rs +18 -0
- package/contracts/layerzero-views/src/tests/layerzero_view_tests.rs +423 -0
- package/contracts/layerzero-views/src/tests/mod.rs +4 -0
- package/contracts/layerzero-views/src/tests/setup.rs +377 -0
- package/contracts/layerzero-views/src/types.rs +50 -0
- package/contracts/macro-integration-tests/Cargo.toml +30 -0
- package/contracts/macro-integration-tests/src/lib.rs +1 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/initialization.rs +62 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +22 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/only_auth_guard.rs +97 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/ownership_transfer.rs +101 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/keyed_roundtrip.rs +225 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/mod.rs +4 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/name_override_runtime.rs +52 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/ttl_extension.rs +261 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/unkeyed_roundtrip.rs +137 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +113 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +139 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/mod.rs +2 -0
- package/contracts/macro-integration-tests/tests/runtime.rs +5 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/decreasing_discriminant.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.rs +21 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_int_discriminant.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_unit_variant.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/attr_on_variant_allowed.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/basic_auto_discriminants.rs +15 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/mixed_discriminants.rs +16 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.rs +22 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.stderr +16 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/minimal_contract.rs +26 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +21 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_auth_env_param_variants.rs +46 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_storage_kinds.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_on_non_persistent.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/non_enum_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/tuple_variant_rejected.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/unknown_variant_attr.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/default_value_on_variant.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_instance_unit_basic.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_persistent_named_fields_keyed.rs +16 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_temporary_unit_option.rs +15 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/name_override.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/no_auto_ttl_extension.rs +19 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/ttl_provider_basic.rs +15 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/minimal_contract.rs +44 -0
- package/contracts/macro-integration-tests/tests/ui_error.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_ownable.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_storage.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_ttl_configurable.rs +12 -0
- package/contracts/message-libs/blocked-message-lib/src/lib.rs +17 -17
- package/contracts/message-libs/message-lib-common/src/errors.rs +7 -2
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/decode_packet_header.rs +64 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet.rs +58 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/encode_packet_header.rs +138 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/mod.rs +6 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload.rs +30 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/payload_hash.rs +15 -0
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1/test_helper.rs +39 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_dvn_option.rs +57 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_lz_receive_option.rs +49 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/append_native_drop_option.rs +73 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/convert_legacy_options.rs +280 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/extract_type_3_options.rs +126 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/left_pad_to_bytes32.rs +48 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/mod.rs +7 -0
- package/contracts/message-libs/message-lib-common/src/tests/worker_options/split_worker_options.rs +139 -0
- package/contracts/message-libs/message-lib-common/src/worker_options.rs +31 -1
- package/contracts/message-libs/simple-message-lib/src/simple_message_lib.rs +7 -9
- package/contracts/message-libs/treasury/src/errors.rs +2 -3
- package/contracts/message-libs/treasury/src/events.rs +1 -1
- package/contracts/message-libs/treasury/src/interfaces/zro_fee_lib.rs +2 -2
- package/contracts/message-libs/treasury/src/lib.rs +3 -3
- package/contracts/message-libs/treasury/src/storage.rs +3 -1
- package/contracts/message-libs/treasury/src/tests/treasury_tests.rs +1 -1
- package/contracts/message-libs/treasury/src/treasury.rs +23 -26
- package/contracts/message-libs/uln-302/Cargo.toml +1 -1
- package/contracts/message-libs/uln-302/src/errors.rs +0 -5
- package/contracts/message-libs/uln-302/src/events.rs +5 -6
- package/contracts/message-libs/uln-302/src/receive_uln.rs +37 -56
- package/contracts/message-libs/uln-302/src/send_uln.rs +112 -138
- package/contracts/message-libs/uln-302/src/storage.rs +5 -5
- package/contracts/message-libs/uln-302/src/tests/receive_uln302/effective_receive_uln_config.rs +5 -7
- package/contracts/message-libs/uln-302/src/tests/receive_uln302/set_default_receive_uln_configs.rs +3 -3
- package/contracts/message-libs/uln-302/src/tests/send_uln302/effective_send_uln_config.rs +6 -9
- package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_executor_configs.rs +2 -2
- package/contracts/message-libs/uln-302/src/tests/send_uln302/set_default_send_uln_configs.rs +3 -3
- package/contracts/message-libs/uln-302/src/tests/setup.rs +9 -0
- package/contracts/message-libs/uln-302/src/tests/testing_utils.rs +5 -0
- package/contracts/message-libs/uln-302/src/tests/uln302/get_app_receive_uln_config.rs +1 -2
- package/contracts/message-libs/uln-302/src/tests/uln302/get_app_send_uln_config.rs +1 -2
- package/contracts/message-libs/uln-302/src/tests/uln302/set_config.rs +37 -55
- package/contracts/message-libs/uln-302/src/uln302.rs +10 -25
- package/contracts/oapps/counter/Cargo.toml +14 -1
- package/contracts/oapps/counter/integration_tests/mod.rs +4 -1
- package/contracts/oapps/counter/integration_tests/setup_sml.rs +169 -0
- package/contracts/oapps/counter/integration_tests/setup_uln.rs +997 -0
- package/contracts/oapps/counter/integration_tests/signing.rs +62 -0
- package/contracts/oapps/counter/integration_tests/test_with_sml.rs +24 -55
- package/contracts/oapps/counter/integration_tests/test_with_uln.rs +314 -0
- package/contracts/oapps/counter/integration_tests/utils.rs +196 -53
- package/contracts/oapps/counter/src/counter.rs +67 -44
- package/contracts/oapps/counter/src/tests/mod.rs +0 -13
- package/contracts/oapps/counter/src/tests/test_counter.rs +5 -7
- package/contracts/oapps/oapp/src/errors.rs +5 -1
- package/contracts/oapps/oapp/src/macro_tests/test_macros.rs +318 -221
- package/contracts/oapps/oapp/src/oapp_core.rs +36 -21
- package/contracts/oapps/oapp/src/oapp_options_type3.rs +48 -12
- package/contracts/oapps/oapp/src/oapp_receiver.rs +106 -41
- package/contracts/oapps/oapp/src/oapp_sender.rs +26 -34
- package/contracts/oapps/oapp/src/tests/test_oapp_core.rs +9 -9
- package/contracts/oapps/oapp/src/tests/test_oapp_options_type3.rs +25 -18
- package/contracts/oapps/oapp/src/tests/test_oapp_receiver.rs +7 -8
- package/contracts/oapps/oapp/src/tests/test_oapp_sender.rs +14 -16
- package/contracts/oapps/oapp-macros/src/generators.rs +128 -0
- package/contracts/oapps/oapp-macros/src/lib.rs +211 -0
- package/contracts/oapps/oft/integration-tests/setup.rs +34 -9
- package/contracts/oapps/oft/integration-tests/utils.rs +1 -1
- package/contracts/oapps/oft/src/errors.rs +6 -1
- package/contracts/oapps/oft/src/extensions/oft_fee.rs +13 -13
- package/contracts/oapps/oft/src/extensions/pausable.rs +5 -5
- package/contracts/oapps/oft/src/extensions/rate_limiter.rs +23 -23
- package/contracts/oapps/oft/src/lib.rs +4 -2
- package/contracts/oapps/oft/src/oft.rs +31 -71
- package/contracts/oapps/oft/src/oft_impl.rs +201 -0
- package/contracts/oapps/oft/src/oft_types/lock_unlock.rs +2 -4
- package/contracts/oapps/oft/src/oft_types/mint_burn.rs +1 -4
- package/contracts/oapps/oft/src/storage.rs +2 -0
- package/contracts/oapps/oft/src/tests/extensions/setup.rs +60 -31
- package/contracts/oapps/oft/src/tests/extensions/test_oft_fee.rs +5 -3
- package/contracts/oapps/oft/src/tests/extensions/test_pausable.rs +5 -3
- package/contracts/oapps/oft/src/tests/extensions/test_rate_limiter.rs +6 -4
- package/contracts/oapps/oft/src/tests/test_decimals.rs +2 -2
- package/contracts/oapps/oft/src/tests/test_oft_msg_codec.rs +1 -2
- package/contracts/oapps/oft/src/tests/test_send.rs +4 -4
- package/contracts/oapps/oft/src/tests/test_utils.rs +122 -81
- package/contracts/oapps/oft/src/types.rs +20 -0
- package/contracts/oapps/oft-std/Cargo.toml +6 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/mod.rs +3 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/test_oft_fee.rs +157 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/test_pausable.rs +162 -0
- package/contracts/oapps/oft-std/integration-tests/extensions/test_rate_limiter.rs +186 -0
- package/contracts/oapps/oft-std/integration-tests/mod.rs +3 -0
- package/contracts/oapps/{counter/integration_tests → oft-std/integration-tests}/setup.rs +76 -30
- package/contracts/oapps/oft-std/integration-tests/utils.rs +427 -0
- package/contracts/oapps/oft-std/src/lib.rs +12 -1
- package/contracts/oapps/oft-std/src/oft.rs +141 -26
- package/contracts/upgrader/Cargo.toml +19 -0
- package/contracts/upgrader/src/lib.rs +96 -0
- package/contracts/upgrader/src/tests/mod.rs +1 -0
- package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract1.wasm +0 -0
- package/contracts/upgrader/src/tests/test_data/test_upgradeable_contract2.wasm +0 -0
- package/contracts/upgrader/src/tests/test_upgrader.rs +120 -0
- package/contracts/utils/src/auth.rs +44 -0
- package/contracts/utils/src/errors.rs +32 -5
- package/contracts/utils/src/lib.rs +5 -1
- package/contracts/utils/src/multisig.rs +211 -0
- package/contracts/utils/src/ownable.rs +50 -60
- package/contracts/utils/src/tests/buffer_reader.rs +6 -6
- package/contracts/utils/src/tests/buffer_writer.rs +6 -6
- package/contracts/utils/src/tests/bytes_ext.rs +2 -4
- package/contracts/utils/src/tests/mod.rs +4 -1
- package/contracts/utils/src/tests/multisig.rs +731 -0
- package/contracts/utils/src/tests/option_ext.rs +18 -0
- package/contracts/utils/src/tests/ownable.rs +22 -70
- package/contracts/utils/src/tests/ttl_configurable.rs +607 -0
- package/contracts/utils/src/tests/upgradeable.rs +290 -0
- package/contracts/utils/src/ttl_configurable.rs +153 -0
- package/contracts/utils/src/ttl_extendable.rs +27 -0
- package/contracts/utils/src/upgradeable.rs +56 -0
- package/contracts/workers/dvn/Cargo.toml +2 -2
- package/contracts/workers/dvn/src/auth.rs +24 -35
- package/contracts/workers/dvn/src/dvn.rs +23 -14
- package/contracts/workers/dvn/src/errors.rs +1 -7
- package/contracts/workers/dvn/src/events.rs +1 -14
- package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
- package/contracts/workers/dvn/src/interfaces/mod.rs +0 -2
- package/contracts/workers/dvn/src/storage.rs +3 -13
- package/contracts/workers/dvn/src/tests/auth.rs +4 -4
- package/contracts/workers/dvn/src/tests/dvn.rs +1 -2
- package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +7 -8
- package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +11 -8
- package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +11 -12
- package/contracts/workers/dvn/src/tests/setup.rs +5 -5
- package/contracts/workers/dvn-fee-lib/Cargo.toml +0 -1
- package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +45 -16
- package/contracts/workers/dvn-fee-lib/src/errors.rs +3 -2
- package/contracts/workers/dvn-fee-lib/src/lib.rs +5 -11
- package/contracts/workers/dvn-fee-lib/src/tests/dvn_fee_lib.rs +30 -16
- package/contracts/workers/executor/src/auth.rs +80 -16
- package/contracts/workers/executor/src/executor.rs +17 -29
- package/contracts/workers/executor/src/storage.rs +2 -9
- package/contracts/workers/executor-fee-lib/Cargo.toml +1 -1
- package/contracts/workers/executor-fee-lib/src/errors.rs +9 -7
- package/contracts/workers/executor-fee-lib/src/executor_fee_lib.rs +153 -121
- package/contracts/workers/executor-helper/Cargo.toml +1 -6
- package/contracts/workers/executor-helper/src/executor_helper.rs +53 -73
- package/contracts/workers/executor-helper/src/lib.rs +1 -7
- package/contracts/workers/price-feed/Cargo.toml +1 -2
- package/contracts/workers/price-feed/src/errors.rs +3 -2
- package/contracts/workers/price-feed/src/lib.rs +5 -6
- package/contracts/workers/price-feed/src/price_feed.rs +42 -23
- package/contracts/workers/worker/Cargo.toml +4 -0
- package/contracts/workers/worker/src/errors.rs +4 -0
- package/contracts/workers/worker/src/interfaces/price_feed.rs +3 -3
- package/contracts/workers/worker/src/lib.rs +2 -2
- package/contracts/workers/worker/src/tests/mod.rs +4 -0
- package/contracts/workers/worker/src/tests/setup.rs +147 -0
- package/contracts/workers/worker/src/tests/worker.rs +502 -0
- package/contracts/workers/worker/src/worker.rs +28 -30
- package/package.json +8 -5
- package/sdk/.turbo/turbo-build.log +1 -0
- package/sdk/.turbo/turbo-test.log +1009 -0
- package/sdk/dist/generated/bml.d.ts +104 -37
- package/sdk/dist/generated/bml.js +83 -42
- package/sdk/dist/generated/counter.d.ts +334 -175
- package/sdk/dist/generated/counter.js +109 -63
- package/sdk/dist/generated/dvn.d.ts +1985 -0
- package/sdk/dist/generated/dvn.js +326 -0
- package/sdk/dist/generated/dvn_fee_lib.d.ts +690 -0
- package/sdk/dist/generated/dvn_fee_lib.js +163 -0
- package/sdk/dist/generated/endpoint.d.ts +155 -46
- package/sdk/dist/generated/endpoint.js +93 -50
- package/sdk/dist/generated/executor.d.ts +1841 -0
- package/sdk/dist/generated/executor.js +312 -0
- package/sdk/dist/generated/executor_fee_lib.d.ts +1083 -0
- package/sdk/dist/generated/executor_fee_lib.js +255 -0
- package/sdk/dist/generated/executor_helper.d.ts +981 -0
- package/sdk/dist/generated/executor_helper.js +236 -0
- package/sdk/dist/generated/oft_std.d.ts +1722 -0
- package/sdk/dist/generated/oft_std.js +316 -0
- package/sdk/dist/generated/price_feed.d.ts +1077 -0
- package/sdk/dist/generated/price_feed.js +210 -0
- package/sdk/dist/generated/sml.d.ts +171 -56
- package/sdk/dist/generated/sml.js +111 -62
- package/sdk/dist/generated/treasury.d.ts +896 -0
- package/sdk/dist/generated/treasury.js +219 -0
- package/sdk/dist/generated/uln302.d.ts +175 -75
- package/sdk/dist/generated/uln302.js +126 -82
- package/sdk/dist/generated/upgrader.d.ts +70 -0
- package/sdk/dist/generated/upgrader.js +19 -0
- package/sdk/dist/index.d.ts +10 -0
- package/sdk/dist/index.js +14 -0
- package/sdk/dist/wasm/blocked-message-lib.d.ts +1 -0
- package/sdk/dist/wasm/blocked-message-lib.js +2 -0
- package/sdk/dist/wasm/counter.d.ts +1 -0
- package/sdk/dist/wasm/counter.js +2 -0
- package/sdk/dist/wasm/dvn-fee-lib.d.ts +1 -0
- package/sdk/dist/wasm/dvn-fee-lib.js +2 -0
- package/sdk/dist/wasm/dvn.d.ts +1 -0
- package/sdk/dist/wasm/dvn.js +2 -0
- package/sdk/dist/wasm/endpoint-v2.d.ts +1 -0
- package/sdk/dist/wasm/endpoint-v2.js +2 -0
- package/sdk/dist/wasm/executor-fee-lib.d.ts +1 -0
- package/sdk/dist/wasm/executor-fee-lib.js +2 -0
- package/sdk/dist/wasm/executor-helper.d.ts +1 -0
- package/sdk/dist/wasm/executor-helper.js +2 -0
- package/sdk/dist/wasm/executor.d.ts +1 -0
- package/sdk/dist/wasm/executor.js +2 -0
- package/sdk/dist/wasm/layerzero-views.d.ts +1 -0
- package/sdk/dist/wasm/layerzero-views.js +2 -0
- package/sdk/dist/wasm/oft-std.d.ts +1 -0
- package/sdk/dist/wasm/oft-std.js +2 -0
- package/sdk/dist/wasm/price-feed.d.ts +1 -0
- package/sdk/dist/wasm/price-feed.js +2 -0
- package/sdk/dist/wasm/simple-message-lib.d.ts +1 -0
- package/sdk/dist/wasm/simple-message-lib.js +2 -0
- package/sdk/dist/wasm/treasury.d.ts +1 -0
- package/sdk/dist/wasm/treasury.js +2 -0
- package/sdk/dist/wasm/uln302.d.ts +1 -0
- package/sdk/dist/wasm/uln302.js +2 -0
- package/sdk/dist/wasm/upgrader.d.ts +1 -0
- package/sdk/dist/wasm/upgrader.js +2 -0
- package/sdk/dist/wasm.d.ts +15 -0
- package/sdk/dist/wasm.js +15 -0
- package/sdk/package.json +7 -4
- package/sdk/src/index.ts +17 -0
- package/sdk/test/counter-sml.test.ts +376 -0
- package/sdk/test/counter-uln.test.ts +493 -0
- package/sdk/test/{oft.test.ts → oft-sml.test.ts} +187 -323
- package/sdk/test/suites/constants.ts +22 -2
- package/sdk/test/suites/dummyContractClient.ts +169 -0
- package/sdk/test/suites/globalSetup.ts +450 -0
- package/sdk/test/suites/localnet.ts +23 -6
- package/sdk/test/upgrader.test.ts +300 -0
- package/sdk/test/utils.ts +558 -85
- package/sdk/vitest.config.ts +21 -0
- package/tools/ts-bindings-gen/src/main.rs +12 -1
- package/turbo.json +2 -0
- package/contracts/common-macros/src/contract_impl.rs +0 -47
- package/contracts/common-macros/src/ownable.rs +0 -59
- package/contracts/common-macros/src/tests/contract_impl.rs +0 -381
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ownable__snapshot_generated_ownable_code.snap +0 -32
- package/contracts/endpoint-v2/src/tests/messaging_channel/clear.rs +0 -316
- package/contracts/endpoint-v2/src/tests/messaging_channel/internal.rs +0 -388
- package/contracts/message-libs/message-lib-common/src/tests/packet_codec_v1.rs +0 -162
- package/contracts/message-libs/message-lib-common/src/tests/worker_options.rs +0 -319
- package/contracts/oapp-macros/src/lib.rs +0 -154
- package/contracts/oapp-macros/src/oapp_core.rs +0 -40
- package/contracts/oapp-macros/src/oapp_full.rs +0 -21
- package/contracts/oapp-macros/src/oapp_options_type3.rs +0 -31
- package/contracts/oapp-macros/src/oapp_receiver.rs +0 -48
- package/contracts/oapp-macros/src/oapp_sender.rs +0 -21
- package/contracts/oapp-macros/src/util.rs +0 -107
- package/contracts/oapps/oft/src/constants.rs +0 -5
- package/contracts/oapps/oft/src/default_oft_impl.rs +0 -146
- package/contracts/utils/src/tests/ttl.rs +0 -421
- package/contracts/utils/src/ttl.rs +0 -123
- package/contracts/workers/dvn/src/interfaces/multisig.rs +0 -56
- package/contracts/workers/dvn/src/multisig.rs +0 -153
- package/sdk/test/index.test.ts +0 -376
- /package/contracts/{oapp-macros → oapps/oapp-macros}/Cargo.toml +0 -0
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
use crate::{errors::SimpleMessageLibError, storage::SmlStorage};
|
|
2
|
-
use common_macros::{contract_impl,
|
|
2
|
+
use common_macros::{contract_impl, lz_contract, only_auth};
|
|
3
3
|
use endpoint_v2::{
|
|
4
4
|
FeeRecipient, FeesAndPacket, IMessageLib, ISendLib, LayerZeroEndpointV2Client, MessageLibType, MessageLibVersion,
|
|
5
5
|
MessagingFee, Origin, OutboundPacket, SetConfigParam,
|
|
6
6
|
};
|
|
7
7
|
use message_lib_common::packet_codec_v1;
|
|
8
|
-
use soroban_sdk::{address_payload::AddressPayload,
|
|
9
|
-
use utils::ownable::Ownable;
|
|
8
|
+
use soroban_sdk::{address_payload::AddressPayload, panic_with_error, vec, Address, Bytes, BytesN, Env, Vec};
|
|
10
9
|
|
|
11
|
-
#[
|
|
12
|
-
#[ttl_configurable]
|
|
10
|
+
#[lz_contract]
|
|
13
11
|
pub struct SimpleMessageLib;
|
|
14
12
|
|
|
15
13
|
#[contract_impl]
|
|
@@ -43,22 +41,22 @@ impl SimpleMessageLib {
|
|
|
43
41
|
// Admin Manager
|
|
44
42
|
// ============================================================================================
|
|
45
43
|
|
|
46
|
-
#[
|
|
44
|
+
#[only_auth]
|
|
47
45
|
pub fn set_fee_recipient(env: &Env, fee_recipient: &Address) {
|
|
48
46
|
SmlStorage::set_fee_recipient(env, fee_recipient);
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
#[
|
|
49
|
+
#[only_auth]
|
|
52
50
|
pub fn set_native_fee(env: &Env, native_fee: &i128) {
|
|
53
51
|
SmlStorage::set_native_fee(env, native_fee);
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
#[
|
|
54
|
+
#[only_auth]
|
|
57
55
|
pub fn set_zro_fee(env: &Env, zro_fee: &i128) {
|
|
58
56
|
SmlStorage::set_zro_fee(env, zro_fee);
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
#[
|
|
59
|
+
#[only_auth]
|
|
62
60
|
pub fn set_whitelisted_caller(env: &Env, whitelisted_caller: &Address) {
|
|
63
61
|
SmlStorage::set_whitelisted_caller(env, whitelisted_caller);
|
|
64
62
|
}
|
|
@@ -4,8 +4,8 @@ use soroban_sdk::{contractclient, Address, Env};
|
|
|
4
4
|
///
|
|
5
5
|
/// The ZRO token fee library calculates treasury fees when paying in ZRO tokens.
|
|
6
6
|
/// This allows for custom fee calculation logic when users opt to pay fees in ZRO.
|
|
7
|
-
#[contractclient(name = "
|
|
8
|
-
pub trait
|
|
7
|
+
#[contractclient(name = "ZroFeeLibClient")]
|
|
8
|
+
pub trait IZroFeeLib {
|
|
9
9
|
/// Get the treasury fee in ZRO tokens based on the worker fee.
|
|
10
10
|
///
|
|
11
11
|
/// # Arguments
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#![no_std]
|
|
2
2
|
|
|
3
|
+
mod errors;
|
|
4
|
+
pub mod events;
|
|
3
5
|
mod interfaces;
|
|
4
6
|
|
|
7
|
+
pub use errors::*;
|
|
5
8
|
pub use interfaces::*;
|
|
6
9
|
|
|
7
10
|
cfg_if::cfg_if! {
|
|
8
11
|
// Include implementation when NOT in library mode, OR when testutils is enabled (for tests)
|
|
9
12
|
if #[cfg(any(not(feature = "library"), feature = "testutils"))] {
|
|
10
|
-
mod errors;
|
|
11
|
-
mod events;
|
|
12
13
|
mod storage;
|
|
13
14
|
mod treasury;
|
|
14
|
-
|
|
15
15
|
pub use treasury::{Treasury, TreasuryClient};
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -5,13 +5,15 @@ use soroban_sdk::Address;
|
|
|
5
5
|
pub enum TreasuryStorage {
|
|
6
6
|
/// Native fee in basis points (0-10000, where 10000 = 100%)
|
|
7
7
|
#[instance(u32)]
|
|
8
|
+
#[default(0)]
|
|
8
9
|
NativeFeeBp,
|
|
9
10
|
|
|
10
11
|
/// Global toggle for all fee collection
|
|
11
12
|
#[instance(bool)]
|
|
13
|
+
#[default(false)]
|
|
12
14
|
FeeEnabled,
|
|
13
15
|
|
|
14
16
|
/// Address of the ZRO token fee library contract for custom fee calculations
|
|
15
17
|
#[instance(Address)]
|
|
16
|
-
|
|
18
|
+
ZroFeeLib,
|
|
17
19
|
}
|
|
@@ -70,7 +70,7 @@ fn test_get_fee_zro_payment_requires_fee_lib() {
|
|
|
70
70
|
|
|
71
71
|
// Should fail when trying to pay in ZRO without fee lib set
|
|
72
72
|
let result = setup.treasury.try_get_fee(&sender, &dst_eid, &1000, &true);
|
|
73
|
-
assert_eq!(result.err().unwrap().ok().unwrap(), TreasuryError::
|
|
73
|
+
assert_eq!(result.err().unwrap().ok().unwrap(), TreasuryError::ZroFeeLibNotSet.into());
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// ============================================================================
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
use crate::{
|
|
2
2
|
errors::TreasuryError,
|
|
3
|
-
events::{FeeEnabledSet, NativeFeeBpSet, TokenWithdrawn,
|
|
4
|
-
interfaces::
|
|
3
|
+
events::{FeeEnabledSet, NativeFeeBpSet, TokenWithdrawn, ZroFeeLibSet},
|
|
4
|
+
interfaces::ZroFeeLibClient,
|
|
5
5
|
storage::TreasuryStorage,
|
|
6
6
|
};
|
|
7
|
-
use common_macros::{contract_impl,
|
|
7
|
+
use common_macros::{contract_impl, lz_contract, only_auth};
|
|
8
8
|
use message_lib_common::interfaces::ILayerZeroTreasury;
|
|
9
|
-
use soroban_sdk::{assert_with_error,
|
|
9
|
+
use soroban_sdk::{assert_with_error, token::Client, Address, Env};
|
|
10
10
|
use utils::option_ext::OptionExt;
|
|
11
11
|
|
|
12
12
|
/// Denominator for basis point calculations (10000 = 100%).
|
|
13
13
|
const BPS_DENOMINATOR: u32 = 10000;
|
|
14
14
|
|
|
15
|
-
#[
|
|
16
|
-
#[ttl_configurable]
|
|
15
|
+
#[lz_contract]
|
|
17
16
|
pub struct Treasury;
|
|
18
17
|
|
|
19
18
|
#[contract_impl]
|
|
@@ -30,7 +29,7 @@ impl Treasury {
|
|
|
30
29
|
///
|
|
31
30
|
/// # Arguments
|
|
32
31
|
/// * `native_fee_bp` - Fee percentage in basis points (0-10000, where 10000 = 100%)
|
|
33
|
-
#[
|
|
32
|
+
#[only_auth]
|
|
34
33
|
pub fn set_native_fee_bp(env: &Env, native_fee_bp: u32) {
|
|
35
34
|
assert_with_error!(env, native_fee_bp <= BPS_DENOMINATOR, TreasuryError::InvalidNativeFeeBp);
|
|
36
35
|
TreasuryStorage::set_native_fee_bp(env, &native_fee_bp);
|
|
@@ -41,7 +40,7 @@ impl Treasury {
|
|
|
41
40
|
///
|
|
42
41
|
/// # Arguments
|
|
43
42
|
/// * `fee_enabled` - Whether fee collection is enabled
|
|
44
|
-
#[
|
|
43
|
+
#[only_auth]
|
|
45
44
|
pub fn set_fee_enabled(env: &Env, fee_enabled: bool) {
|
|
46
45
|
TreasuryStorage::set_fee_enabled(env, &fee_enabled);
|
|
47
46
|
FeeEnabledSet { fee_enabled }.publish(env);
|
|
@@ -51,10 +50,10 @@ impl Treasury {
|
|
|
51
50
|
///
|
|
52
51
|
/// # Arguments
|
|
53
52
|
/// * `zro_fee_lib` - The ZRO fee library contract address, or `None` to remove
|
|
54
|
-
#[
|
|
53
|
+
#[only_auth]
|
|
55
54
|
pub fn set_zro_fee_lib(env: &Env, zro_fee_lib: &Option<Address>) {
|
|
56
55
|
TreasuryStorage::set_or_remove_zro_fee_lib(env, zro_fee_lib);
|
|
57
|
-
|
|
56
|
+
ZroFeeLibSet { zro_fee_lib: zro_fee_lib.clone() }.publish(env);
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
/// Withdraws any token (including native XLM) from the contract to a specified address.
|
|
@@ -65,11 +64,9 @@ impl Treasury {
|
|
|
65
64
|
/// * `token` - The token contract address (can be native XLM or any other token)
|
|
66
65
|
/// * `to` - The recipient address
|
|
67
66
|
/// * `amount` - The amount to withdraw (must be positive)
|
|
68
|
-
#[
|
|
67
|
+
#[only_auth]
|
|
69
68
|
pub fn withdraw_token(env: &Env, token: &Address, to: &Address, amount: i128) {
|
|
70
|
-
|
|
71
|
-
token_client.transfer(&env.current_contract_address(), to, &amount);
|
|
72
|
-
|
|
69
|
+
Client::new(env, token).transfer(&env.current_contract_address(), to, &amount);
|
|
73
70
|
TokenWithdrawn { token: token.clone(), to: to.clone(), amount }.publish(env);
|
|
74
71
|
}
|
|
75
72
|
|
|
@@ -79,12 +76,12 @@ impl Treasury {
|
|
|
79
76
|
|
|
80
77
|
/// Returns the native fee percentage in basis points.
|
|
81
78
|
pub fn native_fee_bp(env: &Env) -> u32 {
|
|
82
|
-
TreasuryStorage::native_fee_bp(env)
|
|
79
|
+
TreasuryStorage::native_fee_bp(env)
|
|
83
80
|
}
|
|
84
81
|
|
|
85
82
|
/// Returns whether fee collection is enabled.
|
|
86
83
|
pub fn fee_enabled(env: &Env) -> bool {
|
|
87
|
-
TreasuryStorage::fee_enabled(env)
|
|
84
|
+
TreasuryStorage::fee_enabled(env)
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
/// Returns the ZRO fee library address if set.
|
|
@@ -102,9 +99,9 @@ impl Treasury {
|
|
|
102
99
|
}
|
|
103
100
|
|
|
104
101
|
/// Returns the ZRO fee library client, panics if not set.
|
|
105
|
-
fn expect_zro_fee_lib_client(env: &Env) ->
|
|
106
|
-
let fee_lib = Self::zro_fee_lib(env).unwrap_or_panic(env, TreasuryError::
|
|
107
|
-
|
|
102
|
+
fn expect_zro_fee_lib_client(env: &Env) -> ZroFeeLibClient<'static> {
|
|
103
|
+
let fee_lib = Self::zro_fee_lib(env).unwrap_or_panic(env, TreasuryError::ZroFeeLibNotSet);
|
|
104
|
+
ZroFeeLibClient::new(env, &fee_lib)
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
107
|
|
|
@@ -125,13 +122,13 @@ impl ILayerZeroTreasury for Treasury {
|
|
|
125
122
|
}
|
|
126
123
|
|
|
127
124
|
let native_treasury_fee = Self::calculate_native_fee(env, total_native_fee);
|
|
128
|
-
if pay_in_zro {
|
|
129
|
-
|
|
130
|
-
Self::expect_zro_fee_lib_client(env).get_fee(sender, &dst_eid, &total_native_fee, &native_treasury_fee);
|
|
131
|
-
assert_with_error!(env, zro_fee >= 0, TreasuryError::InvalidZROFee);
|
|
132
|
-
zro_fee
|
|
133
|
-
} else {
|
|
134
|
-
native_treasury_fee
|
|
125
|
+
if !pay_in_zro {
|
|
126
|
+
return native_treasury_fee;
|
|
135
127
|
}
|
|
128
|
+
|
|
129
|
+
let zro_fee =
|
|
130
|
+
Self::expect_zro_fee_lib_client(env).get_fee(sender, &dst_eid, &total_native_fee, &native_treasury_fee);
|
|
131
|
+
assert_with_error!(env, zro_fee >= 0, TreasuryError::InvalidZroFee);
|
|
132
|
+
zro_fee
|
|
136
133
|
}
|
|
137
134
|
}
|
|
@@ -15,13 +15,8 @@ pub enum Uln302Error {
|
|
|
15
15
|
InvalidOptionalDVNCount,
|
|
16
16
|
InvalidOptionalDVNs,
|
|
17
17
|
InvalidOptionalDVNThreshold,
|
|
18
|
-
InvalidPacketHeader,
|
|
19
18
|
InvalidRequiredDVNCount,
|
|
20
19
|
InvalidRequiredDVNs,
|
|
21
|
-
OAppExecutorConfigNotFound,
|
|
22
|
-
OAppReceiveUlnConfigNotFound,
|
|
23
|
-
OAppSendUlnConfigNotFound,
|
|
24
|
-
OnlyEndpoint,
|
|
25
20
|
UlnAtLeastOneDVN,
|
|
26
21
|
UnsupportedEid,
|
|
27
22
|
Verifying,
|
|
@@ -17,7 +17,7 @@ pub struct ExecutorConfigSet {
|
|
|
17
17
|
|
|
18
18
|
#[contractevent]
|
|
19
19
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
20
|
-
pub struct
|
|
20
|
+
pub struct SendUlnConfigSet {
|
|
21
21
|
#[topic]
|
|
22
22
|
pub sender: Address,
|
|
23
23
|
#[topic]
|
|
@@ -27,7 +27,7 @@ pub struct UlnSendConfigSet {
|
|
|
27
27
|
|
|
28
28
|
#[contractevent]
|
|
29
29
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
30
|
-
pub struct
|
|
30
|
+
pub struct ReceiveUlnConfigSet {
|
|
31
31
|
#[topic]
|
|
32
32
|
pub receiver: Address,
|
|
33
33
|
#[topic]
|
|
@@ -37,19 +37,19 @@ pub struct UlnReceiveConfigSet {
|
|
|
37
37
|
|
|
38
38
|
#[contractevent]
|
|
39
39
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
40
|
-
pub struct
|
|
40
|
+
pub struct DefaultExecutorConfigsSet {
|
|
41
41
|
pub params: Vec<SetDefaultExecutorConfigParam>,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
#[contractevent]
|
|
45
45
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
46
|
-
pub struct
|
|
46
|
+
pub struct DefaultSendUlnConfigsSet {
|
|
47
47
|
pub params: Vec<SetDefaultUlnConfigParam>,
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
#[contractevent]
|
|
51
51
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
52
|
-
pub struct
|
|
52
|
+
pub struct DefaultReceiveUlnConfigsSet {
|
|
53
53
|
pub params: Vec<SetDefaultUlnConfigParam>,
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -64,7 +64,6 @@ pub struct ExecutorFeePaid {
|
|
|
64
64
|
#[contractevent]
|
|
65
65
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
66
66
|
pub struct DVNFeePaid {
|
|
67
|
-
#[topic]
|
|
68
67
|
pub dvns: Vec<Address>,
|
|
69
68
|
pub fees: Vec<FeeRecipient>,
|
|
70
69
|
}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
use super
|
|
1
|
+
use super::{Uln302, Uln302Args, Uln302Client};
|
|
2
|
+
use crate::{
|
|
3
|
+
errors::Uln302Error,
|
|
4
|
+
events::{DefaultReceiveUlnConfigsSet, PayloadVerified, ReceiveUlnConfigSet},
|
|
5
|
+
interfaces::{IReceiveUln302, OAppUlnConfig, SetDefaultUlnConfigParam, UlnConfig},
|
|
6
|
+
storage::UlnStorage,
|
|
7
|
+
};
|
|
8
|
+
use common_macros::{contract_impl, only_auth};
|
|
9
|
+
use endpoint_v2::{util, LayerZeroEndpointV2Client, Origin};
|
|
10
|
+
use message_lib_common::packet_codec_v1::{self, PacketHeader};
|
|
11
|
+
use soroban_sdk::{address_payload::AddressPayload, assert_with_error, Address, Bytes, BytesN, Env, Vec};
|
|
12
|
+
use utils::option_ext::OptionExt;
|
|
2
13
|
|
|
3
14
|
// ============================================================================================
|
|
4
15
|
// IReceiveUln302 Contract Implementation
|
|
@@ -30,7 +41,8 @@ impl IReceiveUln302 for Uln302 {
|
|
|
30
41
|
/// (all required DVNs + optional DVN threshold). Once verified, cleans up DVN confirmation
|
|
31
42
|
/// storage and calls the endpoint to mark the message as verified and executable.
|
|
32
43
|
fn commit_verification(env: &Env, packet_header: &Bytes, payload_hash: &BytesN<32>) {
|
|
33
|
-
let (header,
|
|
44
|
+
let (header, uln_config) = Self::decode_packet_header_with_config(env, packet_header);
|
|
45
|
+
let header_hash = util::keccak256(env, packet_header);
|
|
34
46
|
|
|
35
47
|
// check if the message is verifiable
|
|
36
48
|
assert_with_error!(
|
|
@@ -45,10 +57,12 @@ impl IReceiveUln302 for Uln302 {
|
|
|
45
57
|
});
|
|
46
58
|
|
|
47
59
|
// commit verification to the endpoint
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
LayerZeroEndpointV2Client::new(env, &Self::endpoint(env)).verify(
|
|
61
|
+
&env.current_contract_address(),
|
|
62
|
+
&Origin { src_eid: header.src_eid, sender: header.sender, nonce: header.nonce },
|
|
63
|
+
&Address::from_payload(env, AddressPayload::ContractIdHash(header.receiver)),
|
|
64
|
+
payload_hash,
|
|
65
|
+
);
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
// ============================================================================================
|
|
@@ -58,14 +72,13 @@ impl IReceiveUln302 for Uln302 {
|
|
|
58
72
|
/// Sets default receive ULN configurations for multiple source endpoints.
|
|
59
73
|
///
|
|
60
74
|
/// Validates each config and stores it as the default for the specified source EID.
|
|
61
|
-
#[
|
|
75
|
+
#[only_auth]
|
|
62
76
|
fn set_default_receive_uln_configs(env: &Env, params: &Vec<SetDefaultUlnConfigParam>) {
|
|
63
77
|
for param in params {
|
|
64
78
|
param.config.validate_default_config(env);
|
|
65
79
|
UlnStorage::set_default_receive_uln_configs(env, param.eid, ¶m.config);
|
|
66
80
|
}
|
|
67
|
-
|
|
68
|
-
DefaultUlnReceiveConfigSet { params: params.clone() }.publish(env);
|
|
81
|
+
DefaultReceiveUlnConfigsSet { params: params.clone() }.publish(env);
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
// ============================================================================================
|
|
@@ -79,8 +92,8 @@ impl IReceiveUln302 for Uln302 {
|
|
|
79
92
|
|
|
80
93
|
/// Checks if a message has been sufficiently verified by DVNs and is ready to commit.
|
|
81
94
|
fn verifiable(env: &Env, packet_header: &Bytes, payload_hash: &BytesN<32>) -> bool {
|
|
82
|
-
let (_,
|
|
83
|
-
Self::verifiable_internal(env, &uln_config, &
|
|
95
|
+
let (_, uln_config) = Self::decode_packet_header_with_config(env, packet_header);
|
|
96
|
+
Self::verifiable_internal(env, &uln_config, &util::keccak256(env, packet_header), payload_hash)
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
/// Returns the default receive ULN configuration for a source endpoint.
|
|
@@ -95,13 +108,14 @@ impl IReceiveUln302 for Uln302 {
|
|
|
95
108
|
|
|
96
109
|
/// Returns the effective receive ULN configuration by merging OApp config with defaults.
|
|
97
110
|
fn effective_receive_uln_config(env: &Env, receiver: &Address, src_eid: u32) -> UlnConfig {
|
|
98
|
-
let default_config = Self::
|
|
111
|
+
let default_config = Self::default_receive_uln_config(env, src_eid)
|
|
112
|
+
.unwrap_or_panic(env, Uln302Error::DefaultReceiveUlnConfigNotFound);
|
|
99
113
|
let oapp_config = Self::oapp_receive_uln_config(env, receiver, src_eid).unwrap_or(OAppUlnConfig::default(env));
|
|
100
114
|
|
|
101
|
-
let
|
|
102
|
-
|
|
115
|
+
let effective_config = oapp_config.apply_default_config(&default_config);
|
|
116
|
+
effective_config.validate_at_least_one_dvn(env); // validate the final config
|
|
103
117
|
|
|
104
|
-
|
|
118
|
+
effective_config
|
|
105
119
|
}
|
|
106
120
|
}
|
|
107
121
|
|
|
@@ -112,12 +126,6 @@ impl IReceiveUln302 for Uln302 {
|
|
|
112
126
|
impl Uln302 {
|
|
113
127
|
/// Sets OApp-specific receive ULN config.
|
|
114
128
|
///
|
|
115
|
-
/// # Arguments
|
|
116
|
-
/// * `receiver` - The receiver OApp address
|
|
117
|
-
/// * `src_eid` - The source endpoint ID
|
|
118
|
-
/// * `config` - The OApp-specific receive ULN configuration
|
|
119
|
-
///
|
|
120
|
-
/// # Panics
|
|
121
129
|
/// Panics if the final effective config is invalid.
|
|
122
130
|
pub(super) fn set_receive_uln_config(env: &Env, receiver: &Address, src_eid: u32, config: &OAppUlnConfig) {
|
|
123
131
|
config.validate_oapp_config(env);
|
|
@@ -126,15 +134,15 @@ impl Uln302 {
|
|
|
126
134
|
// validate the config by getting the effective config
|
|
127
135
|
let _ = Self::effective_receive_uln_config(env, receiver, src_eid);
|
|
128
136
|
|
|
129
|
-
|
|
137
|
+
ReceiveUlnConfigSet { receiver: receiver.clone(), src_eid, config: config.clone() }.publish(env);
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
// ============================================================================================
|
|
133
141
|
// Verification Helpers Functions
|
|
134
142
|
// ============================================================================================
|
|
135
143
|
|
|
136
|
-
///
|
|
137
|
-
fn
|
|
144
|
+
/// Decodes packet header and returns header and effective ULN config.
|
|
145
|
+
fn decode_packet_header_with_config(env: &Env, packet_header: &Bytes) -> (PacketHeader, UlnConfig) {
|
|
138
146
|
let header = packet_codec_v1::decode_packet_header(env, packet_header);
|
|
139
147
|
assert_with_error!(
|
|
140
148
|
env,
|
|
@@ -142,25 +150,15 @@ impl Uln302 {
|
|
|
142
150
|
Uln302Error::InvalidEID
|
|
143
151
|
);
|
|
144
152
|
|
|
145
|
-
let
|
|
146
|
-
let uln_config = Self::effective_receive_uln_config(
|
|
147
|
-
env,
|
|
148
|
-
&Address::from_payload(env, AddressPayload::ContractIdHash(header.receiver.clone())),
|
|
149
|
-
header.src_eid,
|
|
150
|
-
);
|
|
153
|
+
let receiver = Address::from_payload(env, AddressPayload::ContractIdHash(header.receiver.clone()));
|
|
154
|
+
let uln_config = Self::effective_receive_uln_config(env, &receiver, header.src_eid);
|
|
151
155
|
|
|
152
|
-
(header,
|
|
156
|
+
(header, uln_config)
|
|
153
157
|
}
|
|
154
158
|
|
|
155
159
|
/// Checks if all required DVNs verified and optional DVN threshold is met.
|
|
156
160
|
///
|
|
157
|
-
///
|
|
158
|
-
/// * `uln_config` - The effective ULN configuration
|
|
159
|
-
/// * `header_hash` - The hash of the packet header
|
|
160
|
-
/// * `payload_hash` - The hash of the message payload
|
|
161
|
-
///
|
|
162
|
-
/// # Returns
|
|
163
|
-
/// True if the message has been verified by enough DVNs to be committed, false otherwise
|
|
161
|
+
/// Returns true if the message has been verified by enough DVNs to be committed, false otherwise
|
|
164
162
|
fn verifiable_internal(
|
|
165
163
|
env: &Env,
|
|
166
164
|
uln_config: &UlnConfig,
|
|
@@ -177,14 +175,7 @@ impl Uln302 {
|
|
|
177
175
|
|
|
178
176
|
/// Checks if a DVN has submitted enough confirmations for the message.
|
|
179
177
|
///
|
|
180
|
-
///
|
|
181
|
-
/// * `dvn` - The DVN address
|
|
182
|
-
/// * `header_hash` - The hash of the packet header
|
|
183
|
-
/// * `payload_hash` - The hash of the message payload
|
|
184
|
-
/// * `confirmations` - The number of block confirmations the DVN has observed
|
|
185
|
-
///
|
|
186
|
-
/// # Returns
|
|
187
|
-
/// True if the DVN has submitted enough confirmations for the message, false otherwise
|
|
178
|
+
/// Returns true if the DVN has submitted enough confirmations for the message, false otherwise
|
|
188
179
|
fn verified(
|
|
189
180
|
env: &Env,
|
|
190
181
|
dvn: &Address,
|
|
@@ -194,14 +185,4 @@ impl Uln302 {
|
|
|
194
185
|
) -> bool {
|
|
195
186
|
Self::confirmations(env, dvn, header_hash, payload_hash).map(|c| c >= confirmations).unwrap_or(false)
|
|
196
187
|
}
|
|
197
|
-
|
|
198
|
-
// ============================================================================================
|
|
199
|
-
// Helper Functions
|
|
200
|
-
// ============================================================================================
|
|
201
|
-
|
|
202
|
-
/// Returns default receive ULN config or panics if not found.
|
|
203
|
-
fn expect_default_receive_uln_config(env: &Env, src_eid: u32) -> UlnConfig {
|
|
204
|
-
Self::default_receive_uln_config(env, src_eid)
|
|
205
|
-
.unwrap_or_panic(env, Uln302Error::DefaultReceiveUlnConfigNotFound)
|
|
206
|
-
}
|
|
207
188
|
}
|