@layerzerolabs/protocol-stellar-v2 0.2.21 → 0.2.23
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 +347 -271
- package/.turbo/turbo-lint.log +277 -208
- package/.turbo/turbo-test.log +1700 -1370
- package/Cargo.lock +22 -51
- package/Cargo.toml +6 -1
- package/contracts/common-macros/src/auth.rs +10 -9
- package/contracts/common-macros/src/contract_ttl.rs +1 -4
- package/contracts/common-macros/src/error.rs +1 -3
- package/contracts/common-macros/src/lib.rs +65 -61
- package/contracts/common-macros/src/storage.rs +212 -65
- package/contracts/common-macros/src/tests/auth.rs +75 -6
- package/contracts/common-macros/src/tests/contract_ttl.rs +383 -350
- package/contracts/common-macros/src/tests/error.rs +9 -21
- package/contracts/common-macros/src/tests/lz_contract.rs +80 -0
- package/contracts/common-macros/src/tests/mod.rs +2 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -3
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +28 -1
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap +8 -43
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +6 -29
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__lz_contract__snapshot_generated_lz_contract_code.snap +31 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_extendable__snapshot_generated_ttl_extendable_code.snap +8 -0
- package/contracts/common-macros/src/tests/storage/extract_fields.rs +87 -0
- package/contracts/common-macros/src/tests/storage/gen_accessor_methods.rs +223 -0
- package/contracts/common-macros/src/tests/storage/gen_args.rs +65 -0
- package/contracts/common-macros/src/tests/storage/gen_enum_variant.rs +78 -0
- package/contracts/common-macros/src/tests/storage/gen_key.rs +108 -0
- package/contracts/common-macros/src/tests/storage/gen_params.rs +105 -0
- package/contracts/common-macros/src/tests/{storage.rs → storage/generate_storage.rs} +54 -129
- package/contracts/common-macros/src/tests/storage/is_primitive_type.rs +48 -0
- package/contracts/common-macros/src/tests/storage/mod.rs +16 -0
- package/contracts/common-macros/src/tests/storage/parse_default.rs +164 -0
- package/contracts/common-macros/src/tests/storage/parse_name.rs +159 -0
- package/contracts/common-macros/src/tests/storage/parse_no_ttl_extension.rs +124 -0
- package/contracts/common-macros/src/tests/storage/parse_storage_type.rs +174 -0
- package/contracts/common-macros/src/tests/storage/snapshots/common_macros__tests__storage__generate_storage__snapshot_generated_storage_code.snap +412 -0
- package/contracts/common-macros/src/tests/storage/storage_kind.rs +39 -0
- package/contracts/common-macros/src/tests/storage/test_setup.rs +25 -0
- package/contracts/common-macros/src/tests/storage/validate_attrs.rs +138 -0
- package/contracts/common-macros/src/tests/storage/variant_config.rs +226 -0
- package/contracts/common-macros/src/tests/test_helpers.rs +4 -10
- package/contracts/common-macros/src/tests/ttl_configurable.rs +2 -2
- package/contracts/common-macros/src/tests/ttl_extendable.rs +32 -0
- package/contracts/common-macros/src/tests/upgradeable.rs +118 -2
- package/contracts/common-macros/src/ttl_configurable.rs +1 -4
- package/contracts/common-macros/src/upgradeable.rs +21 -3
- package/contracts/endpoint-v2/Cargo.toml +0 -4
- package/contracts/endpoint-v2/src/endpoint_v2.rs +37 -17
- package/contracts/endpoint-v2/src/errors.rs +26 -1
- package/contracts/endpoint-v2/src/interfaces/layerzero_endpoint_v2.rs +1 -1
- package/contracts/endpoint-v2/src/interfaces/message_lib_manager.rs +4 -4
- package/contracts/endpoint-v2/src/interfaces/messaging_composer.rs +2 -2
- package/contracts/endpoint-v2/src/lib.rs +0 -1
- package/contracts/endpoint-v2/src/message_lib_manager.rs +39 -8
- package/contracts/endpoint-v2/src/messaging_channel.rs +36 -4
- package/contracts/endpoint-v2/src/messaging_composer.rs +18 -4
- package/contracts/endpoint-v2/src/storage.rs +9 -1
- package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +2 -2
- package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
- package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +3 -3
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +5 -5
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +2 -2
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +5 -5
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +3 -3
- package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +1 -1
- package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +4 -3
- package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +7 -2
- package/contracts/endpoint-v2/src/tests/messaging_composer/mod.rs +4 -0
- package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +7 -2
- package/contracts/layerzero-views/src/layerzero_view.rs +0 -1
- package/contracts/layerzero-views/src/tests/mod.rs +1 -0
- package/contracts/layerzero-views/src/tests/types_tests.rs +31 -0
- package/contracts/layerzero-views/src/types.rs +2 -3
- package/contracts/macro-integration-tests/tests/runtime/contract_ttl/constructor.rs +61 -0
- package/contracts/macro-integration-tests/tests/runtime/contract_ttl/contract_impl_ttl_extension.rs +97 -0
- package/contracts/macro-integration-tests/tests/runtime/contract_ttl/contract_trait_ttl_extension.rs +99 -0
- package/contracts/macro-integration-tests/tests/runtime/contract_ttl/mod.rs +3 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/mod.rs +5 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_default.rs +86 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_multisig.rs +47 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_multisig_upgradeable.rs +77 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_upgradeable.rs +114 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_upgradeable_no_migration.rs +105 -0
- package/contracts/macro-integration-tests/tests/runtime/multisig/admin_entrypoints.rs +242 -0
- package/contracts/macro-integration-tests/tests/runtime/multisig/mod.rs +9 -0
- package/contracts/macro-integration-tests/tests/runtime/multisig/self_auth.rs +54 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/initialization.rs +13 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +1 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/ownership_transfer.rs +70 -1
- package/contracts/macro-integration-tests/tests/runtime/ownable/two_step_transfer.rs +219 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/keyed_roundtrip.rs +41 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/ttl_extension.rs +48 -16
- package/contracts/macro-integration-tests/tests/runtime/storage/unkeyed_roundtrip.rs +10 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +96 -3
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +4 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_extendable/extend_instance_ttl.rs +64 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_extendable/mod.rs +16 -0
- package/contracts/macro-integration-tests/tests/runtime/upgradeable/migrate_guard_and_state.rs +305 -0
- package/contracts/macro-integration-tests/tests/runtime/upgradeable/mod.rs +3 -0
- package/contracts/macro-integration-tests/tests/runtime/upgradeable/no_migration.rs +59 -0
- package/contracts/macro-integration-tests/tests/runtime/upgradeable/upgrade_then_migrate.rs +88 -0
- package/contracts/macro-integration-tests/tests/runtime.rs +5 -0
- package/contracts/macro-integration-tests/tests/ui/contract_impl/fail/not_impl_item.rs +6 -0
- package/contracts/macro-integration-tests/tests/ui/contract_impl/fail/not_impl_item.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/contract_impl/pass/basic.rs +102 -0
- package/contracts/macro-integration-tests/tests/ui/contract_trait/fail/not_a_trait.rs +6 -0
- package/contracts/macro-integration-tests/tests/ui/contract_trait/fail/not_a_trait.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/contract_trait/pass/basic.rs +83 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/discriminant_too_large.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/discriminant_too_large.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_enum_input.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_enum_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/basic.rs +22 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/invalid_option.rs +6 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/invalid_option.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/multisig_rejects_ownable_api.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/multisig_rejects_ownable_api.stderr +20 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/not_a_struct.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/not_a_struct.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_invalid_inner_option.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_invalid_inner_option.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_missing_internal.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_missing_internal.stderr +86 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/basic.rs +45 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/multisig.rs +34 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/multisig_upgradeable.rs +30 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/upgradeable.rs +39 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/upgradeable_no_migration.rs +28 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_api.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_api.stderr +12 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_trait.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_trait.stderr +5 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/pass/basic.rs +49 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_auth.rs +19 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_auth.stderr +12 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.rs +1 -1
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.stderr +0 -8
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/basic.rs +39 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_auth_env_param_variants.rs +7 -1
- package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.stderr +1 -1
- package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.stderr +1 -1
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_default_values.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_default_values.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_name_attrs.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_name_attrs.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_no_ttl_extension.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_no_ttl_extension.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.stderr +1 -1
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_rejects_args.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_rejects_args.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/api_surface.rs +102 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/basic.rs +43 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/multi_key.rs +38 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/missing_auth_trait.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/missing_auth_trait.stderr +71 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/{minimal_contract.rs → basic.rs} +2 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/multisig_contract.rs +28 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/ownable_contract.rs +32 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_extendable/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_extendable/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_extendable/pass/basic.rs +23 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_extendable/pass/no_user_contractimpl.rs +21 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/attr_args.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/attr_args.stderr +29 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_auth_trait.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_auth_trait.stderr +71 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_upgradeable_internal.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_upgradeable_internal.stderr +79 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/basic.rs +43 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/multisig_contract.rs +35 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/no_migration.rs +30 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/no_user_contractimpl.rs +29 -0
- package/contracts/macro-integration-tests/tests/ui_contract_impl.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui_contract_trait.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui_lz_contract.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_multisig.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_ttl_extendable.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui_upgradeable.rs +11 -0
- package/contracts/message-libs/blocked-message-lib/Cargo.toml +1 -1
- package/contracts/message-libs/blocked-message-lib/src/lib.rs +4 -1
- package/contracts/message-libs/blocked-message-lib/src/tests/blocked_message_lib_tests.rs +108 -0
- package/contracts/message-libs/blocked-message-lib/src/tests/mod.rs +4 -0
- package/contracts/message-libs/blocked-message-lib/src/tests/setup.rs +40 -0
- package/contracts/message-libs/simple-message-lib/src/lib.rs +1 -1
- package/contracts/message-libs/simple-message-lib/src/tests/mod.rs +2 -0
- package/contracts/message-libs/simple-message-lib/src/tests/setup.rs +124 -0
- package/contracts/message-libs/simple-message-lib/src/tests/simple_message_lib_tests.rs +309 -0
- package/contracts/message-libs/uln-302/src/errors.rs +21 -0
- package/contracts/message-libs/uln-302/src/interfaces/receive_uln.rs +1 -1
- package/contracts/message-libs/uln-302/src/receive_uln.rs +6 -4
- package/contracts/message-libs/uln-302/src/send_uln.rs +15 -6
- package/contracts/message-libs/uln-302/src/storage.rs +5 -5
- package/contracts/message-libs/uln-302/src/tests/uln302/get_config.rs +71 -0
- package/contracts/message-libs/uln-302/src/tests/uln302/mod.rs +1 -0
- package/contracts/message-libs/uln-302/src/uln302.rs +3 -0
- package/contracts/oapps/counter/Cargo.toml +2 -0
- package/contracts/oapps/counter/integration_tests/mod.rs +1 -0
- package/contracts/oapps/counter/integration_tests/setup_sml.rs +6 -4
- package/contracts/oapps/counter/integration_tests/setup_uln.rs +12 -5
- package/contracts/oapps/counter/integration_tests/test_with_blocked.rs +67 -0
- package/contracts/oapps/counter/src/tests/mod.rs +1 -0
- package/contracts/oapps/counter/src/tests/test_u256_ext.rs +48 -0
- package/contracts/oapps/oapp/src/lib.rs +0 -3
- package/contracts/oapps/oapp/src/tests/mod.rs +1 -0
- package/contracts/oapps/oft/integration-tests/setup.rs +2 -3
- package/contracts/oapps/oft/src/lib.rs +3 -0
- package/contracts/oapps/oft/src/tests/extensions/mod.rs +3 -0
- package/contracts/oapps/oft/src/tests/extensions/oft_fee.rs +240 -0
- package/contracts/oapps/oft/src/tests/extensions/pausable.rs +141 -0
- package/contracts/oapps/oft/src/tests/extensions/rate_limiter.rs +447 -0
- package/contracts/oapps/oft/src/tests/mod.rs +2 -0
- package/contracts/oapps/oft/src/tests/oft_types/lock_unlock.rs +180 -0
- package/contracts/oapps/oft/src/tests/oft_types/mod.rs +1 -0
- package/contracts/oapps/oft-core/integration-tests/setup.rs +2 -3
- package/contracts/oapps/oft-core/src/lib.rs +2 -2
- package/contracts/oapps/oft-core/src/tests/mod.rs +1 -1
- package/contracts/oapps/oft-core/src/tests/{test_oft_version.rs → test_oft_version_and_approval.rs} +9 -0
- package/contracts/oapps/oft-core/src/tests/test_utils.rs +0 -43
- package/contracts/upgrader/src/tests/test_upgrader.rs +18 -0
- package/contracts/utils/src/auth.rs +2 -2
- package/contracts/utils/src/buffer_reader.rs +61 -10
- package/contracts/utils/src/buffer_writer.rs +35 -20
- package/contracts/utils/src/bytes_ext.rs +1 -2
- package/contracts/utils/src/errors.rs +5 -3
- package/contracts/utils/src/multisig.rs +59 -36
- package/contracts/utils/src/option_ext.rs +3 -3
- package/contracts/utils/src/ownable.rs +12 -6
- package/contracts/utils/src/tests/auth.rs +179 -0
- package/contracts/utils/src/tests/buffer_reader.rs +203 -1
- package/contracts/utils/src/tests/buffer_writer.rs +176 -5
- package/contracts/utils/src/tests/mod.rs +2 -0
- package/contracts/utils/src/tests/multisig.rs +170 -141
- package/contracts/utils/src/tests/option_ext.rs +1 -1
- package/contracts/utils/src/tests/ownable.rs +156 -161
- package/contracts/utils/src/tests/test_helper.rs +21 -1
- package/contracts/utils/src/tests/testing_utils.rs +84 -2
- package/contracts/utils/src/tests/ttl_configurable.rs +66 -86
- package/contracts/utils/src/tests/ttl_extendable.rs +64 -0
- package/contracts/utils/src/tests/upgradeable.rs +115 -6
- package/contracts/utils/src/ttl_configurable.rs +22 -12
- package/contracts/utils/src/ttl_extendable.rs +1 -3
- package/contracts/utils/src/upgradeable.rs +21 -24
- package/contracts/workers/dvn/src/auth.rs +1 -1
- package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
- package/contracts/workers/dvn/src/storage.rs +1 -1
- package/contracts/workers/dvn/src/tests/auth.rs +136 -3
- package/contracts/workers/dvn/src/tests/mod.rs +0 -1
- package/contracts/workers/dvn/src/tests/setup.rs +4 -10
- package/contracts/workers/executor-helper/src/tests/executor_helper.rs +279 -0
- package/contracts/workers/executor-helper/src/tests/setup.rs +106 -1
- package/contracts/workers/worker/src/worker.rs +1 -1
- package/docs/oft-guide.md +5 -5
- package/package.json +5 -7
- package/sdk/.turbo/turbo-test.log +662 -466
- package/sdk/LICENSE +23 -0
- package/sdk/dist/generated/bml.d.ts +101 -106
- package/sdk/dist/generated/bml.js +108 -26
- package/sdk/dist/generated/counter.d.ts +123 -484
- package/sdk/dist/generated/counter.js +103 -25
- package/sdk/dist/generated/dvn.d.ts +141 -699
- package/sdk/dist/generated/dvn.js +106 -28
- package/sdk/dist/generated/dvn_fee_lib.d.ts +31 -248
- package/sdk/dist/generated/dvn_fee_lib.js +27 -24
- package/sdk/dist/generated/endpoint.d.ts +158 -836
- package/sdk/dist/generated/endpoint.js +107 -29
- package/sdk/dist/generated/executor.d.ts +139 -671
- package/sdk/dist/generated/executor.js +106 -28
- package/sdk/dist/generated/executor_fee_lib.d.ts +109 -264
- package/sdk/dist/generated/executor_fee_lib.js +106 -28
- package/sdk/dist/generated/executor_helper.d.ts +95 -92
- package/sdk/dist/generated/executor_helper.js +103 -25
- package/sdk/dist/generated/layerzero_view.d.ts +178 -335
- package/sdk/dist/generated/layerzero_view.js +172 -33
- package/sdk/dist/generated/oft.d.ts +137 -680
- package/sdk/dist/generated/oft.js +103 -25
- package/sdk/dist/generated/price_feed.d.ts +45 -444
- package/sdk/dist/generated/price_feed.js +27 -24
- package/sdk/dist/generated/sml.d.ts +119 -428
- package/sdk/dist/generated/sml.js +103 -25
- package/sdk/dist/generated/treasury.d.ts +109 -288
- package/sdk/dist/generated/treasury.js +103 -25
- package/sdk/dist/generated/uln302.d.ts +190 -527
- package/sdk/dist/generated/uln302.js +170 -31
- package/sdk/dist/generated/upgrader.d.ts +14 -34
- package/sdk/dist/generated/upgrader.js +24 -21
- package/sdk/package.json +3 -4
- package/sdk/test/counter-sml.test.ts +218 -142
- package/sdk/test/counter-uln.test.ts +189 -145
- package/sdk/test/oft-sml.test.ts +173 -156
- package/sdk/test/suites/constants.ts +7 -1
- package/sdk/test/suites/globalSetup.ts +140 -74
- package/sdk/turbo.json +1 -1
- package/tools/ts-bindings-gen/Cargo.toml +4 -4
- package/tools/ts-bindings-gen/src/main.rs +4 -0
- package/turbo.json +3 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +0 -1072
- package/contracts/endpoint-v2/src/constants.rs +0 -52
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.rs +0 -12
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.stderr +0 -7
- package/contracts/macro-integration-tests/tests/ui/error/pass/attr_on_variant_allowed.rs +0 -20
- package/contracts/macro-integration-tests/tests/ui/error/pass/basic_auto_discriminants.rs +0 -15
- package/contracts/macro-integration-tests/tests/ui/error/pass/mixed_discriminants.rs +0 -16
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/minimal_contract.rs +0 -26
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +0 -21
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.rs +0 -12
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.stderr +0 -7
- package/contracts/macro-integration-tests/tests/ui/storage/pass/default_value_on_variant.rs +0 -14
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_instance_unit_basic.rs +0 -14
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_persistent_named_fields_keyed.rs +0 -16
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_temporary_unit_option.rs +0 -15
- package/contracts/macro-integration-tests/tests/ui/storage/pass/name_override.rs +0 -14
- package/contracts/macro-integration-tests/tests/ui/storage/pass/no_auto_ttl_extension.rs +0 -19
- package/contracts/macro-integration-tests/tests/ui/storage/pass/ttl_provider_basic.rs +0 -15
- package/contracts/message-libs/simple-message-lib/src/test.rs +0 -280
- package/contracts/oapps/oapp/src/macro_tests/mod.rs +0 -1
- package/contracts/workers/dvn/src/tests/multisig/mod.rs +0 -3
- package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +0 -132
- package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +0 -109
- package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +0 -106
- /package/contracts/oapps/oapp/src/{macro_tests → tests}/test_macros.rs +0 -0
|
@@ -61,10 +61,9 @@ impl Parse for UpgradeableConfig {
|
|
|
61
61
|
pub fn generate_upgradeable_impl(attr: TokenStream, input: TokenStream) -> TokenStream {
|
|
62
62
|
let config: UpgradeableConfig =
|
|
63
63
|
syn::parse2(attr).unwrap_or_else(|e| panic!("failed to parse upgradeable config: {}", e));
|
|
64
|
-
let item_struct: ItemStruct =
|
|
65
|
-
syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
|
|
66
|
-
let name = &item_struct.ident;
|
|
64
|
+
let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
|
|
67
65
|
|
|
66
|
+
let name = &item_struct.ident;
|
|
68
67
|
let binver = set_binver_from_env();
|
|
69
68
|
|
|
70
69
|
// Generate default UpgradeableInternal impl only when no_migration is set
|
|
@@ -109,3 +108,22 @@ fn set_binver_from_env() -> TokenStream {
|
|
|
109
108
|
_ => quote! {},
|
|
110
109
|
}
|
|
111
110
|
}
|
|
111
|
+
|
|
112
|
+
#[cfg(test)]
|
|
113
|
+
mod tests {
|
|
114
|
+
use std::env;
|
|
115
|
+
|
|
116
|
+
use super::*;
|
|
117
|
+
|
|
118
|
+
#[test]
|
|
119
|
+
fn test_set_binver_from_env_zero_version() {
|
|
120
|
+
// Set version to 0.0.0
|
|
121
|
+
env::set_var("CARGO_PKG_VERSION", "0.0.0");
|
|
122
|
+
|
|
123
|
+
let result = set_binver_from_env();
|
|
124
|
+
let result_str = result.to_string();
|
|
125
|
+
|
|
126
|
+
// Should return empty tokens
|
|
127
|
+
assert_eq!(result_str.trim(), "");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
use crate::{
|
|
2
|
-
constants::{NATIVE_TOKEN, STELLAR_EID},
|
|
3
2
|
errors::EndpointError,
|
|
4
3
|
events::{DelegateSet, LzReceiveAlert, PacketDelivered, PacketSent, PacketVerified, ZroSet},
|
|
5
4
|
interfaces::{ILayerZeroEndpointV2, IMessageLibManager, IMessagingChannel, MessagingFee, MessagingReceipt, Origin},
|
|
@@ -17,8 +16,10 @@ pub struct EndpointV2;
|
|
|
17
16
|
|
|
18
17
|
#[contract_impl]
|
|
19
18
|
impl EndpointV2 {
|
|
20
|
-
pub fn __constructor(env: &Env, owner: &Address) {
|
|
19
|
+
pub fn __constructor(env: &Env, owner: &Address, eid: u32, native_token: &Address) {
|
|
21
20
|
Self::init_owner(env, owner);
|
|
21
|
+
EndpointStorage::set_eid(env, &eid);
|
|
22
|
+
EndpointStorage::set_native_token(env, native_token);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/// Recovers tokens sent to this contract by mistake.
|
|
@@ -49,7 +50,10 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
|
|
|
49
50
|
let nonce = Self::outbound_nonce(env, sender, *dst_eid, receiver) + 1;
|
|
50
51
|
let packet = Self::build_outbound_packet(env, sender, *dst_eid, receiver, message, nonce);
|
|
51
52
|
|
|
52
|
-
SendLibClient::new(env, &send_lib).quote(&packet, options, pay_in_zro)
|
|
53
|
+
let fee = SendLibClient::new(env, &send_lib).quote(&packet, options, pay_in_zro);
|
|
54
|
+
assert_with_error!(env, fee.native_fee >= 0 && fee.zro_fee >= 0, EndpointError::InvalidFeeAmount);
|
|
55
|
+
|
|
56
|
+
fee
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
/// Sends a cross-chain message to a destination endpoint.
|
|
@@ -155,8 +159,8 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
|
|
|
155
159
|
// ============================================================================================
|
|
156
160
|
|
|
157
161
|
/// Returns the endpoint ID.
|
|
158
|
-
fn eid(
|
|
159
|
-
|
|
162
|
+
fn eid(env: &Env) -> u32 {
|
|
163
|
+
EndpointStorage::eid(env).unwrap()
|
|
160
164
|
}
|
|
161
165
|
|
|
162
166
|
/// Checks if a messaging path can be/has been initialized for the given origin and receiver.
|
|
@@ -174,7 +178,7 @@ impl ILayerZeroEndpointV2 for EndpointV2 {
|
|
|
174
178
|
|
|
175
179
|
/// Returns the native token address used for fee payments.
|
|
176
180
|
fn native_token(env: &Env) -> Address {
|
|
177
|
-
|
|
181
|
+
EndpointStorage::native_token(env).unwrap()
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
/// Returns the ZRO token address if set.
|
|
@@ -216,7 +220,7 @@ impl EndpointV2 {
|
|
|
216
220
|
}
|
|
217
221
|
|
|
218
222
|
/// Requires authorization from either the OApp itself or its delegate.
|
|
219
|
-
|
|
223
|
+
fn require_oapp_auth(env: &Env, caller: &Address, oapp: &Address) {
|
|
220
224
|
assert_with_error!(
|
|
221
225
|
env,
|
|
222
226
|
caller == oapp || Self::delegate(env, oapp).as_ref() == Some(caller),
|
|
@@ -235,7 +239,7 @@ impl EndpointV2 {
|
|
|
235
239
|
///
|
|
236
240
|
/// # Returns
|
|
237
241
|
/// The total `MessagingFee` paid (native_fee + zro_fee)
|
|
238
|
-
|
|
242
|
+
fn pay_messaging_fees(
|
|
239
243
|
env: &Env,
|
|
240
244
|
pay_in_zro: bool,
|
|
241
245
|
native_fee_recipients: &Vec<FeeRecipient>,
|
|
@@ -255,9 +259,9 @@ impl EndpointV2 {
|
|
|
255
259
|
assert_with_error!(env, r.amount >= 0, EndpointError::InvalidFeeAmount);
|
|
256
260
|
if r.amount > 0 {
|
|
257
261
|
assert_with_error!(env, native_fee_supplied >= r.amount, EndpointError::InsufficientNativeFee);
|
|
258
|
-
native_token_client.transfer(&this_contract, &r.to, &r.amount);
|
|
259
262
|
native_fee_supplied -= r.amount;
|
|
260
263
|
fee_paid.native_fee += r.amount;
|
|
264
|
+
native_token_client.transfer(&this_contract, &r.to, &r.amount);
|
|
261
265
|
}
|
|
262
266
|
});
|
|
263
267
|
// Refund remaining native fees
|
|
@@ -284,9 +288,9 @@ impl EndpointV2 {
|
|
|
284
288
|
assert_with_error!(env, r.amount >= 0, EndpointError::InvalidFeeAmount);
|
|
285
289
|
if r.amount > 0 {
|
|
286
290
|
assert_with_error!(env, zro_fee_supplied >= r.amount, EndpointError::InsufficientZroFee);
|
|
287
|
-
zro_client.transfer(&this_contract, &r.to, &r.amount);
|
|
288
291
|
zro_fee_supplied -= r.amount;
|
|
289
292
|
fee_paid.zro_fee += r.amount;
|
|
293
|
+
zro_client.transfer(&this_contract, &r.to, &r.amount);
|
|
290
294
|
}
|
|
291
295
|
});
|
|
292
296
|
// Refund remaining ZRO fees
|
|
@@ -299,6 +303,13 @@ impl EndpointV2 {
|
|
|
299
303
|
}
|
|
300
304
|
}
|
|
301
305
|
|
|
306
|
+
#[path = "message_lib_manager.rs"]
|
|
307
|
+
mod message_lib_manager;
|
|
308
|
+
#[path = "messaging_channel.rs"]
|
|
309
|
+
mod messaging_channel;
|
|
310
|
+
#[path = "messaging_composer.rs"]
|
|
311
|
+
mod messaging_composer;
|
|
312
|
+
|
|
302
313
|
// ============================================================================
|
|
303
314
|
// Test-only Functions
|
|
304
315
|
// ============================================================================
|
|
@@ -319,12 +330,21 @@ mod test {
|
|
|
319
330
|
) -> OutboundPacket {
|
|
320
331
|
Self::build_outbound_packet(env, sender, dst_eid, receiver, message, nonce)
|
|
321
332
|
}
|
|
333
|
+
|
|
334
|
+
/// Test-only wrapper for require_oapp_auth.
|
|
335
|
+
pub fn require_oapp_auth_for_test(env: &Env, caller: &Address, oapp: &Address) {
|
|
336
|
+
Self::require_oapp_auth(env, caller, oapp)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/// Test-only wrapper for pay_messaging_fees.
|
|
340
|
+
pub fn pay_messaging_fees_for_test(
|
|
341
|
+
env: &Env,
|
|
342
|
+
pay_in_zro: bool,
|
|
343
|
+
native_fee_recipients: &Vec<FeeRecipient>,
|
|
344
|
+
zro_fee_recipients: &Vec<FeeRecipient>,
|
|
345
|
+
refund_address: &Address,
|
|
346
|
+
) -> MessagingFee {
|
|
347
|
+
Self::pay_messaging_fees(env, pay_in_zro, native_fee_recipients, zro_fee_recipients, refund_address)
|
|
348
|
+
}
|
|
322
349
|
}
|
|
323
350
|
}
|
|
324
|
-
|
|
325
|
-
#[path = "message_lib_manager.rs"]
|
|
326
|
-
mod message_lib_manager;
|
|
327
|
-
#[path = "messaging_channel.rs"]
|
|
328
|
-
mod messaging_channel;
|
|
329
|
-
#[path = "messaging_composer.rs"]
|
|
330
|
-
mod messaging_composer;
|
|
@@ -2,29 +2,54 @@ use common_macros::contract_error;
|
|
|
2
2
|
|
|
3
3
|
#[contract_error]
|
|
4
4
|
pub enum EndpointError {
|
|
5
|
+
/// Library is already registered with the endpoint
|
|
5
6
|
AlreadyRegistered,
|
|
7
|
+
/// Compose message already exists for this GUID and index
|
|
6
8
|
ComposeExists,
|
|
9
|
+
/// Compose message not found for the given GUID and index
|
|
7
10
|
ComposeNotFound,
|
|
11
|
+
/// Default receive library is not set for the source endpoint
|
|
8
12
|
DefaultReceiveLibUnavailable,
|
|
13
|
+
/// Default send library is not set for the destination endpoint
|
|
9
14
|
DefaultSendLibUnavailable,
|
|
15
|
+
/// Supplied native token fee is less than required
|
|
10
16
|
InsufficientNativeFee,
|
|
17
|
+
/// Supplied ZRO token fee is less than required
|
|
11
18
|
InsufficientZroFee,
|
|
12
|
-
|
|
19
|
+
/// Timeout expiry is invalid (already expired)
|
|
13
20
|
InvalidExpiry,
|
|
21
|
+
/// Fee amount is invalid (negative)
|
|
22
|
+
InvalidFeeAmount,
|
|
23
|
+
/// Compose index exceeds maximum allowed value
|
|
14
24
|
InvalidIndex,
|
|
25
|
+
/// Nonce is invalid for the requested operation
|
|
15
26
|
InvalidNonce,
|
|
27
|
+
/// Payload hash is invalid (empty hash not allowed)
|
|
16
28
|
InvalidPayloadHash,
|
|
29
|
+
/// Receive library is not valid for the receiver and source endpoint
|
|
17
30
|
InvalidReceiveLibrary,
|
|
31
|
+
/// Operation requires a non-default (custom) library
|
|
18
32
|
OnlyNonDefaultLib,
|
|
33
|
+
/// Library must support receiving messages
|
|
19
34
|
OnlyReceiveLib,
|
|
35
|
+
/// Library must be registered with the endpoint
|
|
20
36
|
OnlyRegisteredLib,
|
|
37
|
+
/// Library must support sending messages
|
|
21
38
|
OnlySendLib,
|
|
39
|
+
/// Messaging path cannot be initialized for the given origin
|
|
22
40
|
PathNotInitializable,
|
|
41
|
+
/// Message cannot be verified for the given origin
|
|
23
42
|
PathNotVerifiable,
|
|
43
|
+
/// Payload hash does not match the stored hash
|
|
24
44
|
PayloadHashNotFound,
|
|
45
|
+
/// New value is the same as existing value
|
|
25
46
|
SameValue,
|
|
47
|
+
/// Caller is not authorized (not OApp or delegate)
|
|
26
48
|
Unauthorized,
|
|
49
|
+
/// Endpoint ID is not supported by the library
|
|
27
50
|
UnsupportedEid,
|
|
51
|
+
/// ZRO fee must be greater than zero when pay_in_zro is true
|
|
28
52
|
ZeroZroFee,
|
|
53
|
+
/// ZRO token address is not set
|
|
29
54
|
ZroUnavailable,
|
|
30
55
|
}
|
|
@@ -122,7 +122,7 @@ pub trait ILayerZeroEndpointV2: IMessageLibManager + IMessagingChannel + IMessag
|
|
|
122
122
|
/// * `origin` - The origin of the message
|
|
123
123
|
/// * `receiver` - The OApp address
|
|
124
124
|
/// * `guid` - The message GUID
|
|
125
|
-
/// * `gas` - The
|
|
125
|
+
/// * `gas` - The fee provided for execution (named "gas" for cross-chain interface consistency, though Stellar uses fees not gas)
|
|
126
126
|
/// * `value` - The value provided for execution
|
|
127
127
|
/// * `message` - The message content
|
|
128
128
|
/// * `extra_data` - Additional data for execution
|
|
@@ -4,9 +4,9 @@ use soroban_sdk::{contractclient, contracttype, Address, Bytes, Env, Vec};
|
|
|
4
4
|
#[contracttype]
|
|
5
5
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
6
6
|
pub struct Timeout {
|
|
7
|
-
/// The
|
|
7
|
+
/// The old library address that remains valid during the grace period.
|
|
8
8
|
pub lib: Address,
|
|
9
|
-
/// Unix timestamp when the timeout expires.
|
|
9
|
+
/// Unix timestamp in seconds when the timeout expires.
|
|
10
10
|
pub expiry: u64,
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -144,7 +144,7 @@ pub trait IMessageLibManager {
|
|
|
144
144
|
///
|
|
145
145
|
/// # Arguments
|
|
146
146
|
/// * `caller` - The caller address, must be the OApp or its delegate
|
|
147
|
-
/// * `sender` - The
|
|
147
|
+
/// * `sender` - The sender OApp address
|
|
148
148
|
/// * `dst_eid` - The destination endpoint ID
|
|
149
149
|
/// * `new_lib` - The library address, or `None` to use the default
|
|
150
150
|
fn set_send_library(env: &Env, caller: &Address, sender: &Address, dst_eid: u32, new_lib: &Option<Address>);
|
|
@@ -152,7 +152,7 @@ pub trait IMessageLibManager {
|
|
|
152
152
|
/// Returns the effective send library for an OApp and destination endpoint.
|
|
153
153
|
///
|
|
154
154
|
/// # Arguments
|
|
155
|
-
/// * `sender` - The
|
|
155
|
+
/// * `sender` - The sender OApp address
|
|
156
156
|
/// * `dst_eid` - The destination endpoint ID
|
|
157
157
|
fn get_send_library(env: &Env, sender: &Address, dst_eid: u32) -> ResolvedLibrary;
|
|
158
158
|
|
|
@@ -33,7 +33,7 @@ pub trait IMessagingComposer {
|
|
|
33
33
|
/// * `to` - The composer address
|
|
34
34
|
/// * `guid` - The message GUID
|
|
35
35
|
/// * `index` - The compose message index
|
|
36
|
-
/// * `gas` - The
|
|
36
|
+
/// * `gas` - The fee provided for execution (named "gas" for cross-chain interface consistency, though Stellar uses fees not gas)
|
|
37
37
|
/// * `value` - The value provided for execution
|
|
38
38
|
/// * `message` - The composed message content
|
|
39
39
|
/// * `extra_data` - Additional data for execution
|
|
@@ -45,7 +45,7 @@ pub trait IMessagingComposer {
|
|
|
45
45
|
to: &Address,
|
|
46
46
|
guid: &BytesN<32>,
|
|
47
47
|
index: u32,
|
|
48
|
-
gas: i128,
|
|
48
|
+
gas: i128,
|
|
49
49
|
value: i128,
|
|
50
50
|
message: &Bytes,
|
|
51
51
|
extra_data: &Bytes,
|
|
@@ -28,7 +28,7 @@ impl IMessageLibManager for EndpointV2 {
|
|
|
28
28
|
let index = Self::registered_libraries_count(env);
|
|
29
29
|
EndpointStorage::set_library_to_index(env, new_lib, &index);
|
|
30
30
|
EndpointStorage::set_index_to_library(env, index, new_lib);
|
|
31
|
-
EndpointStorage::
|
|
31
|
+
EndpointStorage::set_registered_libraries_count(env, &(index + 1)); // increment the registered library count
|
|
32
32
|
|
|
33
33
|
LibraryRegistered { new_lib: new_lib.clone() }.publish(env);
|
|
34
34
|
}
|
|
@@ -159,7 +159,7 @@ impl IMessageLibManager for EndpointV2 {
|
|
|
159
159
|
) {
|
|
160
160
|
Self::require_oapp_auth(env, caller, receiver);
|
|
161
161
|
|
|
162
|
-
//
|
|
162
|
+
// OApp can only set timeout for non-default receive libraries
|
|
163
163
|
let ResolvedLibrary { lib: _, is_default } = Self::get_receive_library(env, receiver, src_eid);
|
|
164
164
|
assert_with_error!(env, !is_default, EndpointError::OnlyNonDefaultLib);
|
|
165
165
|
|
|
@@ -197,12 +197,12 @@ impl IMessageLibManager for EndpointV2 {
|
|
|
197
197
|
|
|
198
198
|
/// Returns the number of registered message libraries.
|
|
199
199
|
fn registered_libraries_count(env: &Env) -> u32 {
|
|
200
|
-
EndpointStorage::
|
|
200
|
+
EndpointStorage::registered_libraries_count(env)
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
/// Returns a list of registered message libraries within the specified range.
|
|
204
204
|
fn get_registered_libraries(env: &Env, start: u32, max_count: u32) -> Vec<Address> {
|
|
205
|
-
let count = EndpointStorage::
|
|
205
|
+
let count = EndpointStorage::registered_libraries_count(env);
|
|
206
206
|
if count == 0 || start >= count {
|
|
207
207
|
return vec![env];
|
|
208
208
|
}
|
|
@@ -296,18 +296,18 @@ impl IMessageLibManager for EndpointV2 {
|
|
|
296
296
|
|
|
297
297
|
impl EndpointV2 {
|
|
298
298
|
/// Requires a message library to be registered.
|
|
299
|
-
|
|
299
|
+
fn require_registered(env: &Env, lib: &Address) {
|
|
300
300
|
assert_with_error!(env, Self::is_registered_library(env, lib), EndpointError::OnlyRegisteredLib);
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
/// Requires an endpoint ID to be supported.
|
|
304
|
-
|
|
304
|
+
fn require_supported_eid(env: &Env, lib: &Address, eid: u32) {
|
|
305
305
|
let is_supported = MessageLibClient::new(env, lib).is_supported_eid(&eid);
|
|
306
306
|
assert_with_error!(env, is_supported, EndpointError::UnsupportedEid);
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
/// Requires a library to be a registered send library and supported for the given endpoint ID.
|
|
310
|
-
|
|
310
|
+
fn require_send_lib_for_eid(env: &Env, lib: &Address, eid: u32) {
|
|
311
311
|
Self::require_registered(env, lib);
|
|
312
312
|
|
|
313
313
|
let message_lib_type = MessageLibClient::new(env, lib).message_lib_type();
|
|
@@ -321,7 +321,7 @@ impl EndpointV2 {
|
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
/// Requires a library to be a registered receive library and supported for the given endpoint ID.
|
|
324
|
-
|
|
324
|
+
fn require_receive_lib_for_eid(env: &Env, lib: &Address, eid: u32) {
|
|
325
325
|
Self::require_registered(env, lib);
|
|
326
326
|
|
|
327
327
|
let message_lib_type = MessageLibClient::new(env, lib).message_lib_type();
|
|
@@ -334,3 +334,34 @@ impl EndpointV2 {
|
|
|
334
334
|
Self::require_supported_eid(env, lib, eid);
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
+
|
|
338
|
+
// ============================================================================
|
|
339
|
+
// Test-only Functions
|
|
340
|
+
// ============================================================================
|
|
341
|
+
|
|
342
|
+
#[cfg(test)]
|
|
343
|
+
mod test {
|
|
344
|
+
use super::*;
|
|
345
|
+
|
|
346
|
+
impl EndpointV2 {
|
|
347
|
+
/// Test-only wrapper for require_registered.
|
|
348
|
+
pub fn require_registered_for_test(env: &Env, lib: &Address) {
|
|
349
|
+
Self::require_registered(env, lib)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/// Test-only wrapper for require_supported_eid.
|
|
353
|
+
pub fn require_supported_eid_for_test(env: &Env, lib: &Address, eid: u32) {
|
|
354
|
+
Self::require_supported_eid(env, lib, eid)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/// Test-only wrapper for require_send_lib_for_eid.
|
|
358
|
+
pub fn require_send_lib_for_eid_for_test(env: &Env, lib: &Address, eid: u32) {
|
|
359
|
+
Self::require_send_lib_for_eid(env, lib, eid)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/// Test-only wrapper for require_receive_lib_for_eid.
|
|
363
|
+
pub fn require_receive_lib_for_eid_for_test(env: &Env, lib: &Address, eid: u32) {
|
|
364
|
+
Self::require_receive_lib_for_eid(env, lib, eid)
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
|
|
2
2
|
use crate::{
|
|
3
|
-
constants::{EMPTY_PAYLOAD_HASH_BYTES, NIL_PAYLOAD_HASH_BYTES},
|
|
4
3
|
errors::EndpointError,
|
|
5
4
|
events::{InboundNonceSkipped, PacketBurnt, PacketNilified},
|
|
6
5
|
interfaces::{ILayerZeroEndpointV2, IMessagingChannel},
|
|
@@ -10,6 +9,12 @@ use crate::{
|
|
|
10
9
|
use common_macros::contract_impl;
|
|
11
10
|
use soroban_sdk::{assert_with_error, Address, Bytes, BytesN, Env};
|
|
12
11
|
|
|
12
|
+
/// Represents an empty payload hash (equivalent to bytes32(uint256(0)) in Solidity)
|
|
13
|
+
const EMPTY_PAYLOAD_HASH_BYTES: [u8; 32] = [0u8; 32];
|
|
14
|
+
|
|
15
|
+
/// Represents a nilified payload hash (equivalent to bytes32(type(uint256).max) in Solidity)
|
|
16
|
+
const NIL_PAYLOAD_HASH_BYTES: [u8; 32] = [0xffu8; 32];
|
|
17
|
+
|
|
13
18
|
#[contract_impl]
|
|
14
19
|
impl IMessagingChannel for EndpointV2 {
|
|
15
20
|
/// Skips the next expected inbound nonce without verifying.
|
|
@@ -72,7 +77,7 @@ impl IMessagingChannel for EndpointV2 {
|
|
|
72
77
|
let cur_payload_hash = Self::inbound_payload_hash(env, receiver, src_eid, sender, nonce);
|
|
73
78
|
assert_with_error!(env, cur_payload_hash.as_ref() == Some(payload_hash), EndpointError::PayloadHashNotFound);
|
|
74
79
|
|
|
75
|
-
// Check if nonce is
|
|
80
|
+
// Check if nonce is at or below the lazy nonce
|
|
76
81
|
let lazy_nonce = Self::lazy_inbound_nonce(env, receiver, src_eid, sender);
|
|
77
82
|
assert_with_error!(env, nonce <= lazy_nonce, EndpointError::InvalidNonce);
|
|
78
83
|
|
|
@@ -187,6 +192,12 @@ impl EndpointV2 {
|
|
|
187
192
|
/// Note: This function does not change `inbound_nonce`, it only changes
|
|
188
193
|
/// the `lazy_inbound_nonce` up to the provided nonce.
|
|
189
194
|
///
|
|
195
|
+
/// # EVM Alignment
|
|
196
|
+
/// This implementation aligns with the EVM endpoint behavior. Executors should call
|
|
197
|
+
/// `clear` from lower nonce to higher nonce sequentially. This ensures the range check
|
|
198
|
+
/// `(current_nonce + 1..=nonce)` remains small, avoiding long iteration when verifying
|
|
199
|
+
/// that all intermediate nonces have been verified.
|
|
200
|
+
///
|
|
190
201
|
/// # Arguments
|
|
191
202
|
/// * `receiver` - The receiver OApp address
|
|
192
203
|
/// * `src_eid` - The source endpoint ID
|
|
@@ -221,12 +232,33 @@ impl EndpointV2 {
|
|
|
221
232
|
}
|
|
222
233
|
|
|
223
234
|
/// Represents an empty payload hash
|
|
224
|
-
|
|
235
|
+
fn empty_payload_hash(env: &Env) -> BytesN<32> {
|
|
225
236
|
BytesN::from_array(env, &EMPTY_PAYLOAD_HASH_BYTES)
|
|
226
237
|
}
|
|
227
238
|
|
|
228
239
|
/// Represents a nilified payload hash
|
|
229
|
-
|
|
240
|
+
fn nil_payload_hash(env: &Env) -> BytesN<32> {
|
|
230
241
|
BytesN::from_array(env, &NIL_PAYLOAD_HASH_BYTES)
|
|
231
242
|
}
|
|
232
243
|
}
|
|
244
|
+
|
|
245
|
+
// ============================================================================
|
|
246
|
+
// Test-only Functions
|
|
247
|
+
// ============================================================================
|
|
248
|
+
|
|
249
|
+
#[cfg(test)]
|
|
250
|
+
mod test {
|
|
251
|
+
use super::*;
|
|
252
|
+
|
|
253
|
+
impl EndpointV2 {
|
|
254
|
+
/// Test-only wrapper for empty_payload_hash.
|
|
255
|
+
pub fn empty_payload_hash_for_test(env: &Env) -> BytesN<32> {
|
|
256
|
+
Self::empty_payload_hash(env)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/// Test-only wrapper for nil_payload_hash.
|
|
260
|
+
pub fn nil_payload_hash_for_test(env: &Env) -> BytesN<32> {
|
|
261
|
+
Self::nil_payload_hash(env)
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
use super::{EndpointV2, EndpointV2Args, EndpointV2Client};
|
|
2
2
|
use crate::{
|
|
3
|
-
constants::{MAX_COMPOSE_INDEX, RECEIVED_MESSAGE_HASH_BYTES},
|
|
4
3
|
errors::EndpointError,
|
|
5
4
|
events::{ComposeDelivered, ComposeSent, LzComposeAlert},
|
|
6
5
|
storage::EndpointStorage,
|
|
@@ -10,6 +9,13 @@ use crate::{
|
|
|
10
9
|
use common_macros::contract_impl;
|
|
11
10
|
use soroban_sdk::{assert_with_error, Address, Bytes, BytesN, Env};
|
|
12
11
|
|
|
12
|
+
/// Represents a received message hash marker (equivalent to bytes32(uint256(1)) in Solidity)
|
|
13
|
+
const RECEIVED_MESSAGE_HASH_BYTES: [u8; 32] =
|
|
14
|
+
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
|
|
15
|
+
|
|
16
|
+
/// Represents the maximum compose index (equivalent to uint16.max in Solidity)
|
|
17
|
+
const MAX_COMPOSE_INDEX: u32 = u16::MAX as u32;
|
|
18
|
+
|
|
13
19
|
#[contract_impl]
|
|
14
20
|
impl IMessagingComposer for EndpointV2 {
|
|
15
21
|
/// Sends a composed message from an OApp to a composer.
|
|
@@ -18,7 +24,7 @@ impl IMessagingComposer for EndpointV2 {
|
|
|
18
24
|
/// With the same GUID, the OApp can send compose to multiple composers at the same time.
|
|
19
25
|
fn send_compose(env: &Env, from: &Address, to: &Address, guid: &BytesN<32>, index: u32, message: &Bytes) {
|
|
20
26
|
from.require_auth();
|
|
21
|
-
|
|
27
|
+
assert_compose_index(env, index);
|
|
22
28
|
|
|
23
29
|
let compose_queue = Self::compose_queue(env, from, to, guid, index);
|
|
24
30
|
assert_with_error!(env, compose_queue.is_none(), EndpointError::ComposeExists);
|
|
@@ -34,12 +40,16 @@ impl IMessagingComposer for EndpointV2 {
|
|
|
34
40
|
/// This is a PULL mode versus the PUSH mode of `lz_compose`.
|
|
35
41
|
fn clear_compose(env: &Env, composer: &Address, from: &Address, guid: &BytesN<32>, index: u32, message: &Bytes) {
|
|
36
42
|
composer.require_auth();
|
|
37
|
-
|
|
43
|
+
assert_compose_index(env, index);
|
|
38
44
|
|
|
39
45
|
let expected_hash = Self::compose_queue(env, from, composer, guid, index);
|
|
40
46
|
let actual_hash = keccak256(env, message);
|
|
41
47
|
assert_with_error!(env, expected_hash == Some(actual_hash), EndpointError::ComposeNotFound);
|
|
42
48
|
|
|
49
|
+
// Marks the message as received to prevent reentrancy.
|
|
50
|
+
// Cannot just delete the value, otherwise the message can be sent again and could result
|
|
51
|
+
// in some undefined behaviour even though the sender (composing OApp) is implicitly fully
|
|
52
|
+
// trusted by the composer. e.g. sender may not even realize it has such a bug.
|
|
43
53
|
let received_hash = BytesN::from_array(env, &RECEIVED_MESSAGE_HASH_BYTES);
|
|
44
54
|
EndpointStorage::set_compose_queue(env, from, composer, guid, index, &received_hash);
|
|
45
55
|
|
|
@@ -63,7 +73,7 @@ impl IMessagingComposer for EndpointV2 {
|
|
|
63
73
|
reason: &Bytes,
|
|
64
74
|
) {
|
|
65
75
|
executor.require_auth();
|
|
66
|
-
|
|
76
|
+
assert_compose_index(env, index);
|
|
67
77
|
LzComposeAlert {
|
|
68
78
|
executor: executor.clone(),
|
|
69
79
|
from: from.clone(),
|
|
@@ -88,3 +98,7 @@ impl IMessagingComposer for EndpointV2 {
|
|
|
88
98
|
EndpointStorage::compose_queue(env, from, to, guid, index)
|
|
89
99
|
}
|
|
90
100
|
}
|
|
101
|
+
|
|
102
|
+
fn assert_compose_index(env: &Env, index: u32) {
|
|
103
|
+
assert_with_error!(env, index <= MAX_COMPOSE_INDEX, EndpointError::InvalidIndex);
|
|
104
|
+
}
|
|
@@ -4,6 +4,14 @@ use soroban_sdk::{Address, BytesN};
|
|
|
4
4
|
|
|
5
5
|
#[storage]
|
|
6
6
|
pub enum EndpointStorage {
|
|
7
|
+
/// The endpoint ID for this chain
|
|
8
|
+
#[instance(u32)]
|
|
9
|
+
Eid,
|
|
10
|
+
|
|
11
|
+
/// The native token address used for messaging fee payments
|
|
12
|
+
#[instance(Address)]
|
|
13
|
+
NativeToken,
|
|
14
|
+
|
|
7
15
|
/// The ZRO token address
|
|
8
16
|
#[instance(Address)]
|
|
9
17
|
Zro,
|
|
@@ -37,7 +45,7 @@ pub enum EndpointStorage {
|
|
|
37
45
|
/// The number of registered libraries
|
|
38
46
|
#[instance(u32)]
|
|
39
47
|
#[default(0)]
|
|
40
|
-
|
|
48
|
+
RegisteredLibrariesCount,
|
|
41
49
|
|
|
42
50
|
/// The mapping of library to index
|
|
43
51
|
#[persistent(u32)]
|
|
@@ -40,9 +40,9 @@ pub fn setup<'a>() -> TestSetup<'a> {
|
|
|
40
40
|
let zro_token_client = StellarAssetClient::new(&env, &zro_token_address);
|
|
41
41
|
|
|
42
42
|
// Deploy the endpoint contract
|
|
43
|
-
let
|
|
43
|
+
let eid: u32 = 30400; // Test EID
|
|
44
|
+
let contract_id = env.register(EndpointV2, (&owner, eid, &native_token_address));
|
|
44
45
|
let endpoint_client = EndpointV2Client::new(&env, &contract_id);
|
|
45
|
-
let eid = endpoint_client.eid();
|
|
46
46
|
|
|
47
47
|
TestSetup { eid, endpoint_client, env, owner, contract_id, native_token_client, zro_token_client }
|
|
48
48
|
}
|
|
@@ -23,7 +23,7 @@ fn pay_messaging_fees(
|
|
|
23
23
|
let env = &context.env;
|
|
24
24
|
let endpoint_addr = &context.endpoint_client.address;
|
|
25
25
|
env.as_contract(endpoint_addr, || {
|
|
26
|
-
EndpointV2::
|
|
26
|
+
EndpointV2::pay_messaging_fees_for_test(env, pay_in_zro, native_fee_recipients, zro_fee_recipients, refund_address)
|
|
27
27
|
})
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -30,7 +30,7 @@ fn test_require_oapp_auth_unauthorized() {
|
|
|
30
30
|
|
|
31
31
|
// Unauthorized address (not oapp itself and not delegate) should fail with Unauthorized error
|
|
32
32
|
env.as_contract(&endpoint_client.address, || {
|
|
33
|
-
EndpointV2::
|
|
33
|
+
EndpointV2::require_oapp_auth_for_test(env, &unauthorized, &oapp);
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -51,6 +51,6 @@ fn test_require_oapp_auth_wrong_delegate() {
|
|
|
51
51
|
|
|
52
52
|
// Wrong delegate (not the actual delegate) should fail with Unauthorized error
|
|
53
53
|
env.as_contract(&endpoint_client.address, || {
|
|
54
|
-
EndpointV2::
|
|
54
|
+
EndpointV2::require_oapp_auth_for_test(env, &wrong_delegate, &oapp);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
@@ -45,7 +45,7 @@ fn test_register_library() {
|
|
|
45
45
|
let stored_lib = storage::EndpointStorage::index_to_library(env, 0);
|
|
46
46
|
assert_eq!(stored_lib, Some(lib_clone.clone()));
|
|
47
47
|
|
|
48
|
-
let new_count = storage::EndpointStorage::
|
|
48
|
+
let new_count = storage::EndpointStorage::registered_libraries_count(env);
|
|
49
49
|
assert_eq!(new_count, 1);
|
|
50
50
|
|
|
51
51
|
let has_library = storage::EndpointStorage::has_library_to_index(env, &lib_clone);
|
|
@@ -90,7 +90,7 @@ fn test_register_library_is_unsupported_interface() {
|
|
|
90
90
|
|
|
91
91
|
// Verify no partial storage updates.
|
|
92
92
|
env.as_contract(&endpoint_client.address, || {
|
|
93
|
-
assert_eq!(storage::EndpointStorage::
|
|
93
|
+
assert_eq!(storage::EndpointStorage::registered_libraries_count(env), 0);
|
|
94
94
|
assert_eq!(storage::EndpointStorage::library_to_index(env, &invalid_lib), None);
|
|
95
95
|
assert!(!storage::EndpointStorage::has_library_to_index(env, &invalid_lib));
|
|
96
96
|
});
|
|
@@ -144,7 +144,7 @@ fn test_register_multiple_libraries_assigns_sequential_indices_and_orders_result
|
|
|
144
144
|
let lib0c = lib0.clone();
|
|
145
145
|
let lib1c = lib1.clone();
|
|
146
146
|
env.as_contract(&endpoint_client.address, || {
|
|
147
|
-
assert_eq!(storage::EndpointStorage::
|
|
147
|
+
assert_eq!(storage::EndpointStorage::registered_libraries_count(env), 2);
|
|
148
148
|
assert_eq!(storage::EndpointStorage::library_to_index(env, &lib0c), Some(0));
|
|
149
149
|
assert_eq!(storage::EndpointStorage::library_to_index(env, &lib1c), Some(1));
|
|
150
150
|
assert_eq!(storage::EndpointStorage::index_to_library(env, 0), Some(lib0c));
|