@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
package/Cargo.lock
CHANGED
|
@@ -329,6 +329,7 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
|
|
329
329
|
name = "counter"
|
|
330
330
|
version = "0.0.1"
|
|
331
331
|
dependencies = [
|
|
332
|
+
"blocked-message-lib",
|
|
332
333
|
"common-macros",
|
|
333
334
|
"dvn",
|
|
334
335
|
"dvn-fee-lib",
|
|
@@ -1676,7 +1677,7 @@ dependencies = [
|
|
|
1676
1677
|
"soroban-env-macros",
|
|
1677
1678
|
"soroban-wasmi",
|
|
1678
1679
|
"static_assertions",
|
|
1679
|
-
"stellar-xdr
|
|
1680
|
+
"stellar-xdr",
|
|
1680
1681
|
"wasmparser",
|
|
1681
1682
|
]
|
|
1682
1683
|
|
|
@@ -1738,15 +1739,15 @@ dependencies = [
|
|
|
1738
1739
|
"quote",
|
|
1739
1740
|
"serde",
|
|
1740
1741
|
"serde_json",
|
|
1741
|
-
"stellar-xdr
|
|
1742
|
+
"stellar-xdr",
|
|
1742
1743
|
"syn 2.0.108",
|
|
1743
1744
|
]
|
|
1744
1745
|
|
|
1745
1746
|
[[package]]
|
|
1746
1747
|
name = "soroban-ledger-snapshot"
|
|
1747
|
-
version = "25.0
|
|
1748
|
+
version = "25.1.0"
|
|
1748
1749
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1749
|
-
checksum = "
|
|
1750
|
+
checksum = "99c5285c83e7a5581879b7a65033eae53b24ac9689975aa6887f1d8ee3e941c9"
|
|
1750
1751
|
dependencies = [
|
|
1751
1752
|
"serde",
|
|
1752
1753
|
"serde_json",
|
|
@@ -1758,9 +1759,9 @@ dependencies = [
|
|
|
1758
1759
|
|
|
1759
1760
|
[[package]]
|
|
1760
1761
|
name = "soroban-sdk"
|
|
1761
|
-
version = "25.0
|
|
1762
|
+
version = "25.1.0"
|
|
1762
1763
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1763
|
-
checksum = "
|
|
1764
|
+
checksum = "b1262aa83e99a0fb3e8cd56d6e5ca4c28ac4f9871ac7173f65301a8b9a12c20f"
|
|
1764
1765
|
dependencies = [
|
|
1765
1766
|
"arbitrary",
|
|
1766
1767
|
"bytes-lit",
|
|
@@ -1782,9 +1783,9 @@ dependencies = [
|
|
|
1782
1783
|
|
|
1783
1784
|
[[package]]
|
|
1784
1785
|
name = "soroban-sdk-macros"
|
|
1785
|
-
version = "25.0
|
|
1786
|
+
version = "25.1.0"
|
|
1786
1787
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1787
|
-
checksum = "
|
|
1788
|
+
checksum = "93b62c526917a1e77b6dce3cd841b6c271f0fff344ea93ad92a8c45afe8051b6"
|
|
1788
1789
|
dependencies = [
|
|
1789
1790
|
"darling 0.20.11",
|
|
1790
1791
|
"heck 0.5.0",
|
|
@@ -1794,57 +1795,45 @@ dependencies = [
|
|
|
1794
1795
|
"quote",
|
|
1795
1796
|
"sha2 0.10.9",
|
|
1796
1797
|
"soroban-env-common",
|
|
1797
|
-
"soroban-spec
|
|
1798
|
+
"soroban-spec",
|
|
1798
1799
|
"soroban-spec-rust",
|
|
1799
|
-
"stellar-xdr
|
|
1800
|
+
"stellar-xdr",
|
|
1800
1801
|
"syn 2.0.108",
|
|
1801
1802
|
]
|
|
1802
1803
|
|
|
1803
1804
|
[[package]]
|
|
1804
1805
|
name = "soroban-spec"
|
|
1805
|
-
version = "
|
|
1806
|
+
version = "25.1.0"
|
|
1806
1807
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1807
|
-
checksum = "
|
|
1808
|
+
checksum = "0186c943a78de7038ce7eee478f521f7a7665440101ae0d24b4a59833fb6d833"
|
|
1808
1809
|
dependencies = [
|
|
1809
1810
|
"base64 0.22.1",
|
|
1810
|
-
"stellar-xdr
|
|
1811
|
-
"thiserror",
|
|
1812
|
-
"wasmparser",
|
|
1813
|
-
]
|
|
1814
|
-
|
|
1815
|
-
[[package]]
|
|
1816
|
-
name = "soroban-spec"
|
|
1817
|
-
version = "25.0.1"
|
|
1818
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1819
|
-
checksum = "1bb240973e06456393328d0bdb3397e86bbe7369972b0a94ad13e51b55eacd65"
|
|
1820
|
-
dependencies = [
|
|
1821
|
-
"base64 0.22.1",
|
|
1822
|
-
"stellar-xdr 25.0.0",
|
|
1811
|
+
"stellar-xdr",
|
|
1823
1812
|
"thiserror",
|
|
1824
1813
|
"wasmparser",
|
|
1825
1814
|
]
|
|
1826
1815
|
|
|
1827
1816
|
[[package]]
|
|
1828
1817
|
name = "soroban-spec-rust"
|
|
1829
|
-
version = "25.0
|
|
1818
|
+
version = "25.1.0"
|
|
1830
1819
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1831
|
-
checksum = "
|
|
1820
|
+
checksum = "7a948196ed0633be3a4125e0c7a4fc0bb6337942e538813b1f171331738f9058"
|
|
1832
1821
|
dependencies = [
|
|
1833
1822
|
"prettyplease",
|
|
1834
1823
|
"proc-macro2",
|
|
1835
1824
|
"quote",
|
|
1836
1825
|
"sha2 0.10.9",
|
|
1837
|
-
"soroban-spec
|
|
1838
|
-
"stellar-xdr
|
|
1826
|
+
"soroban-spec",
|
|
1827
|
+
"stellar-xdr",
|
|
1839
1828
|
"syn 2.0.108",
|
|
1840
1829
|
"thiserror",
|
|
1841
1830
|
]
|
|
1842
1831
|
|
|
1843
1832
|
[[package]]
|
|
1844
1833
|
name = "soroban-spec-typescript"
|
|
1845
|
-
version = "
|
|
1834
|
+
version = "25.1.0"
|
|
1846
1835
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1847
|
-
checksum = "
|
|
1836
|
+
checksum = "25684cb264ba39bac049ba93fc66fd241993c9aefb82d60d60417736408ec61a"
|
|
1848
1837
|
dependencies = [
|
|
1849
1838
|
"base64 0.21.7",
|
|
1850
1839
|
"heck 0.4.1",
|
|
@@ -1855,8 +1844,8 @@ dependencies = [
|
|
|
1855
1844
|
"serde_derive",
|
|
1856
1845
|
"serde_json",
|
|
1857
1846
|
"sha2 0.9.9",
|
|
1858
|
-
"soroban-spec
|
|
1859
|
-
"stellar-xdr
|
|
1847
|
+
"soroban-spec",
|
|
1848
|
+
"stellar-xdr",
|
|
1860
1849
|
"thiserror",
|
|
1861
1850
|
]
|
|
1862
1851
|
|
|
@@ -1922,24 +1911,6 @@ dependencies = [
|
|
|
1922
1911
|
"heapless",
|
|
1923
1912
|
]
|
|
1924
1913
|
|
|
1925
|
-
[[package]]
|
|
1926
|
-
name = "stellar-xdr"
|
|
1927
|
-
version = "23.0.0"
|
|
1928
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1929
|
-
checksum = "89d2848e1694b0c8db81fd812bfab5ea71ee28073e09ccc45620ef3cf7a75a9b"
|
|
1930
|
-
dependencies = [
|
|
1931
|
-
"base64 0.22.1",
|
|
1932
|
-
"cfg_eval",
|
|
1933
|
-
"crate-git-revision",
|
|
1934
|
-
"escape-bytes",
|
|
1935
|
-
"ethnum",
|
|
1936
|
-
"hex",
|
|
1937
|
-
"serde",
|
|
1938
|
-
"serde_with",
|
|
1939
|
-
"sha2 0.10.9",
|
|
1940
|
-
"stellar-strkey 0.0.13",
|
|
1941
|
-
]
|
|
1942
|
-
|
|
1943
1914
|
[[package]]
|
|
1944
1915
|
name = "stellar-xdr"
|
|
1945
1916
|
version = "25.0.0"
|
package/Cargo.toml
CHANGED
|
@@ -14,7 +14,8 @@ license = "MIT"
|
|
|
14
14
|
version = "0.0.1"
|
|
15
15
|
|
|
16
16
|
[workspace.dependencies]
|
|
17
|
-
soroban-sdk = { version = "25.0
|
|
17
|
+
soroban-sdk = { version = "25.1.0", features = ["hazmat-address", "hazmat-crypto"] }
|
|
18
|
+
soroban-spec-typescript = "25.1.0" # used in tools/ts-bindings-gen
|
|
18
19
|
|
|
19
20
|
# Third-party dependencies (production)
|
|
20
21
|
cfg-if = { version = "1.0", default-features = false }
|
|
@@ -31,6 +32,9 @@ insta = "1.44.3"
|
|
|
31
32
|
k256 = "0.13"
|
|
32
33
|
prettyplease = "0.2.37"
|
|
33
34
|
rand = "0.8"
|
|
35
|
+
anyhow = "1.0"
|
|
36
|
+
sha2 = "0.10"
|
|
37
|
+
base64 = "0.22"
|
|
34
38
|
sha3 = "0.10"
|
|
35
39
|
trybuild = "1.0.114"
|
|
36
40
|
|
|
@@ -44,6 +48,7 @@ executor-fee-lib = { path = "contracts/workers/executor-fee-lib" }
|
|
|
44
48
|
executor-helper = { path = "contracts/workers/executor-helper" }
|
|
45
49
|
fee-lib-interfaces = { path = "contracts/workers/fee-lib-interfaces" }
|
|
46
50
|
message-lib-common = { path = "contracts/message-libs/message-lib-common" }
|
|
51
|
+
blocked-message-lib = { path = "contracts/message-libs/blocked-message-lib" }
|
|
47
52
|
oapp = { path = "contracts/oapps/oapp" }
|
|
48
53
|
oapp-macros = { path = "contracts/oapps/oapp-macros" }
|
|
49
54
|
oft = { path = "contracts/oapps/oft" }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//!
|
|
3
3
|
//! This module provides macros for implementing authorization patterns:
|
|
4
4
|
//! - `#[ownable]` - Owner-based access control (external owner address)
|
|
5
|
-
//! - `#[multisig]` -
|
|
5
|
+
//! - `#[multisig]` - MultiSig-based access control (self-owning pattern)
|
|
6
6
|
//! - `#[only_auth]` - Authorization check attribute for functions
|
|
7
7
|
|
|
8
8
|
use crate::utils;
|
|
@@ -16,9 +16,10 @@ use syn::{parse_quote, ItemFn, ItemStruct};
|
|
|
16
16
|
|
|
17
17
|
/// Generates the ownable implementation from the `#[ownable]` attribute macro.
|
|
18
18
|
///
|
|
19
|
-
/// This macro implements
|
|
19
|
+
/// This macro implements `OwnableInitializer`, `Auth`, and `Ownable` traits for the contract:
|
|
20
|
+
/// - `OwnableInitializer` provides `init_owner()` for constructor use
|
|
20
21
|
/// - `Auth::authorizer()` returns the stored owner address
|
|
21
|
-
/// - `Ownable` provides ownership management (transfer, renounce)
|
|
22
|
+
/// - `Ownable` provides ownership management (transfer, propose, accept, renounce)
|
|
22
23
|
pub fn generate_ownable_impl(input: TokenStream) -> TokenStream {
|
|
23
24
|
let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
|
|
24
25
|
let name = &item_struct.ident;
|
|
@@ -43,14 +44,14 @@ pub fn generate_ownable_impl(input: TokenStream) -> TokenStream {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
// ============================================================================
|
|
46
|
-
//
|
|
47
|
+
// MultiSig Macro Implementation
|
|
47
48
|
// ============================================================================
|
|
48
49
|
|
|
49
50
|
/// Generates the multisig implementation from the `#[multisig]` attribute macro.
|
|
50
51
|
///
|
|
51
|
-
/// This macro implements both `Auth` and `
|
|
52
|
+
/// This macro implements both `Auth` and `MultiSig` traits for the contract:
|
|
52
53
|
/// - `Auth::authorizer()` returns the contract's own address (self-owning pattern)
|
|
53
|
-
/// - `
|
|
54
|
+
/// - `MultiSig` provides signature verification and signer management
|
|
54
55
|
pub fn generate_multisig_impl(input: TokenStream) -> TokenStream {
|
|
55
56
|
let item_struct: ItemStruct = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse struct: {}", e));
|
|
56
57
|
let name = &item_struct.ident;
|
|
@@ -58,7 +59,7 @@ pub fn generate_multisig_impl(input: TokenStream) -> TokenStream {
|
|
|
58
59
|
quote! {
|
|
59
60
|
#item_struct
|
|
60
61
|
|
|
61
|
-
use utils::{auth::Auth as _, multisig::
|
|
62
|
+
use utils::{auth::Auth as _, multisig::MultiSig as _};
|
|
62
63
|
|
|
63
64
|
#[common_macros::contract_impl]
|
|
64
65
|
impl utils::auth::Auth for #name {
|
|
@@ -68,7 +69,7 @@ pub fn generate_multisig_impl(input: TokenStream) -> TokenStream {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
#[common_macros::contract_impl(contracttrait)]
|
|
71
|
-
impl utils::multisig::
|
|
72
|
+
impl utils::multisig::MultiSig for #name {}
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -79,7 +80,7 @@ pub fn generate_multisig_impl(input: TokenStream) -> TokenStream {
|
|
|
79
80
|
/// Prepends an auth check to a method using the `Auth` trait.
|
|
80
81
|
///
|
|
81
82
|
/// Works with any contract that implements the `Auth` trait, including both
|
|
82
|
-
/// `Ownable` and `
|
|
83
|
+
/// `Ownable` and `MultiSig` contracts.
|
|
83
84
|
pub fn prepend_only_auth_check(input: TokenStream) -> TokenStream {
|
|
84
85
|
let mut input_fn: ItemFn = syn::parse2(input).unwrap_or_else(|e| panic!("failed to parse function: {}", e));
|
|
85
86
|
|
|
@@ -86,10 +86,7 @@ fn init_default_ttl_configs_stmt(env_param: &utils::EnvParam<'_>) -> syn::Stmt {
|
|
|
86
86
|
/// Generates a statement that extends instance TTL if configured.
|
|
87
87
|
fn extend_instance_ttl_stmt(env_param: &utils::EnvParam<'_>) -> syn::Stmt {
|
|
88
88
|
let env_ref = env_param.as_ref_tokens();
|
|
89
|
-
let env_ident = env_param.ident;
|
|
90
89
|
syn::parse_quote! {
|
|
91
|
-
|
|
92
|
-
#env_ident.storage().instance().extend_ttl(instance_ttl.threshold, instance_ttl.extend_to);
|
|
93
|
-
}
|
|
90
|
+
utils::ttl_configurable::extend_instance_ttl(#env_ref);
|
|
94
91
|
}
|
|
95
92
|
}
|
|
@@ -2,9 +2,7 @@ use proc_macro2::TokenStream;
|
|
|
2
2
|
use quote::quote;
|
|
3
3
|
use syn::{parse_quote, spanned::Spanned, ExprLit, Fields, ItemEnum, Lit, Token};
|
|
4
4
|
|
|
5
|
-
pub fn generate_error(
|
|
6
|
-
assert!(attr.is_empty(), "contract_error attribute is not supported");
|
|
7
|
-
|
|
5
|
+
pub fn generate_error(item: TokenStream) -> TokenStream {
|
|
8
6
|
let mut data_enum: ItemEnum = syn::parse2(item).unwrap_or_else(|e| panic!("failed to parse enum: {}", e));
|
|
9
7
|
|
|
10
8
|
// For variants without an explicit discriminant, assign sequential error codes starting at 1
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
//! Common procedural macros for Stellar smart contracts.
|
|
2
2
|
//!
|
|
3
|
-
//! This crate provides foundational macros for Stellar contract development:
|
|
4
|
-
//! - **Storage macros** - Strongly-typed contract storage API generation
|
|
5
|
-
//! - **Error macros** - Contract error enum generation
|
|
6
|
-
//! - **Auth macros** - Authorization-based access control (ownable, multisig, only_auth)
|
|
7
|
-
//! - **TTL macros** - Time-to-live configuration and automatic extension
|
|
8
|
-
//! - **Wrapper macros** - Convenient macro combinations for common patterns
|
|
9
|
-
//!
|
|
10
3
|
//! # Quick Links
|
|
11
|
-
//! - [`storage`] - Storage enum to API macro
|
|
12
4
|
//! - [`contract_error`] - Error enum generation macro
|
|
13
|
-
//! - [`
|
|
14
|
-
//! - [`
|
|
5
|
+
//! - [`contract_impl`] - Contract impl with automatic instance TTL extension
|
|
6
|
+
//! - [`contract_trait`] - Contract trait with automatic instance TTL extension
|
|
7
|
+
//! - [`lz_contract`] - Wrapper macro combining common LayerZero contract attributes
|
|
8
|
+
//! - [`multisig`] - MultiSig trait implementation macro
|
|
15
9
|
//! - [`only_auth`] - Auth-based access control attribute macro
|
|
10
|
+
//! - [`ownable`] - Ownable trait implementation macro
|
|
11
|
+
//! - [`storage`] - Storage enum to API macro
|
|
16
12
|
//! - [`ttl_configurable`] - TTL configuration with freeze support
|
|
17
13
|
//! - [`ttl_extendable`] - Manual instance TTL extension
|
|
18
|
-
//! - [`contract_impl`] - Contract impl with automatic instance TTL extension
|
|
19
|
-
//! - [`contract_trait`] - Contract trait with automatic instance TTL extension
|
|
20
14
|
//! - [`upgradeable`] - Upgradeable trait implementation macro
|
|
21
|
-
//! - [`lz_contract`] - Wrapper macro combining common LayerZero contract attributes
|
|
22
15
|
//!
|
|
23
16
|
|
|
24
17
|
use proc_macro::TokenStream;
|
|
@@ -43,7 +36,7 @@ mod tests;
|
|
|
43
36
|
/// Generates strongly-typed storage API from enum variants.
|
|
44
37
|
///
|
|
45
38
|
/// Transforms a storage enum into getter/setter/remove/set_or_remove/has/extend_ttl methods.
|
|
46
|
-
/// TTL extension is automatic for persistent storage
|
|
39
|
+
/// TTL extension is automatic for persistent storage on get/set/has operations.
|
|
47
40
|
///
|
|
48
41
|
/// # Example
|
|
49
42
|
/// ```ignore
|
|
@@ -67,23 +60,25 @@ mod tests;
|
|
|
67
60
|
/// TempData,
|
|
68
61
|
/// }
|
|
69
62
|
///
|
|
70
|
-
/// // Generated API for
|
|
63
|
+
/// // Generated API for instance storage (no extend_ttl method):
|
|
71
64
|
/// DataKey::counter(&env) // -> Option<u32>
|
|
72
65
|
/// DataKey::set_counter(&env, &value) // set value
|
|
73
66
|
/// DataKey::has_counter(&env) // -> bool
|
|
74
67
|
/// DataKey::remove_counter(&env) // remove entry
|
|
75
68
|
/// DataKey::set_or_remove_counter(&env, &opt) // set if Some, remove if None
|
|
76
|
-
/// DataKey::extend_counter_ttl(&env, threshold, extend_to) // manual TTL extension
|
|
77
69
|
///
|
|
78
|
-
/// //
|
|
70
|
+
/// // Generated API for persistent/temporary storage (includes extend_ttl):
|
|
79
71
|
/// DataKey::nonce(&env, &user) // -> Option<u64>
|
|
80
72
|
/// DataKey::set_nonce(&env, &user, &value)
|
|
73
|
+
/// DataKey::has_nonce(&env, &user) // -> bool
|
|
74
|
+
/// DataKey::remove_nonce(&env, &user)
|
|
81
75
|
/// DataKey::set_or_remove_nonce(&env, &user, &opt)
|
|
76
|
+
/// DataKey::extend_nonce_ttl(&env, &user, threshold, extend_to) // manual TTL extension
|
|
82
77
|
/// ```
|
|
83
78
|
///
|
|
84
79
|
/// # Storage Types (required, exactly one per variant)
|
|
85
|
-
/// - `#[instance(Type)]` - Stored with contract instance
|
|
86
|
-
/// - `#[persistent(Type)]` - Durable ledger entries (TTL extended
|
|
80
|
+
/// - `#[instance(Type)]` - Stored with contract instance (no extend_ttl method generated)
|
|
81
|
+
/// - `#[persistent(Type)]` - Durable ledger entries (TTL auto-extended on get/set/has)
|
|
87
82
|
/// - `#[temporary(Type)]` - Short-lived entries
|
|
88
83
|
///
|
|
89
84
|
/// # Variant Attributes (optional)
|
|
@@ -91,42 +86,59 @@ mod tests;
|
|
|
91
86
|
/// - `#[name("custom")]` - Override the generated function name base
|
|
92
87
|
/// - `#[no_ttl_extension]` - Disable automatic TTL extension for this persistent variant
|
|
93
88
|
#[proc_macro_attribute]
|
|
94
|
-
pub fn storage(
|
|
95
|
-
storage::generate_storage(
|
|
89
|
+
pub fn storage(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
90
|
+
storage::generate_storage(item.into()).into()
|
|
96
91
|
}
|
|
97
92
|
|
|
98
93
|
// ============================================================================
|
|
99
94
|
// Error Macro
|
|
100
95
|
// ============================================================================
|
|
101
96
|
|
|
102
|
-
/// Generates a contract error enum with
|
|
97
|
+
/// Generates a Soroban contract error enum with all required attributes and derives.
|
|
103
98
|
///
|
|
104
|
-
///
|
|
105
|
-
///
|
|
106
|
-
///
|
|
99
|
+
/// This macro simplifies error enum definitions by automatically adding:
|
|
100
|
+
/// - `#[contracterror]` from soroban-sdk for Soroban compatibility
|
|
101
|
+
/// - `#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]` for standard error traits
|
|
102
|
+
/// - `#[repr(u32)]` for stable ABI representation
|
|
103
|
+
///
|
|
104
|
+
/// # Discriminant Assignment
|
|
105
|
+
///
|
|
106
|
+
/// Variants without explicit discriminants are automatically assigned sequential values
|
|
107
|
+
/// starting at 1. Explicit discriminants must be strictly increasing.
|
|
108
|
+
///
|
|
109
|
+
/// # Constraints
|
|
110
|
+
///
|
|
111
|
+
/// - All variants must be unit variants (no fields)
|
|
112
|
+
/// - Explicit discriminants must be valid `u32` integer literals
|
|
113
|
+
/// - Each discriminant must be greater than the previous one
|
|
114
|
+
///
|
|
115
|
+
/// # Examples
|
|
116
|
+
///
|
|
117
|
+
/// Basic usage with auto-assigned discriminants:
|
|
107
118
|
///
|
|
108
|
-
/// # Example
|
|
109
119
|
/// ```ignore
|
|
110
120
|
/// #[contract_error]
|
|
111
121
|
/// pub enum MyError {
|
|
112
|
-
///
|
|
113
|
-
///
|
|
122
|
+
/// InvalidInput, // = 1
|
|
123
|
+
/// Unauthorized, // = 2
|
|
124
|
+
/// NotFound, // = 3
|
|
114
125
|
/// }
|
|
115
126
|
/// ```
|
|
116
127
|
///
|
|
117
|
-
///
|
|
128
|
+
/// Mixed explicit and auto-assigned discriminants:
|
|
129
|
+
///
|
|
118
130
|
/// ```ignore
|
|
119
|
-
/// #[
|
|
120
|
-
/// #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
|
|
121
|
-
/// #[repr(u32)]
|
|
131
|
+
/// #[contract_error]
|
|
122
132
|
/// pub enum MyError {
|
|
123
|
-
///
|
|
124
|
-
///
|
|
133
|
+
/// InvalidInput, // = 1
|
|
134
|
+
/// Unauthorized, // = 2
|
|
135
|
+
/// NotFound = 10, // = 10 (explicit)
|
|
136
|
+
/// Expired, // = 11
|
|
125
137
|
/// }
|
|
126
138
|
/// ```
|
|
127
139
|
#[proc_macro_attribute]
|
|
128
|
-
pub fn contract_error(
|
|
129
|
-
error::generate_error(
|
|
140
|
+
pub fn contract_error(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
141
|
+
error::generate_error(item.into()).into()
|
|
130
142
|
}
|
|
131
143
|
|
|
132
144
|
// ============================================================================
|
|
@@ -146,19 +158,20 @@ pub fn contract_error(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
146
158
|
///
|
|
147
159
|
/// Generated code includes:
|
|
148
160
|
/// - `OwnableInitializer` trait impl - Use `<Self as OwnableInitializer>::init_owner(env, owner)` to initialize
|
|
149
|
-
/// - `
|
|
161
|
+
/// - `Auth` trait impl - `authorizer(env)` returns the stored owner address
|
|
162
|
+
/// - `Ownable` trait impl
|
|
150
163
|
#[proc_macro_attribute]
|
|
151
164
|
pub fn ownable(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
152
165
|
auth::generate_ownable_impl(item.into()).into()
|
|
153
166
|
}
|
|
154
167
|
|
|
155
168
|
// ============================================================================
|
|
156
|
-
//
|
|
169
|
+
// MultiSig Macro
|
|
157
170
|
// ============================================================================
|
|
158
171
|
|
|
159
172
|
/// Generates multisig implementation with self-owning access control.
|
|
160
173
|
///
|
|
161
|
-
/// Implements the `
|
|
174
|
+
/// Implements the `MultiSig` trait and the `Auth` trait with self-owning pattern,
|
|
162
175
|
/// where the contract's own address is the authorizer. This allows multisig
|
|
163
176
|
/// quorum approval to serve as the authorizer for owner-protected operations
|
|
164
177
|
/// like TTL configuration and upgrades.
|
|
@@ -171,7 +184,7 @@ pub fn ownable(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
171
184
|
///
|
|
172
185
|
/// Generated code includes:
|
|
173
186
|
/// - `Auth` trait impl - `authorizer(env)` returns `env.current_contract_address()`
|
|
174
|
-
/// - `
|
|
187
|
+
/// - `MultiSig` trait impl
|
|
175
188
|
#[proc_macro_attribute]
|
|
176
189
|
pub fn multisig(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
177
190
|
auth::generate_multisig_impl(item.into()).into()
|
|
@@ -187,7 +200,7 @@ pub fn multisig(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
187
200
|
/// using the `Auth` trait. The function will panic if called without authorization.
|
|
188
201
|
///
|
|
189
202
|
/// Works with any contract that implements `Auth`, including both `Ownable` and
|
|
190
|
-
/// `
|
|
203
|
+
/// `MultiSig` contracts.
|
|
191
204
|
///
|
|
192
205
|
/// # Requirements
|
|
193
206
|
/// - The function must have an `Env` parameter (by value or reference)
|
|
@@ -195,7 +208,7 @@ pub fn multisig(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
195
208
|
///
|
|
196
209
|
/// # Example
|
|
197
210
|
/// ```ignore
|
|
198
|
-
/// #[ownable] // or implement
|
|
211
|
+
/// #[ownable] // or implement `#[multisig]`
|
|
199
212
|
/// pub struct MyContract;
|
|
200
213
|
///
|
|
201
214
|
/// #[soroban_sdk::contractimpl]
|
|
@@ -229,20 +242,13 @@ pub fn only_auth(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
229
242
|
/// providing TTL configuration management with auth-based access control.
|
|
230
243
|
///
|
|
231
244
|
/// # Requirements
|
|
232
|
-
/// The contract must implement the `Auth` trait (typically via `#[ownable]` or `
|
|
245
|
+
/// The contract must implement the `Auth` trait (typically via `#[ownable]` or `#[multisig]`).
|
|
233
246
|
///
|
|
234
247
|
/// # Example
|
|
235
248
|
/// ```ignore
|
|
236
|
-
/// #[ownable] // or
|
|
249
|
+
/// #[ownable] // or `#[multisig]` for self-owning contracts
|
|
237
250
|
/// #[ttl_configurable]
|
|
238
251
|
/// pub struct MyContract;
|
|
239
|
-
///
|
|
240
|
-
/// #[contract_impl]
|
|
241
|
-
/// impl MyContract {
|
|
242
|
-
/// pub fn __constructor(env: &Env, owner: &Address) {
|
|
243
|
-
/// <Self as utils::ownable::OwnableInitializer>::init_owner(env, owner);
|
|
244
|
-
/// }
|
|
245
|
-
/// }
|
|
246
252
|
/// ```
|
|
247
253
|
///
|
|
248
254
|
/// Generated code includes:
|
|
@@ -289,7 +295,7 @@ pub fn ttl_extendable(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
289
295
|
/// at the beginning of each contract entry function to keep the contract instance alive.
|
|
290
296
|
///
|
|
291
297
|
/// # Requirements
|
|
292
|
-
/// - The contract struct must have `#[ttl_configurable]` applied to provide `
|
|
298
|
+
/// - The contract struct must have `#[ttl_configurable]` applied to provide `ttl_configs()`
|
|
293
299
|
/// - Methods must have an `Env` parameter to receive TTL extension
|
|
294
300
|
///
|
|
295
301
|
/// # Behavior
|
|
@@ -317,9 +323,7 @@ pub fn ttl_extendable(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
317
323
|
/// #[soroban_sdk::contractimpl]
|
|
318
324
|
/// impl MyContract {
|
|
319
325
|
/// pub fn my_method(env: &Env) {
|
|
320
|
-
///
|
|
321
|
-
/// env.storage().instance().extend_ttl(ttl.threshold, ttl.extend_to);
|
|
322
|
-
/// }
|
|
326
|
+
/// utils::ttl_configurable::extend_instance_ttl(env);
|
|
323
327
|
/// // ... your code
|
|
324
328
|
/// }
|
|
325
329
|
/// }
|
|
@@ -368,9 +372,7 @@ pub fn contract_impl(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
368
372
|
/// #[soroban_sdk::contracttrait]
|
|
369
373
|
/// pub trait MyTrait {
|
|
370
374
|
/// fn my_method(env: &Env) {
|
|
371
|
-
///
|
|
372
|
-
/// env.storage().instance().extend_ttl(ttl.threshold, ttl.extend_to);
|
|
373
|
-
/// }
|
|
375
|
+
/// utils::ttl_configurable::extend_instance_ttl(env);
|
|
374
376
|
/// // ... your code
|
|
375
377
|
/// }
|
|
376
378
|
///
|
|
@@ -391,7 +393,7 @@ pub fn contract_trait(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
391
393
|
/// This macro implements `Upgradeable` using the trait's default methods (which include auth).
|
|
392
394
|
///
|
|
393
395
|
/// # Requirements
|
|
394
|
-
/// - The contract must implement the `Auth` trait (via `#[ownable]` or `
|
|
396
|
+
/// - The contract must implement the `Auth` trait (via `#[ownable]` or `#[multisig]`)
|
|
395
397
|
/// - By default, requires manual `UpgradeableInternal` implementation
|
|
396
398
|
/// - With `no_migration` flag, auto-generates a no-op `UpgradeableInternal` impl
|
|
397
399
|
///
|
|
@@ -402,7 +404,7 @@ pub fn contract_trait(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
402
404
|
/// # Example
|
|
403
405
|
/// ```ignore
|
|
404
406
|
/// // Requires manual UpgradeableInternal implementation (default)
|
|
405
|
-
/// #[ownable]
|
|
407
|
+
/// #[ownable] // or #[multisig]
|
|
406
408
|
/// #[upgradeable]
|
|
407
409
|
/// pub struct MyContract;
|
|
408
410
|
///
|
|
@@ -415,7 +417,7 @@ pub fn contract_trait(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
415
417
|
/// }
|
|
416
418
|
///
|
|
417
419
|
/// // Auto-generates no-op UpgradeableInternal (for initial deployment)
|
|
418
|
-
/// #[ownable]
|
|
420
|
+
/// #[ownable] // or #[multisig]
|
|
419
421
|
/// #[upgradeable(no_migration)]
|
|
420
422
|
/// pub struct MyContract;
|
|
421
423
|
/// // No UpgradeableInternal impl needed!
|
|
@@ -424,6 +426,8 @@ pub fn contract_trait(attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
|
424
426
|
/// Generated code includes:
|
|
425
427
|
/// - `upgrade(env, new_wasm_hash)` - Upgrades the contract WASM (auth required)
|
|
426
428
|
/// - `migrate(env, migration_data)` - Runs migration after upgrade (auth required, XDR-decodes `Bytes` to `MigrationData`)
|
|
429
|
+
/// - `freeze(env)` - Permanently freezes the contract, preventing any future upgrades (auth required, irreversible)
|
|
430
|
+
/// - `is_frozen(env)` - Returns whether the contract is frozen (upgrades disabled)
|
|
427
431
|
/// - `contractmeta!` with `binver` set to the Cargo package version (if not 0.0.0)
|
|
428
432
|
#[proc_macro_attribute]
|
|
429
433
|
pub fn upgradeable(attr: TokenStream, item: TokenStream) -> TokenStream {
|