@layerzerolabs/protocol-stellar-v2 0.2.22 → 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
|
@@ -6,15 +6,13 @@ use crate::{
|
|
|
6
6
|
option_ext::OptionExt,
|
|
7
7
|
ownable::{Ownable, OwnableInitializer},
|
|
8
8
|
testing_utils::assert_eq_event,
|
|
9
|
+
tests::test_helper::mock_auth,
|
|
9
10
|
ttl_configurable::{
|
|
10
|
-
TtlConfig, TtlConfigStorage, TtlConfigsFrozen, TtlConfigsSet, TtlConfigurable,
|
|
11
|
+
init_default_ttl_configs, TtlConfig, TtlConfigStorage, TtlConfigsFrozen, TtlConfigsSet, TtlConfigurable,
|
|
12
|
+
LEDGERS_PER_DAY, MAX_TTL,
|
|
11
13
|
},
|
|
12
14
|
};
|
|
13
|
-
use soroban_sdk::{
|
|
14
|
-
contract, contractimpl,
|
|
15
|
-
testutils::{Address as _, MockAuth, MockAuthInvoke},
|
|
16
|
-
Address, Env, IntoVal,
|
|
17
|
-
};
|
|
15
|
+
use soroban_sdk::{contract, contractimpl, testutils::Address as _, Address, Env};
|
|
18
16
|
|
|
19
17
|
const DEFAULT_INSTANCE_TTL: TtlConfig = TtlConfig::new(5 * LEDGERS_PER_DAY, 10 * LEDGERS_PER_DAY);
|
|
20
18
|
const DEFAULT_PERSISTENT_TTL: TtlConfig = TtlConfig::new(5 * LEDGERS_PER_DAY, 10 * LEDGERS_PER_DAY);
|
|
@@ -92,6 +90,10 @@ impl TtlTestContract {
|
|
|
92
90
|
pub fn is_ttl_configs_frozen(env: &Env) -> bool {
|
|
93
91
|
<Self as TtlConfigurable>::is_ttl_configs_frozen(env)
|
|
94
92
|
}
|
|
93
|
+
|
|
94
|
+
pub fn call_init_default_ttl_configs(env: &Env) {
|
|
95
|
+
init_default_ttl_configs(env);
|
|
96
|
+
}
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
// Enable the default `TtlConfigurable` implementation (which requires `Auth`) on the test contract.
|
|
@@ -118,19 +120,6 @@ fn setup_contract() -> (Env, Address, Address, TtlTestContractClient<'static>) {
|
|
|
118
120
|
(env, contract_id, owner, client)
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
fn mock_auth<A: IntoVal<Env, soroban_sdk::Vec<soroban_sdk::Val>>>(
|
|
122
|
-
env: &Env,
|
|
123
|
-
contract_id: &Address,
|
|
124
|
-
address: &Address,
|
|
125
|
-
fn_name: &'static str,
|
|
126
|
-
args: A,
|
|
127
|
-
) {
|
|
128
|
-
env.mock_auths(&[MockAuth {
|
|
129
|
-
address,
|
|
130
|
-
invoke: &MockAuthInvoke { contract: contract_id, args: args.into_val(env), fn_name, sub_invokes: &[] },
|
|
131
|
-
}]);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
123
|
fn owner_set_ttl_configs(
|
|
135
124
|
env: &Env,
|
|
136
125
|
contract_id: &Address,
|
|
@@ -250,42 +239,35 @@ fn test_ttl_config_data_independent_storage() {
|
|
|
250
239
|
}
|
|
251
240
|
|
|
252
241
|
#[test]
|
|
253
|
-
fn
|
|
242
|
+
fn test_ttl_config_data_remove_when_not_set() {
|
|
254
243
|
let (_, _, _owner, client) = setup_contract();
|
|
255
244
|
|
|
256
|
-
|
|
257
|
-
let persistent_cfg = TtlConfig::new(3000, 4000);
|
|
258
|
-
|
|
259
|
-
// Set all configs
|
|
260
|
-
client.set_instance_ttl(&instance_cfg);
|
|
261
|
-
client.set_persistent_ttl(&persistent_cfg);
|
|
262
|
-
|
|
263
|
-
// Verify all are set
|
|
264
|
-
assert!(client.has_instance_ttl());
|
|
265
|
-
assert!(client.has_persistent_ttl());
|
|
266
|
-
|
|
267
|
-
// Remove all
|
|
245
|
+
// Removing when not set should not panic
|
|
268
246
|
client.remove_instance_ttl();
|
|
269
247
|
client.remove_persistent_ttl();
|
|
270
248
|
|
|
271
|
-
//
|
|
272
|
-
assert!(!client.has_instance_ttl());
|
|
273
|
-
assert!(!client.has_persistent_ttl());
|
|
249
|
+
// Should still return defaults
|
|
274
250
|
assert_eq!(client.instance_ttl(), DEFAULT_INSTANCE_TTL);
|
|
275
251
|
assert_eq!(client.persistent_ttl(), DEFAULT_PERSISTENT_TTL);
|
|
276
252
|
}
|
|
277
253
|
|
|
278
254
|
#[test]
|
|
279
|
-
fn
|
|
255
|
+
fn test_init_default_ttl_configs() {
|
|
280
256
|
let (_, _, _owner, client) = setup_contract();
|
|
281
257
|
|
|
282
|
-
//
|
|
283
|
-
client.
|
|
284
|
-
client.
|
|
258
|
+
// Initially no configs set
|
|
259
|
+
assert!(!client.has_instance_ttl());
|
|
260
|
+
assert!(!client.has_persistent_ttl());
|
|
285
261
|
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
|
|
262
|
+
// Call init_default_ttl_configs
|
|
263
|
+
client.call_init_default_ttl_configs();
|
|
264
|
+
|
|
265
|
+
// Both should now be set to default values (29 days threshold, 30 days extend_to)
|
|
266
|
+
let expected_config = TtlConfig::new(29 * LEDGERS_PER_DAY, 30 * LEDGERS_PER_DAY);
|
|
267
|
+
assert!(client.has_instance_ttl());
|
|
268
|
+
assert!(client.has_persistent_ttl());
|
|
269
|
+
assert_eq!(client.instance_ttl(), expected_config);
|
|
270
|
+
assert_eq!(client.persistent_ttl(), expected_config);
|
|
289
271
|
}
|
|
290
272
|
|
|
291
273
|
// ============================================
|
|
@@ -355,14 +337,15 @@ fn test_default_ttl_configurable_set_and_remove() {
|
|
|
355
337
|
let instance = None;
|
|
356
338
|
let persistent = Some(persistent_cfg);
|
|
357
339
|
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
340
|
+
assert_eq_event(&env, &contract_id, TtlConfigsSet { instance, persistent });
|
|
358
341
|
assert_eq!(client.configurable_ttl_configs(), (None, Some(persistent_cfg)));
|
|
359
342
|
|
|
360
|
-
// Remove by passing None
|
|
343
|
+
// Remove both by passing None
|
|
361
344
|
let instance = None;
|
|
362
345
|
let persistent = None;
|
|
363
346
|
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
364
|
-
|
|
365
|
-
|
|
347
|
+
assert_eq_event(&env, &contract_id, TtlConfigsSet { instance, persistent });
|
|
348
|
+
assert_eq!(client.configurable_ttl_configs(), (None, None));
|
|
366
349
|
}
|
|
367
350
|
|
|
368
351
|
// ============================================
|
|
@@ -380,7 +363,24 @@ fn test_default_ttl_configurable_freeze() {
|
|
|
380
363
|
}
|
|
381
364
|
|
|
382
365
|
#[test]
|
|
383
|
-
|
|
366
|
+
fn test_default_ttl_configurable_freeze_preserves_configs() {
|
|
367
|
+
let (env, contract_id, owner, client) = setup_contract();
|
|
368
|
+
|
|
369
|
+
let instance_cfg = TtlConfig::new(1000, 2000);
|
|
370
|
+
let persistent_cfg = TtlConfig::new(3000, 4000);
|
|
371
|
+
let instance = Some(instance_cfg);
|
|
372
|
+
let persistent = Some(persistent_cfg);
|
|
373
|
+
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
374
|
+
assert_eq!(client.configurable_ttl_configs(), (Some(instance_cfg), Some(persistent_cfg)));
|
|
375
|
+
|
|
376
|
+
owner_freeze_ttl_configs(&env, &contract_id, &owner, &client);
|
|
377
|
+
assert!(client.is_ttl_configs_frozen());
|
|
378
|
+
|
|
379
|
+
// Freezing should not alter existing config values.
|
|
380
|
+
assert_eq!(client.configurable_ttl_configs(), (Some(instance_cfg), Some(persistent_cfg)));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
#[test]
|
|
384
384
|
fn test_default_ttl_configurable_set_when_frozen() {
|
|
385
385
|
let (env, contract_id, owner, client) = setup_contract();
|
|
386
386
|
|
|
@@ -389,17 +389,21 @@ fn test_default_ttl_configurable_set_when_frozen() {
|
|
|
389
389
|
let instance_cfg = TtlConfig::new(1000, 2000);
|
|
390
390
|
let instance = Some(instance_cfg);
|
|
391
391
|
let persistent = None;
|
|
392
|
-
|
|
392
|
+
mock_auth(&env, &contract_id, &owner, "configurable_set_ttl_configs", (&instance, &persistent));
|
|
393
|
+
let res = client.try_configurable_set_ttl_configs(&instance, &persistent);
|
|
394
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), TtlConfigurableError::TtlConfigFrozen.into());
|
|
393
395
|
}
|
|
394
396
|
|
|
395
397
|
#[test]
|
|
396
|
-
#[should_panic(expected = "Error(Contract, #1022)")] // TtlConfigAlreadyFrozen
|
|
397
398
|
fn test_default_ttl_configurable_freeze_when_already_frozen() {
|
|
398
399
|
let (env, contract_id, owner, client) = setup_contract();
|
|
399
400
|
|
|
400
401
|
owner_freeze_ttl_configs(&env, &contract_id, &owner, &client);
|
|
401
402
|
assert_eq_event(&env, &contract_id, TtlConfigsFrozen {});
|
|
402
|
-
|
|
403
|
+
|
|
404
|
+
mock_auth(&env, &contract_id, &owner, "configurable_freeze_ttl_configs", ());
|
|
405
|
+
let res = client.try_configurable_freeze_ttl_configs();
|
|
406
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), TtlConfigurableError::TtlConfigAlreadyFrozen.into());
|
|
403
407
|
}
|
|
404
408
|
|
|
405
409
|
#[test]
|
|
@@ -423,7 +427,6 @@ fn test_default_ttl_configurable_freeze_wrong_signer_fails() {
|
|
|
423
427
|
}
|
|
424
428
|
|
|
425
429
|
#[test]
|
|
426
|
-
#[should_panic(expected = "Error(Contract, #1034)")] // OwnerNotSet
|
|
427
430
|
fn test_default_ttl_configurable_freeze_when_owner_not_set() {
|
|
428
431
|
let env = Env::default();
|
|
429
432
|
let contract_id = env.register(TtlTestContract, ());
|
|
@@ -433,7 +436,8 @@ fn test_default_ttl_configurable_freeze_when_owner_not_set() {
|
|
|
433
436
|
|
|
434
437
|
// Even with auth, `require_owner_auth` should fail because no owner is set in storage.
|
|
435
438
|
mock_auth(&env, &contract_id, &owner, "configurable_freeze_ttl_configs", ());
|
|
436
|
-
client.
|
|
439
|
+
let res = client.try_configurable_freeze_ttl_configs();
|
|
440
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), OwnableError::OwnerNotSet.into());
|
|
437
441
|
}
|
|
438
442
|
|
|
439
443
|
// ============================================
|
|
@@ -441,34 +445,26 @@ fn test_default_ttl_configurable_freeze_when_owner_not_set() {
|
|
|
441
445
|
// ============================================
|
|
442
446
|
|
|
443
447
|
#[test]
|
|
444
|
-
#[should_panic(expected = "Error(Contract, #1020)")] // InvalidTtlConfig
|
|
445
448
|
fn test_default_ttl_configurable_invalid_instance_config() {
|
|
446
449
|
let (env, contract_id, owner, client) = setup_contract();
|
|
447
450
|
// threshold > extend_to is invalid
|
|
448
451
|
let invalid_cfg = TtlConfig::new(3000, 2000);
|
|
449
452
|
let instance = Some(invalid_cfg);
|
|
450
453
|
let persistent = None;
|
|
451
|
-
|
|
454
|
+
mock_auth(&env, &contract_id, &owner, "configurable_set_ttl_configs", (&instance, &persistent));
|
|
455
|
+
let res = client.try_configurable_set_ttl_configs(&instance, &persistent);
|
|
456
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), TtlConfigurableError::InvalidTtlConfig.into());
|
|
452
457
|
}
|
|
453
458
|
|
|
454
459
|
#[test]
|
|
455
|
-
#[should_panic(expected = "Error(Contract, #1020)")] // InvalidTtlConfig
|
|
456
460
|
fn test_default_ttl_configurable_invalid_persistent_config() {
|
|
457
461
|
let (env, contract_id, owner, client) = setup_contract();
|
|
458
462
|
let invalid_cfg = TtlConfig::new(5000, 4000);
|
|
459
463
|
let instance = None;
|
|
460
464
|
let persistent = Some(invalid_cfg);
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
#[test]
|
|
465
|
-
#[should_panic(expected = "Error(Contract, #1020)")] // InvalidTtlConfig
|
|
466
|
-
fn test_default_ttl_configurable_exceeds_max_ttl() {
|
|
467
|
-
let (env, contract_id, owner, client) = setup_contract();
|
|
468
|
-
let invalid_cfg = TtlConfig::new(1000, MAX_TTL + 1);
|
|
469
|
-
let instance = Some(invalid_cfg);
|
|
470
|
-
let persistent = None;
|
|
471
|
-
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
465
|
+
mock_auth(&env, &contract_id, &owner, "configurable_set_ttl_configs", (&instance, &persistent));
|
|
466
|
+
let res = client.try_configurable_set_ttl_configs(&instance, &persistent);
|
|
467
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), TtlConfigurableError::InvalidTtlConfig.into());
|
|
472
468
|
}
|
|
473
469
|
|
|
474
470
|
#[test]
|
|
@@ -529,7 +525,6 @@ fn test_default_ttl_configurable_set_wrong_signer_fails() {
|
|
|
529
525
|
}
|
|
530
526
|
|
|
531
527
|
#[test]
|
|
532
|
-
#[should_panic(expected = "Error(Contract, #1034)")] // OwnerNotSet
|
|
533
528
|
fn test_default_ttl_configurable_set_when_owner_not_set() {
|
|
534
529
|
let env = Env::default();
|
|
535
530
|
let contract_id = env.register(TtlTestContract, ());
|
|
@@ -541,11 +536,11 @@ fn test_default_ttl_configurable_set_when_owner_not_set() {
|
|
|
541
536
|
|
|
542
537
|
// Even with auth, `require_owner_auth` should fail because no owner is set in storage.
|
|
543
538
|
mock_auth(&env, &contract_id, &owner, "configurable_set_ttl_configs", (&instance, &persistent));
|
|
544
|
-
client.
|
|
539
|
+
let res = client.try_configurable_set_ttl_configs(&instance, &persistent);
|
|
540
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), OwnableError::OwnerNotSet.into());
|
|
545
541
|
}
|
|
546
542
|
|
|
547
543
|
#[test]
|
|
548
|
-
#[should_panic(expected = "Error(Contract, #1020)")] // InvalidTtlConfig
|
|
549
544
|
fn test_default_ttl_configurable_exceeds_effective_max_ttl() {
|
|
550
545
|
let (env, contract_id, owner, client) = setup_contract();
|
|
551
546
|
|
|
@@ -554,30 +549,15 @@ fn test_default_ttl_configurable_exceeds_effective_max_ttl() {
|
|
|
554
549
|
let instance = Some(TtlConfig::new(1, invalid_extend_to));
|
|
555
550
|
let persistent = None;
|
|
556
551
|
|
|
557
|
-
|
|
552
|
+
mock_auth(&env, &contract_id, &owner, "configurable_set_ttl_configs", (&instance, &persistent));
|
|
553
|
+
let res = client.try_configurable_set_ttl_configs(&instance, &persistent);
|
|
554
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), TtlConfigurableError::InvalidTtlConfig.into());
|
|
558
555
|
}
|
|
559
556
|
|
|
560
557
|
// ============================================
|
|
561
558
|
// DefaultTtlConfigurable Tests - Boundary Values
|
|
562
559
|
// ============================================
|
|
563
560
|
|
|
564
|
-
#[test]
|
|
565
|
-
fn test_default_ttl_configurable_at_max_ttl() {
|
|
566
|
-
let (env, contract_id, owner, client) = setup_contract();
|
|
567
|
-
|
|
568
|
-
// Get the effective max TTL
|
|
569
|
-
let effective_max = u32::min(MAX_TTL, env.storage().max_ttl());
|
|
570
|
-
|
|
571
|
-
// extend_to == effective_max should be valid
|
|
572
|
-
let valid_cfg = TtlConfig::new(1000, effective_max);
|
|
573
|
-
let instance = Some(valid_cfg);
|
|
574
|
-
let persistent = None;
|
|
575
|
-
owner_set_ttl_configs(&env, &contract_id, &owner, &client, &instance, &persistent);
|
|
576
|
-
|
|
577
|
-
let (instance, _) = client.configurable_ttl_configs();
|
|
578
|
-
assert_eq!(instance, Some(valid_cfg));
|
|
579
|
-
}
|
|
580
|
-
|
|
581
561
|
#[test]
|
|
582
562
|
fn test_default_ttl_configurable_boundary_values() {
|
|
583
563
|
let (env, contract_id, owner, client) = setup_contract();
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
use crate::ttl_extendable::TtlExtendable;
|
|
2
|
+
use soroban_sdk::{contract, contractimpl, testutils::storage::Instance as _, testutils::Ledger as _, Env};
|
|
3
|
+
|
|
4
|
+
// ============================================
|
|
5
|
+
// Test Contract for TtlExtendable
|
|
6
|
+
// ============================================
|
|
7
|
+
|
|
8
|
+
#[contract]
|
|
9
|
+
pub struct TtlExtendableTestContract;
|
|
10
|
+
|
|
11
|
+
#[contractimpl(contracttrait)]
|
|
12
|
+
impl TtlExtendable for TtlExtendableTestContract {}
|
|
13
|
+
|
|
14
|
+
// ============================================
|
|
15
|
+
// TtlExtendable Tests
|
|
16
|
+
// ============================================
|
|
17
|
+
|
|
18
|
+
#[test]
|
|
19
|
+
fn test_extend_instance_ttl_updates_instance_ttl() {
|
|
20
|
+
let env = Env::default();
|
|
21
|
+
let contract_id = env.register(TtlExtendableTestContract, ());
|
|
22
|
+
let client = TtlExtendableTestContractClient::new(&env, &contract_id);
|
|
23
|
+
|
|
24
|
+
// This is a minimal, high-signal assertion:
|
|
25
|
+
// verify we actually extended *instance* TTL via the Soroban host.
|
|
26
|
+
let (ttl_before, seq_before) =
|
|
27
|
+
env.as_contract(&contract_id, || (env.storage().instance().get_ttl(), env.ledger().sequence()));
|
|
28
|
+
let live_until = seq_before + ttl_before;
|
|
29
|
+
let threshold = ttl_before.saturating_sub(1);
|
|
30
|
+
let extend_to = ttl_before + 500;
|
|
31
|
+
|
|
32
|
+
// Move ledger sequence so TTL is below threshold, ensuring extension triggers.
|
|
33
|
+
env.ledger().set_sequence_number(live_until - threshold);
|
|
34
|
+
|
|
35
|
+
client.extend_instance_ttl(&threshold, &extend_to);
|
|
36
|
+
|
|
37
|
+
let ttl_after = env.as_contract(&contract_id, || env.storage().instance().get_ttl());
|
|
38
|
+
assert_eq!(ttl_after, extend_to);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#[test]
|
|
42
|
+
fn test_extend_instance_ttl_noop_when_above_threshold() {
|
|
43
|
+
let env = Env::default();
|
|
44
|
+
let contract_id = env.register(TtlExtendableTestContract, ());
|
|
45
|
+
let client = TtlExtendableTestContractClient::new(&env, &contract_id);
|
|
46
|
+
|
|
47
|
+
// First, force an extension so we have a known positive TTL baseline.
|
|
48
|
+
let (ttl_before, seq_before) =
|
|
49
|
+
env.as_contract(&contract_id, || (env.storage().instance().get_ttl(), env.ledger().sequence()));
|
|
50
|
+
let live_until = seq_before + ttl_before;
|
|
51
|
+
let threshold = ttl_before.saturating_sub(1);
|
|
52
|
+
let extend_to = ttl_before + 500;
|
|
53
|
+
env.ledger().set_sequence_number(live_until - threshold);
|
|
54
|
+
client.extend_instance_ttl(&threshold, &extend_to);
|
|
55
|
+
let ttl_after = env.as_contract(&contract_id, || env.storage().instance().get_ttl());
|
|
56
|
+
assert_eq!(ttl_after, extend_to);
|
|
57
|
+
|
|
58
|
+
// Now call again with a threshold below the current TTL; it should NOT extend further.
|
|
59
|
+
let threshold = ttl_after.saturating_sub(1);
|
|
60
|
+
let extend_to_2 = ttl_after + 500;
|
|
61
|
+
client.extend_instance_ttl(&threshold, &extend_to_2);
|
|
62
|
+
let ttl_after_2 = env.as_contract(&contract_id, || env.storage().instance().get_ttl());
|
|
63
|
+
assert_eq!(ttl_after_2, ttl_after);
|
|
64
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
use crate::errors::UpgradeableError;
|
|
1
2
|
use crate::upgradeable::{Upgradeable, UpgradeableInternal, UpgradeableStorage};
|
|
2
3
|
use soroban_sdk::{contract, contractimpl, xdr::ToXdr, Address, Bytes, Env, Symbol, Val};
|
|
3
4
|
|
|
@@ -334,6 +335,28 @@ impl UpgradeableInternal for DummyContract {
|
|
|
334
335
|
#[contractimpl(contracttrait)]
|
|
335
336
|
impl Upgradeable for DummyContract {}
|
|
336
337
|
|
|
338
|
+
// Same as DummyContract but with a strict migration payload type so we can
|
|
339
|
+
// exercise the InvalidMigrationData error path in Upgradeable::migrate.
|
|
340
|
+
#[contract]
|
|
341
|
+
pub struct U32MigrationContract;
|
|
342
|
+
|
|
343
|
+
impl Auth for U32MigrationContract {
|
|
344
|
+
fn authorizer(env: &Env) -> Address {
|
|
345
|
+
env.current_contract_address()
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
impl UpgradeableInternal for U32MigrationContract {
|
|
350
|
+
type MigrationData = u32;
|
|
351
|
+
|
|
352
|
+
fn __migrate(env: &Env, migration_data: &Self::MigrationData) {
|
|
353
|
+
env.storage().instance().set(&Symbol::new(env, "migrated_u32"), migration_data);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
#[contractimpl(contracttrait)]
|
|
358
|
+
impl Upgradeable for U32MigrationContract {}
|
|
359
|
+
|
|
337
360
|
#[test]
|
|
338
361
|
fn test_upgrade_success() {
|
|
339
362
|
let env = Env::default();
|
|
@@ -358,6 +381,20 @@ fn test_upgrade_success() {
|
|
|
358
381
|
});
|
|
359
382
|
}
|
|
360
383
|
|
|
384
|
+
#[test]
|
|
385
|
+
#[should_panic(expected = "Error(Auth, InvalidAction)")]
|
|
386
|
+
fn test_upgrade_requires_auth() {
|
|
387
|
+
let env = Env::default();
|
|
388
|
+
// Note: NOT calling mock_all_auths() - auth will fail
|
|
389
|
+
let contract_id = env.register(DummyContract, ());
|
|
390
|
+
let client = DummyContractClient::new(&env, &contract_id);
|
|
391
|
+
|
|
392
|
+
// Upload valid contract WASM to get a valid hash
|
|
393
|
+
let wasm_hash = env.deployer().upload_contract_wasm(Bytes::from_slice(&env, TEST_WASM));
|
|
394
|
+
|
|
395
|
+
client.upgrade(&wasm_hash);
|
|
396
|
+
}
|
|
397
|
+
|
|
361
398
|
// After upgrade(), the contract runs TEST_WASM code, so migrate() must match that wasm's API.
|
|
362
399
|
#[test]
|
|
363
400
|
fn test_migrate_success() {
|
|
@@ -384,7 +421,77 @@ fn test_migrate_success() {
|
|
|
384
421
|
}
|
|
385
422
|
|
|
386
423
|
#[test]
|
|
387
|
-
#[should_panic(expected = "Error(
|
|
424
|
+
#[should_panic(expected = "Error(Auth, InvalidAction)")]
|
|
425
|
+
fn test_migrate_requires_auth() {
|
|
426
|
+
let env = Env::default();
|
|
427
|
+
// Note: NOT calling mock_all_auths() - auth will fail
|
|
428
|
+
let contract_id = env.register(DummyContract, ());
|
|
429
|
+
let client = DummyContractClient::new(&env, &contract_id);
|
|
430
|
+
|
|
431
|
+
// Set the migrating flag so we know failure is due to auth, not MigrationNotAllowed.
|
|
432
|
+
env.as_contract(&contract_id, || {
|
|
433
|
+
UpgradeableStorage::set_migrating(&env, &true);
|
|
434
|
+
assert_eq!(UpgradeableStorage::migrating(&env), true);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
let migration_data = Val::VOID.to_xdr(&env);
|
|
438
|
+
client.migrate(&migration_data);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
#[test]
|
|
442
|
+
fn test_migrate_rejects_invalid_migration_data_and_does_not_clear_flag() {
|
|
443
|
+
let env = Env::default();
|
|
444
|
+
env.mock_all_auths();
|
|
445
|
+
let contract_id = env.register(U32MigrationContract, ());
|
|
446
|
+
let client = U32MigrationContractClient::new(&env, &contract_id);
|
|
447
|
+
|
|
448
|
+
// Allow migrate (so we hit the decode path rather than MigrationNotAllowed).
|
|
449
|
+
env.as_contract(&contract_id, || {
|
|
450
|
+
UpgradeableStorage::set_migrating(&env, &true);
|
|
451
|
+
assert_eq!(UpgradeableStorage::migrating(&env), true);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
// Valid XDR, but not a u32 payload => should fail decoding in Upgradeable::migrate.
|
|
455
|
+
let bad_bytes = Val::VOID.to_xdr(&env);
|
|
456
|
+
let res = client.try_migrate(&bad_bytes);
|
|
457
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), UpgradeableError::InvalidMigrationData.into());
|
|
458
|
+
|
|
459
|
+
// Since migration failed before reaching the "clear flag" line, migrating should still be true.
|
|
460
|
+
env.as_contract(&contract_id, || {
|
|
461
|
+
assert_eq!(UpgradeableStorage::migrating(&env), true);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
#[test]
|
|
466
|
+
fn test_can_upgrade_and_migrate_multiple_times() {
|
|
467
|
+
let env = Env::default();
|
|
468
|
+
env.mock_all_auths();
|
|
469
|
+
let contract_id = env.register(DummyContract, ());
|
|
470
|
+
let client = DummyContractClient::new(&env, &contract_id);
|
|
471
|
+
|
|
472
|
+
let wasm_hash = env.deployer().upload_contract_wasm(Bytes::from_slice(&env, TEST_WASM));
|
|
473
|
+
let migration_data = Val::VOID.to_xdr(&env);
|
|
474
|
+
|
|
475
|
+
// First cycle
|
|
476
|
+
client.upgrade(&wasm_hash);
|
|
477
|
+
client.migrate(&migration_data);
|
|
478
|
+
env.as_contract(&contract_id, || {
|
|
479
|
+
assert_eq!(UpgradeableStorage::migrating(&env), false);
|
|
480
|
+
let stored_value: Option<bool> = env.storage().instance().get(&Symbol::new(&env, "migrated"));
|
|
481
|
+
assert_eq!(stored_value, Some(true));
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
// Second cycle (must be allowed)
|
|
485
|
+
client.upgrade(&wasm_hash);
|
|
486
|
+
client.migrate(&migration_data);
|
|
487
|
+
env.as_contract(&contract_id, || {
|
|
488
|
+
assert_eq!(UpgradeableStorage::migrating(&env), false);
|
|
489
|
+
let stored_value: Option<bool> = env.storage().instance().get(&Symbol::new(&env, "migrated"));
|
|
490
|
+
assert_eq!(stored_value, Some(true));
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
#[test]
|
|
388
495
|
fn test_migrate_fail_without_upgrade() {
|
|
389
496
|
let env = Env::default();
|
|
390
497
|
env.mock_all_auths();
|
|
@@ -394,7 +501,8 @@ fn test_migrate_fail_without_upgrade() {
|
|
|
394
501
|
// Try to migrate without setting migrating flag first
|
|
395
502
|
// Should panic with MigrationNotAllowed
|
|
396
503
|
let migration_data = Val::VOID.to_xdr(&env);
|
|
397
|
-
client.
|
|
504
|
+
let result = client.try_migrate(&migration_data);
|
|
505
|
+
assert_eq!(result.err().unwrap().ok().unwrap(), UpgradeableError::MigrationNotAllowed.into());
|
|
398
506
|
}
|
|
399
507
|
|
|
400
508
|
// ============================================
|
|
@@ -402,7 +510,6 @@ fn test_migrate_fail_without_upgrade() {
|
|
|
402
510
|
// ============================================
|
|
403
511
|
|
|
404
512
|
#[test]
|
|
405
|
-
#[should_panic(expected = "Error(Contract, #1051)")] // MigrationNotAllowed
|
|
406
513
|
fn test_cannot_migrate_twice_without_upgrade() {
|
|
407
514
|
let env = Env::default();
|
|
408
515
|
env.mock_all_auths();
|
|
@@ -417,7 +524,8 @@ fn test_cannot_migrate_twice_without_upgrade() {
|
|
|
417
524
|
client.migrate(&migration_data);
|
|
418
525
|
|
|
419
526
|
// Try to migrate again without upgrade - should panic
|
|
420
|
-
client.
|
|
527
|
+
let result = client.try_migrate(&migration_data);
|
|
528
|
+
assert_eq!(result.err().unwrap().ok().unwrap(), UpgradeableError::MigrationNotAllowed.into());
|
|
421
529
|
}
|
|
422
530
|
|
|
423
531
|
// ============================================
|
|
@@ -460,18 +568,19 @@ fn test_upgrade_fails_when_frozen() {
|
|
|
460
568
|
}
|
|
461
569
|
|
|
462
570
|
#[test]
|
|
571
|
+
#[should_panic(expected = "Error(Contract, #1052)")] // UpgradesFrozen
|
|
463
572
|
fn test_freeze_multiple_times() {
|
|
464
573
|
let env = Env::default();
|
|
465
574
|
env.mock_all_auths();
|
|
466
575
|
let contract_id = env.register(DummyContract, ());
|
|
467
576
|
let client = DummyContractClient::new(&env, &contract_id);
|
|
468
577
|
|
|
469
|
-
//
|
|
578
|
+
// First freeze should succeed
|
|
470
579
|
client.freeze();
|
|
471
580
|
assert_eq!(client.is_frozen(), true);
|
|
472
581
|
|
|
582
|
+
// Second freeze should panic with UpgradesFrozen
|
|
473
583
|
client.freeze();
|
|
474
|
-
assert_eq!(client.is_frozen(), true);
|
|
475
584
|
}
|
|
476
585
|
|
|
477
586
|
#[test]
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
use crate::{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
errors::TtlConfigurableError,
|
|
5
|
-
};
|
|
6
|
-
use common_macros::contract_trait;
|
|
7
|
-
use soroban_sdk::{assert_with_error, contractevent, contracttype, Env};
|
|
1
|
+
use crate::{self as utils, auth::Auth, errors::TtlConfigurableError};
|
|
2
|
+
use common_macros::{contract_trait, only_auth, storage};
|
|
3
|
+
use soroban_sdk::{assert_with_error, contractevent, contracttype, Env, IntoVal, Val};
|
|
8
4
|
|
|
9
5
|
/// Ledgers per day (~5 second close time).
|
|
10
6
|
pub const LEDGERS_PER_DAY: u32 = (24 * 3600) / 5;
|
|
@@ -64,7 +60,7 @@ pub struct TtlConfigsFrozen {}
|
|
|
64
60
|
/// Note: Auto-TTL extension is disabled for these instance storage entries to avoid infinite
|
|
65
61
|
/// recursion. Extending TTL config storage would require reading the TTL config, which would
|
|
66
62
|
/// trigger another extension, creating a deep loop.
|
|
67
|
-
#[
|
|
63
|
+
#[storage]
|
|
68
64
|
pub enum TtlConfigStorage {
|
|
69
65
|
#[instance(bool)]
|
|
70
66
|
#[default(false)]
|
|
@@ -86,6 +82,20 @@ pub fn init_default_ttl_configs(env: &Env) {
|
|
|
86
82
|
TtlConfigStorage::set_persistent(env, &default_ttl_config);
|
|
87
83
|
}
|
|
88
84
|
|
|
85
|
+
/// Extends instance storage TTL using the configured settings (if any).
|
|
86
|
+
pub fn extend_instance_ttl(env: &Env) {
|
|
87
|
+
if let Some(TtlConfig { threshold, extend_to }) = TtlConfigStorage::instance(env) {
|
|
88
|
+
env.storage().instance().extend_ttl(threshold, extend_to);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// Extends persistent storage TTL for a key using the configured settings (if any).
|
|
93
|
+
pub fn extend_persistent_ttl<K: IntoVal<Env, Val>>(env: &Env, key: &K) {
|
|
94
|
+
if let Some(TtlConfig { threshold, extend_to }) = TtlConfigStorage::persistent(env) {
|
|
95
|
+
env.storage().persistent().extend_ttl(key, threshold, extend_to);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
89
99
|
/// Trait for contracts that support configurable TTL (Time-To-Live) management.
|
|
90
100
|
///
|
|
91
101
|
/// Allows the contract authorizer to configure how long instance and persistent storage entries
|
|
@@ -96,7 +106,7 @@ pub fn init_default_ttl_configs(env: &Env) {
|
|
|
96
106
|
///
|
|
97
107
|
/// Requires the `Auth` trait to be implemented, which can be provided by either:
|
|
98
108
|
/// - `#[ownable]` macro for single-owner contracts
|
|
99
|
-
/// - `
|
|
109
|
+
/// - `#[multisig]` macro for multisig-controlled contracts
|
|
100
110
|
#[contract_trait]
|
|
101
111
|
pub trait TtlConfigurable: Auth {
|
|
102
112
|
/// Sets TTL configs for instance and persistent storage.
|
|
@@ -111,15 +121,15 @@ pub trait TtlConfigurable: Auth {
|
|
|
111
121
|
/// # Panics
|
|
112
122
|
/// - `TtlConfigFrozen` if configs are frozen
|
|
113
123
|
/// - `InvalidTtlConfig` if validation fails
|
|
124
|
+
#[only_auth]
|
|
114
125
|
fn set_ttl_configs(
|
|
115
126
|
env: &soroban_sdk::Env,
|
|
116
127
|
instance: &Option<utils::ttl_configurable::TtlConfig>,
|
|
117
128
|
persistent: &Option<utils::ttl_configurable::TtlConfig>,
|
|
118
129
|
) {
|
|
119
|
-
auth::require_auth::<Self>(env);
|
|
120
130
|
assert_with_error!(env, !Self::is_ttl_configs_frozen(env), TtlConfigurableError::TtlConfigFrozen);
|
|
121
131
|
|
|
122
|
-
let max_ttl =
|
|
132
|
+
let max_ttl = MAX_TTL.min(env.storage().max_ttl());
|
|
123
133
|
let all_valid = [instance, persistent].iter().all(|c| c.is_none_or(|cfg| cfg.is_valid(max_ttl)));
|
|
124
134
|
assert_with_error!(env, all_valid, TtlConfigurableError::InvalidTtlConfig);
|
|
125
135
|
|
|
@@ -143,8 +153,8 @@ pub trait TtlConfigurable: Auth {
|
|
|
143
153
|
///
|
|
144
154
|
/// # Panics
|
|
145
155
|
/// - `TtlConfigAlreadyFrozen` if already frozen
|
|
156
|
+
#[only_auth]
|
|
146
157
|
fn freeze_ttl_configs(env: &soroban_sdk::Env) {
|
|
147
|
-
auth::require_auth::<Self>(env);
|
|
148
158
|
assert_with_error!(env, !Self::is_ttl_configs_frozen(env), TtlConfigurableError::TtlConfigAlreadyFrozen);
|
|
149
159
|
|
|
150
160
|
TtlConfigStorage::set_frozen(env, &true);
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
//! This module provides the `TtlExtendable` trait which allows external callers
|
|
4
4
|
//! to extend a contract's instance storage TTL, keeping the contract alive.
|
|
5
5
|
|
|
6
|
-
use soroban_sdk::Env;
|
|
7
|
-
|
|
8
6
|
/// Trait for contracts that support manual instance TTL extension.
|
|
9
7
|
///
|
|
10
8
|
/// This trait provides a public contract function to extend the instance storage TTL,
|
|
@@ -21,7 +19,7 @@ pub trait TtlExtendable {
|
|
|
21
19
|
///
|
|
22
20
|
/// * `threshold` - The threshold to extend the TTL (if current TTL is below this, extend).
|
|
23
21
|
/// * `extend_to` - The TTL to extend to.
|
|
24
|
-
fn extend_instance_ttl(env: &Env, threshold: u32, extend_to: u32) {
|
|
22
|
+
fn extend_instance_ttl(env: &soroban_sdk::Env, threshold: u32, extend_to: u32) {
|
|
25
23
|
env.storage().instance().extend_ttl(threshold, extend_to);
|
|
26
24
|
}
|
|
27
25
|
}
|