@layerzerolabs/protocol-stellar-v2 0.2.21 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +347 -271
- package/.turbo/turbo-lint.log +277 -208
- package/.turbo/turbo-test.log +1700 -1370
- package/Cargo.lock +22 -51
- package/Cargo.toml +6 -1
- package/contracts/common-macros/src/auth.rs +10 -9
- package/contracts/common-macros/src/contract_ttl.rs +1 -4
- package/contracts/common-macros/src/error.rs +1 -3
- package/contracts/common-macros/src/lib.rs +65 -61
- package/contracts/common-macros/src/storage.rs +212 -65
- package/contracts/common-macros/src/tests/auth.rs +75 -6
- package/contracts/common-macros/src/tests/contract_ttl.rs +383 -350
- package/contracts/common-macros/src/tests/error.rs +9 -21
- package/contracts/common-macros/src/tests/lz_contract.rs +80 -0
- package/contracts/common-macros/src/tests/mod.rs +2 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -3
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +28 -1
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap +8 -43
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +6 -29
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__lz_contract__snapshot_generated_lz_contract_code.snap +31 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_extendable__snapshot_generated_ttl_extendable_code.snap +8 -0
- package/contracts/common-macros/src/tests/storage/extract_fields.rs +87 -0
- package/contracts/common-macros/src/tests/storage/gen_accessor_methods.rs +223 -0
- package/contracts/common-macros/src/tests/storage/gen_args.rs +65 -0
- package/contracts/common-macros/src/tests/storage/gen_enum_variant.rs +78 -0
- package/contracts/common-macros/src/tests/storage/gen_key.rs +108 -0
- package/contracts/common-macros/src/tests/storage/gen_params.rs +105 -0
- package/contracts/common-macros/src/tests/{storage.rs → storage/generate_storage.rs} +54 -129
- package/contracts/common-macros/src/tests/storage/is_primitive_type.rs +48 -0
- package/contracts/common-macros/src/tests/storage/mod.rs +16 -0
- package/contracts/common-macros/src/tests/storage/parse_default.rs +164 -0
- package/contracts/common-macros/src/tests/storage/parse_name.rs +159 -0
- package/contracts/common-macros/src/tests/storage/parse_no_ttl_extension.rs +124 -0
- package/contracts/common-macros/src/tests/storage/parse_storage_type.rs +174 -0
- package/contracts/common-macros/src/tests/storage/snapshots/common_macros__tests__storage__generate_storage__snapshot_generated_storage_code.snap +412 -0
- package/contracts/common-macros/src/tests/storage/storage_kind.rs +39 -0
- package/contracts/common-macros/src/tests/storage/test_setup.rs +25 -0
- package/contracts/common-macros/src/tests/storage/validate_attrs.rs +138 -0
- package/contracts/common-macros/src/tests/storage/variant_config.rs +226 -0
- package/contracts/common-macros/src/tests/test_helpers.rs +4 -10
- package/contracts/common-macros/src/tests/ttl_configurable.rs +2 -2
- package/contracts/common-macros/src/tests/ttl_extendable.rs +32 -0
- package/contracts/common-macros/src/tests/upgradeable.rs +118 -2
- package/contracts/common-macros/src/ttl_configurable.rs +1 -4
- package/contracts/common-macros/src/upgradeable.rs +21 -3
- package/contracts/endpoint-v2/Cargo.toml +0 -4
- package/contracts/endpoint-v2/src/endpoint_v2.rs +37 -17
- package/contracts/endpoint-v2/src/errors.rs +26 -1
- package/contracts/endpoint-v2/src/interfaces/layerzero_endpoint_v2.rs +1 -1
- package/contracts/endpoint-v2/src/interfaces/message_lib_manager.rs +4 -4
- package/contracts/endpoint-v2/src/interfaces/messaging_composer.rs +2 -2
- package/contracts/endpoint-v2/src/lib.rs +0 -1
- package/contracts/endpoint-v2/src/message_lib_manager.rs +39 -8
- package/contracts/endpoint-v2/src/messaging_channel.rs +36 -4
- package/contracts/endpoint-v2/src/messaging_composer.rs +18 -4
- package/contracts/endpoint-v2/src/storage.rs +9 -1
- package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +2 -2
- package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +1 -1
- package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
- package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +3 -3
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +5 -5
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +2 -2
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +5 -5
- package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +3 -3
- package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +1 -1
- package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +4 -3
- package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +7 -2
- package/contracts/endpoint-v2/src/tests/messaging_composer/mod.rs +4 -0
- package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +7 -2
- package/contracts/layerzero-views/src/layerzero_view.rs +0 -1
- package/contracts/layerzero-views/src/tests/mod.rs +1 -0
- package/contracts/layerzero-views/src/tests/types_tests.rs +31 -0
- package/contracts/layerzero-views/src/types.rs +2 -3
- package/contracts/macro-integration-tests/tests/runtime/contract_ttl/constructor.rs +61 -0
- package/contracts/macro-integration-tests/tests/runtime/contract_ttl/contract_impl_ttl_extension.rs +97 -0
- package/contracts/macro-integration-tests/tests/runtime/contract_ttl/contract_trait_ttl_extension.rs +99 -0
- package/contracts/macro-integration-tests/tests/runtime/contract_ttl/mod.rs +3 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/mod.rs +5 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_default.rs +86 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_multisig.rs +47 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_multisig_upgradeable.rs +77 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_upgradeable.rs +114 -0
- package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_upgradeable_no_migration.rs +105 -0
- package/contracts/macro-integration-tests/tests/runtime/multisig/admin_entrypoints.rs +242 -0
- package/contracts/macro-integration-tests/tests/runtime/multisig/mod.rs +9 -0
- package/contracts/macro-integration-tests/tests/runtime/multisig/self_auth.rs +54 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/initialization.rs +13 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +1 -0
- package/contracts/macro-integration-tests/tests/runtime/ownable/ownership_transfer.rs +70 -1
- package/contracts/macro-integration-tests/tests/runtime/ownable/two_step_transfer.rs +219 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/keyed_roundtrip.rs +41 -0
- package/contracts/macro-integration-tests/tests/runtime/storage/ttl_extension.rs +48 -16
- package/contracts/macro-integration-tests/tests/runtime/storage/unkeyed_roundtrip.rs +10 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +96 -3
- package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +4 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_extendable/extend_instance_ttl.rs +64 -0
- package/contracts/macro-integration-tests/tests/runtime/ttl_extendable/mod.rs +16 -0
- package/contracts/macro-integration-tests/tests/runtime/upgradeable/migrate_guard_and_state.rs +305 -0
- package/contracts/macro-integration-tests/tests/runtime/upgradeable/mod.rs +3 -0
- package/contracts/macro-integration-tests/tests/runtime/upgradeable/no_migration.rs +59 -0
- package/contracts/macro-integration-tests/tests/runtime/upgradeable/upgrade_then_migrate.rs +88 -0
- package/contracts/macro-integration-tests/tests/runtime.rs +5 -0
- package/contracts/macro-integration-tests/tests/ui/contract_impl/fail/not_impl_item.rs +6 -0
- package/contracts/macro-integration-tests/tests/ui/contract_impl/fail/not_impl_item.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/contract_impl/pass/basic.rs +102 -0
- package/contracts/macro-integration-tests/tests/ui/contract_trait/fail/not_a_trait.rs +6 -0
- package/contracts/macro-integration-tests/tests/ui/contract_trait/fail/not_a_trait.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/contract_trait/pass/basic.rs +83 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/discriminant_too_large.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/discriminant_too_large.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_enum_input.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/error/fail/non_enum_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/error/pass/basic.rs +22 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/invalid_option.rs +6 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/invalid_option.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/multisig_rejects_ownable_api.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/multisig_rejects_ownable_api.stderr +20 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/not_a_struct.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/not_a_struct.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_invalid_inner_option.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_invalid_inner_option.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_missing_internal.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_missing_internal.stderr +86 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/basic.rs +45 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/multisig.rs +34 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/multisig_upgradeable.rs +30 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/upgradeable.rs +39 -0
- package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/upgradeable_no_migration.rs +28 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_api.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_api.stderr +12 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_trait.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_trait.stderr +5 -0
- package/contracts/macro-integration-tests/tests/ui/multisig/pass/basic.rs +49 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_auth.rs +19 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_auth.stderr +12 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.rs +1 -1
- package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.stderr +0 -8
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/basic.rs +39 -0
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_auth_env_param_variants.rs +7 -1
- package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.stderr +1 -1
- package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.stderr +1 -1
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_default_values.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_default_values.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_name_attrs.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_name_attrs.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_no_ttl_extension.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_no_ttl_extension.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.stderr +1 -1
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_rejects_args.rs +13 -0
- package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_rejects_args.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/api_surface.rs +102 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/basic.rs +43 -0
- package/contracts/macro-integration-tests/tests/ui/storage/pass/multi_key.rs +38 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/missing_auth_trait.rs +14 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/missing_auth_trait.stderr +71 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/{minimal_contract.rs → basic.rs} +2 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/multisig_contract.rs +28 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/ownable_contract.rs +32 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_extendable/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_extendable/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_extendable/pass/basic.rs +23 -0
- package/contracts/macro-integration-tests/tests/ui/ttl_extendable/pass/no_user_contractimpl.rs +21 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/attr_args.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/attr_args.stderr +29 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_auth_trait.rs +20 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_auth_trait.stderr +71 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_upgradeable_internal.rs +10 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_upgradeable_internal.stderr +79 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/non_struct_input.rs +8 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/non_struct_input.stderr +7 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/basic.rs +43 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/multisig_contract.rs +35 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/no_migration.rs +30 -0
- package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/no_user_contractimpl.rs +29 -0
- package/contracts/macro-integration-tests/tests/ui_contract_impl.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui_contract_trait.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui_lz_contract.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_multisig.rs +11 -0
- package/contracts/macro-integration-tests/tests/ui_ttl_extendable.rs +12 -0
- package/contracts/macro-integration-tests/tests/ui_upgradeable.rs +11 -0
- package/contracts/message-libs/blocked-message-lib/Cargo.toml +1 -1
- package/contracts/message-libs/blocked-message-lib/src/lib.rs +4 -1
- package/contracts/message-libs/blocked-message-lib/src/tests/blocked_message_lib_tests.rs +108 -0
- package/contracts/message-libs/blocked-message-lib/src/tests/mod.rs +4 -0
- package/contracts/message-libs/blocked-message-lib/src/tests/setup.rs +40 -0
- package/contracts/message-libs/simple-message-lib/src/lib.rs +1 -1
- package/contracts/message-libs/simple-message-lib/src/tests/mod.rs +2 -0
- package/contracts/message-libs/simple-message-lib/src/tests/setup.rs +124 -0
- package/contracts/message-libs/simple-message-lib/src/tests/simple_message_lib_tests.rs +309 -0
- package/contracts/message-libs/uln-302/src/errors.rs +21 -0
- package/contracts/message-libs/uln-302/src/interfaces/receive_uln.rs +1 -1
- package/contracts/message-libs/uln-302/src/receive_uln.rs +6 -4
- package/contracts/message-libs/uln-302/src/send_uln.rs +15 -6
- package/contracts/message-libs/uln-302/src/storage.rs +5 -5
- package/contracts/message-libs/uln-302/src/tests/uln302/get_config.rs +71 -0
- package/contracts/message-libs/uln-302/src/tests/uln302/mod.rs +1 -0
- package/contracts/message-libs/uln-302/src/uln302.rs +3 -0
- package/contracts/oapps/counter/Cargo.toml +2 -0
- package/contracts/oapps/counter/integration_tests/mod.rs +1 -0
- package/contracts/oapps/counter/integration_tests/setup_sml.rs +6 -4
- package/contracts/oapps/counter/integration_tests/setup_uln.rs +12 -5
- package/contracts/oapps/counter/integration_tests/test_with_blocked.rs +67 -0
- package/contracts/oapps/counter/src/tests/mod.rs +1 -0
- package/contracts/oapps/counter/src/tests/test_u256_ext.rs +48 -0
- package/contracts/oapps/oapp/src/lib.rs +0 -3
- package/contracts/oapps/oapp/src/tests/mod.rs +1 -0
- package/contracts/oapps/oft/integration-tests/setup.rs +2 -3
- package/contracts/oapps/oft/src/lib.rs +3 -0
- package/contracts/oapps/oft/src/tests/extensions/mod.rs +3 -0
- package/contracts/oapps/oft/src/tests/extensions/oft_fee.rs +240 -0
- package/contracts/oapps/oft/src/tests/extensions/pausable.rs +141 -0
- package/contracts/oapps/oft/src/tests/extensions/rate_limiter.rs +447 -0
- package/contracts/oapps/oft/src/tests/mod.rs +2 -0
- package/contracts/oapps/oft/src/tests/oft_types/lock_unlock.rs +180 -0
- package/contracts/oapps/oft/src/tests/oft_types/mod.rs +1 -0
- package/contracts/oapps/oft-core/integration-tests/setup.rs +2 -3
- package/contracts/oapps/oft-core/src/lib.rs +2 -2
- package/contracts/oapps/oft-core/src/tests/mod.rs +1 -1
- package/contracts/oapps/oft-core/src/tests/{test_oft_version.rs → test_oft_version_and_approval.rs} +9 -0
- package/contracts/oapps/oft-core/src/tests/test_utils.rs +0 -43
- package/contracts/upgrader/src/tests/test_upgrader.rs +18 -0
- package/contracts/utils/src/auth.rs +2 -2
- package/contracts/utils/src/buffer_reader.rs +61 -10
- package/contracts/utils/src/buffer_writer.rs +35 -20
- package/contracts/utils/src/bytes_ext.rs +1 -2
- package/contracts/utils/src/errors.rs +5 -3
- package/contracts/utils/src/multisig.rs +59 -36
- package/contracts/utils/src/option_ext.rs +3 -3
- package/contracts/utils/src/ownable.rs +12 -6
- package/contracts/utils/src/tests/auth.rs +179 -0
- package/contracts/utils/src/tests/buffer_reader.rs +203 -1
- package/contracts/utils/src/tests/buffer_writer.rs +176 -5
- package/contracts/utils/src/tests/mod.rs +2 -0
- package/contracts/utils/src/tests/multisig.rs +170 -141
- package/contracts/utils/src/tests/option_ext.rs +1 -1
- package/contracts/utils/src/tests/ownable.rs +156 -161
- package/contracts/utils/src/tests/test_helper.rs +21 -1
- package/contracts/utils/src/tests/testing_utils.rs +84 -2
- package/contracts/utils/src/tests/ttl_configurable.rs +66 -86
- package/contracts/utils/src/tests/ttl_extendable.rs +64 -0
- package/contracts/utils/src/tests/upgradeable.rs +115 -6
- package/contracts/utils/src/ttl_configurable.rs +22 -12
- package/contracts/utils/src/ttl_extendable.rs +1 -3
- package/contracts/utils/src/upgradeable.rs +21 -24
- package/contracts/workers/dvn/src/auth.rs +1 -1
- package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
- package/contracts/workers/dvn/src/storage.rs +1 -1
- package/contracts/workers/dvn/src/tests/auth.rs +136 -3
- package/contracts/workers/dvn/src/tests/mod.rs +0 -1
- package/contracts/workers/dvn/src/tests/setup.rs +4 -10
- package/contracts/workers/executor-helper/src/tests/executor_helper.rs +279 -0
- package/contracts/workers/executor-helper/src/tests/setup.rs +106 -1
- package/contracts/workers/worker/src/worker.rs +1 -1
- package/docs/oft-guide.md +5 -5
- package/package.json +5 -7
- package/sdk/.turbo/turbo-test.log +662 -466
- package/sdk/LICENSE +23 -0
- package/sdk/dist/generated/bml.d.ts +101 -106
- package/sdk/dist/generated/bml.js +108 -26
- package/sdk/dist/generated/counter.d.ts +123 -484
- package/sdk/dist/generated/counter.js +103 -25
- package/sdk/dist/generated/dvn.d.ts +141 -699
- package/sdk/dist/generated/dvn.js +106 -28
- package/sdk/dist/generated/dvn_fee_lib.d.ts +31 -248
- package/sdk/dist/generated/dvn_fee_lib.js +27 -24
- package/sdk/dist/generated/endpoint.d.ts +158 -836
- package/sdk/dist/generated/endpoint.js +107 -29
- package/sdk/dist/generated/executor.d.ts +139 -671
- package/sdk/dist/generated/executor.js +106 -28
- package/sdk/dist/generated/executor_fee_lib.d.ts +109 -264
- package/sdk/dist/generated/executor_fee_lib.js +106 -28
- package/sdk/dist/generated/executor_helper.d.ts +95 -92
- package/sdk/dist/generated/executor_helper.js +103 -25
- package/sdk/dist/generated/layerzero_view.d.ts +178 -335
- package/sdk/dist/generated/layerzero_view.js +172 -33
- package/sdk/dist/generated/oft.d.ts +137 -680
- package/sdk/dist/generated/oft.js +103 -25
- package/sdk/dist/generated/price_feed.d.ts +45 -444
- package/sdk/dist/generated/price_feed.js +27 -24
- package/sdk/dist/generated/sml.d.ts +119 -428
- package/sdk/dist/generated/sml.js +103 -25
- package/sdk/dist/generated/treasury.d.ts +109 -288
- package/sdk/dist/generated/treasury.js +103 -25
- package/sdk/dist/generated/uln302.d.ts +190 -527
- package/sdk/dist/generated/uln302.js +170 -31
- package/sdk/dist/generated/upgrader.d.ts +14 -34
- package/sdk/dist/generated/upgrader.js +24 -21
- package/sdk/package.json +3 -4
- package/sdk/test/counter-sml.test.ts +218 -142
- package/sdk/test/counter-uln.test.ts +189 -145
- package/sdk/test/oft-sml.test.ts +173 -156
- package/sdk/test/suites/constants.ts +7 -1
- package/sdk/test/suites/globalSetup.ts +140 -74
- package/sdk/turbo.json +1 -1
- package/tools/ts-bindings-gen/Cargo.toml +4 -4
- package/tools/ts-bindings-gen/src/main.rs +4 -0
- package/turbo.json +3 -0
- package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +0 -1072
- package/contracts/endpoint-v2/src/constants.rs +0 -52
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.rs +0 -12
- package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.stderr +0 -7
- package/contracts/macro-integration-tests/tests/ui/error/pass/attr_on_variant_allowed.rs +0 -20
- package/contracts/macro-integration-tests/tests/ui/error/pass/basic_auto_discriminants.rs +0 -15
- package/contracts/macro-integration-tests/tests/ui/error/pass/mixed_discriminants.rs +0 -16
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/minimal_contract.rs +0 -26
- package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +0 -21
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.rs +0 -12
- package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.stderr +0 -7
- package/contracts/macro-integration-tests/tests/ui/storage/pass/default_value_on_variant.rs +0 -14
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_instance_unit_basic.rs +0 -14
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_persistent_named_fields_keyed.rs +0 -16
- package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_temporary_unit_option.rs +0 -15
- package/contracts/macro-integration-tests/tests/ui/storage/pass/name_override.rs +0 -14
- package/contracts/macro-integration-tests/tests/ui/storage/pass/no_auto_ttl_extension.rs +0 -19
- package/contracts/macro-integration-tests/tests/ui/storage/pass/ttl_provider_basic.rs +0 -15
- package/contracts/message-libs/simple-message-lib/src/test.rs +0 -280
- package/contracts/oapps/oapp/src/macro_tests/mod.rs +0 -1
- package/contracts/workers/dvn/src/tests/multisig/mod.rs +0 -3
- package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +0 -132
- package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +0 -109
- package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +0 -106
- /package/contracts/oapps/oapp/src/{macro_tests → tests}/test_macros.rs +0 -0
|
@@ -7,10 +7,11 @@ use crate::{
|
|
|
7
7
|
OwnershipTransferring,
|
|
8
8
|
},
|
|
9
9
|
testing_utils::assert_eq_event,
|
|
10
|
+
tests::test_helper::mock_auth,
|
|
10
11
|
};
|
|
11
12
|
use soroban_sdk::{
|
|
12
13
|
contract, contractimpl,
|
|
13
|
-
testutils::{Address as _, MockAuth, MockAuthInvoke},
|
|
14
|
+
testutils::{storage::Temporary as _, Address as _, Ledger as _, MockAuth, MockAuthInvoke},
|
|
14
15
|
Address, Env, IntoVal,
|
|
15
16
|
};
|
|
16
17
|
|
|
@@ -23,11 +24,6 @@ impl Contract {
|
|
|
23
24
|
Self::init_owner(env, owner);
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
pub fn require_owner_auth(env: &Env) -> u32 {
|
|
27
|
-
ownable::require_owner_auth::<Self>(env);
|
|
28
|
-
1
|
|
29
|
-
}
|
|
30
|
-
|
|
31
27
|
pub fn enforce_and_return_owner(env: &Env) -> Address {
|
|
32
28
|
ownable::enforce_owner_auth::<Self>(env)
|
|
33
29
|
}
|
|
@@ -65,16 +61,8 @@ fn auth_owner_can_call() {
|
|
|
65
61
|
let contract = env.register(Contract, (&owner,));
|
|
66
62
|
let client = ContractClient::new(&env, &contract);
|
|
67
63
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
invoke: &MockAuthInvoke {
|
|
71
|
-
contract: &contract,
|
|
72
|
-
args: ().into_val(&env),
|
|
73
|
-
fn_name: "require_owner_auth",
|
|
74
|
-
sub_invokes: &[],
|
|
75
|
-
},
|
|
76
|
-
}]);
|
|
77
|
-
client.require_owner_auth();
|
|
64
|
+
mock_auth(&env, &contract, &owner, "enforce_and_return_owner", ());
|
|
65
|
+
client.enforce_and_return_owner();
|
|
78
66
|
}
|
|
79
67
|
|
|
80
68
|
#[test]
|
|
@@ -86,29 +74,7 @@ fn auth_non_owner_cannot_call() {
|
|
|
86
74
|
let client = ContractClient::new(&env, &contract);
|
|
87
75
|
|
|
88
76
|
// Try to call without auth should fail
|
|
89
|
-
client.
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
#[test]
|
|
93
|
-
#[should_panic(expected = "Error(Contract, #1034)")] // OwnerNotSet
|
|
94
|
-
fn auth_require_owner_when_no_owner_set() {
|
|
95
|
-
let env = Env::default();
|
|
96
|
-
let owner = Address::generate(&env);
|
|
97
|
-
|
|
98
|
-
let contract = env.register(Contract, (&owner,));
|
|
99
|
-
let client = ContractClient::new(&env, &contract);
|
|
100
|
-
client.remove_owner();
|
|
101
|
-
|
|
102
|
-
env.mock_auths(&[MockAuth {
|
|
103
|
-
address: &owner,
|
|
104
|
-
invoke: &MockAuthInvoke {
|
|
105
|
-
contract: &contract,
|
|
106
|
-
args: ().into_val(&env),
|
|
107
|
-
fn_name: "require_owner_auth",
|
|
108
|
-
sub_invokes: &[],
|
|
109
|
-
},
|
|
110
|
-
}]);
|
|
111
|
-
client.require_owner_auth();
|
|
77
|
+
client.enforce_and_return_owner();
|
|
112
78
|
}
|
|
113
79
|
|
|
114
80
|
// ============================================
|
|
@@ -126,15 +92,7 @@ fn transfer_ownership_with_event() {
|
|
|
126
92
|
|
|
127
93
|
assert_eq!(client.owner(), Some(owner.clone()));
|
|
128
94
|
|
|
129
|
-
env
|
|
130
|
-
address: &owner,
|
|
131
|
-
invoke: &MockAuthInvoke {
|
|
132
|
-
contract: &contract,
|
|
133
|
-
args: (&new_owner,).into_val(&env),
|
|
134
|
-
fn_name: "transfer_ownership",
|
|
135
|
-
sub_invokes: &[],
|
|
136
|
-
},
|
|
137
|
-
}]);
|
|
95
|
+
mock_auth(&env, &contract, &owner, "transfer_ownership", (&new_owner,));
|
|
138
96
|
client.transfer_ownership(&new_owner);
|
|
139
97
|
|
|
140
98
|
assert_eq_event(&env, &contract, OwnershipTransferred { old_owner: owner, new_owner: new_owner.clone() });
|
|
@@ -151,15 +109,7 @@ fn transfer_ownership_to_same_owner() {
|
|
|
151
109
|
|
|
152
110
|
assert_eq!(client.owner(), Some(owner.clone()));
|
|
153
111
|
|
|
154
|
-
env
|
|
155
|
-
address: &owner,
|
|
156
|
-
invoke: &MockAuthInvoke {
|
|
157
|
-
contract: &contract,
|
|
158
|
-
args: (&owner,).into_val(&env),
|
|
159
|
-
fn_name: "transfer_ownership",
|
|
160
|
-
sub_invokes: &[],
|
|
161
|
-
},
|
|
162
|
-
}]);
|
|
112
|
+
mock_auth(&env, &contract, &owner, "transfer_ownership", (&owner,));
|
|
163
113
|
client.transfer_ownership(&owner);
|
|
164
114
|
|
|
165
115
|
// Should still emit event and update (even if same owner)
|
|
@@ -168,7 +118,6 @@ fn transfer_ownership_to_same_owner() {
|
|
|
168
118
|
}
|
|
169
119
|
|
|
170
120
|
#[test]
|
|
171
|
-
#[should_panic(expected = "Error(Contract, #1034)")] // OwnerNotSet
|
|
172
121
|
fn transfer_after_renounce_fails() {
|
|
173
122
|
let env = Env::default();
|
|
174
123
|
let owner = Address::generate(&env);
|
|
@@ -178,32 +127,32 @@ fn transfer_after_renounce_fails() {
|
|
|
178
127
|
let client = ContractClient::new(&env, &contract);
|
|
179
128
|
|
|
180
129
|
// Renounce ownership
|
|
181
|
-
|
|
182
|
-
address: &owner,
|
|
183
|
-
invoke: &MockAuthInvoke {
|
|
184
|
-
contract: &contract,
|
|
185
|
-
args: ().into_val(&env),
|
|
186
|
-
fn_name: "renounce_ownership",
|
|
187
|
-
sub_invokes: &[],
|
|
188
|
-
},
|
|
189
|
-
}]);
|
|
130
|
+
mock_auth(&env, &contract, &owner, "renounce_ownership", ());
|
|
190
131
|
client.renounce_ownership();
|
|
191
132
|
|
|
192
133
|
// Try to transfer after renounce - should fail with OwnerNotSet
|
|
193
|
-
env
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
contract: &contract,
|
|
197
|
-
args: (&new_owner,).into_val(&env),
|
|
198
|
-
fn_name: "transfer_ownership",
|
|
199
|
-
sub_invokes: &[],
|
|
200
|
-
},
|
|
201
|
-
}]);
|
|
202
|
-
client.transfer_ownership(&new_owner);
|
|
134
|
+
mock_auth(&env, &contract, &owner, "transfer_ownership", (&new_owner,));
|
|
135
|
+
let result = client.try_transfer_ownership(&new_owner);
|
|
136
|
+
assert_eq!(result.err().unwrap().ok().unwrap(), OwnableError::OwnerNotSet.into());
|
|
203
137
|
}
|
|
204
138
|
|
|
205
139
|
#[test]
|
|
206
|
-
#[should_panic(expected = "Error(
|
|
140
|
+
#[should_panic(expected = "Error(Auth, InvalidAction)")]
|
|
141
|
+
fn transfer_ownership_non_owner_fails() {
|
|
142
|
+
let env = Env::default();
|
|
143
|
+
let owner = Address::generate(&env);
|
|
144
|
+
let non_owner = Address::generate(&env);
|
|
145
|
+
|
|
146
|
+
let contract = env.register(Contract, (&owner,));
|
|
147
|
+
let client = ContractClient::new(&env, &contract);
|
|
148
|
+
|
|
149
|
+
// Non-owner tries to transfer with their own auth - should fail
|
|
150
|
+
mock_auth(&env, &contract, &non_owner, "transfer_ownership", (&non_owner,));
|
|
151
|
+
client.transfer_ownership(&non_owner);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
#[test]
|
|
155
|
+
#[should_panic(expected = "Error(Contract, #1036)")] // TransferInProgress
|
|
207
156
|
fn transfer_ownership_blocked_during_2step() {
|
|
208
157
|
let env = Env::default();
|
|
209
158
|
let owner = Address::generate(&env);
|
|
@@ -295,6 +244,49 @@ fn propose_ownership_transfer_initiate_and_accept() {
|
|
|
295
244
|
assert_eq!(client.pending_owner(), None);
|
|
296
245
|
}
|
|
297
246
|
|
|
247
|
+
#[test]
|
|
248
|
+
fn pending_owner_expires_after_ttl() {
|
|
249
|
+
let env = Env::default();
|
|
250
|
+
env.ledger().set_sequence_number(1_000);
|
|
251
|
+
|
|
252
|
+
let owner = Address::generate(&env);
|
|
253
|
+
let new_owner = Address::generate(&env);
|
|
254
|
+
|
|
255
|
+
let contract = env.register(Contract, (&owner,));
|
|
256
|
+
let client = ContractClient::new(&env, &contract);
|
|
257
|
+
|
|
258
|
+
let ttl = 10u32;
|
|
259
|
+
|
|
260
|
+
// Initiate transfer
|
|
261
|
+
env.mock_auths(&[MockAuth {
|
|
262
|
+
address: &owner,
|
|
263
|
+
invoke: &MockAuthInvoke {
|
|
264
|
+
contract: &contract,
|
|
265
|
+
args: (&new_owner, ttl).into_val(&env),
|
|
266
|
+
fn_name: "propose_ownership_transfer",
|
|
267
|
+
sub_invokes: &[],
|
|
268
|
+
},
|
|
269
|
+
}]);
|
|
270
|
+
client.propose_ownership_transfer(&new_owner, &ttl);
|
|
271
|
+
assert_eq!(client.pending_owner(), Some(new_owner.clone()));
|
|
272
|
+
|
|
273
|
+
// Advance ledger beyond the actual storage TTL window; temporary pending owner entry should expire.
|
|
274
|
+
// Note: `extend_ttl` cannot reduce TTL, so the effective TTL can be >= the requested `ttl`.
|
|
275
|
+
let (ttl_before, seq_before) = env.as_contract(&contract, || {
|
|
276
|
+
(env.storage().temporary().get_ttl(&OwnableStorage::PendingOwner), env.ledger().sequence())
|
|
277
|
+
});
|
|
278
|
+
assert!(ttl_before >= ttl, "pending owner TTL must be at least requested ttl");
|
|
279
|
+
|
|
280
|
+
let live_until = seq_before + ttl_before;
|
|
281
|
+
env.ledger().set_sequence_number(live_until + 1);
|
|
282
|
+
|
|
283
|
+
assert_eq!(client.pending_owner(), None);
|
|
284
|
+
|
|
285
|
+
// Accept should now fail with NoPendingTransfer (expired).
|
|
286
|
+
let res = client.try_accept_ownership();
|
|
287
|
+
assert_eq!(res.err().unwrap().ok().unwrap(), OwnableError::NoPendingTransfer.into());
|
|
288
|
+
}
|
|
289
|
+
|
|
298
290
|
#[test]
|
|
299
291
|
fn propose_ownership_transfer_cancel() {
|
|
300
292
|
let env = Env::default();
|
|
@@ -338,7 +330,40 @@ fn propose_ownership_transfer_cancel() {
|
|
|
338
330
|
}
|
|
339
331
|
|
|
340
332
|
#[test]
|
|
341
|
-
|
|
333
|
+
fn propose_ownership_transfer_with_max_ttl() {
|
|
334
|
+
let env = Env::default();
|
|
335
|
+
let owner = Address::generate(&env);
|
|
336
|
+
let new_owner = Address::generate(&env);
|
|
337
|
+
|
|
338
|
+
let contract = env.register(Contract, (&owner,));
|
|
339
|
+
let client = ContractClient::new(&env, &contract);
|
|
340
|
+
|
|
341
|
+
// Use max TTL
|
|
342
|
+
let max_ttl = env.storage().max_ttl();
|
|
343
|
+
// Initiate transfer with max TTL
|
|
344
|
+
env.mock_auths(&[MockAuth {
|
|
345
|
+
address: &owner,
|
|
346
|
+
invoke: &MockAuthInvoke {
|
|
347
|
+
contract: &contract,
|
|
348
|
+
args: (&new_owner, max_ttl).into_val(&env),
|
|
349
|
+
fn_name: "propose_ownership_transfer",
|
|
350
|
+
sub_invokes: &[],
|
|
351
|
+
},
|
|
352
|
+
}]);
|
|
353
|
+
client.propose_ownership_transfer(&new_owner, &max_ttl);
|
|
354
|
+
|
|
355
|
+
assert_eq!(client.pending_owner(), Some(new_owner.clone()));
|
|
356
|
+
|
|
357
|
+
// Get the actual TTL of the pending_owner entry
|
|
358
|
+
let actual_ttl = env.as_contract(&contract, || env.storage().temporary().get_ttl(&OwnableStorage::PendingOwner));
|
|
359
|
+
|
|
360
|
+
// The actual TTL should be at least the requested TTL
|
|
361
|
+
// To see the value, temporarily use: assert_eq!(actual_ttl, 0);
|
|
362
|
+
assert!(actual_ttl == max_ttl, "TTL should be max_ttl");
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
#[test]
|
|
366
|
+
#[should_panic(expected = "Error(Contract, #1033)")] // NoPendingTransfer
|
|
342
367
|
fn propose_ownership_transfer_cancel_no_pending_fails() {
|
|
343
368
|
let env = Env::default();
|
|
344
369
|
let owner = Address::generate(&env);
|
|
@@ -361,7 +386,7 @@ fn propose_ownership_transfer_cancel_no_pending_fails() {
|
|
|
361
386
|
}
|
|
362
387
|
|
|
363
388
|
#[test]
|
|
364
|
-
#[should_panic(expected = "Error(Contract, #
|
|
389
|
+
#[should_panic(expected = "Error(Contract, #1031)")] // InvalidPendingOwner
|
|
365
390
|
fn propose_ownership_transfer_cancel_wrong_address_fails() {
|
|
366
391
|
let env = Env::default();
|
|
367
392
|
let owner = Address::generate(&env);
|
|
@@ -399,7 +424,7 @@ fn propose_ownership_transfer_cancel_wrong_address_fails() {
|
|
|
399
424
|
}
|
|
400
425
|
|
|
401
426
|
#[test]
|
|
402
|
-
#[should_panic(expected = "Error(Contract, #
|
|
427
|
+
#[should_panic(expected = "Error(Contract, #1032)")] // InvalidTtl
|
|
403
428
|
fn propose_ownership_transfer_invalid_ttl_exceeds_max_fails() {
|
|
404
429
|
let env = Env::default();
|
|
405
430
|
let owner = Address::generate(&env);
|
|
@@ -409,7 +434,7 @@ fn propose_ownership_transfer_invalid_ttl_exceeds_max_fails() {
|
|
|
409
434
|
let client = ContractClient::new(&env, &contract);
|
|
410
435
|
|
|
411
436
|
// TTL that would exceed max_live_until_ledger
|
|
412
|
-
let ttl =
|
|
437
|
+
let ttl = env.storage().max_ttl() + 1;
|
|
413
438
|
|
|
414
439
|
env.mock_auths(&[MockAuth {
|
|
415
440
|
address: &owner,
|
|
@@ -420,11 +445,12 @@ fn propose_ownership_transfer_invalid_ttl_exceeds_max_fails() {
|
|
|
420
445
|
sub_invokes: &[],
|
|
421
446
|
},
|
|
422
447
|
}]);
|
|
448
|
+
|
|
423
449
|
client.propose_ownership_transfer(&new_owner, &ttl);
|
|
424
450
|
}
|
|
425
451
|
|
|
426
452
|
#[test]
|
|
427
|
-
#[should_panic(expected = "Error(Contract, #
|
|
453
|
+
#[should_panic(expected = "Error(Contract, #1033)")] // NoPendingTransfer
|
|
428
454
|
fn accept_ownership_no_pending_fails() {
|
|
429
455
|
let env = Env::default();
|
|
430
456
|
let owner = Address::generate(&env);
|
|
@@ -553,15 +579,7 @@ fn renounce_ownership_with_event() {
|
|
|
553
579
|
|
|
554
580
|
assert_eq!(client.owner(), Some(owner.clone()));
|
|
555
581
|
|
|
556
|
-
|
|
557
|
-
address: &owner,
|
|
558
|
-
invoke: &MockAuthInvoke {
|
|
559
|
-
contract: &contract,
|
|
560
|
-
args: ().into_val(&env),
|
|
561
|
-
fn_name: "renounce_ownership",
|
|
562
|
-
sub_invokes: &[],
|
|
563
|
-
},
|
|
564
|
-
}]);
|
|
582
|
+
mock_auth(&env, &contract, &owner, "renounce_ownership", ());
|
|
565
583
|
client.renounce_ownership();
|
|
566
584
|
|
|
567
585
|
assert_eq_event(&env, &contract, OwnershipRenounced { old_owner: owner });
|
|
@@ -569,7 +587,6 @@ fn renounce_ownership_with_event() {
|
|
|
569
587
|
}
|
|
570
588
|
|
|
571
589
|
#[test]
|
|
572
|
-
#[should_panic(expected = "Error(Contract, #1034)")] // OwnerNotSet
|
|
573
590
|
fn renounce_after_renounce_fails() {
|
|
574
591
|
let env = Env::default();
|
|
575
592
|
let owner = Address::generate(&env);
|
|
@@ -578,32 +595,32 @@ fn renounce_after_renounce_fails() {
|
|
|
578
595
|
let client = ContractClient::new(&env, &contract);
|
|
579
596
|
|
|
580
597
|
// Renounce ownership
|
|
581
|
-
|
|
582
|
-
address: &owner,
|
|
583
|
-
invoke: &MockAuthInvoke {
|
|
584
|
-
contract: &contract,
|
|
585
|
-
args: ().into_val(&env),
|
|
586
|
-
fn_name: "renounce_ownership",
|
|
587
|
-
sub_invokes: &[],
|
|
588
|
-
},
|
|
589
|
-
}]);
|
|
598
|
+
mock_auth(&env, &contract, &owner, "renounce_ownership", ());
|
|
590
599
|
client.renounce_ownership();
|
|
591
600
|
|
|
592
601
|
// Try to renounce again - should fail with OwnerNotSet
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
+
mock_auth(&env, &contract, &owner, "renounce_ownership", ());
|
|
603
|
+
let result = client.try_renounce_ownership();
|
|
604
|
+
assert_eq!(result.err().unwrap().ok().unwrap(), OwnableError::OwnerNotSet.into());
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
#[test]
|
|
608
|
+
#[should_panic(expected = "Error(Auth, InvalidAction)")]
|
|
609
|
+
fn renounce_ownership_non_owner_fails() {
|
|
610
|
+
let env = Env::default();
|
|
611
|
+
let owner = Address::generate(&env);
|
|
612
|
+
let non_owner = Address::generate(&env);
|
|
613
|
+
|
|
614
|
+
let contract = env.register(Contract, (&owner,));
|
|
615
|
+
let client = ContractClient::new(&env, &contract);
|
|
616
|
+
|
|
617
|
+
// Non-owner tries to renounce with their own auth - should fail
|
|
618
|
+
mock_auth(&env, &contract, &non_owner, "renounce_ownership", ());
|
|
602
619
|
client.renounce_ownership();
|
|
603
620
|
}
|
|
604
621
|
|
|
605
622
|
#[test]
|
|
606
|
-
#[should_panic(expected = "Error(Contract, #
|
|
623
|
+
#[should_panic(expected = "Error(Contract, #1036)")] // TransferInProgress
|
|
607
624
|
fn renounce_blocked_during_2step_transfer() {
|
|
608
625
|
let env = Env::default();
|
|
609
626
|
let owner = Address::generate(&env);
|
|
@@ -654,27 +671,16 @@ fn chain_new_owner_can_transfer() {
|
|
|
654
671
|
let client = ContractClient::new(&env, &contract);
|
|
655
672
|
|
|
656
673
|
// Transfer to new_owner
|
|
657
|
-
env
|
|
658
|
-
address: &owner,
|
|
659
|
-
invoke: &MockAuthInvoke {
|
|
660
|
-
contract: &contract,
|
|
661
|
-
args: (&new_owner,).into_val(&env),
|
|
662
|
-
fn_name: "transfer_ownership",
|
|
663
|
-
sub_invokes: &[],
|
|
664
|
-
},
|
|
665
|
-
}]);
|
|
674
|
+
mock_auth(&env, &contract, &owner, "transfer_ownership", (&new_owner,));
|
|
666
675
|
client.transfer_ownership(&new_owner);
|
|
667
676
|
|
|
677
|
+
// Verify old owner cannot call anymore
|
|
678
|
+
mock_auth(&env, &contract, &owner, "enforce_and_return_owner", ());
|
|
679
|
+
let result = client.try_enforce_and_return_owner();
|
|
680
|
+
assert!(result.is_err(), "old owner should not be able to call after transfer");
|
|
681
|
+
|
|
668
682
|
// new_owner can now transfer to third_owner
|
|
669
|
-
env
|
|
670
|
-
address: &new_owner,
|
|
671
|
-
invoke: &MockAuthInvoke {
|
|
672
|
-
contract: &contract,
|
|
673
|
-
args: (&third_owner,).into_val(&env),
|
|
674
|
-
fn_name: "transfer_ownership",
|
|
675
|
-
sub_invokes: &[],
|
|
676
|
-
},
|
|
677
|
-
}]);
|
|
683
|
+
mock_auth(&env, &contract, &new_owner, "transfer_ownership", (&third_owner,));
|
|
678
684
|
client.transfer_ownership(&third_owner);
|
|
679
685
|
|
|
680
686
|
assert_eq!(client.owner(), Some(third_owner));
|
|
@@ -746,7 +752,6 @@ fn chain_new_owner_can_transfer_2step() {
|
|
|
746
752
|
// ============================================
|
|
747
753
|
|
|
748
754
|
#[test]
|
|
749
|
-
#[should_panic(expected = "Error(Contract, #1033)")] // OwnerAlreadySet
|
|
750
755
|
fn reinit_owner_fails() {
|
|
751
756
|
let env = Env::default();
|
|
752
757
|
let owner = Address::generate(&env);
|
|
@@ -754,7 +759,8 @@ fn reinit_owner_fails() {
|
|
|
754
759
|
let contract = env.register(Contract, (&owner,));
|
|
755
760
|
let client = ContractClient::new(&env, &contract);
|
|
756
761
|
|
|
757
|
-
client.
|
|
762
|
+
let result = client.try_reinit_owner(&new_owner);
|
|
763
|
+
assert_eq!(result.err().unwrap().ok().unwrap(), OwnableError::OwnerAlreadySet.into());
|
|
758
764
|
}
|
|
759
765
|
|
|
760
766
|
// ============================================
|
|
@@ -768,22 +774,13 @@ fn enforce_owner_auth_returns_owner() {
|
|
|
768
774
|
let contract = env.register(Contract, (&owner,));
|
|
769
775
|
let client = ContractClient::new(&env, &contract);
|
|
770
776
|
|
|
771
|
-
|
|
772
|
-
address: &owner,
|
|
773
|
-
invoke: &MockAuthInvoke {
|
|
774
|
-
contract: &contract,
|
|
775
|
-
args: ().into_val(&env),
|
|
776
|
-
fn_name: "enforce_and_return_owner",
|
|
777
|
-
sub_invokes: &[],
|
|
778
|
-
},
|
|
779
|
-
}]);
|
|
777
|
+
mock_auth(&env, &contract, &owner, "enforce_and_return_owner", ());
|
|
780
778
|
|
|
781
779
|
let returned_owner = client.enforce_and_return_owner();
|
|
782
780
|
assert_eq!(returned_owner, owner);
|
|
783
781
|
}
|
|
784
782
|
|
|
785
783
|
#[test]
|
|
786
|
-
#[should_panic(expected = "Error(Contract, #1034)")] // OwnerNotSet
|
|
787
784
|
fn enforce_owner_auth_no_owner_set_fails() {
|
|
788
785
|
let env = Env::default();
|
|
789
786
|
let owner = Address::generate(&env);
|
|
@@ -792,17 +789,23 @@ fn enforce_owner_auth_no_owner_set_fails() {
|
|
|
792
789
|
|
|
793
790
|
client.remove_owner();
|
|
794
791
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
fn_name: "enforce_and_return_owner",
|
|
801
|
-
sub_invokes: &[],
|
|
802
|
-
},
|
|
803
|
-
}]);
|
|
792
|
+
// Even with auth, enforce_owner_auth must fail because no owner is set in storage.
|
|
793
|
+
mock_auth(&env, &contract, &owner, "enforce_and_return_owner", ());
|
|
794
|
+
let result = client.try_enforce_and_return_owner();
|
|
795
|
+
assert_eq!(result.err().unwrap().ok().unwrap(), OwnableError::OwnerNotSet.into());
|
|
796
|
+
}
|
|
804
797
|
|
|
805
|
-
|
|
798
|
+
#[test]
|
|
799
|
+
fn require_owner_auth_no_owner_set_fails() {
|
|
800
|
+
let env = Env::default();
|
|
801
|
+
let owner = Address::generate(&env);
|
|
802
|
+
let contract = env.register(Contract, (&owner,));
|
|
803
|
+
let client = ContractClient::new(&env, &contract);
|
|
804
|
+
|
|
805
|
+
client.remove_owner();
|
|
806
|
+
|
|
807
|
+
let result = client.try_enforce_and_return_owner();
|
|
808
|
+
assert_eq!(result.err().unwrap().ok().unwrap(), OwnableError::OwnerNotSet.into());
|
|
806
809
|
}
|
|
807
810
|
|
|
808
811
|
#[test]
|
|
@@ -814,15 +817,7 @@ fn enforce_owner_auth_wrong_address_fails() {
|
|
|
814
817
|
let contract = env.register(Contract, (&owner,));
|
|
815
818
|
let client = ContractClient::new(&env, &contract);
|
|
816
819
|
|
|
817
|
-
|
|
818
|
-
address: &wrong_address,
|
|
819
|
-
invoke: &MockAuthInvoke {
|
|
820
|
-
contract: &contract,
|
|
821
|
-
args: ().into_val(&env),
|
|
822
|
-
fn_name: "enforce_and_return_owner",
|
|
823
|
-
sub_invokes: &[],
|
|
824
|
-
},
|
|
825
|
-
}]);
|
|
820
|
+
mock_auth(&env, &contract, &wrong_address, "enforce_and_return_owner", ());
|
|
826
821
|
|
|
827
822
|
client.enforce_and_return_owner();
|
|
828
823
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// `utils` crate is `#![no_std]`, but unit tests can use `std`.
|
|
2
2
|
extern crate std;
|
|
3
3
|
|
|
4
|
-
use soroban_sdk::{
|
|
4
|
+
use soroban_sdk::{
|
|
5
|
+
address_payload::AddressPayload,
|
|
6
|
+
testutils::{MockAuth, MockAuthInvoke},
|
|
7
|
+
Address, BytesN, Env, IntoVal, Val,
|
|
8
|
+
};
|
|
5
9
|
|
|
6
10
|
/// Same style as `common-macros` tests helper.
|
|
7
11
|
pub(in crate::tests) fn assert_panics_contains<F>(case: &str, expected_substring: &str, f: F)
|
|
@@ -45,3 +49,19 @@ pub(in crate::tests) fn assert_address_payload_matches(actual: BytesN<32>, expec
|
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
}
|
|
52
|
+
|
|
53
|
+
/// Test helper to mock a single contract invocation auth.
|
|
54
|
+
///
|
|
55
|
+
/// This keeps test files from repeating `env.mock_auths(&[MockAuth { ... }])` blocks.
|
|
56
|
+
pub(in crate::tests) fn mock_auth<A: IntoVal<Env, soroban_sdk::Vec<Val>>>(
|
|
57
|
+
env: &Env,
|
|
58
|
+
contract_id: &Address,
|
|
59
|
+
address: &Address,
|
|
60
|
+
fn_name: &'static str,
|
|
61
|
+
args: A,
|
|
62
|
+
) {
|
|
63
|
+
env.mock_auths(&[MockAuth {
|
|
64
|
+
address,
|
|
65
|
+
invoke: &MockAuthInvoke { contract: contract_id, args: args.into_val(env), fn_name, sub_invokes: &[] },
|
|
66
|
+
}]);
|
|
67
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
extern crate std;
|
|
2
|
+
|
|
3
|
+
use crate::testing_utils::{
|
|
4
|
+
assert_contains_event, assert_contains_events, assert_eq_event, assert_eq_events, decode_event_topics_data,
|
|
5
|
+
};
|
|
6
|
+
use soroban_sdk::{
|
|
7
|
+
contract, contractevent, contractimpl, testutils::Address as _, testutils::Events as _, xdr, Address, Env,
|
|
8
|
+
TryFromVal,
|
|
9
|
+
};
|
|
3
10
|
|
|
4
11
|
// ============================================
|
|
5
12
|
// Test Fixtures
|
|
@@ -215,6 +222,41 @@ fn test_assert_event_data_mismatch() {
|
|
|
215
222
|
assert_eq_event(&env, &contract_id, TestEvent2 { name: 123, count: 789 });
|
|
216
223
|
}
|
|
217
224
|
|
|
225
|
+
// ============================================
|
|
226
|
+
// decode_event_topics_data
|
|
227
|
+
// ============================================
|
|
228
|
+
|
|
229
|
+
#[test]
|
|
230
|
+
fn test_decode_event_topics_data_roundtrip() {
|
|
231
|
+
let env = Env::default();
|
|
232
|
+
let contract_id = env.register(TestingUtilsContract, ());
|
|
233
|
+
let client = TestingUtilsContractClient::new(&env, &contract_id);
|
|
234
|
+
|
|
235
|
+
client.emit_event2(&123, &456);
|
|
236
|
+
|
|
237
|
+
let filtered = env.events().all().filter_by_contract(&contract_id);
|
|
238
|
+
let raw = filtered.events();
|
|
239
|
+
assert_eq!(raw.len(), 1);
|
|
240
|
+
|
|
241
|
+
let event = &raw[0];
|
|
242
|
+
let v0 = match &event.body {
|
|
243
|
+
xdr::ContractEventBody::V0(v0) => v0,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
let (topics, data) = decode_event_topics_data(&env, event).expect("event should decode");
|
|
247
|
+
|
|
248
|
+
// `Val` doesn't implement `PartialEq` in this SDK version, so compare by converting back to XDR.
|
|
249
|
+
let topics_xdr: std::vec::Vec<xdr::ScVal> =
|
|
250
|
+
topics.iter().map(|t| xdr::ScVal::try_from_val(&env, &t).expect("topic Val must convert to XDR")).collect();
|
|
251
|
+
assert_eq!(topics_xdr.len(), v0.topics.len() as usize);
|
|
252
|
+
for (i, t) in v0.topics.iter().enumerate() {
|
|
253
|
+
assert_eq!(topics_xdr[i], *t);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let data_xdr = xdr::ScVal::try_from_val(&env, &data).expect("data Val must convert to XDR");
|
|
257
|
+
assert_eq!(data_xdr, v0.data);
|
|
258
|
+
}
|
|
259
|
+
|
|
218
260
|
// ============================================
|
|
219
261
|
// assert_eq_events
|
|
220
262
|
// ============================================
|
|
@@ -438,3 +480,43 @@ fn test_assert_events_data_mismatch() {
|
|
|
438
480
|
|
|
439
481
|
assert_eq_events(&env, &contract_id, &[&TestEvent2 { name: 100, count: 999 }]);
|
|
440
482
|
}
|
|
483
|
+
|
|
484
|
+
// ============================================
|
|
485
|
+
// assert_contains_event / assert_contains_events (multiset semantics)
|
|
486
|
+
// ============================================
|
|
487
|
+
|
|
488
|
+
#[test]
|
|
489
|
+
#[should_panic(expected = "Expected event not found")]
|
|
490
|
+
fn test_assert_contains_event_not_found_panics() {
|
|
491
|
+
let env = Env::default();
|
|
492
|
+
let contract_id = env.register(TestingUtilsContract, ());
|
|
493
|
+
let client = TestingUtilsContractClient::new(&env, &contract_id);
|
|
494
|
+
|
|
495
|
+
client.emit_event1(&42);
|
|
496
|
+
|
|
497
|
+
assert_contains_event(&env, &contract_id, TestEvent1 { value: 999 });
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
#[test]
|
|
501
|
+
fn test_assert_contains_events_allows_duplicates() {
|
|
502
|
+
let env = Env::default();
|
|
503
|
+
let contract_id = env.register(TestingUtilsContract, ());
|
|
504
|
+
let client = TestingUtilsContractClient::new(&env, &contract_id);
|
|
505
|
+
|
|
506
|
+
client.emit_multiple_events(&42, &42);
|
|
507
|
+
|
|
508
|
+
assert_contains_events(&env, &contract_id, &[&TestEvent1 { value: 42 }, &TestEvent1 { value: 42 }]);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
#[test]
|
|
512
|
+
#[should_panic(expected = "Expected event #1 not found")]
|
|
513
|
+
fn test_assert_contains_events_duplicate_expected_but_not_emitted_panics() {
|
|
514
|
+
let env = Env::default();
|
|
515
|
+
let contract_id = env.register(TestingUtilsContract, ());
|
|
516
|
+
let client = TestingUtilsContractClient::new(&env, &contract_id);
|
|
517
|
+
|
|
518
|
+
client.emit_event1(&42);
|
|
519
|
+
|
|
520
|
+
// Only one emission, but two expectations -> must fail on the second.
|
|
521
|
+
assert_contains_events(&env, &contract_id, &[&TestEvent1 { value: 42 }, &TestEvent1 { value: 42 }]);
|
|
522
|
+
}
|