@layerzerolabs/protocol-stellar-v2 0.2.22 → 0.2.24
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 +331 -261
- package/.turbo/turbo-lint.log +262 -192
- package/.turbo/turbo-test.log +1696 -1368
- 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 +667 -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
|
@@ -1,1072 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
source: contracts/common-macros/src/tests/storage.rs
|
|
3
|
-
assertion_line: 374
|
|
4
|
-
expression: formatted
|
|
5
|
-
---
|
|
6
|
-
#[soroban_sdk::contracttype]
|
|
7
|
-
pub enum StorageKeys {
|
|
8
|
-
Counter,
|
|
9
|
-
Message(Address),
|
|
10
|
-
Flag(String),
|
|
11
|
-
Data(u64, String),
|
|
12
|
-
Owner,
|
|
13
|
-
OptionalData(BytesN<32>),
|
|
14
|
-
TempData,
|
|
15
|
-
UserBalance(Address),
|
|
16
|
-
AnotherVariant(Address),
|
|
17
|
-
U32Value(u32),
|
|
18
|
-
I64Value(i64),
|
|
19
|
-
BoolValue(bool),
|
|
20
|
-
U8Value(u8),
|
|
21
|
-
UsizeValue(usize),
|
|
22
|
-
StringValue(String),
|
|
23
|
-
VecValue(Vec<u32>),
|
|
24
|
-
AddressValue(Address),
|
|
25
|
-
UnitVariant,
|
|
26
|
-
NamedVariant(u32, String, Address),
|
|
27
|
-
CachedValue(Address),
|
|
28
|
-
}
|
|
29
|
-
impl StorageKeys {
|
|
30
|
-
pub fn counter(env: &soroban_sdk::Env) -> u32 {
|
|
31
|
-
let key = StorageKeys::Counter;
|
|
32
|
-
let value = env.storage().instance().get::<_, u32>(&key);
|
|
33
|
-
value.unwrap_or(0)
|
|
34
|
-
}
|
|
35
|
-
pub fn set_counter(env: &soroban_sdk::Env, value: &u32) {
|
|
36
|
-
let key = StorageKeys::Counter;
|
|
37
|
-
env.storage().instance().set(&key, value);
|
|
38
|
-
}
|
|
39
|
-
pub fn remove_counter(env: &soroban_sdk::Env) {
|
|
40
|
-
let key = StorageKeys::Counter;
|
|
41
|
-
env.storage().instance().remove(&key);
|
|
42
|
-
}
|
|
43
|
-
pub fn set_or_remove_counter(env: &soroban_sdk::Env, value: &Option<u32>) {
|
|
44
|
-
match value.as_ref() {
|
|
45
|
-
Some(v) => Self::set_counter(env, v),
|
|
46
|
-
None => Self::remove_counter(env),
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
pub fn has_counter(env: &soroban_sdk::Env) -> bool {
|
|
50
|
-
let key = StorageKeys::Counter;
|
|
51
|
-
env.storage().instance().has(&key)
|
|
52
|
-
}
|
|
53
|
-
pub fn extend_counter_ttl(env: &soroban_sdk::Env, threshold: u32, extend_to: u32) {
|
|
54
|
-
let key = StorageKeys::Counter;
|
|
55
|
-
env.storage().instance().extend_ttl(threshold, extend_to);
|
|
56
|
-
}
|
|
57
|
-
pub fn message(env: &soroban_sdk::Env, sender: &Address) -> String {
|
|
58
|
-
let key = StorageKeys::Message(sender.clone());
|
|
59
|
-
let value = env.storage().persistent().get::<_, String>(&key);
|
|
60
|
-
if value.is_some() {
|
|
61
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
62
|
-
env,
|
|
63
|
-
) {
|
|
64
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
value.unwrap_or("hello".to_string())
|
|
68
|
-
}
|
|
69
|
-
pub fn set_message(env: &soroban_sdk::Env, sender: &Address, value: &String) {
|
|
70
|
-
let key = StorageKeys::Message(sender.clone());
|
|
71
|
-
env.storage().persistent().set(&key, value);
|
|
72
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
73
|
-
env,
|
|
74
|
-
) {
|
|
75
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
pub fn remove_message(env: &soroban_sdk::Env, sender: &Address) {
|
|
79
|
-
let key = StorageKeys::Message(sender.clone());
|
|
80
|
-
env.storage().persistent().remove(&key);
|
|
81
|
-
}
|
|
82
|
-
pub fn set_or_remove_message(
|
|
83
|
-
env: &soroban_sdk::Env,
|
|
84
|
-
sender: &Address,
|
|
85
|
-
value: &Option<String>,
|
|
86
|
-
) {
|
|
87
|
-
match value.as_ref() {
|
|
88
|
-
Some(v) => Self::set_message(env, sender, v),
|
|
89
|
-
None => Self::remove_message(env, sender),
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
pub fn has_message(env: &soroban_sdk::Env, sender: &Address) -> bool {
|
|
93
|
-
let key = StorageKeys::Message(sender.clone());
|
|
94
|
-
let exists = env.storage().persistent().has(&key);
|
|
95
|
-
if exists {
|
|
96
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
97
|
-
env,
|
|
98
|
-
) {
|
|
99
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exists
|
|
103
|
-
}
|
|
104
|
-
pub fn extend_message_ttl(
|
|
105
|
-
env: &soroban_sdk::Env,
|
|
106
|
-
sender: &Address,
|
|
107
|
-
threshold: u32,
|
|
108
|
-
extend_to: u32,
|
|
109
|
-
) {
|
|
110
|
-
let key = StorageKeys::Message(sender.clone());
|
|
111
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
112
|
-
}
|
|
113
|
-
pub fn flag(env: &soroban_sdk::Env, key: &String) -> Option<bool> {
|
|
114
|
-
let key = StorageKeys::Flag(key.clone());
|
|
115
|
-
let value = env.storage().temporary().get::<_, bool>(&key);
|
|
116
|
-
value
|
|
117
|
-
}
|
|
118
|
-
pub fn set_flag(env: &soroban_sdk::Env, key: &String, value: &bool) {
|
|
119
|
-
let key = StorageKeys::Flag(key.clone());
|
|
120
|
-
env.storage().temporary().set(&key, value);
|
|
121
|
-
}
|
|
122
|
-
pub fn remove_flag(env: &soroban_sdk::Env, key: &String) {
|
|
123
|
-
let key = StorageKeys::Flag(key.clone());
|
|
124
|
-
env.storage().temporary().remove(&key);
|
|
125
|
-
}
|
|
126
|
-
pub fn set_or_remove_flag(
|
|
127
|
-
env: &soroban_sdk::Env,
|
|
128
|
-
key: &String,
|
|
129
|
-
value: &Option<bool>,
|
|
130
|
-
) {
|
|
131
|
-
match value.as_ref() {
|
|
132
|
-
Some(v) => Self::set_flag(env, key, v),
|
|
133
|
-
None => Self::remove_flag(env, key),
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
pub fn has_flag(env: &soroban_sdk::Env, key: &String) -> bool {
|
|
137
|
-
let key = StorageKeys::Flag(key.clone());
|
|
138
|
-
env.storage().temporary().has(&key)
|
|
139
|
-
}
|
|
140
|
-
pub fn extend_flag_ttl(
|
|
141
|
-
env: &soroban_sdk::Env,
|
|
142
|
-
key: &String,
|
|
143
|
-
threshold: u32,
|
|
144
|
-
extend_to: u32,
|
|
145
|
-
) {
|
|
146
|
-
let key = StorageKeys::Flag(key.clone());
|
|
147
|
-
env.storage().temporary().extend_ttl(&key, threshold, extend_to);
|
|
148
|
-
}
|
|
149
|
-
pub fn data(env: &soroban_sdk::Env, id: u64, name: &String) -> Option<Vec<u8>> {
|
|
150
|
-
let key = StorageKeys::Data(id, name.clone());
|
|
151
|
-
let value = env.storage().persistent().get::<_, Vec<u8>>(&key);
|
|
152
|
-
if value.is_some() {
|
|
153
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
154
|
-
env,
|
|
155
|
-
) {
|
|
156
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
value
|
|
160
|
-
}
|
|
161
|
-
pub fn set_data(env: &soroban_sdk::Env, id: u64, name: &String, value: &Vec<u8>) {
|
|
162
|
-
let key = StorageKeys::Data(id, name.clone());
|
|
163
|
-
env.storage().persistent().set(&key, value);
|
|
164
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
165
|
-
env,
|
|
166
|
-
) {
|
|
167
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
pub fn remove_data(env: &soroban_sdk::Env, id: u64, name: &String) {
|
|
171
|
-
let key = StorageKeys::Data(id, name.clone());
|
|
172
|
-
env.storage().persistent().remove(&key);
|
|
173
|
-
}
|
|
174
|
-
pub fn set_or_remove_data(
|
|
175
|
-
env: &soroban_sdk::Env,
|
|
176
|
-
id: u64,
|
|
177
|
-
name: &String,
|
|
178
|
-
value: &Option<Vec<u8>>,
|
|
179
|
-
) {
|
|
180
|
-
match value.as_ref() {
|
|
181
|
-
Some(v) => Self::set_data(env, id, name, v),
|
|
182
|
-
None => Self::remove_data(env, id, name),
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
pub fn has_data(env: &soroban_sdk::Env, id: u64, name: &String) -> bool {
|
|
186
|
-
let key = StorageKeys::Data(id, name.clone());
|
|
187
|
-
let exists = env.storage().persistent().has(&key);
|
|
188
|
-
if exists {
|
|
189
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
190
|
-
env,
|
|
191
|
-
) {
|
|
192
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
exists
|
|
196
|
-
}
|
|
197
|
-
pub fn extend_data_ttl(
|
|
198
|
-
env: &soroban_sdk::Env,
|
|
199
|
-
id: u64,
|
|
200
|
-
name: &String,
|
|
201
|
-
threshold: u32,
|
|
202
|
-
extend_to: u32,
|
|
203
|
-
) {
|
|
204
|
-
let key = StorageKeys::Data(id, name.clone());
|
|
205
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
206
|
-
}
|
|
207
|
-
pub fn owner(env: &soroban_sdk::Env) -> Option<Address> {
|
|
208
|
-
let key = StorageKeys::Owner;
|
|
209
|
-
let value = env.storage().persistent().get::<_, Address>(&key);
|
|
210
|
-
if value.is_some() {
|
|
211
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
212
|
-
env,
|
|
213
|
-
) {
|
|
214
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
value
|
|
218
|
-
}
|
|
219
|
-
pub fn set_owner(env: &soroban_sdk::Env, value: &Address) {
|
|
220
|
-
let key = StorageKeys::Owner;
|
|
221
|
-
env.storage().persistent().set(&key, value);
|
|
222
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
223
|
-
env,
|
|
224
|
-
) {
|
|
225
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
pub fn remove_owner(env: &soroban_sdk::Env) {
|
|
229
|
-
let key = StorageKeys::Owner;
|
|
230
|
-
env.storage().persistent().remove(&key);
|
|
231
|
-
}
|
|
232
|
-
pub fn set_or_remove_owner(env: &soroban_sdk::Env, value: &Option<Address>) {
|
|
233
|
-
match value.as_ref() {
|
|
234
|
-
Some(v) => Self::set_owner(env, v),
|
|
235
|
-
None => Self::remove_owner(env),
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
pub fn has_owner(env: &soroban_sdk::Env) -> bool {
|
|
239
|
-
let key = StorageKeys::Owner;
|
|
240
|
-
let exists = env.storage().persistent().has(&key);
|
|
241
|
-
if exists {
|
|
242
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
243
|
-
env,
|
|
244
|
-
) {
|
|
245
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
exists
|
|
249
|
-
}
|
|
250
|
-
pub fn extend_owner_ttl(env: &soroban_sdk::Env, threshold: u32, extend_to: u32) {
|
|
251
|
-
let key = StorageKeys::Owner;
|
|
252
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
253
|
-
}
|
|
254
|
-
pub fn custom_key_name(
|
|
255
|
-
env: &soroban_sdk::Env,
|
|
256
|
-
key: &BytesN<32>,
|
|
257
|
-
) -> Option<Option<Address>> {
|
|
258
|
-
let key = StorageKeys::OptionalData(key.clone());
|
|
259
|
-
let value = env.storage().persistent().get::<_, Option<Address>>(&key);
|
|
260
|
-
if value.is_some() {
|
|
261
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
262
|
-
env,
|
|
263
|
-
) {
|
|
264
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
value
|
|
268
|
-
}
|
|
269
|
-
pub fn set_custom_key_name(
|
|
270
|
-
env: &soroban_sdk::Env,
|
|
271
|
-
key: &BytesN<32>,
|
|
272
|
-
value: &Option<Address>,
|
|
273
|
-
) {
|
|
274
|
-
let key = StorageKeys::OptionalData(key.clone());
|
|
275
|
-
env.storage().persistent().set(&key, value);
|
|
276
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
277
|
-
env,
|
|
278
|
-
) {
|
|
279
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
pub fn remove_custom_key_name(env: &soroban_sdk::Env, key: &BytesN<32>) {
|
|
283
|
-
let key = StorageKeys::OptionalData(key.clone());
|
|
284
|
-
env.storage().persistent().remove(&key);
|
|
285
|
-
}
|
|
286
|
-
pub fn set_or_remove_custom_key_name(
|
|
287
|
-
env: &soroban_sdk::Env,
|
|
288
|
-
key: &BytesN<32>,
|
|
289
|
-
value: &Option<Option<Address>>,
|
|
290
|
-
) {
|
|
291
|
-
match value.as_ref() {
|
|
292
|
-
Some(v) => Self::set_custom_key_name(env, key, v),
|
|
293
|
-
None => Self::remove_custom_key_name(env, key),
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
pub fn has_custom_key_name(env: &soroban_sdk::Env, key: &BytesN<32>) -> bool {
|
|
297
|
-
let key = StorageKeys::OptionalData(key.clone());
|
|
298
|
-
let exists = env.storage().persistent().has(&key);
|
|
299
|
-
if exists {
|
|
300
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
301
|
-
env,
|
|
302
|
-
) {
|
|
303
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
exists
|
|
307
|
-
}
|
|
308
|
-
pub fn extend_custom_key_name_ttl(
|
|
309
|
-
env: &soroban_sdk::Env,
|
|
310
|
-
key: &BytesN<32>,
|
|
311
|
-
threshold: u32,
|
|
312
|
-
extend_to: u32,
|
|
313
|
-
) {
|
|
314
|
-
let key = StorageKeys::OptionalData(key.clone());
|
|
315
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
316
|
-
}
|
|
317
|
-
pub fn temp_data(env: &soroban_sdk::Env) -> Option<u64> {
|
|
318
|
-
let key = StorageKeys::TempData;
|
|
319
|
-
let value = env.storage().temporary().get::<_, u64>(&key);
|
|
320
|
-
value
|
|
321
|
-
}
|
|
322
|
-
pub fn set_temp_data(env: &soroban_sdk::Env, value: &u64) {
|
|
323
|
-
let key = StorageKeys::TempData;
|
|
324
|
-
env.storage().temporary().set(&key, value);
|
|
325
|
-
}
|
|
326
|
-
pub fn remove_temp_data(env: &soroban_sdk::Env) {
|
|
327
|
-
let key = StorageKeys::TempData;
|
|
328
|
-
env.storage().temporary().remove(&key);
|
|
329
|
-
}
|
|
330
|
-
pub fn set_or_remove_temp_data(env: &soroban_sdk::Env, value: &Option<u64>) {
|
|
331
|
-
match value.as_ref() {
|
|
332
|
-
Some(v) => Self::set_temp_data(env, v),
|
|
333
|
-
None => Self::remove_temp_data(env),
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
pub fn has_temp_data(env: &soroban_sdk::Env) -> bool {
|
|
337
|
-
let key = StorageKeys::TempData;
|
|
338
|
-
env.storage().temporary().has(&key)
|
|
339
|
-
}
|
|
340
|
-
pub fn extend_temp_data_ttl(env: &soroban_sdk::Env, threshold: u32, extend_to: u32) {
|
|
341
|
-
let key = StorageKeys::TempData;
|
|
342
|
-
env.storage().temporary().extend_ttl(&key, threshold, extend_to);
|
|
343
|
-
}
|
|
344
|
-
pub fn user_balance(env: &soroban_sdk::Env, user: &Address) -> Option<u32> {
|
|
345
|
-
let key = StorageKeys::UserBalance(user.clone());
|
|
346
|
-
let value = env.storage().persistent().get::<_, u32>(&key);
|
|
347
|
-
if value.is_some() {
|
|
348
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
349
|
-
env,
|
|
350
|
-
) {
|
|
351
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
value
|
|
355
|
-
}
|
|
356
|
-
pub fn set_user_balance(env: &soroban_sdk::Env, user: &Address, value: &u32) {
|
|
357
|
-
let key = StorageKeys::UserBalance(user.clone());
|
|
358
|
-
env.storage().persistent().set(&key, value);
|
|
359
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
360
|
-
env,
|
|
361
|
-
) {
|
|
362
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
pub fn remove_user_balance(env: &soroban_sdk::Env, user: &Address) {
|
|
366
|
-
let key = StorageKeys::UserBalance(user.clone());
|
|
367
|
-
env.storage().persistent().remove(&key);
|
|
368
|
-
}
|
|
369
|
-
pub fn set_or_remove_user_balance(
|
|
370
|
-
env: &soroban_sdk::Env,
|
|
371
|
-
user: &Address,
|
|
372
|
-
value: &Option<u32>,
|
|
373
|
-
) {
|
|
374
|
-
match value.as_ref() {
|
|
375
|
-
Some(v) => Self::set_user_balance(env, user, v),
|
|
376
|
-
None => Self::remove_user_balance(env, user),
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
pub fn has_user_balance(env: &soroban_sdk::Env, user: &Address) -> bool {
|
|
380
|
-
let key = StorageKeys::UserBalance(user.clone());
|
|
381
|
-
let exists = env.storage().persistent().has(&key);
|
|
382
|
-
if exists {
|
|
383
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
384
|
-
env,
|
|
385
|
-
) {
|
|
386
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
exists
|
|
390
|
-
}
|
|
391
|
-
pub fn extend_user_balance_ttl(
|
|
392
|
-
env: &soroban_sdk::Env,
|
|
393
|
-
user: &Address,
|
|
394
|
-
threshold: u32,
|
|
395
|
-
extend_to: u32,
|
|
396
|
-
) {
|
|
397
|
-
let key = StorageKeys::UserBalance(user.clone());
|
|
398
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
399
|
-
}
|
|
400
|
-
pub fn custom(env: &soroban_sdk::Env, key: &Address) -> Option<u32> {
|
|
401
|
-
let key = StorageKeys::AnotherVariant(key.clone());
|
|
402
|
-
let value = env.storage().persistent().get::<_, u32>(&key);
|
|
403
|
-
if value.is_some() {
|
|
404
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
405
|
-
env,
|
|
406
|
-
) {
|
|
407
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
value
|
|
411
|
-
}
|
|
412
|
-
pub fn set_custom(env: &soroban_sdk::Env, key: &Address, value: &u32) {
|
|
413
|
-
let key = StorageKeys::AnotherVariant(key.clone());
|
|
414
|
-
env.storage().persistent().set(&key, value);
|
|
415
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
416
|
-
env,
|
|
417
|
-
) {
|
|
418
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
pub fn remove_custom(env: &soroban_sdk::Env, key: &Address) {
|
|
422
|
-
let key = StorageKeys::AnotherVariant(key.clone());
|
|
423
|
-
env.storage().persistent().remove(&key);
|
|
424
|
-
}
|
|
425
|
-
pub fn set_or_remove_custom(
|
|
426
|
-
env: &soroban_sdk::Env,
|
|
427
|
-
key: &Address,
|
|
428
|
-
value: &Option<u32>,
|
|
429
|
-
) {
|
|
430
|
-
match value.as_ref() {
|
|
431
|
-
Some(v) => Self::set_custom(env, key, v),
|
|
432
|
-
None => Self::remove_custom(env, key),
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
pub fn has_custom(env: &soroban_sdk::Env, key: &Address) -> bool {
|
|
436
|
-
let key = StorageKeys::AnotherVariant(key.clone());
|
|
437
|
-
let exists = env.storage().persistent().has(&key);
|
|
438
|
-
if exists {
|
|
439
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
440
|
-
env,
|
|
441
|
-
) {
|
|
442
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
exists
|
|
446
|
-
}
|
|
447
|
-
pub fn extend_custom_ttl(
|
|
448
|
-
env: &soroban_sdk::Env,
|
|
449
|
-
key: &Address,
|
|
450
|
-
threshold: u32,
|
|
451
|
-
extend_to: u32,
|
|
452
|
-
) {
|
|
453
|
-
let key = StorageKeys::AnotherVariant(key.clone());
|
|
454
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
455
|
-
}
|
|
456
|
-
pub fn u32_value(env: &soroban_sdk::Env, key: u32) -> Option<u32> {
|
|
457
|
-
let key = StorageKeys::U32Value(key);
|
|
458
|
-
let value = env.storage().persistent().get::<_, u32>(&key);
|
|
459
|
-
if value.is_some() {
|
|
460
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
461
|
-
env,
|
|
462
|
-
) {
|
|
463
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
value
|
|
467
|
-
}
|
|
468
|
-
pub fn set_u32_value(env: &soroban_sdk::Env, key: u32, value: &u32) {
|
|
469
|
-
let key = StorageKeys::U32Value(key);
|
|
470
|
-
env.storage().persistent().set(&key, value);
|
|
471
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
472
|
-
env,
|
|
473
|
-
) {
|
|
474
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
pub fn remove_u32_value(env: &soroban_sdk::Env, key: u32) {
|
|
478
|
-
let key = StorageKeys::U32Value(key);
|
|
479
|
-
env.storage().persistent().remove(&key);
|
|
480
|
-
}
|
|
481
|
-
pub fn set_or_remove_u32_value(
|
|
482
|
-
env: &soroban_sdk::Env,
|
|
483
|
-
key: u32,
|
|
484
|
-
value: &Option<u32>,
|
|
485
|
-
) {
|
|
486
|
-
match value.as_ref() {
|
|
487
|
-
Some(v) => Self::set_u32_value(env, key, v),
|
|
488
|
-
None => Self::remove_u32_value(env, key),
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
pub fn has_u32_value(env: &soroban_sdk::Env, key: u32) -> bool {
|
|
492
|
-
let key = StorageKeys::U32Value(key);
|
|
493
|
-
let exists = env.storage().persistent().has(&key);
|
|
494
|
-
if exists {
|
|
495
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
496
|
-
env,
|
|
497
|
-
) {
|
|
498
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
exists
|
|
502
|
-
}
|
|
503
|
-
pub fn extend_u32_value_ttl(
|
|
504
|
-
env: &soroban_sdk::Env,
|
|
505
|
-
key: u32,
|
|
506
|
-
threshold: u32,
|
|
507
|
-
extend_to: u32,
|
|
508
|
-
) {
|
|
509
|
-
let key = StorageKeys::U32Value(key);
|
|
510
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
511
|
-
}
|
|
512
|
-
pub fn i64_value(env: &soroban_sdk::Env, key: i64) -> Option<i64> {
|
|
513
|
-
let key = StorageKeys::I64Value(key);
|
|
514
|
-
let value = env.storage().persistent().get::<_, i64>(&key);
|
|
515
|
-
if value.is_some() {
|
|
516
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
517
|
-
env,
|
|
518
|
-
) {
|
|
519
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
value
|
|
523
|
-
}
|
|
524
|
-
pub fn set_i64_value(env: &soroban_sdk::Env, key: i64, value: &i64) {
|
|
525
|
-
let key = StorageKeys::I64Value(key);
|
|
526
|
-
env.storage().persistent().set(&key, value);
|
|
527
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
528
|
-
env,
|
|
529
|
-
) {
|
|
530
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
pub fn remove_i64_value(env: &soroban_sdk::Env, key: i64) {
|
|
534
|
-
let key = StorageKeys::I64Value(key);
|
|
535
|
-
env.storage().persistent().remove(&key);
|
|
536
|
-
}
|
|
537
|
-
pub fn set_or_remove_i64_value(
|
|
538
|
-
env: &soroban_sdk::Env,
|
|
539
|
-
key: i64,
|
|
540
|
-
value: &Option<i64>,
|
|
541
|
-
) {
|
|
542
|
-
match value.as_ref() {
|
|
543
|
-
Some(v) => Self::set_i64_value(env, key, v),
|
|
544
|
-
None => Self::remove_i64_value(env, key),
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
pub fn has_i64_value(env: &soroban_sdk::Env, key: i64) -> bool {
|
|
548
|
-
let key = StorageKeys::I64Value(key);
|
|
549
|
-
let exists = env.storage().persistent().has(&key);
|
|
550
|
-
if exists {
|
|
551
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
552
|
-
env,
|
|
553
|
-
) {
|
|
554
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
exists
|
|
558
|
-
}
|
|
559
|
-
pub fn extend_i64_value_ttl(
|
|
560
|
-
env: &soroban_sdk::Env,
|
|
561
|
-
key: i64,
|
|
562
|
-
threshold: u32,
|
|
563
|
-
extend_to: u32,
|
|
564
|
-
) {
|
|
565
|
-
let key = StorageKeys::I64Value(key);
|
|
566
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
567
|
-
}
|
|
568
|
-
pub fn bool_value(env: &soroban_sdk::Env, key: bool) -> Option<bool> {
|
|
569
|
-
let key = StorageKeys::BoolValue(key);
|
|
570
|
-
let value = env.storage().persistent().get::<_, bool>(&key);
|
|
571
|
-
if value.is_some() {
|
|
572
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
573
|
-
env,
|
|
574
|
-
) {
|
|
575
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
value
|
|
579
|
-
}
|
|
580
|
-
pub fn set_bool_value(env: &soroban_sdk::Env, key: bool, value: &bool) {
|
|
581
|
-
let key = StorageKeys::BoolValue(key);
|
|
582
|
-
env.storage().persistent().set(&key, value);
|
|
583
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
584
|
-
env,
|
|
585
|
-
) {
|
|
586
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
pub fn remove_bool_value(env: &soroban_sdk::Env, key: bool) {
|
|
590
|
-
let key = StorageKeys::BoolValue(key);
|
|
591
|
-
env.storage().persistent().remove(&key);
|
|
592
|
-
}
|
|
593
|
-
pub fn set_or_remove_bool_value(
|
|
594
|
-
env: &soroban_sdk::Env,
|
|
595
|
-
key: bool,
|
|
596
|
-
value: &Option<bool>,
|
|
597
|
-
) {
|
|
598
|
-
match value.as_ref() {
|
|
599
|
-
Some(v) => Self::set_bool_value(env, key, v),
|
|
600
|
-
None => Self::remove_bool_value(env, key),
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
pub fn has_bool_value(env: &soroban_sdk::Env, key: bool) -> bool {
|
|
604
|
-
let key = StorageKeys::BoolValue(key);
|
|
605
|
-
let exists = env.storage().persistent().has(&key);
|
|
606
|
-
if exists {
|
|
607
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
608
|
-
env,
|
|
609
|
-
) {
|
|
610
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
exists
|
|
614
|
-
}
|
|
615
|
-
pub fn extend_bool_value_ttl(
|
|
616
|
-
env: &soroban_sdk::Env,
|
|
617
|
-
key: bool,
|
|
618
|
-
threshold: u32,
|
|
619
|
-
extend_to: u32,
|
|
620
|
-
) {
|
|
621
|
-
let key = StorageKeys::BoolValue(key);
|
|
622
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
623
|
-
}
|
|
624
|
-
pub fn u8_value(env: &soroban_sdk::Env, key: &u8) -> Option<u32> {
|
|
625
|
-
let key = StorageKeys::U8Value(key.clone());
|
|
626
|
-
let value = env.storage().persistent().get::<_, u32>(&key);
|
|
627
|
-
if value.is_some() {
|
|
628
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
629
|
-
env,
|
|
630
|
-
) {
|
|
631
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
value
|
|
635
|
-
}
|
|
636
|
-
pub fn set_u8_value(env: &soroban_sdk::Env, key: &u8, value: &u32) {
|
|
637
|
-
let key = StorageKeys::U8Value(key.clone());
|
|
638
|
-
env.storage().persistent().set(&key, value);
|
|
639
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
640
|
-
env,
|
|
641
|
-
) {
|
|
642
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
pub fn remove_u8_value(env: &soroban_sdk::Env, key: &u8) {
|
|
646
|
-
let key = StorageKeys::U8Value(key.clone());
|
|
647
|
-
env.storage().persistent().remove(&key);
|
|
648
|
-
}
|
|
649
|
-
pub fn set_or_remove_u8_value(
|
|
650
|
-
env: &soroban_sdk::Env,
|
|
651
|
-
key: &u8,
|
|
652
|
-
value: &Option<u32>,
|
|
653
|
-
) {
|
|
654
|
-
match value.as_ref() {
|
|
655
|
-
Some(v) => Self::set_u8_value(env, key, v),
|
|
656
|
-
None => Self::remove_u8_value(env, key),
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
pub fn has_u8_value(env: &soroban_sdk::Env, key: &u8) -> bool {
|
|
660
|
-
let key = StorageKeys::U8Value(key.clone());
|
|
661
|
-
let exists = env.storage().persistent().has(&key);
|
|
662
|
-
if exists {
|
|
663
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
664
|
-
env,
|
|
665
|
-
) {
|
|
666
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
exists
|
|
670
|
-
}
|
|
671
|
-
pub fn extend_u8_value_ttl(
|
|
672
|
-
env: &soroban_sdk::Env,
|
|
673
|
-
key: &u8,
|
|
674
|
-
threshold: u32,
|
|
675
|
-
extend_to: u32,
|
|
676
|
-
) {
|
|
677
|
-
let key = StorageKeys::U8Value(key.clone());
|
|
678
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
679
|
-
}
|
|
680
|
-
pub fn usize_value(env: &soroban_sdk::Env, key: &usize) -> Option<u32> {
|
|
681
|
-
let key = StorageKeys::UsizeValue(key.clone());
|
|
682
|
-
let value = env.storage().persistent().get::<_, u32>(&key);
|
|
683
|
-
if value.is_some() {
|
|
684
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
685
|
-
env,
|
|
686
|
-
) {
|
|
687
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
value
|
|
691
|
-
}
|
|
692
|
-
pub fn set_usize_value(env: &soroban_sdk::Env, key: &usize, value: &u32) {
|
|
693
|
-
let key = StorageKeys::UsizeValue(key.clone());
|
|
694
|
-
env.storage().persistent().set(&key, value);
|
|
695
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
696
|
-
env,
|
|
697
|
-
) {
|
|
698
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
pub fn remove_usize_value(env: &soroban_sdk::Env, key: &usize) {
|
|
702
|
-
let key = StorageKeys::UsizeValue(key.clone());
|
|
703
|
-
env.storage().persistent().remove(&key);
|
|
704
|
-
}
|
|
705
|
-
pub fn set_or_remove_usize_value(
|
|
706
|
-
env: &soroban_sdk::Env,
|
|
707
|
-
key: &usize,
|
|
708
|
-
value: &Option<u32>,
|
|
709
|
-
) {
|
|
710
|
-
match value.as_ref() {
|
|
711
|
-
Some(v) => Self::set_usize_value(env, key, v),
|
|
712
|
-
None => Self::remove_usize_value(env, key),
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
pub fn has_usize_value(env: &soroban_sdk::Env, key: &usize) -> bool {
|
|
716
|
-
let key = StorageKeys::UsizeValue(key.clone());
|
|
717
|
-
let exists = env.storage().persistent().has(&key);
|
|
718
|
-
if exists {
|
|
719
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
720
|
-
env,
|
|
721
|
-
) {
|
|
722
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
exists
|
|
726
|
-
}
|
|
727
|
-
pub fn extend_usize_value_ttl(
|
|
728
|
-
env: &soroban_sdk::Env,
|
|
729
|
-
key: &usize,
|
|
730
|
-
threshold: u32,
|
|
731
|
-
extend_to: u32,
|
|
732
|
-
) {
|
|
733
|
-
let key = StorageKeys::UsizeValue(key.clone());
|
|
734
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
735
|
-
}
|
|
736
|
-
pub fn string_value(env: &soroban_sdk::Env, key: &String) -> Option<String> {
|
|
737
|
-
let key = StorageKeys::StringValue(key.clone());
|
|
738
|
-
let value = env.storage().persistent().get::<_, String>(&key);
|
|
739
|
-
if value.is_some() {
|
|
740
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
741
|
-
env,
|
|
742
|
-
) {
|
|
743
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
value
|
|
747
|
-
}
|
|
748
|
-
pub fn set_string_value(env: &soroban_sdk::Env, key: &String, value: &String) {
|
|
749
|
-
let key = StorageKeys::StringValue(key.clone());
|
|
750
|
-
env.storage().persistent().set(&key, value);
|
|
751
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
752
|
-
env,
|
|
753
|
-
) {
|
|
754
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
pub fn remove_string_value(env: &soroban_sdk::Env, key: &String) {
|
|
758
|
-
let key = StorageKeys::StringValue(key.clone());
|
|
759
|
-
env.storage().persistent().remove(&key);
|
|
760
|
-
}
|
|
761
|
-
pub fn set_or_remove_string_value(
|
|
762
|
-
env: &soroban_sdk::Env,
|
|
763
|
-
key: &String,
|
|
764
|
-
value: &Option<String>,
|
|
765
|
-
) {
|
|
766
|
-
match value.as_ref() {
|
|
767
|
-
Some(v) => Self::set_string_value(env, key, v),
|
|
768
|
-
None => Self::remove_string_value(env, key),
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
pub fn has_string_value(env: &soroban_sdk::Env, key: &String) -> bool {
|
|
772
|
-
let key = StorageKeys::StringValue(key.clone());
|
|
773
|
-
let exists = env.storage().persistent().has(&key);
|
|
774
|
-
if exists {
|
|
775
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
776
|
-
env,
|
|
777
|
-
) {
|
|
778
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
exists
|
|
782
|
-
}
|
|
783
|
-
pub fn extend_string_value_ttl(
|
|
784
|
-
env: &soroban_sdk::Env,
|
|
785
|
-
key: &String,
|
|
786
|
-
threshold: u32,
|
|
787
|
-
extend_to: u32,
|
|
788
|
-
) {
|
|
789
|
-
let key = StorageKeys::StringValue(key.clone());
|
|
790
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
791
|
-
}
|
|
792
|
-
pub fn vec_value(env: &soroban_sdk::Env, key: &Vec<u32>) -> Option<Vec<u32>> {
|
|
793
|
-
let key = StorageKeys::VecValue(key.clone());
|
|
794
|
-
let value = env.storage().persistent().get::<_, Vec<u32>>(&key);
|
|
795
|
-
if value.is_some() {
|
|
796
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
797
|
-
env,
|
|
798
|
-
) {
|
|
799
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
value
|
|
803
|
-
}
|
|
804
|
-
pub fn set_vec_value(env: &soroban_sdk::Env, key: &Vec<u32>, value: &Vec<u32>) {
|
|
805
|
-
let key = StorageKeys::VecValue(key.clone());
|
|
806
|
-
env.storage().persistent().set(&key, value);
|
|
807
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
808
|
-
env,
|
|
809
|
-
) {
|
|
810
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
pub fn remove_vec_value(env: &soroban_sdk::Env, key: &Vec<u32>) {
|
|
814
|
-
let key = StorageKeys::VecValue(key.clone());
|
|
815
|
-
env.storage().persistent().remove(&key);
|
|
816
|
-
}
|
|
817
|
-
pub fn set_or_remove_vec_value(
|
|
818
|
-
env: &soroban_sdk::Env,
|
|
819
|
-
key: &Vec<u32>,
|
|
820
|
-
value: &Option<Vec<u32>>,
|
|
821
|
-
) {
|
|
822
|
-
match value.as_ref() {
|
|
823
|
-
Some(v) => Self::set_vec_value(env, key, v),
|
|
824
|
-
None => Self::remove_vec_value(env, key),
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
pub fn has_vec_value(env: &soroban_sdk::Env, key: &Vec<u32>) -> bool {
|
|
828
|
-
let key = StorageKeys::VecValue(key.clone());
|
|
829
|
-
let exists = env.storage().persistent().has(&key);
|
|
830
|
-
if exists {
|
|
831
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
832
|
-
env,
|
|
833
|
-
) {
|
|
834
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
exists
|
|
838
|
-
}
|
|
839
|
-
pub fn extend_vec_value_ttl(
|
|
840
|
-
env: &soroban_sdk::Env,
|
|
841
|
-
key: &Vec<u32>,
|
|
842
|
-
threshold: u32,
|
|
843
|
-
extend_to: u32,
|
|
844
|
-
) {
|
|
845
|
-
let key = StorageKeys::VecValue(key.clone());
|
|
846
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
847
|
-
}
|
|
848
|
-
pub fn address_value(env: &soroban_sdk::Env, key: &Address) -> Option<Address> {
|
|
849
|
-
let key = StorageKeys::AddressValue(key.clone());
|
|
850
|
-
let value = env.storage().persistent().get::<_, Address>(&key);
|
|
851
|
-
if value.is_some() {
|
|
852
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
853
|
-
env,
|
|
854
|
-
) {
|
|
855
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
value
|
|
859
|
-
}
|
|
860
|
-
pub fn set_address_value(env: &soroban_sdk::Env, key: &Address, value: &Address) {
|
|
861
|
-
let key = StorageKeys::AddressValue(key.clone());
|
|
862
|
-
env.storage().persistent().set(&key, value);
|
|
863
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
864
|
-
env,
|
|
865
|
-
) {
|
|
866
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
pub fn remove_address_value(env: &soroban_sdk::Env, key: &Address) {
|
|
870
|
-
let key = StorageKeys::AddressValue(key.clone());
|
|
871
|
-
env.storage().persistent().remove(&key);
|
|
872
|
-
}
|
|
873
|
-
pub fn set_or_remove_address_value(
|
|
874
|
-
env: &soroban_sdk::Env,
|
|
875
|
-
key: &Address,
|
|
876
|
-
value: &Option<Address>,
|
|
877
|
-
) {
|
|
878
|
-
match value.as_ref() {
|
|
879
|
-
Some(v) => Self::set_address_value(env, key, v),
|
|
880
|
-
None => Self::remove_address_value(env, key),
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
pub fn has_address_value(env: &soroban_sdk::Env, key: &Address) -> bool {
|
|
884
|
-
let key = StorageKeys::AddressValue(key.clone());
|
|
885
|
-
let exists = env.storage().persistent().has(&key);
|
|
886
|
-
if exists {
|
|
887
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
888
|
-
env,
|
|
889
|
-
) {
|
|
890
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
exists
|
|
894
|
-
}
|
|
895
|
-
pub fn extend_address_value_ttl(
|
|
896
|
-
env: &soroban_sdk::Env,
|
|
897
|
-
key: &Address,
|
|
898
|
-
threshold: u32,
|
|
899
|
-
extend_to: u32,
|
|
900
|
-
) {
|
|
901
|
-
let key = StorageKeys::AddressValue(key.clone());
|
|
902
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
903
|
-
}
|
|
904
|
-
pub fn unit_variant(env: &soroban_sdk::Env) -> Option<u32> {
|
|
905
|
-
let key = StorageKeys::UnitVariant;
|
|
906
|
-
let value = env.storage().persistent().get::<_, u32>(&key);
|
|
907
|
-
if value.is_some() {
|
|
908
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
909
|
-
env,
|
|
910
|
-
) {
|
|
911
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
value
|
|
915
|
-
}
|
|
916
|
-
pub fn set_unit_variant(env: &soroban_sdk::Env, value: &u32) {
|
|
917
|
-
let key = StorageKeys::UnitVariant;
|
|
918
|
-
env.storage().persistent().set(&key, value);
|
|
919
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
920
|
-
env,
|
|
921
|
-
) {
|
|
922
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
pub fn remove_unit_variant(env: &soroban_sdk::Env) {
|
|
926
|
-
let key = StorageKeys::UnitVariant;
|
|
927
|
-
env.storage().persistent().remove(&key);
|
|
928
|
-
}
|
|
929
|
-
pub fn set_or_remove_unit_variant(env: &soroban_sdk::Env, value: &Option<u32>) {
|
|
930
|
-
match value.as_ref() {
|
|
931
|
-
Some(v) => Self::set_unit_variant(env, v),
|
|
932
|
-
None => Self::remove_unit_variant(env),
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
pub fn has_unit_variant(env: &soroban_sdk::Env) -> bool {
|
|
936
|
-
let key = StorageKeys::UnitVariant;
|
|
937
|
-
let exists = env.storage().persistent().has(&key);
|
|
938
|
-
if exists {
|
|
939
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
940
|
-
env,
|
|
941
|
-
) {
|
|
942
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
exists
|
|
946
|
-
}
|
|
947
|
-
pub fn extend_unit_variant_ttl(
|
|
948
|
-
env: &soroban_sdk::Env,
|
|
949
|
-
threshold: u32,
|
|
950
|
-
extend_to: u32,
|
|
951
|
-
) {
|
|
952
|
-
let key = StorageKeys::UnitVariant;
|
|
953
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
954
|
-
}
|
|
955
|
-
pub fn named_variant(
|
|
956
|
-
env: &soroban_sdk::Env,
|
|
957
|
-
first: u32,
|
|
958
|
-
second: &String,
|
|
959
|
-
third: &Address,
|
|
960
|
-
) -> Option<u32> {
|
|
961
|
-
let key = StorageKeys::NamedVariant(first, second.clone(), third.clone());
|
|
962
|
-
let value = env.storage().persistent().get::<_, u32>(&key);
|
|
963
|
-
if value.is_some() {
|
|
964
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
965
|
-
env,
|
|
966
|
-
) {
|
|
967
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
value
|
|
971
|
-
}
|
|
972
|
-
pub fn set_named_variant(
|
|
973
|
-
env: &soroban_sdk::Env,
|
|
974
|
-
first: u32,
|
|
975
|
-
second: &String,
|
|
976
|
-
third: &Address,
|
|
977
|
-
value: &u32,
|
|
978
|
-
) {
|
|
979
|
-
let key = StorageKeys::NamedVariant(first, second.clone(), third.clone());
|
|
980
|
-
env.storage().persistent().set(&key, value);
|
|
981
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
982
|
-
env,
|
|
983
|
-
) {
|
|
984
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
pub fn remove_named_variant(
|
|
988
|
-
env: &soroban_sdk::Env,
|
|
989
|
-
first: u32,
|
|
990
|
-
second: &String,
|
|
991
|
-
third: &Address,
|
|
992
|
-
) {
|
|
993
|
-
let key = StorageKeys::NamedVariant(first, second.clone(), third.clone());
|
|
994
|
-
env.storage().persistent().remove(&key);
|
|
995
|
-
}
|
|
996
|
-
pub fn set_or_remove_named_variant(
|
|
997
|
-
env: &soroban_sdk::Env,
|
|
998
|
-
first: u32,
|
|
999
|
-
second: &String,
|
|
1000
|
-
third: &Address,
|
|
1001
|
-
value: &Option<u32>,
|
|
1002
|
-
) {
|
|
1003
|
-
match value.as_ref() {
|
|
1004
|
-
Some(v) => Self::set_named_variant(env, first, second, third, v),
|
|
1005
|
-
None => Self::remove_named_variant(env, first, second, third),
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
pub fn has_named_variant(
|
|
1009
|
-
env: &soroban_sdk::Env,
|
|
1010
|
-
first: u32,
|
|
1011
|
-
second: &String,
|
|
1012
|
-
third: &Address,
|
|
1013
|
-
) -> bool {
|
|
1014
|
-
let key = StorageKeys::NamedVariant(first, second.clone(), third.clone());
|
|
1015
|
-
let exists = env.storage().persistent().has(&key);
|
|
1016
|
-
if exists {
|
|
1017
|
-
if let Some(utils::ttl_configurable::TtlConfig { threshold, extend_to }) = utils::ttl_configurable::TtlConfigStorage::persistent(
|
|
1018
|
-
env,
|
|
1019
|
-
) {
|
|
1020
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
exists
|
|
1024
|
-
}
|
|
1025
|
-
pub fn extend_named_variant_ttl(
|
|
1026
|
-
env: &soroban_sdk::Env,
|
|
1027
|
-
first: u32,
|
|
1028
|
-
second: &String,
|
|
1029
|
-
third: &Address,
|
|
1030
|
-
threshold: u32,
|
|
1031
|
-
extend_to: u32,
|
|
1032
|
-
) {
|
|
1033
|
-
let key = StorageKeys::NamedVariant(first, second.clone(), third.clone());
|
|
1034
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
1035
|
-
}
|
|
1036
|
-
pub fn cached_value(env: &soroban_sdk::Env, key: &Address) -> Option<u64> {
|
|
1037
|
-
let key = StorageKeys::CachedValue(key.clone());
|
|
1038
|
-
let value = env.storage().persistent().get::<_, u64>(&key);
|
|
1039
|
-
value
|
|
1040
|
-
}
|
|
1041
|
-
pub fn set_cached_value(env: &soroban_sdk::Env, key: &Address, value: &u64) {
|
|
1042
|
-
let key = StorageKeys::CachedValue(key.clone());
|
|
1043
|
-
env.storage().persistent().set(&key, value);
|
|
1044
|
-
}
|
|
1045
|
-
pub fn remove_cached_value(env: &soroban_sdk::Env, key: &Address) {
|
|
1046
|
-
let key = StorageKeys::CachedValue(key.clone());
|
|
1047
|
-
env.storage().persistent().remove(&key);
|
|
1048
|
-
}
|
|
1049
|
-
pub fn set_or_remove_cached_value(
|
|
1050
|
-
env: &soroban_sdk::Env,
|
|
1051
|
-
key: &Address,
|
|
1052
|
-
value: &Option<u64>,
|
|
1053
|
-
) {
|
|
1054
|
-
match value.as_ref() {
|
|
1055
|
-
Some(v) => Self::set_cached_value(env, key, v),
|
|
1056
|
-
None => Self::remove_cached_value(env, key),
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
pub fn has_cached_value(env: &soroban_sdk::Env, key: &Address) -> bool {
|
|
1060
|
-
let key = StorageKeys::CachedValue(key.clone());
|
|
1061
|
-
env.storage().persistent().has(&key)
|
|
1062
|
-
}
|
|
1063
|
-
pub fn extend_cached_value_ttl(
|
|
1064
|
-
env: &soroban_sdk::Env,
|
|
1065
|
-
key: &Address,
|
|
1066
|
-
threshold: u32,
|
|
1067
|
-
extend_to: u32,
|
|
1068
|
-
) {
|
|
1069
|
-
let key = StorageKeys::CachedValue(key.clone());
|
|
1070
|
-
env.storage().persistent().extend_ttl(&key, threshold, extend_to);
|
|
1071
|
-
}
|
|
1072
|
-
}
|