@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.
Files changed (328) hide show
  1. package/.turbo/turbo-build.log +347 -271
  2. package/.turbo/turbo-lint.log +277 -208
  3. package/.turbo/turbo-test.log +1700 -1370
  4. package/Cargo.lock +22 -51
  5. package/Cargo.toml +6 -1
  6. package/contracts/common-macros/src/auth.rs +10 -9
  7. package/contracts/common-macros/src/contract_ttl.rs +1 -4
  8. package/contracts/common-macros/src/error.rs +1 -3
  9. package/contracts/common-macros/src/lib.rs +65 -61
  10. package/contracts/common-macros/src/storage.rs +212 -65
  11. package/contracts/common-macros/src/tests/auth.rs +75 -6
  12. package/contracts/common-macros/src/tests/contract_ttl.rs +383 -350
  13. package/contracts/common-macros/src/tests/error.rs +9 -21
  14. package/contracts/common-macros/src/tests/lz_contract.rs +80 -0
  15. package/contracts/common-macros/src/tests/mod.rs +2 -0
  16. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_multisig_code.snap +20 -3
  17. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__auth__snapshot_generated_ownable_code.snap +28 -1
  18. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contractimpl_code.snap +8 -43
  19. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__contract_ttl__snapshot_generated_contracttrait_code.snap +6 -29
  20. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__lz_contract__snapshot_generated_lz_contract_code.snap +31 -0
  21. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__ttl_extendable__snapshot_generated_ttl_extendable_code.snap +8 -0
  22. package/contracts/common-macros/src/tests/storage/extract_fields.rs +87 -0
  23. package/contracts/common-macros/src/tests/storage/gen_accessor_methods.rs +223 -0
  24. package/contracts/common-macros/src/tests/storage/gen_args.rs +65 -0
  25. package/contracts/common-macros/src/tests/storage/gen_enum_variant.rs +78 -0
  26. package/contracts/common-macros/src/tests/storage/gen_key.rs +108 -0
  27. package/contracts/common-macros/src/tests/storage/gen_params.rs +105 -0
  28. package/contracts/common-macros/src/tests/{storage.rs → storage/generate_storage.rs} +54 -129
  29. package/contracts/common-macros/src/tests/storage/is_primitive_type.rs +48 -0
  30. package/contracts/common-macros/src/tests/storage/mod.rs +16 -0
  31. package/contracts/common-macros/src/tests/storage/parse_default.rs +164 -0
  32. package/contracts/common-macros/src/tests/storage/parse_name.rs +159 -0
  33. package/contracts/common-macros/src/tests/storage/parse_no_ttl_extension.rs +124 -0
  34. package/contracts/common-macros/src/tests/storage/parse_storage_type.rs +174 -0
  35. package/contracts/common-macros/src/tests/storage/snapshots/common_macros__tests__storage__generate_storage__snapshot_generated_storage_code.snap +412 -0
  36. package/contracts/common-macros/src/tests/storage/storage_kind.rs +39 -0
  37. package/contracts/common-macros/src/tests/storage/test_setup.rs +25 -0
  38. package/contracts/common-macros/src/tests/storage/validate_attrs.rs +138 -0
  39. package/contracts/common-macros/src/tests/storage/variant_config.rs +226 -0
  40. package/contracts/common-macros/src/tests/test_helpers.rs +4 -10
  41. package/contracts/common-macros/src/tests/ttl_configurable.rs +2 -2
  42. package/contracts/common-macros/src/tests/ttl_extendable.rs +32 -0
  43. package/contracts/common-macros/src/tests/upgradeable.rs +118 -2
  44. package/contracts/common-macros/src/ttl_configurable.rs +1 -4
  45. package/contracts/common-macros/src/upgradeable.rs +21 -3
  46. package/contracts/endpoint-v2/Cargo.toml +0 -4
  47. package/contracts/endpoint-v2/src/endpoint_v2.rs +37 -17
  48. package/contracts/endpoint-v2/src/errors.rs +26 -1
  49. package/contracts/endpoint-v2/src/interfaces/layerzero_endpoint_v2.rs +1 -1
  50. package/contracts/endpoint-v2/src/interfaces/message_lib_manager.rs +4 -4
  51. package/contracts/endpoint-v2/src/interfaces/messaging_composer.rs +2 -2
  52. package/contracts/endpoint-v2/src/lib.rs +0 -1
  53. package/contracts/endpoint-v2/src/message_lib_manager.rs +39 -8
  54. package/contracts/endpoint-v2/src/messaging_channel.rs +36 -4
  55. package/contracts/endpoint-v2/src/messaging_composer.rs +18 -4
  56. package/contracts/endpoint-v2/src/storage.rs +9 -1
  57. package/contracts/endpoint-v2/src/tests/endpoint_setup.rs +2 -2
  58. package/contracts/endpoint-v2/src/tests/endpoint_v2/pay_messaging_fees.rs +1 -1
  59. package/contracts/endpoint-v2/src/tests/endpoint_v2/require_oapp_auth.rs +2 -2
  60. package/contracts/endpoint-v2/src/tests/message_lib_manager/register_library.rs +3 -3
  61. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_receive_lib_for_eid.rs +5 -5
  62. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_registered.rs +2 -2
  63. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_send_lib_for_eid.rs +5 -5
  64. package/contracts/endpoint-v2/src/tests/message_lib_manager/require_supported_eid.rs +3 -3
  65. package/contracts/endpoint-v2/src/tests/messaging_channel/nilify.rs +1 -1
  66. package/contracts/endpoint-v2/src/tests/messaging_composer/clear_compose.rs +4 -3
  67. package/contracts/endpoint-v2/src/tests/messaging_composer/lz_compose_alert.rs +7 -2
  68. package/contracts/endpoint-v2/src/tests/messaging_composer/mod.rs +4 -0
  69. package/contracts/endpoint-v2/src/tests/messaging_composer/send_compose.rs +7 -2
  70. package/contracts/layerzero-views/src/layerzero_view.rs +0 -1
  71. package/contracts/layerzero-views/src/tests/mod.rs +1 -0
  72. package/contracts/layerzero-views/src/tests/types_tests.rs +31 -0
  73. package/contracts/layerzero-views/src/types.rs +2 -3
  74. package/contracts/macro-integration-tests/tests/runtime/contract_ttl/constructor.rs +61 -0
  75. package/contracts/macro-integration-tests/tests/runtime/contract_ttl/contract_impl_ttl_extension.rs +97 -0
  76. package/contracts/macro-integration-tests/tests/runtime/contract_ttl/contract_trait_ttl_extension.rs +99 -0
  77. package/contracts/macro-integration-tests/tests/runtime/contract_ttl/mod.rs +3 -0
  78. package/contracts/macro-integration-tests/tests/runtime/lz_contract/mod.rs +5 -0
  79. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_default.rs +86 -0
  80. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_multisig.rs +47 -0
  81. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_multisig_upgradeable.rs +77 -0
  82. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_upgradeable.rs +114 -0
  83. package/contracts/macro-integration-tests/tests/runtime/lz_contract/wrapper_upgradeable_no_migration.rs +105 -0
  84. package/contracts/macro-integration-tests/tests/runtime/multisig/admin_entrypoints.rs +242 -0
  85. package/contracts/macro-integration-tests/tests/runtime/multisig/mod.rs +9 -0
  86. package/contracts/macro-integration-tests/tests/runtime/multisig/self_auth.rs +54 -0
  87. package/contracts/macro-integration-tests/tests/runtime/ownable/initialization.rs +13 -0
  88. package/contracts/macro-integration-tests/tests/runtime/ownable/mod.rs +1 -0
  89. package/contracts/macro-integration-tests/tests/runtime/ownable/ownership_transfer.rs +70 -1
  90. package/contracts/macro-integration-tests/tests/runtime/ownable/two_step_transfer.rs +219 -0
  91. package/contracts/macro-integration-tests/tests/runtime/storage/keyed_roundtrip.rs +41 -0
  92. package/contracts/macro-integration-tests/tests/runtime/storage/ttl_extension.rs +48 -16
  93. package/contracts/macro-integration-tests/tests/runtime/storage/unkeyed_roundtrip.rs +10 -0
  94. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/configuration.rs +96 -3
  95. package/contracts/macro-integration-tests/tests/runtime/ttl_configurable/freeze.rs +4 -0
  96. package/contracts/macro-integration-tests/tests/runtime/ttl_extendable/extend_instance_ttl.rs +64 -0
  97. package/contracts/macro-integration-tests/tests/runtime/ttl_extendable/mod.rs +16 -0
  98. package/contracts/macro-integration-tests/tests/runtime/upgradeable/migrate_guard_and_state.rs +305 -0
  99. package/contracts/macro-integration-tests/tests/runtime/upgradeable/mod.rs +3 -0
  100. package/contracts/macro-integration-tests/tests/runtime/upgradeable/no_migration.rs +59 -0
  101. package/contracts/macro-integration-tests/tests/runtime/upgradeable/upgrade_then_migrate.rs +88 -0
  102. package/contracts/macro-integration-tests/tests/runtime.rs +5 -0
  103. package/contracts/macro-integration-tests/tests/ui/contract_impl/fail/not_impl_item.rs +6 -0
  104. package/contracts/macro-integration-tests/tests/ui/contract_impl/fail/not_impl_item.stderr +7 -0
  105. package/contracts/macro-integration-tests/tests/ui/contract_impl/pass/basic.rs +102 -0
  106. package/contracts/macro-integration-tests/tests/ui/contract_trait/fail/not_a_trait.rs +6 -0
  107. package/contracts/macro-integration-tests/tests/ui/contract_trait/fail/not_a_trait.stderr +7 -0
  108. package/contracts/macro-integration-tests/tests/ui/contract_trait/pass/basic.rs +83 -0
  109. package/contracts/macro-integration-tests/tests/ui/error/fail/discriminant_too_large.rs +11 -0
  110. package/contracts/macro-integration-tests/tests/ui/error/fail/discriminant_too_large.stderr +7 -0
  111. package/contracts/macro-integration-tests/tests/ui/error/fail/non_enum_input.rs +11 -0
  112. package/contracts/macro-integration-tests/tests/ui/error/fail/non_enum_input.stderr +7 -0
  113. package/contracts/macro-integration-tests/tests/ui/error/pass/basic.rs +22 -0
  114. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/invalid_option.rs +6 -0
  115. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/invalid_option.stderr +7 -0
  116. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/multisig_rejects_ownable_api.rs +20 -0
  117. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/multisig_rejects_ownable_api.stderr +20 -0
  118. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/not_a_struct.rs +8 -0
  119. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/not_a_struct.stderr +7 -0
  120. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_invalid_inner_option.rs +10 -0
  121. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_invalid_inner_option.stderr +7 -0
  122. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_missing_internal.rs +20 -0
  123. package/contracts/macro-integration-tests/tests/ui/lz_contract/fail/upgradeable_missing_internal.stderr +86 -0
  124. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/basic.rs +45 -0
  125. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/multisig.rs +34 -0
  126. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/multisig_upgradeable.rs +30 -0
  127. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/upgradeable.rs +39 -0
  128. package/contracts/macro-integration-tests/tests/ui/lz_contract/pass/upgradeable_no_migration.rs +28 -0
  129. package/contracts/macro-integration-tests/tests/ui/multisig/fail/non_struct_input.rs +8 -0
  130. package/contracts/macro-integration-tests/tests/ui/multisig/fail/non_struct_input.stderr +7 -0
  131. package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_api.rs +20 -0
  132. package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_api.stderr +12 -0
  133. package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_trait.rs +20 -0
  134. package/contracts/macro-integration-tests/tests/ui/multisig/fail/rejects_ownable_trait.stderr +5 -0
  135. package/contracts/macro-integration-tests/tests/ui/multisig/pass/basic.rs +49 -0
  136. package/contracts/macro-integration-tests/tests/ui/ownable/fail/non_struct_input.rs +8 -0
  137. package/contracts/macro-integration-tests/tests/ui/ownable/fail/non_struct_input.stderr +7 -0
  138. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_auth.rs +19 -0
  139. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_auth.stderr +12 -0
  140. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.rs +1 -1
  141. package/contracts/macro-integration-tests/tests/ui/ownable/fail/only_auth_missing_env.stderr +0 -8
  142. package/contracts/macro-integration-tests/tests/ui/ownable/pass/basic.rs +39 -0
  143. package/contracts/macro-integration-tests/tests/ui/ownable/pass/only_auth_env_param_variants.rs +7 -1
  144. package/contracts/macro-integration-tests/tests/ui/storage/fail/invalid_storage_type_param.stderr +1 -1
  145. package/contracts/macro-integration-tests/tests/ui/storage/fail/missing_storage_type_param.stderr +1 -1
  146. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_default_values.rs +11 -0
  147. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_default_values.stderr +7 -0
  148. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_name_attrs.rs +11 -0
  149. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_name_attrs.stderr +7 -0
  150. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_no_ttl_extension.rs +11 -0
  151. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_no_ttl_extension.stderr +7 -0
  152. package/contracts/macro-integration-tests/tests/ui/storage/fail/multiple_type_params.stderr +1 -1
  153. package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_rejects_args.rs +13 -0
  154. package/contracts/macro-integration-tests/tests/ui/storage/fail/no_ttl_extension_rejects_args.stderr +7 -0
  155. package/contracts/macro-integration-tests/tests/ui/storage/pass/api_surface.rs +102 -0
  156. package/contracts/macro-integration-tests/tests/ui/storage/pass/basic.rs +43 -0
  157. package/contracts/macro-integration-tests/tests/ui/storage/pass/multi_key.rs +38 -0
  158. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/missing_auth_trait.rs +14 -0
  159. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/missing_auth_trait.stderr +71 -0
  160. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/non_struct_input.rs +8 -0
  161. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/fail/non_struct_input.stderr +7 -0
  162. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/{minimal_contract.rs → basic.rs} +2 -0
  163. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/multisig_contract.rs +28 -0
  164. package/contracts/macro-integration-tests/tests/ui/ttl_configurable/pass/ownable_contract.rs +32 -0
  165. package/contracts/macro-integration-tests/tests/ui/ttl_extendable/fail/non_struct_input.rs +8 -0
  166. package/contracts/macro-integration-tests/tests/ui/ttl_extendable/fail/non_struct_input.stderr +7 -0
  167. package/contracts/macro-integration-tests/tests/ui/ttl_extendable/pass/basic.rs +23 -0
  168. package/contracts/macro-integration-tests/tests/ui/ttl_extendable/pass/no_user_contractimpl.rs +21 -0
  169. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/attr_args.rs +11 -0
  170. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/attr_args.stderr +29 -0
  171. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_auth_trait.rs +20 -0
  172. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_auth_trait.stderr +71 -0
  173. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_upgradeable_internal.rs +10 -0
  174. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/missing_upgradeable_internal.stderr +79 -0
  175. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/non_struct_input.rs +8 -0
  176. package/contracts/macro-integration-tests/tests/ui/upgradeable/fail/non_struct_input.stderr +7 -0
  177. package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/basic.rs +43 -0
  178. package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/multisig_contract.rs +35 -0
  179. package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/no_migration.rs +30 -0
  180. package/contracts/macro-integration-tests/tests/ui/upgradeable/pass/no_user_contractimpl.rs +29 -0
  181. package/contracts/macro-integration-tests/tests/ui_contract_impl.rs +12 -0
  182. package/contracts/macro-integration-tests/tests/ui_contract_trait.rs +12 -0
  183. package/contracts/macro-integration-tests/tests/ui_lz_contract.rs +11 -0
  184. package/contracts/macro-integration-tests/tests/ui_multisig.rs +11 -0
  185. package/contracts/macro-integration-tests/tests/ui_ttl_extendable.rs +12 -0
  186. package/contracts/macro-integration-tests/tests/ui_upgradeable.rs +11 -0
  187. package/contracts/message-libs/blocked-message-lib/Cargo.toml +1 -1
  188. package/contracts/message-libs/blocked-message-lib/src/lib.rs +4 -1
  189. package/contracts/message-libs/blocked-message-lib/src/tests/blocked_message_lib_tests.rs +108 -0
  190. package/contracts/message-libs/blocked-message-lib/src/tests/mod.rs +4 -0
  191. package/contracts/message-libs/blocked-message-lib/src/tests/setup.rs +40 -0
  192. package/contracts/message-libs/simple-message-lib/src/lib.rs +1 -1
  193. package/contracts/message-libs/simple-message-lib/src/tests/mod.rs +2 -0
  194. package/contracts/message-libs/simple-message-lib/src/tests/setup.rs +124 -0
  195. package/contracts/message-libs/simple-message-lib/src/tests/simple_message_lib_tests.rs +309 -0
  196. package/contracts/message-libs/uln-302/src/errors.rs +21 -0
  197. package/contracts/message-libs/uln-302/src/interfaces/receive_uln.rs +1 -1
  198. package/contracts/message-libs/uln-302/src/receive_uln.rs +6 -4
  199. package/contracts/message-libs/uln-302/src/send_uln.rs +15 -6
  200. package/contracts/message-libs/uln-302/src/storage.rs +5 -5
  201. package/contracts/message-libs/uln-302/src/tests/uln302/get_config.rs +71 -0
  202. package/contracts/message-libs/uln-302/src/tests/uln302/mod.rs +1 -0
  203. package/contracts/message-libs/uln-302/src/uln302.rs +3 -0
  204. package/contracts/oapps/counter/Cargo.toml +2 -0
  205. package/contracts/oapps/counter/integration_tests/mod.rs +1 -0
  206. package/contracts/oapps/counter/integration_tests/setup_sml.rs +6 -4
  207. package/contracts/oapps/counter/integration_tests/setup_uln.rs +12 -5
  208. package/contracts/oapps/counter/integration_tests/test_with_blocked.rs +67 -0
  209. package/contracts/oapps/counter/src/tests/mod.rs +1 -0
  210. package/contracts/oapps/counter/src/tests/test_u256_ext.rs +48 -0
  211. package/contracts/oapps/oapp/src/lib.rs +0 -3
  212. package/contracts/oapps/oapp/src/tests/mod.rs +1 -0
  213. package/contracts/oapps/oft/integration-tests/setup.rs +2 -3
  214. package/contracts/oapps/oft/src/lib.rs +3 -0
  215. package/contracts/oapps/oft/src/tests/extensions/mod.rs +3 -0
  216. package/contracts/oapps/oft/src/tests/extensions/oft_fee.rs +240 -0
  217. package/contracts/oapps/oft/src/tests/extensions/pausable.rs +141 -0
  218. package/contracts/oapps/oft/src/tests/extensions/rate_limiter.rs +447 -0
  219. package/contracts/oapps/oft/src/tests/mod.rs +2 -0
  220. package/contracts/oapps/oft/src/tests/oft_types/lock_unlock.rs +180 -0
  221. package/contracts/oapps/oft/src/tests/oft_types/mod.rs +1 -0
  222. package/contracts/oapps/oft-core/integration-tests/setup.rs +2 -3
  223. package/contracts/oapps/oft-core/src/lib.rs +2 -2
  224. package/contracts/oapps/oft-core/src/tests/mod.rs +1 -1
  225. package/contracts/oapps/oft-core/src/tests/{test_oft_version.rs → test_oft_version_and_approval.rs} +9 -0
  226. package/contracts/oapps/oft-core/src/tests/test_utils.rs +0 -43
  227. package/contracts/upgrader/src/tests/test_upgrader.rs +18 -0
  228. package/contracts/utils/src/auth.rs +2 -2
  229. package/contracts/utils/src/buffer_reader.rs +61 -10
  230. package/contracts/utils/src/buffer_writer.rs +35 -20
  231. package/contracts/utils/src/bytes_ext.rs +1 -2
  232. package/contracts/utils/src/errors.rs +5 -3
  233. package/contracts/utils/src/multisig.rs +59 -36
  234. package/contracts/utils/src/option_ext.rs +3 -3
  235. package/contracts/utils/src/ownable.rs +12 -6
  236. package/contracts/utils/src/tests/auth.rs +179 -0
  237. package/contracts/utils/src/tests/buffer_reader.rs +203 -1
  238. package/contracts/utils/src/tests/buffer_writer.rs +176 -5
  239. package/contracts/utils/src/tests/mod.rs +2 -0
  240. package/contracts/utils/src/tests/multisig.rs +170 -141
  241. package/contracts/utils/src/tests/option_ext.rs +1 -1
  242. package/contracts/utils/src/tests/ownable.rs +156 -161
  243. package/contracts/utils/src/tests/test_helper.rs +21 -1
  244. package/contracts/utils/src/tests/testing_utils.rs +84 -2
  245. package/contracts/utils/src/tests/ttl_configurable.rs +66 -86
  246. package/contracts/utils/src/tests/ttl_extendable.rs +64 -0
  247. package/contracts/utils/src/tests/upgradeable.rs +115 -6
  248. package/contracts/utils/src/ttl_configurable.rs +22 -12
  249. package/contracts/utils/src/ttl_extendable.rs +1 -3
  250. package/contracts/utils/src/upgradeable.rs +21 -24
  251. package/contracts/workers/dvn/src/auth.rs +1 -1
  252. package/contracts/workers/dvn/src/interfaces/dvn.rs +2 -2
  253. package/contracts/workers/dvn/src/storage.rs +1 -1
  254. package/contracts/workers/dvn/src/tests/auth.rs +136 -3
  255. package/contracts/workers/dvn/src/tests/mod.rs +0 -1
  256. package/contracts/workers/dvn/src/tests/setup.rs +4 -10
  257. package/contracts/workers/executor-helper/src/tests/executor_helper.rs +279 -0
  258. package/contracts/workers/executor-helper/src/tests/setup.rs +106 -1
  259. package/contracts/workers/worker/src/worker.rs +1 -1
  260. package/docs/oft-guide.md +5 -5
  261. package/package.json +5 -7
  262. package/sdk/.turbo/turbo-test.log +662 -466
  263. package/sdk/LICENSE +23 -0
  264. package/sdk/dist/generated/bml.d.ts +101 -106
  265. package/sdk/dist/generated/bml.js +108 -26
  266. package/sdk/dist/generated/counter.d.ts +123 -484
  267. package/sdk/dist/generated/counter.js +103 -25
  268. package/sdk/dist/generated/dvn.d.ts +141 -699
  269. package/sdk/dist/generated/dvn.js +106 -28
  270. package/sdk/dist/generated/dvn_fee_lib.d.ts +31 -248
  271. package/sdk/dist/generated/dvn_fee_lib.js +27 -24
  272. package/sdk/dist/generated/endpoint.d.ts +158 -836
  273. package/sdk/dist/generated/endpoint.js +107 -29
  274. package/sdk/dist/generated/executor.d.ts +139 -671
  275. package/sdk/dist/generated/executor.js +106 -28
  276. package/sdk/dist/generated/executor_fee_lib.d.ts +109 -264
  277. package/sdk/dist/generated/executor_fee_lib.js +106 -28
  278. package/sdk/dist/generated/executor_helper.d.ts +95 -92
  279. package/sdk/dist/generated/executor_helper.js +103 -25
  280. package/sdk/dist/generated/layerzero_view.d.ts +178 -335
  281. package/sdk/dist/generated/layerzero_view.js +172 -33
  282. package/sdk/dist/generated/oft.d.ts +137 -680
  283. package/sdk/dist/generated/oft.js +103 -25
  284. package/sdk/dist/generated/price_feed.d.ts +45 -444
  285. package/sdk/dist/generated/price_feed.js +27 -24
  286. package/sdk/dist/generated/sml.d.ts +119 -428
  287. package/sdk/dist/generated/sml.js +103 -25
  288. package/sdk/dist/generated/treasury.d.ts +109 -288
  289. package/sdk/dist/generated/treasury.js +103 -25
  290. package/sdk/dist/generated/uln302.d.ts +190 -527
  291. package/sdk/dist/generated/uln302.js +170 -31
  292. package/sdk/dist/generated/upgrader.d.ts +14 -34
  293. package/sdk/dist/generated/upgrader.js +24 -21
  294. package/sdk/package.json +3 -4
  295. package/sdk/test/counter-sml.test.ts +218 -142
  296. package/sdk/test/counter-uln.test.ts +189 -145
  297. package/sdk/test/oft-sml.test.ts +173 -156
  298. package/sdk/test/suites/constants.ts +7 -1
  299. package/sdk/test/suites/globalSetup.ts +140 -74
  300. package/sdk/turbo.json +1 -1
  301. package/tools/ts-bindings-gen/Cargo.toml +4 -4
  302. package/tools/ts-bindings-gen/src/main.rs +4 -0
  303. package/turbo.json +3 -0
  304. package/contracts/common-macros/src/tests/snapshots/common_macros__tests__storage__snapshot_generated_storage_code.snap +0 -1072
  305. package/contracts/endpoint-v2/src/constants.rs +0 -52
  306. package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.rs +0 -12
  307. package/contracts/macro-integration-tests/tests/ui/error/fail/attr_not_empty.stderr +0 -7
  308. package/contracts/macro-integration-tests/tests/ui/error/pass/attr_on_variant_allowed.rs +0 -20
  309. package/contracts/macro-integration-tests/tests/ui/error/pass/basic_auto_discriminants.rs +0 -15
  310. package/contracts/macro-integration-tests/tests/ui/error/pass/mixed_discriminants.rs +0 -16
  311. package/contracts/macro-integration-tests/tests/ui/ownable/pass/minimal_contract.rs +0 -26
  312. package/contracts/macro-integration-tests/tests/ui/ownable/pass/namespacing_and_imports.rs +0 -21
  313. package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.rs +0 -12
  314. package/contracts/macro-integration-tests/tests/ui/storage/fail/storage_attr_rejects_args.stderr +0 -7
  315. package/contracts/macro-integration-tests/tests/ui/storage/pass/default_value_on_variant.rs +0 -14
  316. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_instance_unit_basic.rs +0 -14
  317. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_persistent_named_fields_keyed.rs +0 -16
  318. package/contracts/macro-integration-tests/tests/ui/storage/pass/enum_temporary_unit_option.rs +0 -15
  319. package/contracts/macro-integration-tests/tests/ui/storage/pass/name_override.rs +0 -14
  320. package/contracts/macro-integration-tests/tests/ui/storage/pass/no_auto_ttl_extension.rs +0 -19
  321. package/contracts/macro-integration-tests/tests/ui/storage/pass/ttl_provider_basic.rs +0 -15
  322. package/contracts/message-libs/simple-message-lib/src/test.rs +0 -280
  323. package/contracts/oapps/oapp/src/macro_tests/mod.rs +0 -1
  324. package/contracts/workers/dvn/src/tests/multisig/mod.rs +0 -3
  325. package/contracts/workers/dvn/src/tests/multisig/set_signer.rs +0 -132
  326. package/contracts/workers/dvn/src/tests/multisig/set_threshold.rs +0 -109
  327. package/contracts/workers/dvn/src/tests/multisig/verify_signatures.rs +0 -106
  328. /package/contracts/oapps/oapp/src/{macro_tests → tests}/test_macros.rs +0 -0
@@ -1,7 +1,7 @@
1
1
  use proc_macro2::TokenStream;
2
2
  use quote::quote;
3
3
 
4
- use crate::tests::test_helpers::assert_panics_contains;
4
+ use crate::tests::test_helpers::{assert_panics_contains, filter_item_inputs_excluding_labels};
5
5
 
6
6
  // ============================================================================
7
7
  // Snapshot Tests
@@ -19,6 +19,10 @@ fn snapshot_generated_contractimpl_code() {
19
19
  let empty_attr = TokenStream::new();
20
20
  let inherent_input = quote! {
21
21
  impl MyContract {
22
+ // Non-fn items should be preserved by the macro
23
+ const A_CONST: u32 = 1;
24
+ type Alias = u32;
25
+
22
26
  /// Public method with Env - should have TTL extension
23
27
  pub fn public_with_env(env: Env, value: u32) -> u32 {
24
28
  value * 2
@@ -121,6 +125,10 @@ fn snapshot_generated_contracttrait_code() {
121
125
  let empty_attr = TokenStream::new();
122
126
  let trait_input = quote! {
123
127
  pub trait MyTrait: Sized {
128
+ // Non-fn items should be preserved by the macro
129
+ const A_CONST: u32;
130
+ type Alias;
131
+
124
132
  /// Default method with Env - should have TTL extension
125
133
  fn default_with_env(env: Env, value: u32) -> u32 {
126
134
  value * 2
@@ -183,175 +191,107 @@ fn snapshot_generated_contracttrait_code() {
183
191
  // ============================================================================
184
192
 
185
193
  #[test]
186
- fn test_contractimpl_non_impl_block_input() {
187
- let invalid_inputs = vec![
188
- (
189
- "struct",
190
- quote! {
191
- struct MyStruct {
192
- field: u32,
193
- }
194
- },
195
- ),
194
+ fn test_contractimpl_with_ttl_rejects_non_impl_block_input() {
195
+ for (case, input) in filter_item_inputs_excluding_labels(&["impl block"]) {
196
+ assert_panics_contains(case, "failed to parse impl block", || {
197
+ crate::contract_ttl::contractimpl_with_ttl(TokenStream::new(), input.clone());
198
+ });
199
+ }
200
+ }
201
+
202
+ #[test]
203
+ fn test_contracttrait_with_ttl_rejects_non_trait_input() {
204
+ for (case, input) in filter_item_inputs_excluding_labels(&["trait"]) {
205
+ assert_panics_contains(case, "failed to parse trait definition", || {
206
+ crate::contract_ttl::contracttrait_with_ttl(TokenStream::new(), input.clone());
207
+ });
208
+ }
209
+ }
210
+
211
+ // ============================================================================
212
+ // Unit Tests: Attribute Handling
213
+ // ============================================================================
214
+
215
+ #[test]
216
+ fn test_contractimpl_with_ttl_adds_contractimpl_attribute_table_driven() {
217
+ // (name, attr, input, expected_substrings, forbidden_substrings)
218
+ let cases: Vec<(&str, TokenStream, TokenStream, Vec<&str>, Vec<&str>)> = vec![
196
219
  (
197
- "enum",
220
+ "empty attr",
221
+ TokenStream::new(),
198
222
  quote! {
199
- enum MyEnum {
200
- Variant1,
201
- Variant2,
223
+ impl MyContract {
224
+ pub fn my_method(env: Env) {}
202
225
  }
203
226
  },
227
+ vec!["# [soroban_sdk :: contractimpl]"],
228
+ // ensure we don't emit `#[...::contractimpl(...)]` when attr is empty
229
+ vec!["contractimpl(", "contractimpl ("],
204
230
  ),
205
- ("function", quote! { fn a_function() {} }),
206
- ("const item", quote! { const A_CONST: u32 = 1; }),
207
- ("type alias", quote! { type AnAlias = u32; }),
208
231
  (
209
- "trait",
232
+ "with attr",
233
+ quote! { contracttrait },
210
234
  quote! {
211
- trait ATrait {
212
- fn method(&self);
235
+ impl SomeTrait for MyContract {
236
+ fn my_method(env: Env) {}
213
237
  }
214
238
  },
239
+ vec!["contractimpl (contracttrait)"],
240
+ vec![],
215
241
  ),
216
242
  ];
217
243
 
218
- for (case, input) in invalid_inputs {
219
- assert_panics_contains(case, "failed to parse impl block", || {
220
- crate::contract_ttl::contractimpl_with_ttl(TokenStream::new(), input.clone());
221
- });
244
+ for (name, attr, input, expected, forbidden) in cases {
245
+ let result = crate::contract_ttl::contractimpl_with_ttl(attr, input);
246
+ let result_str = result.to_string();
247
+ for needle in expected {
248
+ assert!(result_str.contains(needle), "{name}: expected '{needle}'. Got: {result_str}");
249
+ }
250
+ for needle in forbidden {
251
+ assert!(!result_str.contains(needle), "{name}: should NOT contain '{needle}'. Got: {result_str}");
252
+ }
222
253
  }
223
254
  }
224
255
 
225
256
  #[test]
226
- fn test_contracttrait_non_trait_input() {
227
- let invalid_inputs = vec![
228
- (
229
- "struct",
230
- quote! {
231
- struct MyStruct {
232
- field: u32,
233
- }
234
- },
235
- ),
257
+ fn test_contracttrait_with_ttl_adds_contracttrait_attribute_table_driven() {
258
+ // (name, attr, input, expected_substrings, forbidden_substrings)
259
+ let cases: Vec<(&str, TokenStream, TokenStream, Vec<&str>, Vec<&str>)> = vec![
236
260
  (
237
- "enum",
261
+ "empty attr",
262
+ TokenStream::new(),
238
263
  quote! {
239
- enum MyEnum {
240
- Variant1,
241
- Variant2,
264
+ pub trait MyTrait {
265
+ fn my_method(env: Env) {}
242
266
  }
243
267
  },
268
+ vec!["# [soroban_sdk :: contracttrait]"],
269
+ // ensure we don't emit `#[...::contracttrait(...)]` when attr is empty
270
+ vec!["contracttrait(", "contracttrait ("],
244
271
  ),
245
- ("function", quote! { fn a_function() {} }),
246
- ("const item", quote! { const A_CONST: u32 = 1; }),
247
- ("type alias", quote! { type AnAlias = u32; }),
248
272
  (
249
- "impl block",
273
+ "with attr",
274
+ quote! { crate = "my_crate" },
250
275
  quote! {
251
- impl MyContract {
252
- fn method(&self) {}
276
+ pub trait MyTrait {
277
+ fn my_method(env: Env) {}
253
278
  }
254
279
  },
280
+ vec!["contracttrait (crate = \"my_crate\")"],
281
+ vec![],
255
282
  ),
256
283
  ];
257
284
 
258
- for (case, input) in invalid_inputs {
259
- assert_panics_contains(case, "failed to parse trait definition", || {
260
- crate::contract_ttl::contracttrait_with_ttl(TokenStream::new(), input.clone());
261
- });
262
- }
263
- }
264
-
265
- // ============================================================================
266
- // Unit Tests: Attribute Handling
267
- // ============================================================================
268
-
269
- /// Verifies that contractimpl_with_ttl adds #[soroban_sdk::contractimpl] without parentheses when attr is empty
270
- #[test]
271
- fn test_contractimpl_adds_attribute_without_attr() {
272
- let input = quote! {
273
- impl MyContract {
274
- pub fn my_method(env: Env) {}
275
- }
276
- };
277
-
278
- let result = crate::contract_ttl::contractimpl_with_ttl(TokenStream::new(), input);
279
- let result_str = result.to_string();
280
-
281
- assert!(
282
- result_str.contains("# [soroban_sdk :: contractimpl]"),
283
- "should add #[soroban_sdk::contractimpl] attribute without parentheses when attr is empty. Got: {}",
284
- result_str
285
- );
286
- assert!(
287
- !result_str.contains("contractimpl ()"),
288
- "should NOT have empty parentheses when attr is empty. Got: {}",
289
- result_str
290
- );
291
- }
292
-
293
- /// Verifies that contractimpl_with_ttl adds #[soroban_sdk::contractimpl(attr)] when attr is provided
294
- #[test]
295
- fn test_contractimpl_adds_attribute_with_attr() {
296
- let input = quote! {
297
- impl SomeTrait for MyContract {
298
- fn my_method(env: Env) {}
285
+ for (name, attr, input, expected, forbidden) in cases {
286
+ let result = crate::contract_ttl::contracttrait_with_ttl(attr, input);
287
+ let result_str = result.to_string();
288
+ for needle in expected {
289
+ assert!(result_str.contains(needle), "{name}: expected '{needle}'. Got: {result_str}");
299
290
  }
300
- };
301
-
302
- let attr = quote! { contracttrait };
303
- let result = crate::contract_ttl::contractimpl_with_ttl(attr, input);
304
- let result_str = result.to_string();
305
-
306
- assert!(
307
- result_str.contains("contractimpl (contracttrait)"),
308
- "should add #[soroban_sdk::contractimpl(contracttrait)] attribute. Got: {}",
309
- result_str
310
- );
311
- }
312
-
313
- /// Verifies that contracttrait_with_ttl adds #[soroban_sdk::contracttrait] without parentheses when attr is empty
314
- #[test]
315
- fn test_contracttrait_adds_attribute_without_attr() {
316
- let input = quote! {
317
- pub trait MyTrait {
318
- fn my_method(env: Env) {}
291
+ for needle in forbidden {
292
+ assert!(!result_str.contains(needle), "{name}: should NOT contain '{needle}'. Got: {result_str}");
319
293
  }
320
- };
321
-
322
- let result = crate::contract_ttl::contracttrait_with_ttl(TokenStream::new(), input);
323
- let result_str = result.to_string();
324
-
325
- assert!(
326
- result_str.contains("# [soroban_sdk :: contracttrait]"),
327
- "should add #[soroban_sdk::contracttrait] attribute without parentheses when attr is empty. Got: {}",
328
- result_str
329
- );
330
- assert!(
331
- !result_str.contains("contracttrait ()"),
332
- "should NOT have empty parentheses when attr is empty. Got: {}",
333
- result_str
334
- );
335
- }
336
-
337
- /// Verifies that contracttrait_with_ttl adds #[soroban_sdk::contracttrait(attr)] when attr is provided
338
- #[test]
339
- fn test_contracttrait_adds_attribute_with_attr() {
340
- let input = quote! {
341
- pub trait MyTrait {
342
- fn my_method(env: Env) {}
343
- }
344
- };
345
-
346
- let attr = quote! { crate = "my_crate" };
347
- let result = crate::contract_ttl::contracttrait_with_ttl(attr, input);
348
- let result_str = result.to_string();
349
-
350
- assert!(
351
- result_str.contains("contracttrait (crate = \"my_crate\")"),
352
- "should add #[soroban_sdk::contracttrait(crate = \"my_crate\")] attribute. Got: {}",
353
- result_str
354
- );
294
+ }
355
295
  }
356
296
 
357
297
  // ============================================================================
@@ -363,10 +303,9 @@ fn test_contracttrait_adds_attribute_with_attr() {
363
303
  enum TtlExpectation {
364
304
  /// TTL extension should NOT be inserted
365
305
  None,
366
- /// TTL extension should be inserted with the given env patterns
367
- /// - `instance_arg`: pattern in `TtlConfigStorage::instance(...)` (e.g., "& env" for owned, "env" for ref)
368
- /// - `storage_ident`: identifier for `.storage()` call
369
- Present { instance_arg: &'static str, storage_ident: &'static str },
306
+ /// TTL extension should be inserted with the given env argument
307
+ /// - `env_arg`: pattern in `extend_instance_ttl(...)` (e.g., "& env" for owned, "env" for ref)
308
+ Present { env_arg: &'static str },
370
309
  }
371
310
 
372
311
  /// Test runner for contractimpl_with_ttl TTL behavior
@@ -377,13 +316,8 @@ struct ImplTtlTestCase {
377
316
  }
378
317
 
379
318
  impl ImplTtlTestCase {
380
- fn expect_ttl(
381
- name: &'static str,
382
- input: TokenStream,
383
- instance_arg: &'static str,
384
- storage_ident: &'static str,
385
- ) -> Self {
386
- Self { name, input, expectation: TtlExpectation::Present { instance_arg, storage_ident } }
319
+ fn expect_ttl(name: &'static str, input: TokenStream, env_arg: &'static str) -> Self {
320
+ Self { name, input, expectation: TtlExpectation::Present { env_arg } }
387
321
  }
388
322
 
389
323
  fn expect_no_ttl(name: &'static str, input: TokenStream) -> Self {
@@ -405,13 +339,8 @@ struct TraitTtlTestCase {
405
339
  }
406
340
 
407
341
  impl TraitTtlTestCase {
408
- fn expect_ttl(
409
- name: &'static str,
410
- input: TokenStream,
411
- instance_arg: &'static str,
412
- storage_ident: &'static str,
413
- ) -> Self {
414
- Self { name, input, expectation: TtlExpectation::Present { instance_arg, storage_ident } }
342
+ fn expect_ttl(name: &'static str, input: TokenStream, env_arg: &'static str) -> Self {
343
+ Self { name, input, expectation: TtlExpectation::Present { env_arg } }
415
344
  }
416
345
 
417
346
  fn expect_no_ttl(name: &'static str, input: TokenStream) -> Self {
@@ -426,27 +355,23 @@ impl TraitTtlTestCase {
426
355
  }
427
356
 
428
357
  fn assert_ttl_expectation(expectation: &TtlExpectation, result_str: &str, name: &str) {
429
- let has_ttl = result_str.contains("TtlConfigStorage :: instance");
358
+ let has_ttl = result_str.contains("extend_instance_ttl");
430
359
 
431
360
  match expectation {
432
361
  TtlExpectation::None => {
433
362
  assert!(!has_ttl, "{}: TTL extension should NOT be present, but was found", name);
434
363
  }
435
- TtlExpectation::Present { instance_arg, storage_ident } => {
364
+ TtlExpectation::Present { env_arg } => {
436
365
  assert!(has_ttl, "{}: TTL extension should be present, but was not found", name);
437
- assert!(result_str.contains("extend_ttl"), "{}: should insert extend_ttl call", name);
438
366
 
439
- let instance_pattern = format!("TtlConfigStorage :: instance ({})", instance_arg);
367
+ let extend_pattern = format!("extend_instance_ttl ({})", env_arg);
440
368
  assert!(
441
- result_str.contains(&instance_pattern),
442
- "{}: expected '{}' in TtlConfigStorage::instance call. Got: {}",
369
+ result_str.contains(&extend_pattern),
370
+ "{}: expected '{}' in extend_instance_ttl call. Got: {}",
443
371
  name,
444
- instance_arg,
372
+ env_arg,
445
373
  result_str
446
374
  );
447
-
448
- let storage_pattern = format!("{} . storage ()", storage_ident);
449
- assert!(result_str.contains(&storage_pattern), "{}: expected '{}.storage()' call", name, storage_ident);
450
375
  }
451
376
  }
452
377
  }
@@ -456,119 +381,168 @@ fn assert_ttl_expectation(expectation: &TtlExpectation, result_str: &str, name:
456
381
  // ============================================================================
457
382
 
458
383
  #[test]
459
- fn test_impl_ttl_extension_with_owned_env() {
460
- ImplTtlTestCase::expect_ttl(
461
- "public method with owned Env",
462
- quote! {
463
- impl MyContract {
464
- pub fn my_method(env: Env) { let x = 1; }
465
- }
466
- },
467
- "& env", // instance takes reference
468
- "env", // storage called on ident
469
- )
470
- .run();
471
- }
472
-
473
- #[test]
474
- fn test_impl_ttl_extension_with_ref_env() {
475
- ImplTtlTestCase::expect_ttl(
476
- "public method with ref Env",
477
- quote! {
478
- impl MyContract {
479
- pub fn my_method(env: &Env) { let x = 1; }
480
- }
481
- },
482
- "env", // instance takes ident directly (already a ref)
483
- "env",
484
- )
485
- .run();
486
- }
487
-
488
- #[test]
489
- fn test_impl_ttl_extension_with_custom_env_ident_owned() {
490
- ImplTtlTestCase::expect_ttl(
491
- "custom Env identifier (owned)",
492
- quote! {
493
- impl MyContract {
494
- pub fn my_method(my_custom_env: Env) { let x = 1; }
495
- }
496
- },
497
- "& my_custom_env",
498
- "my_custom_env",
499
- )
500
- .run();
501
- }
502
-
503
- #[test]
504
- fn test_impl_ttl_extension_with_custom_env_ident_ref() {
505
- ImplTtlTestCase::expect_ttl(
506
- "custom Env identifier (ref)",
507
- quote! {
508
- impl MyContract {
509
- pub fn my_method(my_custom_env: &Env) { let x = 1; }
510
- }
511
- },
512
- "my_custom_env",
513
- "my_custom_env",
514
- )
515
- .run();
516
- }
517
-
518
- #[test]
519
- fn test_impl_ttl_extension_for_trait_impl_owned_env() {
520
- ImplTtlTestCase::expect_ttl(
521
- "trait impl method with owned Env",
522
- quote! {
523
- impl SomeTrait for MyContract {
524
- fn trait_method(env: Env) { let x = 1; }
525
- }
526
- },
527
- "& env",
528
- "env",
529
- )
530
- .run();
531
- }
384
+ fn test_contractimpl_with_ttl_inserts_ttl_for_methods_with_env_table_driven() {
385
+ // contractimpl_with_ttl: TTL should be inserted for methods with Env
386
+ // - inherent impl: only `pub` methods are eligible
387
+ // - trait impl: all methods are eligible
388
+ //
389
+ // (name, input, env_arg)
390
+ let test_data = vec![
391
+ (
392
+ "public method with owned Env",
393
+ quote! {
394
+ impl MyContract {
395
+ pub fn my_method(env: Env) { let x = 1; }
396
+ }
397
+ },
398
+ "& env",
399
+ ),
400
+ (
401
+ "public method with ref Env",
402
+ quote! {
403
+ impl MyContract {
404
+ pub fn my_method(env: &Env) { let x = 1; }
405
+ }
406
+ },
407
+ "env",
408
+ ),
409
+ (
410
+ "public method with mut ref Env",
411
+ quote! {
412
+ impl MyContract {
413
+ pub fn my_method(env: &mut Env) { let x = 1; }
414
+ }
415
+ },
416
+ "env",
417
+ ),
418
+ (
419
+ "custom Env identifier (owned)",
420
+ quote! {
421
+ impl MyContract {
422
+ pub fn my_method(my_custom_env: Env) { let x = 1; }
423
+ }
424
+ },
425
+ "& my_custom_env",
426
+ ),
427
+ (
428
+ "custom Env identifier (ref)",
429
+ quote! {
430
+ impl MyContract {
431
+ pub fn my_method(my_custom_env: &Env) { let x = 1; }
432
+ }
433
+ },
434
+ "my_custom_env",
435
+ ),
436
+ (
437
+ "public method with receiver and Env",
438
+ quote! {
439
+ impl MyContract {
440
+ pub fn my_method(&self, env: &Env) { let x = 1; }
441
+ }
442
+ },
443
+ "env",
444
+ ),
445
+ (
446
+ "public method with mut Env binding (owned)",
447
+ quote! {
448
+ impl MyContract {
449
+ pub fn my_method(mut env: Env) { let x = 1; }
450
+ }
451
+ },
452
+ "& env",
453
+ ),
454
+ (
455
+ "public method with ::soroban_sdk::Env (owned)",
456
+ quote! {
457
+ impl MyContract {
458
+ pub fn my_method(env: ::soroban_sdk::Env) { let x = 1; }
459
+ }
460
+ },
461
+ "& env",
462
+ ),
463
+ (
464
+ "public method with &::soroban_sdk::Env (ref)",
465
+ quote! {
466
+ impl MyContract {
467
+ pub fn my_method(env: &::soroban_sdk::Env) { let x = 1; }
468
+ }
469
+ },
470
+ "env",
471
+ ),
472
+ (
473
+ "trait impl method with owned Env",
474
+ quote! {
475
+ impl SomeTrait for MyContract {
476
+ fn trait_method(env: Env) { let x = 1; }
477
+ }
478
+ },
479
+ "& env",
480
+ ),
481
+ (
482
+ "trait impl method with ref Env",
483
+ quote! {
484
+ impl SomeTrait for MyContract {
485
+ fn trait_method(env: &Env) { let x = 1; }
486
+ }
487
+ },
488
+ "env",
489
+ ),
490
+ ];
532
491
 
533
- #[test]
534
- fn test_impl_ttl_extension_for_trait_impl_ref_env() {
535
- ImplTtlTestCase::expect_ttl(
536
- "trait impl method with ref Env",
537
- quote! {
538
- impl SomeTrait for MyContract {
539
- fn trait_method(env: &Env) { let x = 1; }
540
- }
541
- },
542
- "env",
543
- "env",
544
- )
545
- .run();
492
+ for (name, input, env_arg) in test_data {
493
+ ImplTtlTestCase::expect_ttl(name, input, env_arg).run();
494
+ }
546
495
  }
547
496
 
548
497
  #[test]
549
- fn test_impl_no_ttl_extension_for_private_method() {
550
- ImplTtlTestCase::expect_no_ttl(
551
- "private method with Env",
552
- quote! {
553
- impl MyContract {
554
- fn private_method(env: Env) { let x = 1; }
555
- }
556
- },
557
- )
558
- .run();
559
- }
498
+ fn test_contractimpl_with_ttl_skips_ttl_insertion_table_driven() {
499
+ // (name, input)
500
+ let cases = vec![
501
+ (
502
+ "private method with Env",
503
+ quote! {
504
+ impl MyContract {
505
+ fn private_method(env: Env) { let x = 1; }
506
+ }
507
+ },
508
+ ),
509
+ (
510
+ "public method without Env",
511
+ quote! {
512
+ impl MyContract {
513
+ pub fn no_env_method(value: u32) -> u32 { value }
514
+ }
515
+ },
516
+ ),
517
+ (
518
+ "public method with wildcard Env binding (unsupported pattern)",
519
+ quote! {
520
+ impl MyContract {
521
+ pub fn my_method(_: Env) { let x = 1; }
522
+ }
523
+ },
524
+ ),
525
+ (
526
+ "pub(super) method with Env (not fully public)",
527
+ quote! {
528
+ impl MyContract {
529
+ pub(super) fn my_method(env: Env) { let x = 1; }
530
+ }
531
+ },
532
+ ),
533
+ (
534
+ "pub(in ...) method with Env (not fully public)",
535
+ quote! {
536
+ impl MyContract {
537
+ pub(in crate::some_module) fn my_method(env: Env) { let x = 1; }
538
+ }
539
+ },
540
+ ),
541
+ ];
560
542
 
561
- #[test]
562
- fn test_impl_no_ttl_extension_without_env_param() {
563
- ImplTtlTestCase::expect_no_ttl(
564
- "public method without Env",
565
- quote! {
566
- impl MyContract {
567
- pub fn no_env_method(value: u32) -> u32 { value }
568
- }
569
- },
570
- )
571
- .run();
543
+ for (name, input) in cases {
544
+ ImplTtlTestCase::expect_no_ttl(name, input).run();
545
+ }
572
546
  }
573
547
 
574
548
  // ============================================================================
@@ -576,87 +550,146 @@ fn test_impl_no_ttl_extension_without_env_param() {
576
550
  // ============================================================================
577
551
 
578
552
  #[test]
579
- fn test_trait_ttl_extension_with_owned_env() {
580
- TraitTtlTestCase::expect_ttl(
581
- "default method with owned Env",
582
- quote! {
583
- trait MyTrait {
584
- fn my_method(env: Env) { let x = 1; }
585
- }
586
- },
587
- "& env", // instance takes reference
588
- "env", // storage called on ident
589
- )
590
- .run();
591
- }
553
+ fn test_contracttrait_with_ttl_inserts_ttl_for_default_methods_with_env_table_driven() {
554
+ // (name, input, env_arg)
555
+ let test_data = vec![
556
+ (
557
+ "default method with owned Env",
558
+ quote! {
559
+ trait MyTrait {
560
+ fn my_method(env: Env) { let x = 1; }
561
+ }
562
+ },
563
+ "& env",
564
+ ),
565
+ (
566
+ "default method with ref Env",
567
+ quote! {
568
+ trait MyTrait {
569
+ fn my_method(env: &Env) { let x = 1; }
570
+ }
571
+ },
572
+ "env",
573
+ ),
574
+ (
575
+ "default method with mut ref Env",
576
+ quote! {
577
+ trait MyTrait {
578
+ fn my_method(env: &mut Env) { let x = 1; }
579
+ }
580
+ },
581
+ "env",
582
+ ),
583
+ (
584
+ "custom Env identifier (owned)",
585
+ quote! {
586
+ trait MyTrait {
587
+ fn my_method(my_custom_env: Env) { let x = 1; }
588
+ }
589
+ },
590
+ "& my_custom_env",
591
+ ),
592
+ (
593
+ "custom Env identifier (ref)",
594
+ quote! {
595
+ trait MyTrait {
596
+ fn my_method(my_custom_env: &Env) { let x = 1; }
597
+ }
598
+ },
599
+ "my_custom_env",
600
+ ),
601
+ (
602
+ "default method with receiver and Env",
603
+ quote! {
604
+ trait MyTrait {
605
+ fn my_method(&self, env: &Env) { let x = 1; }
606
+ }
607
+ },
608
+ "env",
609
+ ),
610
+ ];
592
611
 
593
- #[test]
594
- fn test_trait_ttl_extension_with_ref_env() {
595
- TraitTtlTestCase::expect_ttl(
596
- "default method with ref Env",
597
- quote! {
598
- trait MyTrait {
599
- fn my_method(env: &Env) { let x = 1; }
600
- }
601
- },
602
- "env", // instance takes ident directly (already a ref)
603
- "env",
604
- )
605
- .run();
612
+ for (name, input, env_arg) in test_data {
613
+ TraitTtlTestCase::expect_ttl(name, input, env_arg).run();
614
+ }
606
615
  }
607
616
 
608
- #[test]
609
- fn test_trait_ttl_extension_with_custom_env_ident_owned() {
610
- TraitTtlTestCase::expect_ttl(
611
- "custom Env identifier (owned)",
612
- quote! {
613
- trait MyTrait {
614
- fn my_method(my_custom_env: Env) { let x = 1; }
615
- }
616
- },
617
- "& my_custom_env",
618
- "my_custom_env",
619
- )
620
- .run();
621
- }
617
+ // ============================================================================
618
+ // Constructor behavior: contractimpl_with_ttl
619
+ // ============================================================================
622
620
 
623
621
  #[test]
624
- fn test_trait_ttl_extension_with_custom_env_ident_ref() {
625
- TraitTtlTestCase::expect_ttl(
626
- "custom Env identifier (ref)",
627
- quote! {
628
- trait MyTrait {
629
- fn my_method(my_custom_env: &Env) { let x = 1; }
630
- }
631
- },
632
- "my_custom_env",
633
- "my_custom_env",
634
- )
635
- .run();
636
- }
622
+ fn test_contractimpl_with_ttl_injects_init_default_ttl_configs_only_in_constructor() {
623
+ // `__constructor` should get default TTL config init, and should NOT get TTL extension.
624
+ let cases: Vec<(&str, TokenStream, Vec<&str>, Vec<&str>)> = vec![
625
+ (
626
+ "constructor with owned Env",
627
+ quote! {
628
+ impl MyContract {
629
+ pub fn __constructor(env: Env) { let x = 1; }
630
+ }
631
+ },
632
+ // expects init call and correct arg form (`&env` because Env is owned)
633
+ vec!["ttl_configurable :: init_default_ttl_configs (& env)"],
634
+ // should not insert TTL extension
635
+ vec!["TtlConfigStorage :: instance", "extend_ttl"],
636
+ ),
637
+ (
638
+ "constructor with ref Env",
639
+ quote! {
640
+ impl MyContract {
641
+ pub fn __constructor(env: &Env) { let x = 1; }
642
+ }
643
+ },
644
+ // expects init call and correct arg form (`env` because Env is already a ref)
645
+ vec!["ttl_configurable :: init_default_ttl_configs (env)"],
646
+ vec!["TtlConfigStorage :: instance", "extend_ttl"],
647
+ ),
648
+ ];
637
649
 
638
- #[test]
639
- fn test_trait_no_ttl_extension_for_abstract_method() {
640
- TraitTtlTestCase::expect_no_ttl(
641
- "abstract method with Env (no body)",
642
- quote! {
643
- trait MyTrait {
644
- fn abstract_method(env: Env) -> u32;
645
- }
646
- },
647
- )
648
- .run();
650
+ for (name, input, expected, forbidden) in cases {
651
+ let result = crate::contract_ttl::contractimpl_with_ttl(TokenStream::new(), input);
652
+ let result_str = result.to_string();
653
+ for needle in expected {
654
+ assert!(result_str.contains(needle), "{name}: expected '{needle}'. Got: {result_str}");
655
+ }
656
+ for needle in forbidden {
657
+ assert!(!result_str.contains(needle), "{name}: should NOT contain '{needle}'. Got: {result_str}");
658
+ }
659
+ }
649
660
  }
650
661
 
651
662
  #[test]
652
- fn test_trait_no_ttl_extension_without_env_param() {
653
- TraitTtlTestCase::expect_no_ttl(
654
- "default method without Env",
655
- quote! {
656
- trait MyTrait {
657
- fn no_env_method(value: u32) -> u32 { value }
658
- }
659
- },
660
- )
661
- .run();
663
+ fn test_contracttrait_with_ttl_skips_ttl_insertion_table_driven() {
664
+ // (name, input)
665
+ let cases = vec![
666
+ (
667
+ "abstract method with Env (no body)",
668
+ quote! {
669
+ trait MyTrait {
670
+ fn abstract_method(env: Env) -> u32;
671
+ }
672
+ },
673
+ ),
674
+ (
675
+ "default method without Env",
676
+ quote! {
677
+ trait MyTrait {
678
+ fn no_env_method(value: u32) -> u32 { value }
679
+ }
680
+ },
681
+ ),
682
+ (
683
+ "default method with wildcard Env binding (unsupported pattern)",
684
+ quote! {
685
+ trait MyTrait {
686
+ fn my_method(_: Env) { let x = 1; }
687
+ }
688
+ },
689
+ ),
690
+ ];
691
+
692
+ for (name, input) in cases {
693
+ TraitTtlTestCase::expect_no_ttl(name, input).run();
694
+ }
662
695
  }