@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,49 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
source: contracts/common-macros/src/tests/ttl_configurable.rs
|
|
3
|
-
assertion_line: 20
|
|
4
3
|
expression: formatted
|
|
5
4
|
---
|
|
6
|
-
#[common_macros::ownable]
|
|
7
5
|
pub struct MyContract {
|
|
8
6
|
some_field: u32,
|
|
9
7
|
}
|
|
10
|
-
use utils::
|
|
11
|
-
#[
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
persistent: &Option<utils::ttl::TtlConfig>,
|
|
18
|
-
) {
|
|
19
|
-
utils::ttl::DefaultTtlConfigurable::set_ttl_configs(env, instance, persistent);
|
|
20
|
-
}
|
|
21
|
-
fn ttl_configs(
|
|
22
|
-
env: &soroban_sdk::Env,
|
|
23
|
-
) -> (Option<utils::ttl::TtlConfig>, Option<utils::ttl::TtlConfig>) {
|
|
24
|
-
utils::ttl::DefaultTtlConfigurable::ttl_configs(env)
|
|
25
|
-
}
|
|
26
|
-
#[common_macros::only_owner]
|
|
27
|
-
fn freeze_ttl_configs(env: &soroban_sdk::Env) {
|
|
28
|
-
utils::ttl::DefaultTtlConfigurable::freeze_ttl_configs(env);
|
|
29
|
-
}
|
|
30
|
-
fn is_ttl_configs_frozen(env: &soroban_sdk::Env) -> bool {
|
|
31
|
-
utils::ttl::DefaultTtlConfigurable::is_ttl_configs_frozen(env)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/// Uses `soroban_sdk::contractimpl` directly instead of `common_macros::contract_impl`
|
|
35
|
-
/// because `contract_impl` automatically extends TTL on every invocation. Since this
|
|
36
|
-
/// impl block provides manual TTL extension control, auto-extension would be redundant
|
|
37
|
-
/// and could mask the intended behavior of `extend_instance_ttl`.
|
|
38
|
-
#[soroban_sdk::contractimpl]
|
|
39
|
-
impl MyContract {
|
|
40
|
-
/// Extends the instance TTL.
|
|
41
|
-
///
|
|
42
|
-
/// # Arguments
|
|
43
|
-
///
|
|
44
|
-
/// * `threshold` - The threshold to extend the TTL.
|
|
45
|
-
/// * `extend_to` - The TTL to extend to.
|
|
46
|
-
pub fn extend_instance_ttl(env: &soroban_sdk::Env, threshold: u32, extend_to: u32) {
|
|
47
|
-
env.storage().instance().extend_ttl(threshold, extend_to);
|
|
48
|
-
}
|
|
8
|
+
use utils::ttl_configurable::TtlConfigurable as _;
|
|
9
|
+
#[doc(hidden)]
|
|
10
|
+
mod __ttl_configurable_impl_my_contract {
|
|
11
|
+
use super::*;
|
|
12
|
+
use utils::ttl_configurable::{TtlConfig, TtlConfigurable};
|
|
13
|
+
#[common_macros::contract_impl(contracttrait)]
|
|
14
|
+
impl TtlConfigurable for MyContract {}
|
|
49
15
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: contracts/common-macros/src/tests/upgradeable.rs
|
|
3
|
+
assertion_line: 17
|
|
4
|
+
expression: formatted
|
|
5
|
+
---
|
|
6
|
+
pub struct MyContract;
|
|
7
|
+
use utils::upgradeable::Upgradeable as _;
|
|
8
|
+
soroban_sdk::contractmeta!(key = "binver", val = "0.0.1");
|
|
9
|
+
type MigrationData = <MyContract as utils::upgradeable::UpgradeableInternal>::MigrationData;
|
|
10
|
+
/// Implement the Upgradeable trait for the contract.
|
|
11
|
+
#[common_macros::contract_impl]
|
|
12
|
+
impl utils::upgradeable::Upgradeable for MyContract {
|
|
13
|
+
#[common_macros::only_auth]
|
|
14
|
+
fn upgrade(env: &soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>) {
|
|
15
|
+
utils::upgradeable::upgrade(env, new_wasm_hash)
|
|
16
|
+
}
|
|
17
|
+
#[common_macros::only_auth]
|
|
18
|
+
fn migrate(env: &soroban_sdk::Env, migration_data: &MigrationData) {
|
|
19
|
+
utils::upgradeable::migrate::<Self>(env, migration_data)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
use quote::quote;
|
|
2
|
+
|
|
3
|
+
use crate::tests::test_helpers::{assert_panics_contains, non_struct_item_inputs};
|
|
4
|
+
|
|
5
|
+
// ============================================
|
|
6
|
+
// Snapshot Test: Upgradeable Code Generation
|
|
7
|
+
// ============================================
|
|
8
|
+
|
|
9
|
+
#[test]
|
|
10
|
+
fn snapshot_generated_upgradeable_code() {
|
|
11
|
+
let input = quote! {
|
|
12
|
+
pub struct MyContract;
|
|
13
|
+
};
|
|
14
|
+
let result = crate::upgradeable::generate_upgradeable_impl(input);
|
|
15
|
+
let formatted = prettyplease::unparse(&syn::parse2::<syn::File>(result).expect("failed to parse generated code"));
|
|
16
|
+
|
|
17
|
+
insta::assert_snapshot!(formatted);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ============================================
|
|
21
|
+
// Error Cases: upgradeable macro non-struct input
|
|
22
|
+
// ============================================
|
|
23
|
+
|
|
24
|
+
#[test]
|
|
25
|
+
fn test_upgradeable_rejects_non_struct_inputs() {
|
|
26
|
+
for (case, input) in non_struct_item_inputs() {
|
|
27
|
+
assert_panics_contains(case, "failed to parse struct", || {
|
|
28
|
+
crate::upgradeable::generate_upgradeable_impl(input.clone());
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,80 +1,35 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//!
|
|
3
|
-
//! Generates a complete contract setup with:
|
|
4
|
-
//! - `#[contract]` attribute
|
|
5
|
-
//! - Ownable trait implementation
|
|
6
|
-
//! - TtlConfigurable trait implementation with owner auth checks
|
|
1
|
+
//! TtlConfigurable macro for Stellar smart contracts.
|
|
7
2
|
|
|
3
|
+
use crate::utils;
|
|
8
4
|
use proc_macro2::TokenStream;
|
|
9
5
|
use quote::quote;
|
|
6
|
+
use syn::ItemStruct;
|
|
10
7
|
|
|
11
|
-
/// Generates the TtlConfigurable trait implementation for a contract.
|
|
8
|
+
/// Generates the `TtlConfigurable` trait implementation for a contract.
|
|
12
9
|
///
|
|
13
|
-
///
|
|
14
|
-
///
|
|
10
|
+
/// This macro implements `TtlConfigurable` using the trait's default methods (which include auth).
|
|
11
|
+
///
|
|
12
|
+
/// The contract must also implement `Auth` (typically via `#[ownable]` or `Multisig`).
|
|
13
|
+
///
|
|
14
|
+
/// For manual TTL extension functionality, use the `#[ttl_extendable]` macro which provides
|
|
15
|
+
/// the `extend_instance_ttl` function.
|
|
15
16
|
pub fn generate_ttl_configurable_impl(input: TokenStream) -> TokenStream {
|
|
16
|
-
let item_struct:
|
|
17
|
+
let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
|
|
17
18
|
let name = &item_struct.ident;
|
|
19
|
+
let impl_mod = utils::impl_mod_ident(name, "ttl_configurable");
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
#[common_macros::contract_impl]
|
|
23
|
-
impl utils::ttl::TtlConfigurable for #name {
|
|
24
|
-
|
|
25
|
-
#[common_macros::only_owner]
|
|
26
|
-
fn set_ttl_configs(
|
|
27
|
-
env: &soroban_sdk::Env,
|
|
28
|
-
instance: &Option<utils::ttl::TtlConfig>,
|
|
29
|
-
persistent: &Option<utils::ttl::TtlConfig>,
|
|
30
|
-
) {
|
|
31
|
-
utils::ttl::DefaultTtlConfigurable::set_ttl_configs(env, instance, persistent);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
fn ttl_configs(
|
|
35
|
-
env: &soroban_sdk::Env,
|
|
36
|
-
) -> (
|
|
37
|
-
Option<utils::ttl::TtlConfig>,
|
|
38
|
-
Option<utils::ttl::TtlConfig>,
|
|
39
|
-
) {
|
|
40
|
-
utils::ttl::DefaultTtlConfigurable::ttl_configs(env)
|
|
41
|
-
}
|
|
21
|
+
quote! {
|
|
22
|
+
#item_struct
|
|
42
23
|
|
|
43
|
-
|
|
44
|
-
fn freeze_ttl_configs(env: &soroban_sdk::Env) {
|
|
45
|
-
utils::ttl::DefaultTtlConfigurable::freeze_ttl_configs(env);
|
|
46
|
-
}
|
|
24
|
+
use utils::ttl_configurable::TtlConfigurable as _;
|
|
47
25
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
26
|
+
#[doc(hidden)]
|
|
27
|
+
mod #impl_mod {
|
|
28
|
+
use super::*;
|
|
29
|
+
use utils::ttl_configurable::{TtlConfig, TtlConfigurable};
|
|
53
30
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/// because `contract_impl` automatically extends TTL on every invocation. Since this
|
|
57
|
-
/// impl block provides manual TTL extension control, auto-extension would be redundant
|
|
58
|
-
/// and could mask the intended behavior of `extend_instance_ttl`.
|
|
59
|
-
#[soroban_sdk::contractimpl]
|
|
60
|
-
impl #name {
|
|
61
|
-
/// Extends the instance TTL.
|
|
62
|
-
///
|
|
63
|
-
/// # Arguments
|
|
64
|
-
///
|
|
65
|
-
/// * `threshold` - The threshold to extend the TTL.
|
|
66
|
-
/// * `extend_to` - The TTL to extend to.
|
|
67
|
-
pub fn extend_instance_ttl(env: &soroban_sdk::Env, threshold: u32, extend_to: u32) {
|
|
68
|
-
env.storage().instance().extend_ttl(threshold, extend_to);
|
|
69
|
-
}
|
|
31
|
+
#[common_macros::contract_impl(contracttrait)]
|
|
32
|
+
impl TtlConfigurable for #name {}
|
|
70
33
|
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
quote! {
|
|
74
|
-
#[common_macros::ownable]
|
|
75
|
-
#item_struct
|
|
76
|
-
|
|
77
|
-
#expanded
|
|
78
|
-
#inherent_impl
|
|
79
34
|
}
|
|
80
35
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//! TtlExtendable macro for Stellar smart contracts.
|
|
2
|
+
|
|
3
|
+
use crate::utils;
|
|
4
|
+
use proc_macro2::TokenStream;
|
|
5
|
+
use quote::quote;
|
|
6
|
+
use syn::ItemStruct;
|
|
7
|
+
|
|
8
|
+
/// Generates the TtlExtendable trait implementation from the `#[ttl_extendable]` attribute macro.
|
|
9
|
+
///
|
|
10
|
+
/// This macro implements the `TtlExtendable` trait for a contract struct,
|
|
11
|
+
/// providing a public `extend_instance_ttl` function for manual TTL extension.
|
|
12
|
+
///
|
|
13
|
+
/// Uses `soroban_sdk::contractimpl` directly instead of `common_macros::contract_impl`
|
|
14
|
+
/// because `contract_impl` automatically extends TTL on every invocation. Since this
|
|
15
|
+
/// impl block provides manual TTL extension control, auto-extension would be redundant
|
|
16
|
+
/// and could mask the intended behavior of `extend_instance_ttl`.
|
|
17
|
+
pub fn generate_ttl_extendable_impl(input: TokenStream) -> TokenStream {
|
|
18
|
+
let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
|
|
19
|
+
let name = &item_struct.ident;
|
|
20
|
+
let impl_mod = utils::impl_mod_ident(name, "ttl_extendable");
|
|
21
|
+
|
|
22
|
+
quote! {
|
|
23
|
+
#item_struct
|
|
24
|
+
|
|
25
|
+
use utils::ttl_extendable::TtlExtendable as _;
|
|
26
|
+
|
|
27
|
+
#[doc(hidden)]
|
|
28
|
+
mod #impl_mod {
|
|
29
|
+
use super::*;
|
|
30
|
+
use utils::ttl_extendable::TtlExtendable;
|
|
31
|
+
|
|
32
|
+
#[soroban_sdk::contractimpl(contracttrait)]
|
|
33
|
+
impl TtlExtendable for #name {}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
use proc_macro2::TokenStream;
|
|
2
|
+
use quote::quote;
|
|
3
|
+
use syn::ItemStruct;
|
|
4
|
+
|
|
5
|
+
/// Generates the upgradeable implementation from the `#[upgradeable]` attribute macro.
|
|
6
|
+
///
|
|
7
|
+
/// This function generates the implementation of the `Upgradeable` trait for a
|
|
8
|
+
/// given contract type, enabling the contract to be upgraded by replacing its
|
|
9
|
+
/// WASM bytecode with migration support.
|
|
10
|
+
///
|
|
11
|
+
/// # Behavior
|
|
12
|
+
///
|
|
13
|
+
/// - Implements the `upgrade` and `migrate` functions with auth-based access control.
|
|
14
|
+
/// - Sets the contract crate version as `"binver"` metadata using
|
|
15
|
+
/// `soroban_sdk::contractmeta!`. Gets the crate version via the env variable
|
|
16
|
+
/// `CARGO_PKG_VERSION` which corresponds to the "version" attribute in
|
|
17
|
+
/// Cargo.toml. If no such attribute or if it is "0.0.0", skips this step.
|
|
18
|
+
/// - Requires the contract to implement `Auth` and `UpgradeableInternal` traits.
|
|
19
|
+
///
|
|
20
|
+
/// # Example
|
|
21
|
+
/// ```ignore
|
|
22
|
+
/// #[ownable] // or implement Multisig for self-owning contracts
|
|
23
|
+
/// #[upgradeable]
|
|
24
|
+
/// pub struct MyContract;
|
|
25
|
+
/// ```
|
|
26
|
+
pub fn generate_upgradeable_impl(input: TokenStream) -> TokenStream {
|
|
27
|
+
let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
|
|
28
|
+
let name = &item_struct.ident;
|
|
29
|
+
|
|
30
|
+
let binver = set_binver_from_env();
|
|
31
|
+
|
|
32
|
+
let upgradeable_impl = quote! {
|
|
33
|
+
use utils::upgradeable::Upgradeable as _;
|
|
34
|
+
|
|
35
|
+
#binver
|
|
36
|
+
|
|
37
|
+
// Type alias to avoid path complexity in contractimpl
|
|
38
|
+
type MigrationData = <#name as utils::upgradeable::UpgradeableInternal>::MigrationData;
|
|
39
|
+
|
|
40
|
+
/// Implement the Upgradeable trait for the contract.
|
|
41
|
+
#[common_macros::contract_impl]
|
|
42
|
+
impl utils::upgradeable::Upgradeable for #name {
|
|
43
|
+
#[common_macros::only_auth]
|
|
44
|
+
fn upgrade(env: &soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>) {
|
|
45
|
+
utils::upgradeable::upgrade(env, new_wasm_hash)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[common_macros::only_auth]
|
|
49
|
+
fn migrate(env: &soroban_sdk::Env, migration_data: &MigrationData) {
|
|
50
|
+
utils::upgradeable::migrate::<Self>(env, migration_data)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
quote! {
|
|
56
|
+
#item_struct
|
|
57
|
+
#upgradeable_impl
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Sets the value of the environment variable `CARGO_PKG_VERSION` as `binver`
|
|
62
|
+
/// in the wasm binary metadata. This env variable corresponds to the attribute
|
|
63
|
+
/// "version" in Cargo.toml. If the attribute is missing or if it is "0.0.0",
|
|
64
|
+
/// the function does nothing.
|
|
65
|
+
fn set_binver_from_env() -> TokenStream {
|
|
66
|
+
// However when "version" is missing from Cargo.toml,
|
|
67
|
+
// the following does not return error, but Ok("0.0.0")
|
|
68
|
+
let version = std::env::var("CARGO_PKG_VERSION");
|
|
69
|
+
|
|
70
|
+
match version {
|
|
71
|
+
Ok(v) if v != "0.0.0" => {
|
|
72
|
+
quote! { soroban_sdk::contractmeta!(key = "binver", val = #v); }
|
|
73
|
+
}
|
|
74
|
+
_ => quote! {},
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
use heck::ToSnakeCase;
|
|
1
2
|
use proc_macro2::TokenStream;
|
|
2
3
|
use quote::quote;
|
|
3
4
|
use syn::{punctuated::Punctuated, token::Comma, FnArg, Ident, Pat, Type, TypePath};
|
|
@@ -54,3 +55,11 @@ pub fn is_env_type(ty: &Type) -> bool {
|
|
|
54
55
|
fn is_reference_type(ty: &Type) -> bool {
|
|
55
56
|
matches!(ty, Type::Reference(_))
|
|
56
57
|
}
|
|
58
|
+
|
|
59
|
+
/// Creates a unique hidden module identifier for trait implementations.
|
|
60
|
+
///
|
|
61
|
+
/// Generates a module name in the format `__{trait_name}_impl_{struct_name}` to avoid
|
|
62
|
+
/// name collisions when multiple traits are implemented for the same struct.
|
|
63
|
+
pub fn impl_mod_ident(struct_name: &Ident, trait_name: &str) -> Ident {
|
|
64
|
+
Ident::new(&format!("__{}_impl_{}", trait_name, struct_name.to_string().to_snake_case()), struct_name.span())
|
|
65
|
+
}
|
|
@@ -7,7 +7,7 @@ cfg_if::cfg_if! {
|
|
|
7
7
|
if #[cfg(any(test, feature = "testutils"))] {
|
|
8
8
|
/// Stellar Endpoint ID for unit test environment.
|
|
9
9
|
/// TODO: This is a placeholder value for testing purposes.
|
|
10
|
-
pub const STELLAR_EID: u32 =
|
|
10
|
+
pub const STELLAR_EID: u32 = 30400;
|
|
11
11
|
|
|
12
12
|
/// Native token address for unit test environment.
|
|
13
13
|
pub const NATIVE_TOKEN: &str = "CBEPDNVYXQGWB5YUBXKJWYJA7OXTZW5LFLNO5JRRGE6Z6C5OSUZPCCEL";
|
|
@@ -15,7 +15,7 @@ cfg_if::cfg_if! {
|
|
|
15
15
|
} else if #[cfg(feature = "testnet")] {
|
|
16
16
|
/// Stellar Endpoint ID for testnet environment.
|
|
17
17
|
/// TODO: Confirm this EID value with LayerZero before testnet deployment.
|
|
18
|
-
pub const STELLAR_EID: u32 =
|
|
18
|
+
pub const STELLAR_EID: u32 = 20400;
|
|
19
19
|
|
|
20
20
|
/// Native token address for testnet (Stellar testnet XLM wrapper).
|
|
21
21
|
pub const NATIVE_TOKEN: &str = "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC";
|
|
@@ -23,7 +23,7 @@ cfg_if::cfg_if! {
|
|
|
23
23
|
} else if #[cfg(feature = "sandbox")] {
|
|
24
24
|
/// Stellar Endpoint ID for sandbox environment.
|
|
25
25
|
/// TODO: Confirm this EID value with LayerZero before sandbox deployment.
|
|
26
|
-
pub const STELLAR_EID: u32 =
|
|
26
|
+
pub const STELLAR_EID: u32 = 30400;
|
|
27
27
|
|
|
28
28
|
/// Native token address for sandbox environment.
|
|
29
29
|
pub const NATIVE_TOKEN: &str = "CDMLFMKMMD7MWZP3FKUBZPVHTUEDLSX4BYGYKH4GCESXYHS3IHQ4EIG4";
|
|
@@ -31,7 +31,7 @@ cfg_if::cfg_if! {
|
|
|
31
31
|
} else {
|
|
32
32
|
/// Stellar Endpoint ID for mainnet environment.
|
|
33
33
|
/// TODO: Confirm this EID value with LayerZero before mainnet deployment.
|
|
34
|
-
pub const STELLAR_EID: u32 =
|
|
34
|
+
pub const STELLAR_EID: u32 = 30400;
|
|
35
35
|
|
|
36
36
|
/// Native token address for mainnet (Stellar mainnet XLM wrapper).
|
|
37
37
|
pub const NATIVE_TOKEN: &str = "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA";
|
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
constants::{
|
|
3
|
-
EMPTY_PAYLOAD_HASH_BYTES, MAX_COMPOSE_INDEX, NATIVE_TOKEN, NIL_PAYLOAD_HASH_BYTES, RECEIVED_MESSAGE_HASH_BYTES,
|
|
4
|
-
STELLAR_EID,
|
|
5
|
-
},
|
|
2
|
+
constants::{NATIVE_TOKEN, STELLAR_EID},
|
|
6
3
|
errors::EndpointError,
|
|
7
|
-
events::{
|
|
8
|
-
ComposeDelivered, ComposeSent, DefaultReceiveLibTimeoutSet, DefaultReceiveLibrarySet, DefaultSendLibrarySet,
|
|
9
|
-
DelegateSet, InboundNonceSkipped, LibraryRegistered, LzComposeAlert, LzReceiveAlert, PacketBurnt,
|
|
10
|
-
PacketDelivered, PacketNilified, PacketSent, PacketVerified, ReceiveLibrarySet, ReceiveLibraryTimeoutSet,
|
|
11
|
-
SendLibrarySet, ZROSet,
|
|
12
|
-
},
|
|
4
|
+
events::{DelegateSet, LzReceiveAlert, PacketDelivered, PacketSent, PacketVerified, ZroSet},
|
|
13
5
|
interfaces::{ILayerZeroEndpointV2, IMessageLibManager, IMessagingChannel, MessagingFee, MessagingReceipt, Origin},
|
|
14
6
|
storage::EndpointStorage,
|
|
15
|
-
util::{build_payload, compute_guid
|
|
16
|
-
FeeRecipient, FeesAndPacket,
|
|
17
|
-
|
|
7
|
+
util::{build_payload, compute_guid},
|
|
8
|
+
FeeRecipient, FeesAndPacket, LayerZeroReceiverClient, MessagingParams, OutboundPacket, ResolvedLibrary,
|
|
9
|
+
SendLibClient,
|
|
18
10
|
};
|
|
19
|
-
use common_macros::{contract_impl,
|
|
20
|
-
use soroban_sdk::{assert_with_error,
|
|
11
|
+
use common_macros::{contract_impl, lz_contract, only_auth};
|
|
12
|
+
use soroban_sdk::{assert_with_error, token::TokenClient, Address, Bytes, BytesN, Env, Vec};
|
|
21
13
|
use utils::option_ext::OptionExt;
|
|
22
14
|
|
|
23
|
-
#[
|
|
24
|
-
#[ttl_configurable]
|
|
15
|
+
#[lz_contract]
|
|
25
16
|
pub struct EndpointV2;
|
|
26
17
|
|
|
27
18
|
#[contract_impl]
|
|
@@ -36,7 +27,7 @@ impl EndpointV2 {
|
|
|
36
27
|
/// * `token` - The token address to recover
|
|
37
28
|
/// * `to` - The address to send the token to
|
|
38
29
|
/// * `amount` - The amount to send
|
|
39
|
-
#[
|
|
30
|
+
#[only_auth]
|
|
40
31
|
pub fn recover_token(env: &Env, token: &Address, to: &Address, amount: i128) {
|
|
41
32
|
TokenClient::new(env, token).transfer(&env.current_contract_address(), to, &amount);
|
|
42
33
|
}
|
|
@@ -50,7 +41,7 @@ impl EndpointV2 {
|
|
|
50
41
|
impl ILayerZeroEndpointV2 for EndpointV2 {
|
|
51
42
|
/// Quotes the messaging fee for sending a cross-chain message.
|
|
52
43
|
fn quote(env: &Env, sender: &Address, params: &MessagingParams) -> MessagingFee {
|
|
53
|
-
assert_with_error!(env, !params.pay_in_zro || EndpointStorage::has_zro(env), EndpointError::
|
|
44
|
+
assert_with_error!(env, !params.pay_in_zro || EndpointStorage::has_zro(env), EndpointError::ZroUnavailable);
|
|
54
45
|
|
|
55
46
|
let MessagingParams { dst_eid, receiver, message, options, pay_in_zro } = params;
|
|
56
47
|
let ResolvedLibrary { lib: send_lib, .. } = Self::get_send_library(env, sender, *dst_eid);
|
|
@@ -66,7 +57,7 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
|
|
|
66
57
|
/// OApp sender needs to transfer the fees to the endpoint before sending the message
|
|
67
58
|
fn send(env: &Env, sender: &Address, params: &MessagingParams, refund_address: &Address) -> MessagingReceipt {
|
|
68
59
|
sender.require_auth();
|
|
69
|
-
assert_with_error!(env, !params.pay_in_zro || EndpointStorage::has_zro(env), EndpointError::
|
|
60
|
+
assert_with_error!(env, !params.pay_in_zro || EndpointStorage::has_zro(env), EndpointError::ZroUnavailable);
|
|
70
61
|
|
|
71
62
|
let MessagingParams { dst_eid, receiver, message, options, pay_in_zro } = params;
|
|
72
63
|
let ResolvedLibrary { lib: send_library, .. } = Self::get_send_library(env, sender, *dst_eid);
|
|
@@ -146,10 +137,10 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
|
|
|
146
137
|
}
|
|
147
138
|
|
|
148
139
|
/// Sets the ZRO token address for fee payments.
|
|
149
|
-
#[
|
|
140
|
+
#[only_auth]
|
|
150
141
|
fn set_zro(env: &Env, zro: &Address) {
|
|
151
142
|
EndpointStorage::set_zro(env, zro);
|
|
152
|
-
|
|
143
|
+
ZroSet { zro: zro.clone() }.publish(env);
|
|
153
144
|
}
|
|
154
145
|
|
|
155
146
|
/// Sets or removes a delegate address that can act on behalf of the OApp.
|
|
@@ -257,11 +248,17 @@ impl EndpointV2 {
|
|
|
257
248
|
// Pay native fees
|
|
258
249
|
let native_token_client = TokenClient::new(env, &Self::native_token(env));
|
|
259
250
|
let mut native_fee_supplied = native_token_client.balance(&this_contract);
|
|
260
|
-
native_fee_recipients.iter().
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
251
|
+
native_fee_recipients.iter().for_each(|r| {
|
|
252
|
+
// Fee amounts are modeled as non-negative values. The field type is i128 for
|
|
253
|
+
// compatibility with token APIs, but negative fees are always invalid and rejected
|
|
254
|
+
// here, while zero amounts are treated as a no-op (skipped by the check below).
|
|
255
|
+
assert_with_error!(env, r.amount >= 0, EndpointError::InvalidFeeAmount);
|
|
256
|
+
if r.amount > 0 {
|
|
257
|
+
assert_with_error!(env, native_fee_supplied >= r.amount, EndpointError::InsufficientNativeFee);
|
|
258
|
+
native_token_client.transfer(&this_contract, &r.to, &r.amount);
|
|
259
|
+
native_fee_supplied -= r.amount;
|
|
260
|
+
fee_paid.native_fee += r.amount;
|
|
261
|
+
}
|
|
265
262
|
});
|
|
266
263
|
// Refund remaining native fees
|
|
267
264
|
if native_fee_supplied > 0 {
|
|
@@ -270,7 +267,7 @@ impl EndpointV2 {
|
|
|
270
267
|
|
|
271
268
|
// Pay ZRO fees
|
|
272
269
|
if pay_in_zro {
|
|
273
|
-
let zro_addr = Self::zro(env).unwrap_or_panic(env, EndpointError::
|
|
270
|
+
let zro_addr = Self::zro(env).unwrap_or_panic(env, EndpointError::ZroUnavailable);
|
|
274
271
|
let zro_client = TokenClient::new(env, &zro_addr);
|
|
275
272
|
|
|
276
273
|
// If pay_in_zro is true, the supplied fee must be greater than 0 to prevent a race condition
|
|
@@ -278,13 +275,19 @@ impl EndpointV2 {
|
|
|
278
275
|
// being sent and the tx being mined. if the required zro fee is 0 and the old zro token would be
|
|
279
276
|
// locked in the contract instead of being refunded
|
|
280
277
|
let mut zro_fee_supplied = zro_client.balance(&this_contract);
|
|
281
|
-
assert_with_error!(env, zro_fee_supplied > 0, EndpointError::
|
|
282
|
-
|
|
283
|
-
zro_fee_recipients.iter().
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
278
|
+
assert_with_error!(env, zro_fee_supplied > 0, EndpointError::ZeroZroFee);
|
|
279
|
+
|
|
280
|
+
zro_fee_recipients.iter().for_each(|r| {
|
|
281
|
+
// Fee amounts are modeled as non-negative values. The field type is i128 for
|
|
282
|
+
// compatibility with token APIs, but negative fees are always invalid and rejected
|
|
283
|
+
// here, while zero amounts are treated as a no-op (skipped by the check below).
|
|
284
|
+
assert_with_error!(env, r.amount >= 0, EndpointError::InvalidFeeAmount);
|
|
285
|
+
if r.amount > 0 {
|
|
286
|
+
assert_with_error!(env, zro_fee_supplied >= r.amount, EndpointError::InsufficientZroFee);
|
|
287
|
+
zro_client.transfer(&this_contract, &r.to, &r.amount);
|
|
288
|
+
zro_fee_supplied -= r.amount;
|
|
289
|
+
fee_paid.zro_fee += r.amount;
|
|
290
|
+
}
|
|
288
291
|
});
|
|
289
292
|
// Refund remaining ZRO fees
|
|
290
293
|
if zro_fee_supplied > 0 {
|
|
@@ -297,9 +300,28 @@ impl EndpointV2 {
|
|
|
297
300
|
}
|
|
298
301
|
|
|
299
302
|
// ============================================================================
|
|
300
|
-
//
|
|
303
|
+
// Test-only Functions
|
|
301
304
|
// ============================================================================
|
|
302
305
|
|
|
306
|
+
#[cfg(test)]
|
|
307
|
+
mod test {
|
|
308
|
+
use super::*;
|
|
309
|
+
|
|
310
|
+
impl EndpointV2 {
|
|
311
|
+
/// Test-only wrapper for build_outbound_packet to enable testing.
|
|
312
|
+
pub fn build_outbound_packet_for_test(
|
|
313
|
+
env: &Env,
|
|
314
|
+
sender: &Address,
|
|
315
|
+
dst_eid: u32,
|
|
316
|
+
receiver: &BytesN<32>,
|
|
317
|
+
message: &Bytes,
|
|
318
|
+
nonce: u64,
|
|
319
|
+
) -> OutboundPacket {
|
|
320
|
+
Self::build_outbound_packet(env, sender, dst_eid, receiver, message, nonce)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
303
325
|
#[path = "message_lib_manager.rs"]
|
|
304
326
|
mod message_lib_manager;
|
|
305
327
|
#[path = "messaging_channel.rs"]
|
|
@@ -8,7 +8,8 @@ pub enum EndpointError {
|
|
|
8
8
|
DefaultReceiveLibUnavailable,
|
|
9
9
|
DefaultSendLibUnavailable,
|
|
10
10
|
InsufficientNativeFee,
|
|
11
|
-
|
|
11
|
+
InsufficientZroFee,
|
|
12
|
+
InvalidFeeAmount,
|
|
12
13
|
InvalidExpiry,
|
|
13
14
|
InvalidIndex,
|
|
14
15
|
InvalidNonce,
|
|
@@ -24,6 +25,6 @@ pub enum EndpointError {
|
|
|
24
25
|
SameValue,
|
|
25
26
|
Unauthorized,
|
|
26
27
|
UnsupportedEid,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
ZeroZroFee,
|
|
29
|
+
ZroUnavailable,
|
|
29
30
|
}
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
use super
|
|
1
|
+
use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
|
|
2
|
+
use crate::{
|
|
3
|
+
errors::EndpointError,
|
|
4
|
+
events::{
|
|
5
|
+
DefaultReceiveLibTimeoutSet, DefaultReceiveLibrarySet, DefaultSendLibrarySet, LibraryRegistered,
|
|
6
|
+
ReceiveLibrarySet, ReceiveLibraryTimeoutSet, SendLibrarySet,
|
|
7
|
+
},
|
|
8
|
+
interfaces::IMessageLibManager,
|
|
9
|
+
storage::EndpointStorage,
|
|
10
|
+
MessageLibClient, MessageLibType, ResolvedLibrary, SetConfigParam, Timeout,
|
|
11
|
+
};
|
|
12
|
+
use common_macros::{contract_impl, only_auth};
|
|
13
|
+
use soroban_sdk::{assert_with_error, vec, Address, Bytes, Env, Vec};
|
|
14
|
+
use utils::option_ext::OptionExt;
|
|
2
15
|
|
|
3
16
|
#[contract_impl]
|
|
4
17
|
impl IMessageLibManager for EndpointV2 {
|
|
5
18
|
/// Registers a new message library with the endpoint.
|
|
6
|
-
#[
|
|
19
|
+
#[only_auth]
|
|
7
20
|
fn register_library(env: &Env, new_lib: &Address) {
|
|
8
21
|
// Call library get type to make sure it's a valid library, will panic if not
|
|
9
22
|
let _ = MessageLibClient::new(env, new_lib).message_lib_type();
|
|
@@ -21,7 +34,7 @@ impl IMessageLibManager for EndpointV2 {
|
|
|
21
34
|
}
|
|
22
35
|
|
|
23
36
|
/// Sets the default send library for a destination endpoint.
|
|
24
|
-
#[
|
|
37
|
+
#[only_auth]
|
|
25
38
|
fn set_default_send_library(env: &Env, dst_eid: u32, new_lib: &Address) {
|
|
26
39
|
Self::require_send_lib_for_eid(env, new_lib, dst_eid);
|
|
27
40
|
|
|
@@ -36,7 +49,7 @@ impl IMessageLibManager for EndpointV2 {
|
|
|
36
49
|
///
|
|
37
50
|
/// If a grace period is provided and there was a previous library, the old library
|
|
38
51
|
/// remains valid until the grace period expires.
|
|
39
|
-
#[
|
|
52
|
+
#[only_auth]
|
|
40
53
|
fn set_default_receive_library(env: &Env, src_eid: u32, new_lib: &Address, grace_period: u64) {
|
|
41
54
|
Self::require_receive_lib_for_eid(env, new_lib, src_eid);
|
|
42
55
|
|
|
@@ -63,7 +76,7 @@ impl IMessageLibManager for EndpointV2 {
|
|
|
63
76
|
///
|
|
64
77
|
/// If a timeout is provided, it must be valid and not expired. If no timeout is provided,
|
|
65
78
|
/// the default receive library timeout is removed.
|
|
66
|
-
#[
|
|
79
|
+
#[only_auth]
|
|
67
80
|
fn set_default_receive_lib_timeout(env: &Env, src_eid: u32, timeout: &Option<Timeout>) {
|
|
68
81
|
if let Some(t) = timeout {
|
|
69
82
|
Self::require_receive_lib_for_eid(env, &t.lib, src_eid);
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
use super
|
|
1
|
+
use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
|
|
2
|
+
use crate::{
|
|
3
|
+
constants::{EMPTY_PAYLOAD_HASH_BYTES, NIL_PAYLOAD_HASH_BYTES},
|
|
4
|
+
errors::EndpointError,
|
|
5
|
+
events::{InboundNonceSkipped, PacketBurnt, PacketNilified},
|
|
6
|
+
interfaces::{ILayerZeroEndpointV2, IMessagingChannel},
|
|
7
|
+
storage::EndpointStorage,
|
|
8
|
+
util::{compute_guid, keccak256},
|
|
9
|
+
};
|
|
10
|
+
use common_macros::contract_impl;
|
|
11
|
+
use soroban_sdk::{assert_with_error, Address, Bytes, BytesN, Env};
|
|
2
12
|
|
|
3
13
|
#[contract_impl]
|
|
4
14
|
impl IMessagingChannel for EndpointV2 {
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
use super
|
|
1
|
+
use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
|
|
2
|
+
use crate::{
|
|
3
|
+
constants::{MAX_COMPOSE_INDEX, RECEIVED_MESSAGE_HASH_BYTES},
|
|
4
|
+
errors::EndpointError,
|
|
5
|
+
events::{ComposeDelivered, ComposeSent, LzComposeAlert},
|
|
6
|
+
storage::EndpointStorage,
|
|
7
|
+
util::keccak256,
|
|
8
|
+
IMessagingComposer,
|
|
9
|
+
};
|
|
10
|
+
use common_macros::contract_impl;
|
|
11
|
+
use soroban_sdk::{assert_with_error, Address, Bytes, BytesN, Env};
|
|
2
12
|
|
|
3
13
|
#[contract_impl]
|
|
4
14
|
impl IMessagingComposer for EndpointV2 {
|