@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
|
@@ -5,15 +5,14 @@
|
|
|
5
5
|
//! signatures for authorization and implements Soroban's custom account
|
|
6
6
|
//! interface for transaction signing.
|
|
7
7
|
|
|
8
|
-
use crate::{
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
use common_macros::{contract_impl, ttl_configurable};
|
|
8
|
+
use crate::{errors::DvnError, events::SetDstConfig, storage::DvnStorage, Call, DstConfig, DstConfigParam, IDVN};
|
|
9
|
+
use common_macros::{contract_impl, lz_contract};
|
|
12
10
|
use endpoint_v2::FeeRecipient;
|
|
13
11
|
use message_lib_common::interfaces::ILayerZeroDVN;
|
|
14
|
-
use soroban_sdk::{
|
|
15
|
-
use utils::
|
|
16
|
-
|
|
12
|
+
use soroban_sdk::{xdr::ToXdr, Address, Bytes, BytesN, Env, Vec};
|
|
13
|
+
use utils::{
|
|
14
|
+
buffer_writer::BufferWriter, multisig, option_ext::OptionExt, ttl_configurable, upgradeable::UpgradeableInternal,
|
|
15
|
+
};
|
|
17
16
|
use worker::{
|
|
18
17
|
assert_acl, assert_not_paused, assert_supported_message_lib, init_worker, require_admin_auth, set_admin_by_admin,
|
|
19
18
|
set_admin_by_owner, DvnFeeLibClient, DvnFeeParams, Worker,
|
|
@@ -23,8 +22,7 @@ use worker::{
|
|
|
23
22
|
///
|
|
24
23
|
/// Implements multisig-based verification with custom account authorization.
|
|
25
24
|
/// The contract owns itself, allowing the multisig quorum to authorize operations.
|
|
26
|
-
#[
|
|
27
|
-
#[ttl_configurable]
|
|
25
|
+
#[lz_contract(multisig, upgradeable)]
|
|
28
26
|
pub struct LzDVN;
|
|
29
27
|
|
|
30
28
|
// ============================================================================
|
|
@@ -57,8 +55,8 @@ impl LzDVN {
|
|
|
57
55
|
worker_fee_lib: &Address,
|
|
58
56
|
deposit_address: &Address,
|
|
59
57
|
) {
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
ttl_configurable::init_default_ttl_configs(env);
|
|
59
|
+
multisig::init_multisig(env, signers, threshold);
|
|
62
60
|
init_worker::<Self>(
|
|
63
61
|
env,
|
|
64
62
|
admins,
|
|
@@ -200,14 +198,25 @@ impl ILayerZeroDVN for LzDVN {
|
|
|
200
198
|
// Worker Implementation
|
|
201
199
|
// ============================================================================
|
|
202
200
|
|
|
201
|
+
/// Worker trait implementation using default methods for pause, admin, ACL, and fee configuration.
|
|
203
202
|
#[contract_impl(contracttrait)]
|
|
204
203
|
impl Worker for LzDVN {}
|
|
205
204
|
|
|
206
205
|
// ============================================================================
|
|
207
|
-
//
|
|
206
|
+
// Upgradeable Implementation
|
|
207
|
+
// ============================================================================
|
|
208
|
+
|
|
209
|
+
impl UpgradeableInternal for LzDVN {
|
|
210
|
+
type MigrationData = ();
|
|
211
|
+
|
|
212
|
+
fn __migrate(_env: &Env, _migration_data: &Self::MigrationData) {
|
|
213
|
+
// No migration logic needed for initial upgrade capability
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ============================================================================
|
|
218
|
+
// Include Auth Module
|
|
208
219
|
// ============================================================================
|
|
209
220
|
|
|
210
221
|
#[path = "auth.rs"]
|
|
211
222
|
pub mod auth;
|
|
212
|
-
#[path = "multisig.rs"]
|
|
213
|
-
pub mod multisig;
|
|
@@ -5,14 +5,8 @@ pub enum DvnError {
|
|
|
5
5
|
AuthDataExpired,
|
|
6
6
|
EidNotSupported,
|
|
7
7
|
HashAlreadyUsed,
|
|
8
|
-
|
|
8
|
+
InvalidInvocation,
|
|
9
9
|
InvalidVid,
|
|
10
10
|
NonContractInvoke,
|
|
11
11
|
OnlyAdmin,
|
|
12
|
-
SignatureError,
|
|
13
|
-
SignerAlreadyExists,
|
|
14
|
-
SignerNotFound,
|
|
15
|
-
TotalSignersLessThanThreshold,
|
|
16
|
-
UnsortedSigners,
|
|
17
|
-
ZeroThreshold,
|
|
18
12
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
use crate::DstConfigParam;
|
|
2
|
-
use soroban_sdk::{contractevent,
|
|
3
|
-
|
|
4
|
-
#[contractevent]
|
|
5
|
-
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
6
|
-
pub struct SignerSet {
|
|
7
|
-
pub signer: BytesN<20>,
|
|
8
|
-
pub active: bool,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
#[contractevent]
|
|
12
|
-
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
13
|
-
pub struct ThresholdSet {
|
|
14
|
-
pub threshold: u32,
|
|
15
|
-
}
|
|
2
|
+
use soroban_sdk::{contractevent, Vec};
|
|
16
3
|
|
|
17
4
|
#[contractevent]
|
|
18
5
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
use crate::IMultisig;
|
|
2
1
|
use message_lib_common::interfaces::ILayerZeroDVN;
|
|
3
2
|
use soroban_sdk::{contractclient, contracttype, Address, BytesN, Env, Symbol, Val, Vec};
|
|
3
|
+
use utils::multisig::Multisig;
|
|
4
4
|
use worker::Worker;
|
|
5
5
|
|
|
6
6
|
/// Configuration for a destination chain.
|
|
@@ -47,7 +47,7 @@ pub struct Call {
|
|
|
47
47
|
/// Extends the LayerZero DVN interface with destination configuration management
|
|
48
48
|
/// and multisig capabilities for secure cross-chain message verification.
|
|
49
49
|
#[contractclient(name = "DVNClient")]
|
|
50
|
-
pub trait IDVN: ILayerZeroDVN + Worker +
|
|
50
|
+
pub trait IDVN: ILayerZeroDVN + Worker + Multisig {
|
|
51
51
|
/// Sets the configuration for one or more destination chains.
|
|
52
52
|
///
|
|
53
53
|
/// # Arguments
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
use crate::DstConfig;
|
|
2
2
|
use common_macros::storage;
|
|
3
|
-
use soroban_sdk::
|
|
3
|
+
use soroban_sdk::BytesN;
|
|
4
4
|
|
|
5
5
|
/// DVN contract storage keys.
|
|
6
|
+
///
|
|
7
|
+
/// Note: Multisig storage (Signers, Threshold) is provided by `utils::multisig::MultisigStorage`.
|
|
6
8
|
#[storage]
|
|
7
9
|
pub enum DvnStorage {
|
|
8
|
-
// ======================== Multisig ========================
|
|
9
|
-
/// List of authorized signer addresses (20-byte Ethereum addresses).
|
|
10
|
-
#[persistent(Vec<BytesN<20>>)]
|
|
11
|
-
#[default(Vec::new(env))]
|
|
12
|
-
Signers,
|
|
13
|
-
|
|
14
|
-
/// Minimum number of signatures required for multisig operations.
|
|
15
|
-
#[instance(u32)]
|
|
16
|
-
#[default(0)]
|
|
17
|
-
Threshold,
|
|
18
|
-
|
|
19
|
-
// ======================== DVN ============================
|
|
20
10
|
/// Verifier ID - unique identifier for this DVN instance.
|
|
21
11
|
#[instance(u32)]
|
|
22
12
|
Vid,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
use crate::tests::setup::{TestSetup, VID};
|
|
2
1
|
use crate::{
|
|
3
2
|
dvn::auth::{Sender, TransactionAuthData},
|
|
4
3
|
errors::DvnError,
|
|
4
|
+
tests::setup::{TestSetup, VID},
|
|
5
5
|
};
|
|
6
6
|
use ed25519_dalek::{Signer, SigningKey};
|
|
7
7
|
use rand::thread_rng;
|
|
@@ -134,15 +134,15 @@ fn test_check_auth_wrong_signer_fails() {
|
|
|
134
134
|
sender: Sender::Admin(public_key, signature),
|
|
135
135
|
};
|
|
136
136
|
|
|
137
|
-
// verify_signatures panics with
|
|
138
|
-
let res = env.try_invoke_contract_check_auth::<
|
|
137
|
+
// verify_signatures panics with MultisigError::SignerNotFound when signer is not found
|
|
138
|
+
let res = env.try_invoke_contract_check_auth::<utils::errors::MultisigError>(
|
|
139
139
|
&setup.contract_id,
|
|
140
140
|
&payload,
|
|
141
141
|
tx_auth.into_val(&env),
|
|
142
142
|
&auth_contexts,
|
|
143
143
|
);
|
|
144
144
|
|
|
145
|
-
assert_eq!(res, Err(Ok(
|
|
145
|
+
assert_eq!(res, Err(Ok(utils::errors::MultisigError::SignerNotFound)));
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
#[test]
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
use crate::tests::setup::TestSetup;
|
|
2
|
-
use crate::{dvn::LzDVN, DVNClient, DstConfig, DstConfigParam, IDVN};
|
|
1
|
+
use crate::{dvn::LzDVN, tests::setup::TestSetup, DVNClient, DstConfig, DstConfigParam, IDVN};
|
|
3
2
|
use endpoint_v2::FeeRecipient;
|
|
4
3
|
use message_lib_common::interfaces::ILayerZeroDVN;
|
|
5
4
|
use soroban_sdk::{
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
use crate::errors::DvnError;
|
|
2
|
-
use crate::storage::DvnStorage;
|
|
3
1
|
use crate::tests::setup::TestSetup;
|
|
4
2
|
use soroban_sdk::{
|
|
5
3
|
testutils::{AuthorizedFunction, BytesN as _},
|
|
6
4
|
BytesN, Env, IntoVal, Symbol,
|
|
7
5
|
};
|
|
6
|
+
use utils::errors::MultisigError;
|
|
8
7
|
|
|
9
8
|
fn random_signer(env: &Env) -> BytesN<20> {
|
|
10
9
|
BytesN::random(env)
|
|
@@ -12,7 +11,7 @@ fn random_signer(env: &Env) -> BytesN<20> {
|
|
|
12
11
|
|
|
13
12
|
fn clear_signers(setup: &TestSetup) {
|
|
14
13
|
setup.env.as_contract(&setup.contract_id, || {
|
|
15
|
-
|
|
14
|
+
utils::multisig::MultisigStorage::remove_signers(&setup.env);
|
|
16
15
|
});
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -48,7 +47,7 @@ fn test_set_signer_duplicate_fails() {
|
|
|
48
47
|
setup.multisig_client.set_signer(&signer, &true);
|
|
49
48
|
let res = setup.multisig_client.try_set_signer(&signer, &true);
|
|
50
49
|
|
|
51
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
50
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignerAlreadyExists.into());
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
#[test]
|
|
@@ -69,7 +68,7 @@ fn test_set_signer_remove_not_found() {
|
|
|
69
68
|
let signer = random_signer(&setup.env);
|
|
70
69
|
|
|
71
70
|
let res = setup.multisig_client.try_set_signer(&signer, &false);
|
|
72
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
71
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignerNotFound.into());
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
#[test]
|
|
@@ -78,7 +77,7 @@ fn test_set_signer_invalid_signer_zero_address() {
|
|
|
78
77
|
let zero = BytesN::from_array(&setup.env, &[0u8; 20]);
|
|
79
78
|
|
|
80
79
|
let res = setup.multisig_client.try_set_signer(&zero, &true);
|
|
81
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
80
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::InvalidSigner.into());
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
#[test]
|
|
@@ -115,7 +114,7 @@ fn test_remove_signer_when_no_signers() {
|
|
|
115
114
|
|
|
116
115
|
let signer = random_signer(&setup.env);
|
|
117
116
|
let res = setup.multisig_client.try_set_signer(&signer, &false);
|
|
118
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
117
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignerNotFound.into());
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
#[test]
|
|
@@ -129,5 +128,5 @@ fn test_remove_signer_violates_threshold() {
|
|
|
129
128
|
|
|
130
129
|
// Removing a signer should fail because it would leave only 1 signer with threshold 2
|
|
131
130
|
let res = setup.multisig_client.try_set_signer(&signer_to_remove, &false);
|
|
132
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
131
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::TotalSignersLessThanThreshold.into());
|
|
133
132
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
use crate::
|
|
2
|
-
|
|
1
|
+
use crate::{
|
|
2
|
+
dvn::LzDVN,
|
|
3
|
+
tests::setup::{TestSetup, DEFAULT_MULTIPLIER_BPS, VID},
|
|
4
|
+
};
|
|
3
5
|
use soroban_sdk::{
|
|
4
6
|
testutils::{Address as _, AuthorizedFunction, BytesN as _},
|
|
5
7
|
vec, Address, BytesN, Env, IntoVal, Symbol, Vec,
|
|
6
8
|
};
|
|
9
|
+
use utils::errors::MultisigError;
|
|
7
10
|
|
|
8
11
|
fn random_signer(env: &Env) -> BytesN<20> {
|
|
9
12
|
BytesN::random(env)
|
|
@@ -66,7 +69,7 @@ fn test_set_threshold_zero_fails() {
|
|
|
66
69
|
let setup = TestSetup::new(1);
|
|
67
70
|
|
|
68
71
|
let res = setup.multisig_client.try_set_threshold(&0);
|
|
69
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
72
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::ZeroThreshold.into());
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
#[test]
|
|
@@ -74,7 +77,7 @@ fn test_set_threshold_above_signers_fails() {
|
|
|
74
77
|
let setup = TestSetup::new(2);
|
|
75
78
|
|
|
76
79
|
let res = setup.multisig_client.try_set_threshold(&3);
|
|
77
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
80
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::TotalSignersLessThanThreshold.into());
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
#[test]
|
|
@@ -82,15 +85,15 @@ fn test_set_threshold_with_no_signers_fails() {
|
|
|
82
85
|
let setup = TestSetup::new(1);
|
|
83
86
|
|
|
84
87
|
setup.env.as_contract(&setup.contract_id, || {
|
|
85
|
-
|
|
88
|
+
utils::multisig::MultisigStorage::remove_signers(&setup.env);
|
|
86
89
|
});
|
|
87
90
|
|
|
88
91
|
let res = setup.multisig_client.try_set_threshold(&1);
|
|
89
|
-
assert_eq!(res.err().unwrap().ok().unwrap(),
|
|
92
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::TotalSignersLessThanThreshold.into());
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
#[test]
|
|
93
|
-
#[should_panic(expected = "Error(Contract, #
|
|
96
|
+
#[should_panic(expected = "Error(Contract, #1067)")] // ZeroThreshold
|
|
94
97
|
fn test_constructor_threshold_zero_panics() {
|
|
95
98
|
let env = Env::default();
|
|
96
99
|
env.mock_all_auths();
|
|
@@ -99,7 +102,7 @@ fn test_constructor_threshold_zero_panics() {
|
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
#[test]
|
|
102
|
-
#[should_panic(expected = "Error(Contract, #
|
|
105
|
+
#[should_panic(expected = "Error(Contract, #1065)")] // TotalSignersLessThanThreshold
|
|
103
106
|
fn test_constructor_signers_less_than_threshold_panics() {
|
|
104
107
|
let env = Env::default();
|
|
105
108
|
env.mock_all_auths();
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
extern crate std;
|
|
2
2
|
|
|
3
|
-
use crate::
|
|
4
|
-
use crate::tests::key_pair::KeyPair;
|
|
5
|
-
use crate::tests::setup::TestSetup;
|
|
3
|
+
use crate::tests::{key_pair::KeyPair, setup::TestSetup};
|
|
6
4
|
use soroban_sdk::{vec, Bytes, BytesN, Vec};
|
|
5
|
+
use utils::errors::MultisigError;
|
|
7
6
|
|
|
8
7
|
fn hash(env: &soroban_sdk::Env, label: &[u8]) -> BytesN<32> {
|
|
9
8
|
env.crypto().keccak256(&Bytes::from_slice(env, label)).to_bytes()
|
|
@@ -59,7 +58,6 @@ fn test_verify_signatures_raw_v_path() {
|
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
#[test]
|
|
62
|
-
#[should_panic(expected = "Error(Contract, #10)")] // DvnError::SignerNotFound
|
|
63
61
|
fn test_verify_signatures_with_wrong_signer() {
|
|
64
62
|
let setup = TestSetup::new(1);
|
|
65
63
|
let digest = hash(&setup.env, b"test");
|
|
@@ -67,22 +65,22 @@ fn test_verify_signatures_with_wrong_signer() {
|
|
|
67
65
|
let signature = wrong_key_pair.sign(&digest.to_array());
|
|
68
66
|
let signatures: Vec<BytesN<65>> = vec![&setup.env, BytesN::from_array(&setup.env, &signature)];
|
|
69
67
|
|
|
70
|
-
setup.multisig_client.
|
|
68
|
+
let res = setup.multisig_client.try_verify_signatures(&digest, &signatures);
|
|
69
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignerNotFound.into());
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
#[test]
|
|
74
|
-
#[should_panic(expected = "Error(Contract, #8)")] // DvnError::SignatureError
|
|
75
73
|
fn test_verify_signatures_insufficient_signatures() {
|
|
76
74
|
let setup = TestSetup::new(2);
|
|
77
75
|
let digest = hash(&setup.env, b"insufficient");
|
|
78
76
|
|
|
79
77
|
let signatures: Vec<BytesN<65>> = vec![&setup.env, sign(&setup, 0, &digest)];
|
|
80
78
|
|
|
81
|
-
setup.multisig_client.
|
|
79
|
+
let res = setup.multisig_client.try_verify_signatures(&digest, &signatures);
|
|
80
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::SignatureError.into());
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
#[test]
|
|
85
|
-
#[should_panic(expected = "Error(Contract, #12)")] // DvnError::UnsortedSigners
|
|
86
84
|
fn test_verify_signatures_duplicate_signer() {
|
|
87
85
|
let setup = TestSetup::new(2);
|
|
88
86
|
let digest = hash(&setup.env, b"duplicate");
|
|
@@ -90,20 +88,21 @@ fn test_verify_signatures_duplicate_signer() {
|
|
|
90
88
|
let sig1 = sign(&setup, 0, &digest);
|
|
91
89
|
let signatures: Vec<BytesN<65>> = vec![&setup.env, sig1.clone(), sig1];
|
|
92
90
|
|
|
93
|
-
setup.multisig_client.
|
|
91
|
+
let res = setup.multisig_client.try_verify_signatures(&digest, &signatures);
|
|
92
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::UnsortedSigners.into());
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
#[test]
|
|
97
|
-
#[should_panic(expected = "Error(Contract, #13)")] // DvnError::ZeroThreshold
|
|
98
96
|
fn test_verify_signatures_threshold_zero() {
|
|
99
97
|
let setup = TestSetup::new(1);
|
|
100
98
|
// Force threshold to 0 via storage to hit ZeroThreshold branch
|
|
101
99
|
setup.env.as_contract(&setup.contract_id, || {
|
|
102
|
-
|
|
100
|
+
utils::multisig::MultisigStorage::set_threshold(&setup.env, &0);
|
|
103
101
|
});
|
|
104
102
|
let digest = hash(&setup.env, b"threshold_zero");
|
|
105
103
|
|
|
106
104
|
let signatures: Vec<BytesN<65>> = vec![&setup.env, sign(&setup, 0, &digest)];
|
|
107
105
|
|
|
108
|
-
setup.multisig_client.
|
|
106
|
+
let res = setup.multisig_client.try_verify_signatures(&digest, &signatures);
|
|
107
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), MultisigError::ZeroThreshold.into());
|
|
109
108
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
extern crate std;
|
|
4
4
|
|
|
5
|
-
use crate::tests::key_pair::KeyPair;
|
|
6
|
-
use crate::{dvn::LzDVN, interfaces::MultiSigClient};
|
|
5
|
+
use crate::{dvn::LzDVN, tests::key_pair::KeyPair};
|
|
7
6
|
use soroban_sdk::{address_payload::AddressPayload, testutils::Address as _, vec, Address, BytesN, Env, Vec};
|
|
7
|
+
use utils::multisig::MultisigClient;
|
|
8
8
|
use std::vec::Vec as StdVec;
|
|
9
9
|
|
|
10
10
|
pub const VID: u32 = 1;
|
|
@@ -13,7 +13,7 @@ pub const DEFAULT_MULTIPLIER_BPS: u32 = 10000;
|
|
|
13
13
|
pub struct TestSetup<'a> {
|
|
14
14
|
pub env: Env,
|
|
15
15
|
pub contract_id: Address,
|
|
16
|
-
pub multisig_client:
|
|
16
|
+
pub multisig_client: MultisigClient<'a>,
|
|
17
17
|
pub key_pairs: StdVec<KeyPair>,
|
|
18
18
|
pub admins: Vec<Address>,
|
|
19
19
|
}
|
|
@@ -58,7 +58,7 @@ impl<'a> TestSetup<'a> {
|
|
|
58
58
|
),
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
let multisig_client =
|
|
61
|
+
let multisig_client = MultisigClient::new(&env, &contract_id);
|
|
62
62
|
|
|
63
63
|
Self { env, contract_id, multisig_client, key_pairs, admins }
|
|
64
64
|
}
|
|
@@ -102,7 +102,7 @@ impl<'a> TestSetup<'a> {
|
|
|
102
102
|
),
|
|
103
103
|
);
|
|
104
104
|
|
|
105
|
-
let multisig_client =
|
|
105
|
+
let multisig_client = MultisigClient::new(&env, &contract_id);
|
|
106
106
|
|
|
107
107
|
Self { env, contract_id, multisig_client, key_pairs, admins }
|
|
108
108
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
use crate::DvnFeeLibError;
|
|
2
|
-
use common_macros::contract_impl;
|
|
3
|
-
use soroban_sdk::{assert_with_error,
|
|
1
|
+
use crate::errors::DvnFeeLibError;
|
|
2
|
+
use common_macros::{contract_impl, lz_contract};
|
|
3
|
+
use soroban_sdk::{assert_with_error, Address, Env};
|
|
4
|
+
use utils::upgradeable::UpgradeableInternal;
|
|
4
5
|
use worker::{DvnFeeParams, IDvnFeeLib, LayerZeroPriceFeedClient};
|
|
5
6
|
|
|
6
7
|
// ============================================================================
|
|
@@ -11,13 +12,13 @@ use worker::{DvnFeeParams, IDvnFeeLib, LayerZeroPriceFeedClient};
|
|
|
11
12
|
pub(crate) const BPS_BASE: i128 = 10000;
|
|
12
13
|
|
|
13
14
|
/// Fixed bytes for execute function call.
|
|
14
|
-
pub(crate) const EXECUTE_FIXED_BYTES:
|
|
15
|
+
pub(crate) const EXECUTE_FIXED_BYTES: u32 = 260;
|
|
15
16
|
|
|
16
17
|
/// Raw signature bytes length (65 bytes: 64 for signature + 1 for recovery ID).
|
|
17
|
-
pub(crate) const SIGNATURE_RAW_BYTES:
|
|
18
|
+
pub(crate) const SIGNATURE_RAW_BYTES: u32 = 65;
|
|
18
19
|
|
|
19
20
|
/// Verify function bytes (padded).
|
|
20
|
-
pub(crate) const VERIFY_BYTES:
|
|
21
|
+
pub(crate) const VERIFY_BYTES: u32 = 288;
|
|
21
22
|
|
|
22
23
|
/// Native token decimal rate for XLM (10^7 stroops per XLM).
|
|
23
24
|
pub(crate) const NATIVE_DECIMALS_RATE: u128 = 10_000_000;
|
|
@@ -27,30 +28,35 @@ pub(crate) const NATIVE_DECIMALS_RATE: u128 = 10_000_000;
|
|
|
27
28
|
/// Provides fee calculation logic based on quorum size, destination gas costs,
|
|
28
29
|
/// and current gas prices from the price feed. Handles fee multipliers and
|
|
29
30
|
/// floor margins.
|
|
30
|
-
#[
|
|
31
|
+
#[lz_contract(upgradeable)]
|
|
31
32
|
pub struct DvnFeeLib;
|
|
32
33
|
|
|
34
|
+
#[contract_impl]
|
|
35
|
+
impl DvnFeeLib {
|
|
36
|
+
pub fn __constructor(env: &Env, owner: &Address) {
|
|
37
|
+
Self::init_owner(env, owner);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
#[contract_impl]
|
|
34
42
|
impl IDvnFeeLib for DvnFeeLib {
|
|
35
43
|
fn get_fee(env: &Env, _dvn: &Address, params: &DvnFeeParams) -> i128 {
|
|
36
|
-
assert_with_error!(env, params.gas
|
|
44
|
+
assert_with_error!(env, params.gas != 0, DvnFeeLibError::EidNotSupported);
|
|
37
45
|
assert_with_error!(env, params.options.is_empty(), DvnFeeLibError::InvalidDVNOptions);
|
|
38
46
|
|
|
39
|
-
let call_data_size = get_call_data_size(params.quorum
|
|
40
|
-
let call_data_size_u32 =
|
|
41
|
-
u32::try_from(call_data_size).expect("call data size should comfortably fit into u32 for WASM");
|
|
47
|
+
let call_data_size = get_call_data_size(params.quorum);
|
|
42
48
|
|
|
43
49
|
// Get estimated fee from price feed
|
|
44
50
|
let price_feed_client = LayerZeroPriceFeedClient::new(env, ¶ms.price_feed);
|
|
45
51
|
let fee_result = price_feed_client.estimate_fee_by_eid(
|
|
46
52
|
&env.current_contract_address(),
|
|
47
53
|
¶ms.dst_eid,
|
|
48
|
-
&
|
|
54
|
+
&call_data_size,
|
|
49
55
|
¶ms.gas,
|
|
50
56
|
);
|
|
51
|
-
assert_with_error!(env, fee_result.total_gas_fee >= 0, DvnFeeLibError::NegativeFee);
|
|
52
57
|
|
|
53
58
|
apply_premium(
|
|
59
|
+
env,
|
|
54
60
|
fee_result.total_gas_fee,
|
|
55
61
|
params.multiplier_bps,
|
|
56
62
|
params.default_multiplier_bps,
|
|
@@ -60,6 +66,18 @@ impl IDvnFeeLib for DvnFeeLib {
|
|
|
60
66
|
}
|
|
61
67
|
}
|
|
62
68
|
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// Upgradeable Implementation
|
|
71
|
+
// ============================================================================
|
|
72
|
+
|
|
73
|
+
impl UpgradeableInternal for DvnFeeLib {
|
|
74
|
+
type MigrationData = ();
|
|
75
|
+
|
|
76
|
+
fn __migrate(_env: &Env, _migration_data: &Self::MigrationData) {
|
|
77
|
+
// No migration logic needed for initial upgrade capability
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
63
81
|
// ============================================================================
|
|
64
82
|
// Internal Helper Functions
|
|
65
83
|
// ============================================================================
|
|
@@ -79,19 +97,24 @@ impl IDvnFeeLib for DvnFeeLib {
|
|
|
79
97
|
/// # Returns
|
|
80
98
|
/// Fee with premium applied (max of multiplier fee and margin fee).
|
|
81
99
|
pub(crate) fn apply_premium(
|
|
100
|
+
env: &Env,
|
|
82
101
|
fee: i128,
|
|
83
102
|
multiplier_bps: u32,
|
|
84
103
|
default_multiplier_bps: u32,
|
|
85
104
|
floor_margin_usd: u128,
|
|
86
105
|
native_price_usd: u128,
|
|
87
106
|
) -> i128 {
|
|
88
|
-
|
|
107
|
+
assert_with_error!(env, fee >= 0, DvnFeeLibError::InvalidFee);
|
|
89
108
|
|
|
109
|
+
let effective_multiplier_bps = if multiplier_bps == 0 { default_multiplier_bps } else { multiplier_bps };
|
|
90
110
|
let fee_with_multiplier = fee * (effective_multiplier_bps as i128) / BPS_BASE;
|
|
91
111
|
if native_price_usd == 0 || floor_margin_usd == 0 {
|
|
92
112
|
return fee_with_multiplier;
|
|
93
113
|
}
|
|
94
|
-
|
|
114
|
+
|
|
115
|
+
let floor_margin_in_native = safe_u128_to_i128(env, floor_margin_usd * NATIVE_DECIMALS_RATE / native_price_usd);
|
|
116
|
+
let fee_with_floor_margin = fee + floor_margin_in_native;
|
|
117
|
+
|
|
95
118
|
fee_with_floor_margin.max(fee_with_multiplier)
|
|
96
119
|
}
|
|
97
120
|
|
|
@@ -105,10 +128,16 @@ pub(crate) fn apply_premium(
|
|
|
105
128
|
///
|
|
106
129
|
/// # Returns
|
|
107
130
|
/// Total calldata size in bytes.
|
|
108
|
-
pub(crate) fn get_call_data_size(quorum:
|
|
131
|
+
pub(crate) fn get_call_data_size(quorum: u32) -> u32 {
|
|
109
132
|
let mut total_signature_bytes = quorum * SIGNATURE_RAW_BYTES;
|
|
110
133
|
if !total_signature_bytes.is_multiple_of(32) {
|
|
111
134
|
total_signature_bytes = total_signature_bytes - (total_signature_bytes % 32) + 32;
|
|
112
135
|
}
|
|
113
136
|
EXECUTE_FIXED_BYTES + VERIFY_BYTES + total_signature_bytes + 32
|
|
114
137
|
}
|
|
138
|
+
|
|
139
|
+
/// Safely converts u128 to i128, panicking if value exceeds i128::MAX.
|
|
140
|
+
fn safe_u128_to_i128(env: &Env, value: u128) -> i128 {
|
|
141
|
+
assert_with_error!(env, value <= i128::MAX as u128, DvnFeeLibError::Overflow);
|
|
142
|
+
value as i128
|
|
143
|
+
}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
#![no_std]
|
|
2
|
-
#[cfg(test)]
|
|
3
|
-
extern crate std;
|
|
4
|
-
|
|
5
|
-
mod errors;
|
|
6
2
|
|
|
7
|
-
pub
|
|
3
|
+
pub mod dvn_fee_lib;
|
|
4
|
+
pub mod errors;
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
if #[cfg(any(not(feature = "library"), feature = "testutils"))] {
|
|
11
|
-
mod dvn_fee_lib;
|
|
12
|
-
pub use dvn_fee_lib::DvnFeeLib;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
6
|
+
pub use dvn_fee_lib::{DvnFeeLib, DvnFeeLibClient};
|
|
15
7
|
|
|
8
|
+
#[cfg(test)]
|
|
9
|
+
extern crate std;
|
|
16
10
|
#[cfg(test)]
|
|
17
11
|
mod tests;
|